-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathplayground-test.gts
722 lines (674 loc) · 25 KB
/
playground-test.gts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
import { click } from '@ember/test-helpers';
import window from 'ember-window-mock';
import { module, test, skip } from 'qunit';
import type { Realm } from '@cardstack/runtime-common';
import {
percySnapshot,
setupAcceptanceTestRealm,
setupLocalIndexing,
setupServerSentEvents,
testRealmURL,
visitOperatorMode,
type TestContextWithSSE,
} from '../../helpers';
import { setupMockMatrix } from '../../helpers/mock-matrix';
import { setupApplicationTest } from '../../helpers/setup';
module('Acceptance | code-submode | playground panel', function (hooks) {
let realm: Realm;
setupApplicationTest(hooks);
setupLocalIndexing(hooks);
setupServerSentEvents(hooks);
setupMockMatrix(hooks, {
loggedInAs: '@testuser:staging',
activeRealms: [testRealmURL],
});
const authorCard = `import { contains, field, CardDef, Component } from "https://cardstack.com/base/card-api";
import MarkdownField from 'https://cardstack.com/base/markdown';
import StringField from "https://cardstack.com/base/string";
export class Author extends CardDef {
static displayName = 'Author';
@field firstName = contains(StringField);
@field lastName = contains(StringField);
@field bio = contains(MarkdownField);
@field title = contains(StringField, {
computeVia: function (this: Author) {
return [this.firstName, this.lastName].filter(Boolean).join(' ');
},
});
static isolated = class Isolated extends Component<typeof this> {
<template>
<article>
<header>
<h1 data-test-author-title><@fields.title /></h1>
</header>
<div data-test-author-bio><@fields.bio /></div>
</article>
<style scoped>
article {
margin-inline: 20px;
}
</style>
</template>
}
}`;
const blogPostCard = `import { contains, field, linksTo, linksToMany, CardDef, Component } from "https://cardstack.com/base/card-api";
import DatetimeField from 'https://cardstack.com/base/datetime';
import MarkdownField from 'https://cardstack.com/base/markdown';
import StringField from "https://cardstack.com/base/string";
import { Author } from './author';
export class Category extends CardDef {
static displayName = 'Category';
static fitted = class Fitted extends Component<typeof this> {
<template>
<div data-test-category-fitted><@fields.title /></div>
</template>
}
}
class Status extends StringField {
static displayName = 'Status';
}
export class BlogPost extends CardDef {
static displayName = 'Blog Post';
@field publishDate = contains(DatetimeField);
@field author = linksTo(Author);
@field categories = linksToMany(Category);
@field body = contains(MarkdownField);
@field status = contains(Status, {
computeVia: function (this: BlogPost) {
if (!this.publishDate) {
return 'Draft';
}
if (Date.now() >= Date.parse(String(this.publishDate))) {
return 'Published';
}
return 'Scheduled';
},
});
static isolated = class Isolated extends Component<typeof this> {
<template>
<article>
<header>
<h1 data-test-post-title><@fields.title /></h1>
</header>
<div data-test-byline><@fields.author /></div>
<div data-test-post-body><@fields.body /></div>
</article>
<style scoped>
article {
margin-inline: 20px;
}
</style>
</template>
}
}`;
hooks.beforeEach(async function () {
({ realm } = await setupAcceptanceTestRealm({
contents: {
'author.gts': authorCard,
'blog-post.gts': blogPostCard,
'Author/jane-doe.json': {
data: {
attributes: {
firstName: 'Jane',
lastName: 'Doe',
bio: "Jane Doe is the Senior Managing Editor at <em>Ramped.com</em>, where she leads content strategy, editorial direction, and ensures the highest standards of quality across all publications. With over a decade of experience in digital media and editorial management, Jane has a proven track record of shaping impactful narratives, growing engaged audiences, and collaborating with cross-functional teams to deliver compelling content. When she's not editing, you can find her exploring new books, hiking, or indulging in her love of photography.",
},
meta: {
adoptsFrom: {
module: `${testRealmURL}author`,
name: 'Author',
},
},
},
},
'BlogPost/remote-work.json': {
data: {
attributes: {
title: 'The Ultimate Guide to Remote Work',
description:
'In today’s digital age, remote work has transformed from a luxury to a necessity. This comprehensive guide will help you navigate the world of remote work, offering tips, tools, and best practices for success.',
},
relationships: {
author: {
links: {
self: `${testRealmURL}Author/jane-doe`,
},
},
},
meta: {
adoptsFrom: {
module: `${testRealmURL}blog-post`,
name: 'BlogPost',
},
},
},
},
'BlogPost/mad-hatter.json': {
data: {
attributes: { title: 'Mad As a Hatter' },
relationships: {
author: {
links: {
self: `${testRealmURL}Author/jane-doe`,
},
},
},
meta: {
adoptsFrom: {
module: `${testRealmURL}blog-post`,
name: 'BlogPost',
},
},
},
},
'BlogPost/urban-living.json': {
data: {
attributes: {
title:
'The Future of Urban Living: Skyscrapers or Sustainable Communities?',
},
relationships: {
author: {
links: {
self: `${testRealmURL}Author/jane-doe`,
},
},
},
meta: {
adoptsFrom: {
module: `${testRealmURL}blog-post`,
name: 'BlogPost',
},
},
},
},
'Category/city-design.json': {
data: {
attributes: { title: 'City Design' },
meta: {
adoptsFrom: {
module: `${testRealmURL}blog-post`,
name: 'Category',
},
},
},
},
'Category/future-tech.json': {
data: {
attributes: { title: 'Future Tech' },
meta: {
adoptsFrom: {
module: `${testRealmURL}blog-post`,
name: 'Category',
},
},
},
},
},
}));
window.localStorage.setItem(
'recent-files',
JSON.stringify([
[testRealmURL, 'blog-post.gts'],
[testRealmURL, 'author.gts'],
[testRealmURL, 'BlogPost/mad-hatter.json'],
[testRealmURL, 'Category/city-design.json'],
[testRealmURL, 'Category/future-tech.json'],
[testRealmURL, 'BlogPost/remote-work.json'],
[testRealmURL, 'BlogPost/urban-living.json'],
[testRealmURL, 'Author/jane-doe.json'],
]),
);
window.localStorage.setItem('playground-selections', '');
});
test('can render playground panel when a card def is selected', async function (assert) {
await visitOperatorMode({
submode: 'code',
codePath: `${testRealmURL}blog-post.gts`,
});
assert
.dom(
'[data-test-in-this-file-selector] [data-test-boxel-selector-item-selected] [data-test-boxel-selector-item-text="Category"]',
)
.exists();
assert.dom('[data-test-accordion-item="playground"]').exists();
// TODO: extend playground to field defs and test that it only works for field and card defs
await click(
'[data-test-in-this-file-selector] [data-test-boxel-selector-item-text="Status"]',
);
assert
.dom('[data-test-accordion-item="playground"]')
.doesNotExist('playground panel currently only exists for card defs');
await click(
'[data-test-in-this-file-selector] [data-test-boxel-selector-item-text="BlogPost"]',
);
await click('[data-test-accordion-item="playground"] button');
assert.dom('[data-test-playground-panel]').exists();
});
test('can populate instance chooser dropdown options from recent files', async function (assert) {
window.localStorage.setItem('recent-files', '');
window.localStorage.setItem('playground-selections', '');
await visitOperatorMode({
submode: 'code',
codePath: `${testRealmURL}blog-post.gts`,
});
await click('[data-test-accordion-item="playground"] button');
assert.dom('[data-test-instance-chooser]').hasText('Please Select');
window.localStorage.setItem(
'recent-files',
JSON.stringify([
[testRealmURL, 'BlogPost/mad-hatter.json'],
[testRealmURL, 'Category/future-tech.json'],
[testRealmURL, 'Category/city-design.json'],
[testRealmURL, 'BlogPost/remote-work.json'],
[testRealmURL, 'BlogPost/urban-living.json'],
[testRealmURL, 'Author/jane-doe.json'],
]),
);
await click('[data-test-instance-chooser]');
assert
.dom('[data-option-index] [data-test-category-fitted]')
.exists({ count: 2 });
await click('[data-option-index="1"]');
assert.dom('[data-test-selected-item]').hasText('Future Tech');
await percySnapshot(assert);
});
test('can update the instance chooser when selected card def changes (same file)', async function (assert) {
await visitOperatorMode({
submode: 'code',
codePath: `${testRealmURL}blog-post.gts`,
});
await click('[data-test-accordion-item="playground"] button');
await click('[data-test-instance-chooser]');
assert.dom('[data-option-index]').exists({ count: 2 });
assert.dom('[data-option-index="0"]').containsText('City Design');
await click('[data-option-index="0"]');
assert.dom('[data-test-selected-item]').containsText('City Design');
await click(
'[data-test-in-this-file-selector] [data-test-boxel-selector-item-text="BlogPost"]',
);
await click('[data-test-instance-chooser]');
assert.dom('[data-option-index]').exists({ count: 3 });
assert.dom('[data-option-index="0"]').containsText('Mad As a Hatter');
await click('[data-option-index="0"]');
assert.dom('[data-test-selected-item]').containsText('Mad As a Hatter');
});
test('can update the instance chooser when a different file is opened', async function (assert) {
await visitOperatorMode({
submode: 'code',
codePath: `${testRealmURL}blog-post.gts`,
});
await click('[data-test-accordion-item="playground"] button');
await click('[data-test-instance-chooser]');
assert.dom('[data-option-index]').exists({ count: 2 });
assert.dom('[data-option-index="0"]').containsText('City Design');
await click('[data-option-index="0"]');
assert.dom('[data-test-selected-item]').containsText('City Design');
await click('[data-test-file-browser-toggle]');
await click('[data-test-file="author.gts"]');
assert.dom('[data-test-instance-chooser]').hasText('Please Select');
await click('[data-test-instance-chooser]');
assert.dom('li.ember-power-select-option').exists({ count: 1 });
assert.dom('[data-option-index="0"]').containsText('Jane Doe');
await click('[data-option-index="0"]');
assert.dom('[data-test-selected-item]').containsText('Jane Doe');
});
test('can populate playground preview with previous choices saved in local storage', async function (assert) {
let selections = {
[`${testRealmURL}author/Author`]: `${testRealmURL}Author/jane-doe.json`,
[`${testRealmURL}blog-post/BlogPost`]: `${testRealmURL}BlogPost/remote-work.json`,
[`${testRealmURL}blog-post/Category`]: `${testRealmURL}Category/city-design.json`,
};
window.localStorage.setItem(
'playground-selections',
JSON.stringify(selections),
);
const assertCardExists = (fileName: string) => {
const dataAttr = `[data-test-playground-panel] [data-test-card="${testRealmURL}${fileName}"]`;
assert.dom(dataAttr).exists();
};
await visitOperatorMode({
submode: 'code',
codePath: `${testRealmURL}author.gts`,
});
await click('[data-test-accordion-item="playground"] button');
assert.dom('[data-test-selected-item]').hasText('Jane Doe');
assertCardExists('Author/jane-doe');
await click(`[data-test-recent-file="${testRealmURL}blog-post.gts"]`);
assert.dom('[data-test-selected-item]').hasText('City Design');
assertCardExists('Category/city-design');
await click(
'[data-test-in-this-file-selector] [data-test-boxel-selector-item-text="BlogPost"]',
);
assert.dom('[data-test-selected-item]').containsText('Remote Work');
assertCardExists('BlogPost/remote-work');
});
test('can display selected card in isolated format', async function (assert) {
await visitOperatorMode({
submode: 'code',
codePath: `${testRealmURL}author.gts`,
});
await click('[data-test-accordion-item="playground"] button');
await click('[data-test-instance-chooser]');
await click('[data-option-index="0"]');
assert
.dom('[data-test-playground-panel] [data-test-boxel-card-header-title]')
.hasText('Author');
assert
.dom(
`[data-test-playground-panel] [data-test-card="${testRealmURL}Author/jane-doe"][data-test-card-format="isolated"]`,
)
.exists();
assert.dom('[data-test-author-title]').hasText('Jane Doe');
assert
.dom('[data-test-author-bio]')
.containsText('Jane Doe is the Senior Managing Editor');
});
test('can use the header context menu to open instance in code mode', async function (assert) {
await visitOperatorMode({
submode: 'code',
codePath: `${testRealmURL}author.gts`,
});
await click('[data-test-accordion-item="playground"] button');
await click('[data-test-instance-chooser]');
await click('[data-option-index="0"]');
await click('[data-test-more-options-button]');
assert
.dom('[data-test-boxel-dropdown-content] [data-test-boxel-menu-item]')
.exists({ count: 3 });
await click('[data-test-boxel-menu-item-text="Open in Code Mode"]');
assert
.dom(
`[data-test-code-mode-card-preview-header="${testRealmURL}Author/jane-doe"]`,
)
.exists();
assert.dom('[data-test-accordion-item="playground"]').doesNotExist();
});
test('can use the header context menu to open instance in interact mode', async function (assert) {
await visitOperatorMode({
submode: 'code',
codePath: `${testRealmURL}author.gts`,
});
await click('[data-test-accordion-item="playground"] button');
await click('[data-test-instance-chooser]');
await click('[data-option-index="0"]');
await click('[data-test-more-options-button]');
await click('[data-test-boxel-menu-item-text="Open in Interact Mode"]');
assert
.dom(
`[data-test-stack-card-index="0"][data-test-stack-card="${testRealmURL}Author/jane-doe"]`,
)
.exists();
assert.dom('[data-test-author-title]').hasText('Jane Doe');
});
test('can display selected card in the chosen format', async function (assert) {
await visitOperatorMode({
submode: 'code',
codePath: `${testRealmURL}author.gts`,
});
await click('[data-test-accordion-item="playground"] button');
await click('[data-test-instance-chooser]');
await click('[data-option-index="0"]');
assert
.dom('[data-test-playground-panel] [data-test-boxel-card-header-title]')
.hasText('Author');
assert
.dom(
`[data-test-playground-panel] [data-test-card="${testRealmURL}Author/jane-doe"][data-test-card-format="isolated"]`,
)
.exists();
assert.dom('[data-test-author-title]').hasText('Jane Doe');
assert
.dom('[data-test-author-bio]')
.containsText('Jane Doe is the Senior Managing Editor');
assert.dom('[data-test-format-chooser-isolated]').hasClass('active');
await click('[data-test-format-chooser-embedded]');
assert.dom('[data-test-format-chooser-isolated]').hasNoClass('active');
assert.dom('[data-test-format-chooser-embedded]').hasClass('active');
assert
.dom('[data-test-playground-panel] [data-test-boxel-card-header-title]')
.doesNotExist();
assert
.dom(
`[data-test-playground-panel] [data-test-card="${testRealmURL}Author/jane-doe"][data-test-card-format="embedded"]`,
)
.exists();
await click('[data-test-format-chooser-edit]');
assert.dom('[data-test-format-chooser-embedded]').hasNoClass('active');
assert.dom('[data-test-format-chooser-edit]').hasClass('active');
assert
.dom('[data-test-playground-panel] [data-test-boxel-card-header-title]')
.hasText('Author');
assert
.dom(
`[data-test-playground-panel] [data-test-card="${testRealmURL}Author/jane-doe"][data-test-card-format="edit"]`,
)
.exists();
await click('[data-test-format-chooser-atom]');
assert.dom('[data-test-format-chooser-edit]').hasNoClass('active');
assert.dom('[data-test-format-chooser-atom]').hasClass('active');
assert
.dom('[data-test-atom-preview]')
.hasText(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do Jane Doe tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
);
await click('[data-test-format-chooser-fitted]');
assert.dom('[data-test-format-chooser-atom]').hasNoClass('active');
assert.dom('[data-test-format-chooser-fitted]').hasClass('active');
assert
.dom('[data-test-playground-panel] [data-test-card-format="fitted"]')
.exists({ count: 16 });
});
test('can use the header context menu to open instance in edit format in interact mode', async function (assert) {
await visitOperatorMode({
submode: 'code',
codePath: `${testRealmURL}author.gts`,
});
await click('[data-test-accordion-item="playground"] button');
await click('[data-test-instance-chooser]');
await click('[data-option-index="0"]');
await click('[data-test-format-chooser-edit]');
await click('[data-test-more-options-button]');
await click('[data-test-boxel-menu-item-text="Open in Interact Mode"]');
assert
.dom(
`[data-test-stack-card-index="0"][data-test-stack-card="${testRealmURL}Author/jane-doe"]`,
)
.exists();
assert
.dom(`[data-test-stack-item-content] [data-test-card-format="edit"]`)
.exists();
});
test('can choose another instance to be opened in playground panel', async function (assert) {
window.localStorage.removeItem('recent-files');
await visitOperatorMode({
submode: 'code',
codePath: `${testRealmURL}blog-post.gts`,
});
await click('[data-boxel-selector-item-text="BlogPost"]');
await click('[data-test-accordion-item="playground"] button');
await click('[data-test-instance-chooser]');
await click('[data-test-choose-another-instance]');
assert.dom('[data-test-card-catalog-modal]').exists();
assert.dom('[data-test-card-catalog-item]').exists({ count: 3 });
assert
.dom(`[data-test-card-catalog-item="${testRealmURL}BlogPost/mad-hatter"]`)
.exists();
assert
.dom(
`[data-test-card-catalog-item="${testRealmURL}BlogPost/urban-living"]`,
)
.exists();
assert
.dom(
`[data-test-card-catalog-item="${testRealmURL}BlogPost/remote-work"]`,
)
.exists();
await click(
`[data-test-card-catalog-item="${testRealmURL}BlogPost/mad-hatter"]`,
);
await click('[data-test-card-catalog-go-button]');
assert
.dom(
`[data-test-playground-panel] [data-test-card="${testRealmURL}BlogPost/mad-hatter"][data-test-card-format="isolated"]`,
)
.exists();
let recentFiles = JSON.parse(window.localStorage.getItem('recent-files')!);
assert.deepEqual(recentFiles[0], [
testRealmURL,
'BlogPost/mad-hatter.json',
]);
});
test<TestContextWithSSE>('playground preview for card with contained fields can live update when module changes', async function (assert) {
// change: added "Hello" before rendering title on the template
const authorCard = `import { contains, field, CardDef, Component } from "https://cardstack.com/base/card-api";
import MarkdownField from 'https://cardstack.com/base/markdown';
import StringField from "https://cardstack.com/base/string";
export class Author extends CardDef {
static displayName = 'Author';
@field firstName = contains(StringField);
@field lastName = contains(StringField);
@field bio = contains(MarkdownField);
@field title = contains(StringField, {
computeVia: function (this: Author) {
return [this.firstName, this.lastName].filter(Boolean).join(' ');
},
});
static isolated = class Isolated extends Component<typeof this> {
<template>
<article>
<header>
<h1 data-test-author-title>Hello <@fields.title /></h1>
</header>
<div data-test-author-bio><@fields.bio /></div>
</article>
<style scoped>
article {
margin-inline: 20px;
}
</style>
</template>
}
}`;
let expectedEvents = [
{
type: 'index',
data: {
type: 'incremental-index-initiation',
realmURL: testRealmURL,
updatedFile: `${testRealmURL}author.gts`,
},
},
{
type: 'index',
data: {
type: 'incremental',
invalidations: [`${testRealmURL}author.gts`],
},
},
];
await visitOperatorMode({
stacks: [],
submode: 'code',
codePath: `${testRealmURL}author.gts`,
});
await click('[data-test-accordion-item="playground"] button');
await click('[data-test-instance-chooser]');
await click('[data-option-index="0"]');
assert.dom('[data-test-author-title]').containsText('Jane Doe');
await this.expectEvents({
assert,
realm,
expectedEvents,
callback: async () => await realm.write('author.gts', authorCard),
});
assert.dom('[data-test-author-title]').containsText('Hello Jane Doe');
});
skip<TestContextWithSSE>('playground preview for card with linked fields can live update when module changes', async function (assert) {
// change: added "Hello" before rendering title on the template
const blogPostCard = `import { contains, field, linksTo, linksToMany, CardDef, Component } from "https://cardstack.com/base/card-api";
import DatetimeField from 'https://cardstack.com/base/datetime';
import MarkdownField from 'https://cardstack.com/base/markdown';
import StringField from "https://cardstack.com/base/string";
import { Author } from './author';
export class Category extends CardDef {
static displayName = 'Category';
static fitted = class Fitted extends Component<typeof this> {
<template>
<div data-test-category-fitted><@fields.title /></div>
</template>
}
}
class Status extends StringField {
static displayName = 'Status';
}
export class BlogPost extends CardDef {
static displayName = 'Blog Post';
@field publishDate = contains(DatetimeField);
@field author = linksTo(Author);
@field categories = linksToMany(Category);
@field body = contains(MarkdownField);
@field status = contains(Status, {
computeVia: function (this: BlogPost) {
if (!this.publishDate) {
return 'Draft';
}
if (Date.now() >= Date.parse(String(this.publishDate))) {
return 'Published';
}
return 'Scheduled';
},
});
static isolated = class Isolated extends Component<typeof this> {
<template>
<article>
<header>
<h1 data-test-post-title>Hello <@fields.title /></h1>
</header>
<div data-test-byline><@fields.author /></div>
<div data-test-post-body><@fields.body /></div>
</article>
<style scoped>
article {
margin-inline: 20px;
}
</style>
</template>
}
}`;
let expectedEvents = [
{
type: 'index',
data: {
type: 'incremental-index-initiation',
realmURL: testRealmURL,
updatedFile: `${testRealmURL}blog-post.gts`,
},
},
{
type: 'index',
data: {
type: 'incremental',
invalidations: [`${testRealmURL}blog-post.gts`],
},
},
];
await visitOperatorMode({
stacks: [],
submode: 'code',
codePath: `${testRealmURL}blog-post.gts`,
});
await click('[data-test-boxel-selector-item-text="BlogPost"]');
await click('[data-test-accordion-item="playground"] button');
await click('[data-test-instance-chooser]');
await click('[data-option-index="0"]');
assert.dom('[data-test-post-title]').hasText('Mad As a Hatter');
await this.expectEvents({
assert,
realm,
expectedEvents,
callback: async () => await realm.write('blog-post.gts', blogPostCard),
});
assert.dom('[data-test-post-title]').includesText('Hello Mad As a Hatter');
});
});