forked from CoreBunch/Instatic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapabilities.e2e.ts
More file actions
1533 lines (1394 loc) · 57.2 KB
/
Copy pathcapabilities.e2e.ts
File metadata and controls
1533 lines (1394 loc) · 57.2 KB
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
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { expect, test, type Browser, type Page } from '@playwright/test'
import { strToU8, zipSync } from 'fflate'
import {
ANONYMOUS_STATE,
OWNER,
completeStepUp,
createPage,
login,
loginAs,
openLayersPanel,
openSiteEditor,
saveDraft,
setPropValue,
canvasFrame,
insertNotchModule,
} from './helpers'
const PNG_1X1 = Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==',
'base64',
)
interface PersonaAccount {
roleName: string
email: string
password: string
}
test.describe.serial('capability boundaries', () => {
test.use({ storageState: ANONYMOUS_STATE })
test.setTimeout(180_000)
const suffix = Date.now().toString(36)
const seededText = `Capability seed ${suffix}`
const secondText = `Capability spare ${suffix}`
const contentText = `Content persona copy ${suffix}`
const styleClass = `cap-style-${suffix}`
let pageName = ''
const personas: Record<'content' | 'style' | 'structure', PersonaAccount> = {
content: {
roleName: `CAP Content ${suffix}`,
email: `cap-content-${suffix}@example.com`,
password: 'cap-content-pass-12345',
},
style: {
roleName: `CAP Style ${suffix}`,
email: `cap-style-${suffix}@example.com`,
password: 'cap-style-pass-12345',
},
structure: {
roleName: `CAP Structure ${suffix}`,
email: `cap-structure-${suffix}@example.com`,
password: 'cap-structure-pass-12345',
},
}
test.beforeAll(async ({ browser }, testInfo) => {
testInfo.setTimeout(180_000)
const context = await browser.newContext()
const ownerPage = await context.newPage()
try {
await login(ownerPage)
pageName = await seedCapabilityPage(ownerPage, suffix, seededText, secondText)
await createRole(ownerPage, personas.content.roleName, [
'View site',
'Edit site content',
])
await createRole(ownerPage, personas.style.roleName, [
'View site',
'Edit site styles',
])
await createRole(ownerPage, personas.structure.roleName, [
'View site',
'Edit site structure',
'Edit pages',
])
for (const persona of Object.values(personas)) {
await createUser(ownerPage, {
email: persona.email,
displayName: persona.roleName,
password: persona.password,
role: persona.roleName,
})
}
} finally {
await context.close()
}
})
test('content editor can edit copy but not style or structure (CAP-002)', async ({
browser,
}) => {
await withPersona(browser, personas.content, async (personaPage) => {
await openNamedPage(personaPage, pageName)
await canvasFrame(personaPage).getByText(seededText, { exact: true }).click()
await setPropValue(personaPage, 'text', contentText)
await expectAbsentOrDisabled(personaPage.getByTestId('canvas-notch-text-btn'))
await expect(
personaPage.getByText('Styles are read-only for your role'),
).toBeVisible()
await saveDraft(personaPage)
await personaPage.reload()
await openNamedPage(personaPage, pageName)
await expect(
canvasFrame(personaPage).getByText(contentText, { exact: true }),
).toBeVisible()
})
})
test('style editor can edit CSS but not copy (CAP-002)', async ({ browser }) => {
await withPersona(browser, personas.style, async (personaPage) => {
await openNamedPage(personaPage, pageName)
const editableText = canvasFrame(personaPage).getByText(contentText, { exact: true })
await editableText.click()
await expect(personaPage.getByTestId('property-control-text')).toHaveAttribute(
'data-disabled',
'true',
)
await personaPage.getByTestId('class-picker-input').fill(styleClass)
await personaPage.getByTestId('class-picker-submit').click()
await expect(personaPage.getByTestId(`class-chip-${styleClass}`)).toBeVisible()
await personaPage.getByLabel('Search class style properties to add').fill('font size')
const fontSizeInput = personaPage
.getByTestId('css-property-row-fontSize')
.getByLabel('Font size')
await fontSizeInput.fill('23px')
await fontSizeInput.blur()
await expect(editableText).toHaveCSS('font-size', '23px')
await saveDraft(personaPage)
await personaPage.reload()
await openNamedPage(personaPage, pageName)
const reloadedText = canvasFrame(personaPage).getByText(contentText, { exact: true })
await reloadedText.click()
await expect(reloadedText).toHaveCSS('font-size', '23px')
})
})
test('structure editor can insert layers but not edit copy (CAP-002)', async ({
browser,
}) => {
await withPersona(browser, personas.structure, async (personaPage) => {
await openNamedPage(personaPage, pageName)
await canvasFrame(personaPage).getByText(contentText, { exact: true }).click()
await expect(personaPage.getByTestId('property-control-text')).toHaveAttribute(
'data-disabled',
'true',
)
await openLayersPanel(personaPage)
const tree = personaPage.getByRole('tree', { name: 'Page element tree' })
await expect(tree.getByRole('treeitem', { name: 'Text' })).toHaveCount(2)
await insertNotchModule(personaPage, 'text')
await expect(tree.getByRole('treeitem', { name: 'Text' })).toHaveCount(3)
await saveDraft(personaPage)
await personaPage.reload()
await openNamedPage(personaPage, pageName)
await openLayersPanel(personaPage)
await expect(
personaPage
.getByRole('tree', { name: 'Page element tree' })
.getByRole('treeitem', { name: 'Text' }),
).toHaveCount(3)
})
})
})
test.describe.serial('media capability boundaries', () => {
test.use({ storageState: ANONYMOUS_STATE })
test.setTimeout(180_000)
const suffix = Date.now().toString(36)
const seededFilename = `cap-media-seed-${suffix}.png`
const writerFilename = `cap-media-writer-${suffix}.png`
const replaceOriginalFilename = `cap-media-replace-original-${suffix}.png`
const replaceNextFilename = `cap-media-replace-next-${suffix}.png`
const deleteFilename = `cap-media-delete-${suffix}.png`
const personas: Record<'reader' | 'writer' | 'replacer' | 'deleter', PersonaAccount> = {
reader: {
roleName: `CAP Media Reader ${suffix}`,
email: `cap-media-reader-${suffix}@example.com`,
password: 'cap-media-reader-pass-12345',
},
writer: {
roleName: `CAP Media Writer ${suffix}`,
email: `cap-media-writer-${suffix}@example.com`,
password: 'cap-media-writer-pass-12345',
},
replacer: {
roleName: `CAP Media Replacer ${suffix}`,
email: `cap-media-replacer-${suffix}@example.com`,
password: 'cap-media-replacer-pass-12345',
},
deleter: {
roleName: `CAP Media Deleter ${suffix}`,
email: `cap-media-deleter-${suffix}@example.com`,
password: 'cap-media-deleter-pass-12345',
},
}
test.beforeAll(async ({ browser }, testInfo) => {
testInfo.setTimeout(180_000)
const context = await browser.newContext()
const ownerPage = await context.newPage()
try {
await login(ownerPage)
await ownerPage.goto('/admin/media')
await uploadMediaFile(ownerPage, seededFilename)
await uploadMediaFile(ownerPage, replaceOriginalFilename)
await uploadMediaFile(ownerPage, deleteFilename)
await createRole(ownerPage, personas.reader.roleName, ['Browse media library'])
await createRole(ownerPage, personas.writer.roleName, [
'Browse media library',
'Upload and edit media',
])
await createRole(ownerPage, personas.replacer.roleName, [
'Browse media library',
'Replace media bytes',
])
await createRole(ownerPage, personas.deleter.roleName, [
'Browse media library',
'Delete media',
])
for (const persona of Object.values(personas)) {
await createUser(ownerPage, {
email: persona.email,
displayName: persona.roleName,
password: persona.password,
role: persona.roleName,
})
}
} finally {
await context.close()
}
})
test('media reader can browse without write/replace/delete controls (CAP-004)', async ({
browser,
}) => {
await withPersona(browser, personas.reader, async (personaPage) => {
await openMediaWorkspace(personaPage)
await expect(personaPage.getByRole('button', { name: 'Upload media' })).toHaveCount(0)
const asset = personaPage.getByRole('button', { name: `Open ${seededFilename}` })
await expect(asset).toBeVisible()
await asset.click({ button: 'right' })
const menu = personaPage.getByRole('menu', { name: 'Media item options' })
await expect(menu.getByText('Copy URL')).toBeVisible()
await expect(menu.getByText('Rename')).toHaveCount(0)
await expect(menu.getByText('Delete')).toHaveCount(0)
await personaPage.keyboard.press('Escape')
await asset.click()
const viewer = personaPage.getByTestId('media-viewer-window')
await expect(viewer).toBeVisible()
await expect(viewer.getByLabel('Title')).toBeDisabled()
await expect(viewer.getByLabel('Filename')).toBeDisabled()
await expect(viewer.getByRole('button', { name: 'Replace file' })).toHaveCount(0)
})
})
test('media writer can upload and edit metadata without replace/delete controls (CAP-004)', async ({
browser,
}) => {
await withPersona(browser, personas.writer, async (personaPage) => {
await openMediaWorkspace(personaPage)
await expect(personaPage.getByRole('button', { name: 'Upload media' })).toBeVisible()
await uploadMediaFile(personaPage, writerFilename)
const asset = personaPage.getByRole('button', { name: `Open ${writerFilename}` })
await expect(asset).toBeVisible()
await asset.click({ button: 'right' })
const menu = personaPage.getByRole('menu', { name: 'Media item options' })
await expect(menu.getByText('Rename')).toBeVisible()
await expect(menu.getByText('Delete')).toHaveCount(0)
await personaPage.keyboard.press('Escape')
await asset.click()
const viewer = personaPage.getByTestId('media-viewer-window')
await expect(viewer).toBeVisible()
await expect(viewer.getByLabel('Title')).toBeEnabled()
await expect(viewer.getByLabel('Filename')).toBeEnabled()
await expect(viewer.getByRole('button', { name: 'Replace file' })).toHaveCount(0)
})
})
test('media replacer can replace bytes without metadata or delete controls (CAP-004)', async ({
browser,
}) => {
await withPersona(browser, personas.replacer, async (personaPage) => {
await openMediaWorkspace(personaPage)
await expect(personaPage.getByRole('button', { name: 'Upload media' })).toHaveCount(0)
const asset = personaPage.getByRole('button', { name: `Open ${replaceOriginalFilename}` })
await expect(asset).toBeVisible()
await asset.click({ button: 'right' })
const menu = personaPage.getByRole('menu', { name: 'Media item options' })
await expect(menu.getByText('Copy URL')).toBeVisible()
await expect(menu.getByText('Rename')).toHaveCount(0)
await expect(menu.getByText('Delete')).toHaveCount(0)
await personaPage.keyboard.press('Escape')
await asset.click()
const viewer = personaPage.getByRole('dialog', { name: `Viewer: ${replaceOriginalFilename}` })
await expect(viewer).toBeVisible()
await expect(viewer.getByLabel('Title')).toBeDisabled()
await expect(viewer.getByLabel('Filename')).toBeDisabled()
await viewer.getByRole('button', { name: 'Replace file' }).click()
const replaceDialog = personaPage.getByRole('dialog', { name: 'Replace file' })
await expect(replaceDialog).toBeVisible()
await replaceDialog
.locator('input[type="file"]')
.setInputFiles({ name: replaceNextFilename, mimeType: 'image/png', buffer: PNG_1X1 })
await expect(replaceDialog.getByRole('status')).toContainText(replaceNextFilename)
await Promise.all([
waitForMediaReplace(personaPage),
replaceDialog.getByRole('button', { name: 'Replace file' }).click(),
])
await expect(replaceDialog).toBeHidden()
const replacedViewer = personaPage.getByRole('dialog', { name: `Viewer: ${replaceNextFilename}` })
await expect(replacedViewer).toBeVisible()
await expect(replacedViewer).toContainText('Replaced')
await expect(personaPage.getByRole('button', { name: `Open ${replaceNextFilename}` })).toBeVisible()
})
})
test('media deleter can trash and purge without upload or replace controls (CAP-004)', async ({
browser,
}) => {
await withPersona(browser, personas.deleter, async (personaPage) => {
await openMediaWorkspace(personaPage)
await expect(personaPage.getByRole('button', { name: 'Upload media' })).toHaveCount(0)
const asset = personaPage.getByRole('button', { name: `Open ${deleteFilename}` })
await expect(asset).toBeVisible()
await asset.click()
const viewer = personaPage.getByRole('dialog', { name: `Viewer: ${deleteFilename}` })
await expect(viewer).toBeVisible()
await expect(viewer.getByLabel('Title')).toBeDisabled()
await expect(viewer.getByLabel('Filename')).toBeDisabled()
await expect(viewer.getByRole('button', { name: 'Replace file' })).toHaveCount(0)
await viewer.getByRole('button', { name: `Close ${deleteFilename} panel` }).click()
await asset.click({ button: 'right' })
const activeMenu = personaPage.getByRole('menu', { name: 'Media item options' })
await expect(activeMenu.getByText('Rename')).toHaveCount(0)
await expect(activeMenu.getByRole('menuitem', { name: 'Delete' })).toBeVisible()
await Promise.all([
waitForMediaDelete(personaPage),
activeMenu.getByRole('menuitem', { name: 'Delete' }).click(),
])
await expect(personaPage.getByRole('button', { name: `Open ${deleteFilename}` })).toHaveCount(0)
await personaPage.getByTestId('media-folder-row-trash').click()
const trashedAsset = personaPage.getByRole('button', { name: `Open ${deleteFilename}` })
await expect(trashedAsset).toBeVisible()
await trashedAsset.click({ button: 'right' })
const trashMenu = personaPage.getByRole('menu', { name: 'Media item options' })
await expect(trashMenu.getByText('Restore')).toHaveCount(0)
await expect(trashMenu.getByRole('menuitem', { name: 'Delete' })).toBeVisible()
await Promise.all([
waitForMediaDelete(personaPage),
trashMenu.getByRole('menuitem', { name: 'Delete' }).click(),
])
await expect(personaPage.getByRole('button', { name: `Open ${deleteFilename}` })).toHaveCount(0)
await expect(personaPage.getByText('Trash is empty')).toBeVisible()
})
})
})
test.describe.serial('data capability boundaries', () => {
test.use({ storageState: ANONYMOUS_STATE })
test.setTimeout(180_000)
const suffix = Date.now().toString(36)
const tableName = `Capability Records ${suffix}`
const personas: Record<'reader' | 'manager' | 'exporter' | 'importer', PersonaAccount> = {
reader: {
roleName: `CAP Data Reader ${suffix}`,
email: `cap-data-reader-${suffix}@example.com`,
password: 'cap-data-reader-pass-12345',
},
manager: {
roleName: `CAP Data Manager ${suffix}`,
email: `cap-data-manager-${suffix}@example.com`,
password: 'cap-data-manager-pass-12345',
},
exporter: {
roleName: `CAP Data Exporter ${suffix}`,
email: `cap-data-exporter-${suffix}@example.com`,
password: 'cap-data-exporter-pass-12345',
},
importer: {
roleName: `CAP Data Importer ${suffix}`,
email: `cap-data-importer-${suffix}@example.com`,
password: 'cap-data-importer-pass-12345',
},
}
test.beforeAll(async ({ browser }, testInfo) => {
testInfo.setTimeout(180_000)
const context = await browser.newContext()
const ownerPage = await context.newPage()
try {
await login(ownerPage)
await createCustomDataTable(ownerPage, tableName)
await createRole(ownerPage, personas.reader.roleName, ['Browse custom tables'])
await createRole(ownerPage, personas.manager.roleName, ['Manage custom tables'])
await createRole(ownerPage, personas.exporter.roleName, [
'Browse custom tables',
'Export data bundles',
])
await createRole(ownerPage, personas.importer.roleName, [
'Browse custom tables',
'Import data bundles',
])
for (const persona of Object.values(personas)) {
await createUser(ownerPage, {
email: persona.email,
displayName: persona.roleName,
password: persona.password,
role: persona.roleName,
})
}
} finally {
await context.close()
}
})
test('custom table reader can browse without manage or transfer controls (CAP-004)', async ({
browser,
}) => {
await withPersona(browser, personas.reader, async (personaPage) => {
await openDataWorkspace(personaPage)
await expectDataTableVisible(personaPage, tableName)
await expect(personaPage.getByText('System', { exact: true })).toHaveCount(0)
await expect(personaPage.getByRole('alert')).toHaveCount(0)
await expect(personaPage.getByRole('button', { name: 'New table' })).toHaveCount(0)
await expect(personaPage.getByRole('button', { name: 'Export site' })).toHaveCount(0)
await expect(personaPage.getByRole('button', { name: 'Import site' })).toHaveCount(0)
})
})
test('custom table manager can create tables without import/export controls (CAP-004)', async ({
browser,
}) => {
await withPersona(browser, personas.manager, async (personaPage) => {
await openDataWorkspace(personaPage)
await expectDataTableVisible(personaPage, tableName)
await expect(personaPage.getByRole('button', { name: 'New table' })).toBeVisible()
await expect(personaPage.getByRole('button', { name: 'Export site' })).toHaveCount(0)
await expect(personaPage.getByRole('button', { name: 'Import site' })).toHaveCount(0)
})
})
test('data exporter sees export but not import or schema creation controls (CAP-004)', async ({
browser,
}) => {
await withPersona(browser, personas.exporter, async (personaPage) => {
await openDataWorkspace(personaPage)
await expectDataTableVisible(personaPage, tableName)
await expect(personaPage.getByRole('button', { name: 'New table' })).toHaveCount(0)
await expect(personaPage.getByRole('button', { name: 'Import site' })).toHaveCount(0)
await personaPage.getByRole('button', { name: 'Export site' }).click()
await expect(personaPage.getByRole('dialog', { name: 'Export site' })).toBeVisible()
})
})
test('data importer sees import but not export or schema creation controls (CAP-004)', async ({
browser,
}) => {
await withPersona(browser, personas.importer, async (personaPage) => {
await openDataWorkspace(personaPage)
await expectDataTableVisible(personaPage, tableName)
await expect(personaPage.getByRole('button', { name: 'New table' })).toHaveCount(0)
await expect(personaPage.getByRole('button', { name: 'Export site' })).toHaveCount(0)
await personaPage.getByRole('button', { name: 'Import site' }).click()
await expect(personaPage.getByRole('dialog', { name: 'Import site' })).toBeVisible()
})
})
})
test.describe.serial('content row move capability boundaries', () => {
test.use({ storageState: ANONYMOUS_STATE })
test.setTimeout(180_000)
const suffix = Date.now().toString(36)
const sourceCollectionName = `CAP Source ${suffix}`
const targetCollectionName = `CAP Target ${suffix}`
const entryTitle = `CAP movable entry ${suffix}`
const personas: Record<'editor' | 'mover', PersonaAccount> = {
editor: {
roleName: `CAP Content Editor ${suffix}`,
email: `cap-content-editor-${suffix}@example.com`,
password: 'cap-content-editor-pass-12345',
},
mover: {
roleName: `CAP Content Mover ${suffix}`,
email: `cap-content-mover-${suffix}@example.com`,
password: 'cap-content-mover-pass-12345',
},
}
test.beforeAll(async ({ browser }, testInfo) => {
testInfo.setTimeout(180_000)
const context = await browser.newContext()
const ownerPage = await context.newPage()
try {
await login(ownerPage)
await createContentCollection(ownerPage, sourceCollectionName, 'Source item')
await createContentCollection(ownerPage, targetCollectionName, 'Target item')
await createContentEntry(ownerPage, sourceCollectionName, 'Source item', entryTitle)
await createRole(ownerPage, personas.editor.roleName, ['Edit any content'])
await createRole(ownerPage, personas.mover.roleName, [
'Edit any content',
'Move rows between tables',
])
for (const persona of Object.values(personas)) {
await createUser(ownerPage, {
email: persona.email,
displayName: persona.roleName,
password: persona.password,
role: persona.roleName,
})
}
} finally {
await context.close()
}
})
test('content editor without row-move capability cannot see move controls (CAP-004)', async ({
browser,
}) => {
await withPersona(browser, personas.editor, async (personaPage) => {
await openContentWorkspace(personaPage)
await selectContentCollection(personaPage, sourceCollectionName)
const entry = contentEntryRow(personaPage, entryTitle)
await expect(entry).toBeVisible()
await entry.click({ button: 'right' })
const menu = personaPage.getByRole('menu', { name: 'Content item options' })
await expect(menu).toBeVisible()
await expect(
menu.getByRole('menuitem', { name: 'Move to collection' }),
).toHaveCount(0)
})
})
test('content mover can move an entry between collections (CAP-004)', async ({
browser,
}) => {
await withPersona(browser, personas.mover, async (personaPage) => {
await openContentWorkspace(personaPage)
await selectContentCollection(personaPage, sourceCollectionName)
const entry = contentEntryRow(personaPage, entryTitle)
await expect(entry).toBeVisible()
await entry.click({ button: 'right' })
const menu = personaPage.getByRole('menu', { name: 'Content item options' })
await menu.getByRole('menuitem', { name: 'Move to collection' }).hover()
await personaPage.getByRole('menuitem', { name: targetCollectionName }).click()
await expect(menu).toBeHidden()
await expect(contentEntryRow(personaPage, entryTitle)).toHaveCount(0)
await selectContentCollection(personaPage, targetCollectionName)
await expect(contentEntryRow(personaPage, entryTitle)).toBeVisible({
timeout: 20_000,
})
})
})
})
test.describe.serial('site import step-up boundaries', () => {
test.use({ storageState: ANONYMOUS_STATE })
test.setTimeout(180_000)
test('destructive site import requires successful step-up before mutating (CAP-003)', async ({
browser,
}) => {
const suffix = Date.now().toString(36)
const bundledTableName = `CAP Imported Bundle ${suffix}`
const localTableName = `CAP Local Table ${suffix}`
let bundle: unknown
const setupContext = await browser.newContext()
const setupPage = await setupContext.newPage()
try {
await login(setupPage)
await createCustomDataTable(setupPage, bundledTableName)
bundle = await exportCmsBundle(setupPage)
await createCustomDataTable(setupPage, localTableName)
} finally {
await setupContext.close()
}
const context = await browser.newContext()
const page = await context.newPage()
try {
await login(page)
await openDataWorkspace(page)
await expectDataTableVisible(page, bundledTableName)
await expectDataTableVisible(page, localTableName)
await openReplaceImportReview(page, bundle, `cap-replace-${suffix}.json`)
await page.getByRole('button', { name: 'Replace site' }).click()
const stepUpDialog = page.getByTestId('step-up-dialog')
await expect(stepUpDialog).toBeVisible()
await stepUpDialog.getByRole('button', { name: 'Cancel' }).click()
await expect(stepUpDialog).toBeHidden()
await closeImportReview(page)
await expectDataTablePresence(page, localTableName, true)
await openReplaceImportReview(page, bundle, `cap-replace-retry-${suffix}.json`)
await page.getByRole('button', { name: 'Replace site' }).click()
await expect(stepUpDialog).toBeVisible()
await page.getByTestId('step-up-password').fill('wrong-password-12345')
await page.getByTestId('step-up-confirm').click()
await expect(stepUpDialog.getByRole('alert')).toBeVisible()
await expectDataTablePresence(page, localTableName, true)
await page.getByTestId('step-up-password').fill(OWNER.password)
await page.getByTestId('step-up-confirm').click()
await expect(stepUpDialog).toBeHidden({ timeout: 20_000 })
await expect(siteImportDialog(page, 'Review bundle')).toHaveCount(0)
await expectDataTablePresence(page, bundledTableName, true)
await expectDataTablePresence(page, localTableName, false)
} finally {
await context.close()
}
})
})
test.describe.serial('plugin capability boundaries', () => {
test.use({ storageState: ANONYMOUS_STATE })
test.setTimeout(180_000)
const suffix = Date.now().toString(36)
const actionPluginName = `CAP Plugin Actions ${suffix}`
const automationPluginId = `cap.automation-${suffix}`
const automationPluginName = `CAP Plugin Automation ${suffix}`
const automationScheduleId = `${automationPluginId}.heartbeat`
const actionPluginManifest = {
id: `cap.actions-${suffix}`,
name: actionPluginName,
version: '1.0.0',
apiVersion: 1,
description: 'Capability fixture for plugin action visibility.',
permissions: [],
settings: [
{
id: 'mode',
label: 'Mode',
type: 'text',
default: 'draft',
},
],
}
const personas: Record<'reader' | 'installer' | 'configurator' | 'lifecycle', PersonaAccount> = {
reader: {
roleName: `CAP Plugin Reader ${suffix}`,
email: `cap-plugin-reader-${suffix}@example.com`,
password: 'cap-plugin-reader-pass-12345',
},
installer: {
roleName: `CAP Plugin Installer ${suffix}`,
email: `cap-plugin-installer-${suffix}@example.com`,
password: 'cap-plugin-installer-pass-12345',
},
configurator: {
roleName: `CAP Plugin Configurator ${suffix}`,
email: `cap-plugin-configurator-${suffix}@example.com`,
password: 'cap-plugin-configurator-pass-12345',
},
lifecycle: {
roleName: `CAP Plugin Lifecycle ${suffix}`,
email: `cap-plugin-lifecycle-${suffix}@example.com`,
password: 'cap-plugin-lifecycle-pass-12345',
},
}
test.beforeAll(async ({ browser }, testInfo) => {
testInfo.setTimeout(180_000)
const context = await browser.newContext()
const ownerPage = await context.newPage()
try {
await login(ownerPage)
await openPluginsWorkspace(ownerPage)
await installReviewedPlugin(ownerPage, actionPluginManifest, OWNER.password)
await installReviewedPluginPackage(
ownerPage,
automationPluginId,
automationPluginName,
pluginAutomationPackageFiles(automationPluginId, automationPluginName),
OWNER.password,
)
await createRole(ownerPage, personas.reader.roleName, ['Browse installed plugins'])
await createRole(ownerPage, personas.installer.roleName, [
'Browse installed plugins',
'Install or uninstall plugins',
])
await createRole(ownerPage, personas.configurator.roleName, [
'Browse installed plugins',
'Configure plugins',
])
await createRole(ownerPage, personas.lifecycle.roleName, [
'Browse installed plugins',
'Plugin lifecycle control',
])
for (const persona of Object.values(personas)) {
await createUser(ownerPage, {
email: persona.email,
displayName: persona.roleName,
password: persona.password,
role: persona.roleName,
})
}
} finally {
await context.close()
}
})
test('plugin reader can browse without install controls (CAP-005)', async ({
browser,
}) => {
await withPersona(browser, personas.reader, async (personaPage) => {
await openPluginsWorkspace(personaPage)
await expect(personaPage.getByRole('button', { name: 'Upload Plugin' })).toHaveCount(0)
const pluginCard = installedPluginCard(personaPage, actionPluginName)
await expect(pluginCard).toBeVisible()
await expect(
pluginCard.getByRole('button', { name: `Edit settings for ${actionPluginName}` }),
).toHaveCount(0)
await expect(
pluginCard.getByRole('button', { name: `Disable ${actionPluginName}` }),
).toHaveCount(0)
await expect(
pluginCard.getByRole('button', { name: `Remove ${actionPluginName}` }),
).toHaveCount(0)
const automationCard = installedPluginCard(personaPage, automationPluginName)
await expect(automationCard).toBeVisible()
await expectPackResyncButton(automationCard, automationPluginName, false)
await expectScheduleControls(
personaPage,
automationCard,
automationPluginName,
automationScheduleId,
false,
)
})
})
test('plugin installer can access upload controls (CAP-005)', async ({
browser,
}) => {
await withPersona(browser, personas.installer, async (personaPage) => {
await openPluginsWorkspace(personaPage)
await expect(personaPage.getByRole('button', { name: 'Upload Plugin' })).toBeVisible()
const pluginCard = installedPluginCard(personaPage, actionPluginName)
await expect(
pluginCard.getByRole('button', { name: `Remove ${actionPluginName}` }),
).toBeVisible()
await expect(
pluginCard.getByRole('button', { name: `Edit settings for ${actionPluginName}` }),
).toHaveCount(0)
await expect(
pluginCard.getByRole('button', { name: `Disable ${actionPluginName}` }),
).toHaveCount(0)
const automationCard = installedPluginCard(personaPage, automationPluginName)
await expect(automationCard).toBeVisible()
await expectPackResyncButton(automationCard, automationPluginName, true)
await expect(
automationCard.getByRole('button', { name: `View schedules for ${automationPluginName}` }),
).toBeVisible()
})
})
test('plugin configurator can open settings without install or lifecycle controls (CAP-005)', async ({
browser,
}) => {
await withPersona(browser, personas.configurator, async (personaPage) => {
await openPluginsWorkspace(personaPage)
await expect(personaPage.getByRole('button', { name: 'Upload Plugin' })).toHaveCount(0)
const pluginCard = installedPluginCard(personaPage, actionPluginName)
await expect(
pluginCard.getByRole('button', { name: `Edit settings for ${actionPluginName}` }),
).toBeVisible()
await expect(
pluginCard.getByRole('button', { name: `Disable ${actionPluginName}` }),
).toHaveCount(0)
await expect(
pluginCard.getByRole('button', { name: `Remove ${actionPluginName}` }),
).toHaveCount(0)
await pluginCard
.getByRole('button', { name: `Edit settings for ${actionPluginName}` })
.click()
const dialog = personaPage.getByRole('dialog', { name: actionPluginName })
await expect(dialog).toBeVisible()
await expect(dialog.getByLabel('Mode')).toHaveValue('draft')
await dialog.getByRole('button', { name: 'Cancel' }).click()
const automationCard = installedPluginCard(personaPage, automationPluginName)
await expect(automationCard).toBeVisible()
await expectPackResyncButton(automationCard, automationPluginName, false)
await expect(
automationCard.getByRole('button', { name: `View schedules for ${automationPluginName}` }),
).toBeVisible()
})
})
test('plugin lifecycle operator can toggle without install or settings controls (CAP-005)', async ({
browser,
}) => {
await withPersona(browser, personas.lifecycle, async (personaPage) => {
await openPluginsWorkspace(personaPage)
await expect(personaPage.getByRole('button', { name: 'Upload Plugin' })).toHaveCount(0)
const pluginCard = installedPluginCard(personaPage, actionPluginName)
await expect(
pluginCard.getByRole('button', { name: `Disable ${actionPluginName}` }),
).toBeVisible()
await expect(
pluginCard.getByRole('button', { name: `Edit settings for ${actionPluginName}` }),
).toHaveCount(0)
await expect(
pluginCard.getByRole('button', { name: `Remove ${actionPluginName}` }),
).toHaveCount(0)
const automationCard = installedPluginCard(personaPage, automationPluginName)
await expect(automationCard).toBeVisible()
await expectPackResyncButton(automationCard, automationPluginName, false)
await expectScheduleControls(
personaPage,
automationCard,
automationPluginName,
automationScheduleId,
true,
)
})
})
test('plugin install requires successful step-up before mutating (CAP-003)', async ({
browser,
}) => {
await withPersona(browser, personas.installer, async (personaPage) => {
await openPluginsWorkspace(personaPage)
const pluginName = `CAP Step-Up Plugin ${suffix}`
await uploadPluginManifest(personaPage, {
id: `cap.stepup-${suffix}`,
name: pluginName,
version: '1.0.0',
apiVersion: 1,
permissions: [],
})
await expect(
personaPage.getByRole('heading', { name: `Review ${pluginName}` }),
).toBeVisible()
await expect(installedPluginHeading(personaPage, pluginName)).toHaveCount(0)
await personaPage.getByRole('button', { name: 'Approve and Install' }).click()
const stepUpDialog = personaPage.getByTestId('step-up-dialog')
await expect(stepUpDialog).toBeVisible()
await stepUpDialog.getByRole('button', { name: 'Cancel' }).click()
await expect(stepUpDialog).toBeHidden()
await expect(installedPluginHeading(personaPage, pluginName)).toHaveCount(0)
await personaPage.getByRole('button', { name: 'Approve and Install' }).click()
await expect(stepUpDialog).toBeVisible()
await personaPage.getByTestId('step-up-password').fill('wrong-password-12345')
await personaPage.getByTestId('step-up-confirm').click()
await expect(stepUpDialog.getByRole('alert')).toBeVisible()
await expect(installedPluginHeading(personaPage, pluginName)).toHaveCount(0)
await personaPage.getByTestId('step-up-password').fill(personas.installer.password)
await personaPage.getByTestId('step-up-confirm').click()
await expect(stepUpDialog).toBeHidden({ timeout: 20_000 })
await expect(
personaPage.getByRole('heading', { name: `Review ${pluginName}` }),
).toHaveCount(0)
await expect(installedPluginHeading(personaPage, pluginName)).toBeVisible()
})
})
test('plugin uninstall requires successful step-up before mutating (CAP-003)', async ({
browser,
}) => {
const pluginName = `CAP Remove Plugin ${suffix}`
const manifest = {
id: `cap.remove-${suffix}`,
name: pluginName,
version: '1.0.0',
apiVersion: 1,
permissions: [],
}
await withPersona(browser, personas.installer, async (personaPage) => {
await openPluginsWorkspace(personaPage)
await installReviewedPlugin(personaPage, manifest, personas.installer.password)
await expect(installedPluginHeading(personaPage, pluginName)).toBeVisible()
})
await withPersona(browser, personas.installer, async (personaPage) => {
await openPluginsWorkspace(personaPage)
await expect(installedPluginHeading(personaPage, pluginName)).toBeVisible()
await openRemovePluginDialog(personaPage, pluginName)
const stepUpDialog = personaPage.getByTestId('step-up-dialog')
await expect(stepUpDialog).toBeVisible()
await stepUpDialog.getByRole('button', { name: 'Cancel' }).click()
await expect(stepUpDialog).toBeHidden()
await expect(installedPluginHeading(personaPage, pluginName)).toBeVisible()
await openRemovePluginDialog(personaPage, pluginName)
await expect(stepUpDialog).toBeVisible()
await personaPage.getByTestId('step-up-password').fill('wrong-password-12345')
await personaPage.getByTestId('step-up-confirm').click()
await expect(stepUpDialog.getByRole('alert')).toBeVisible()
await expect(installedPluginHeading(personaPage, pluginName)).toBeVisible()
await personaPage.getByTestId('step-up-password').fill(personas.installer.password)
await personaPage.getByTestId('step-up-confirm').click()
await expect(stepUpDialog).toBeHidden({ timeout: 20_000 })
await expect(installedPluginHeading(personaPage, pluginName)).toHaveCount(0)
})
})
})
test.describe.serial('AI capability boundaries', () => {
test.use({ storageState: ANONYMOUS_STATE })
test.setTimeout(180_000)
const suffix = Date.now().toString(36)
const personas: Record<'siteReader' | 'chatReader' | 'providerManager' | 'auditor', PersonaAccount> = {
siteReader: {
roleName: `CAP AI Site Reader ${suffix}`,
email: `cap-ai-site-reader-${suffix}@example.com`,
password: 'cap-ai-site-reader-pass-12345',
},
chatReader: {
roleName: `CAP AI Chat Reader ${suffix}`,
email: `cap-ai-chat-reader-${suffix}@example.com`,
password: 'cap-ai-chat-reader-pass-12345',
},
providerManager: {
roleName: `CAP AI Provider Manager ${suffix}`,
email: `cap-ai-provider-manager-${suffix}@example.com`,
password: 'cap-ai-provider-manager-pass-12345',
},
auditor: {
roleName: `CAP AI Auditor ${suffix}`,
email: `cap-ai-auditor-${suffix}@example.com`,
password: 'cap-ai-auditor-pass-12345',
},
}
test.beforeAll(async ({ browser }, testInfo) => {
testInfo.setTimeout(180_000)
const context = await browser.newContext()
const ownerPage = await context.newPage()
try {
await login(ownerPage)
await createRole(ownerPage, personas.siteReader.roleName, ['View site'])
await createRole(ownerPage, personas.chatReader.roleName, [
'View site',
'Use AI chat',
])
await createRole(ownerPage, personas.providerManager.roleName, [
'Manage AI providers',
])
await createRole(ownerPage, personas.auditor.roleName, [
'Read AI audit log',
])
for (const persona of Object.values(personas)) {
await createUser(ownerPage, {
email: persona.email,
displayName: persona.roleName,
password: persona.password,
role: persona.roleName,
})
}
} finally {
await context.close()
}
})