@@ -26,6 +26,7 @@ import {
26
26
getPlaygroundSelections ,
27
27
getRecentFiles ,
28
28
assertCardExists ,
29
+ selectDeclaration ,
29
30
} from ' ../../helpers/playground' ;
30
31
31
32
import { setupApplicationTest } from ' ../../helpers/setup' ;
@@ -66,6 +67,9 @@ const personCardSource = `
66
67
export class PersonField extends FieldDef {
67
68
static displayName = 'PersonField';
68
69
}
70
+ export class DifferentField extends FieldDef {
71
+ static displayName = 'DifferentField';
72
+ }
69
73
` ;
70
74
71
75
const person1CardSource = `
@@ -461,6 +465,26 @@ module('Acceptance | Spec preview', function (hooks) {
461
465
},
462
466
},
463
467
},
468
+ ' different-field-entry.json' : {
469
+ data: {
470
+ type: ' card' ,
471
+ attributes: {
472
+ title: ' DifferentField' ,
473
+ description: ' Spec for DifferentField' ,
474
+ specType: ' field' ,
475
+ ref: {
476
+ module: ` ./person ` ,
477
+ name: ' DifferentField' ,
478
+ },
479
+ },
480
+ meta: {
481
+ adoptsFrom: {
482
+ module: ` ${baseRealm .url }spec ` ,
483
+ name: ' Spec' ,
484
+ },
485
+ },
486
+ },
487
+ },
464
488
' .realm.json' : {
465
489
name: ' Test Workspace B' ,
466
490
backgroundURL:
@@ -1022,4 +1046,50 @@ module('Acceptance | Spec preview', function (hooks) {
1022
1046
assert .dom (' [data-test-exported-name]' ).hasText (' Pet' );
1023
1047
assert .dom (' [data-test-module-href]' ).hasText (` ${testRealmURL }pet ` );
1024
1048
});
1049
+
1050
+ test (' it does not set the wrong spec for field playground' , async function (assert ) {
1051
+ await visitOperatorMode ({
1052
+ submode: ' code' ,
1053
+ codePath: ` ${testRealmURL }person.gts ` ,
1054
+ });
1055
+ await click (' [data-test-accordion-item="playground"] button' );
1056
+ assert .dom (' [data-test-playground-panel]' ).exists ();
1057
+ let selection =
1058
+ getPlaygroundSelections ()?.[` ${testRealmURL }person/PersonField ` ];
1059
+ assert .strictEqual (selection , undefined );
1060
+
1061
+ await selectDeclaration (' PersonField' );
1062
+ selection =
1063
+ getPlaygroundSelections ()?.[` ${testRealmURL }person/PersonField ` ];
1064
+ assert .strictEqual (
1065
+ selection ,
1066
+ undefined ,
1067
+ ' Person Spec is not set as the spec for PersonField' ,
1068
+ );
1069
+ assert .dom (' [data-test-create-spec-button]' ).exists ();
1070
+
1071
+ await selectDeclaration (' DifferentField' );
1072
+ let newSelection =
1073
+ getPlaygroundSelections ()?.[` ${testRealmURL }person/DifferentField ` ];
1074
+ assert .strictEqual (
1075
+ newSelection ?.cardId ,
1076
+ ` ${testRealmURL }different-field-entry ` ,
1077
+ );
1078
+ assert .dom (' [data-test-create-spec-button]' ).doesNotExist ();
1079
+
1080
+ await selectDeclaration (' PersonField' );
1081
+ selection =
1082
+ getPlaygroundSelections ()?.[` ${testRealmURL }person/PersonField ` ];
1083
+ assert .strictEqual (
1084
+ selection ,
1085
+ undefined ,
1086
+ ' DifferentField Spec is not set as the spec for PersonField' ,
1087
+ );
1088
+ assert .strictEqual (
1089
+ selection ,
1090
+ undefined ,
1091
+ ' DifferentField Spec is not set as the spec for PersonField' ,
1092
+ );
1093
+ assert .dom (' [data-test-create-spec-button]' ).exists ();
1094
+ });
1025
1095
});
0 commit comments