@@ -14,6 +14,36 @@ Cypress.on("uncaught:exception", err => {
1414} ) ;
1515
1616describe ( "Palette Category Navigation E2E Integration" , ( ) => {
17+ const paletteRows = "#palette > div > table:last-child tbody tr" ;
18+
19+ const openPalette = ( label , name ) => {
20+ cy . contains ( paletteRows , new RegExp ( `^${ label } $` ) )
21+ . should ( "be.visible" )
22+ . click ( ) ;
23+ cy . get ( "#PaletteBody" , { timeout : 15000 } ) . should ( "be.visible" ) ;
24+ cy . get ( "#PaletteBody thead" ) . should ( "contain.text" , label ) ;
25+ cy . get ( "#PaletteBody_items tr" ) . should ( "have.length.greaterThan" , 0 ) ;
26+ cy . window ( ) . should ( win => {
27+ const activity = win . ActivityContext
28+ ? win . ActivityContext . getActivity ( )
29+ : win . globalActivity ;
30+ expect ( activity , "Activity singleton should be loaded" ) . to . exist ;
31+ expect ( activity . palettes , "Palettes instance should be loaded" ) . to . exist ;
32+ expect ( activity . palettes . activePalette , `activePalette should be ${ name } ` ) . to . equal (
33+ name
34+ ) ;
35+ } ) ;
36+ } ;
37+
38+ const closePalette = ( ) => {
39+ cy . get ( '#PaletteBody img[alt="Close"]' ) . click ( ) ;
40+ cy . get ( "#PaletteBody" ) . should ( "not.exist" ) ;
41+ } ;
42+
43+ const selectPaletteGroup = index => {
44+ cy . get ( '#palette [role="tab"]' ) . eq ( index ) . should ( "be.visible" ) . trigger ( "mouseover" ) ;
45+ } ;
46+
1747 before ( ( ) => {
1848 cy . visit ( "http://127.0.0.1:3000" ) ;
1949 cy . clearLocalStorage ( ) ;
@@ -31,86 +61,22 @@ describe("Palette Category Navigation E2E Integration", () => {
3161 } ) ;
3262
3363 it ( "switches across palette categories and verifies DOM rendering and activePalette state" , ( ) => {
34- // Assert the main palette sidebar container is present and visible
3564 cy . get ( "#palette" , { timeout : 30000 } ) . should ( "be.visible" ) ;
65+ cy . get ( '#palette [role="tab"]' ) . should ( "have.length" , 3 ) ;
3666
37- // 1. Navigate to Rhythm palette (row index 1 in default Music group)
38- cy . get ( '[width="126"] tbody tr' ) . eq ( 1 ) . find ( "img" ) . click ( ) ;
39- cy . get ( "#PaletteBody" , { timeout : 15000 } ) . should ( "be.visible" ) ;
40- cy . get ( "#PaletteBody thead" , { timeout : 15000 } ) . should ( "contain.text" , "Rhythm" ) ;
41- cy . get ( "#PaletteBody_items tr" , { timeout : 15000 } ) . should ( "have.length.greaterThan" , 0 ) ;
42- cy . window ( ) . should ( win => {
43- const activity = win . ActivityContext
44- ? win . ActivityContext . getActivity ( )
45- : win . globalActivity ;
46- expect ( activity , "Activity singleton should be loaded" ) . to . exist ;
47- expect ( activity . palettes , "Palettes instance should be loaded" ) . to . exist ;
48- expect ( activity . palettes . activePalette , "activePalette should be rhythm" ) . to . equal (
49- "rhythm"
50- ) ;
51- } ) ;
52-
53- // 2. Navigate to Widgets palette (row index 2 in default Music group)
54- cy . get ( '[width="126"] tbody tr' ) . eq ( 2 ) . find ( "img" ) . click ( ) ;
55- cy . get ( "#PaletteBody" , { timeout : 15000 } ) . should ( "be.visible" ) ;
56- cy . get ( "#PaletteBody thead" , { timeout : 15000 } ) . should ( "contain.text" , "Widgets" ) ;
57- cy . get ( "#PaletteBody_items tr" , { timeout : 15000 } ) . should ( "have.length.greaterThan" , 0 ) ;
58- cy . window ( ) . should ( win => {
59- const activity = win . ActivityContext
60- ? win . ActivityContext . getActivity ( )
61- : win . globalActivity ;
62- expect ( activity . palettes . activePalette , "activePalette should be widgets" ) . to . equal (
63- "widgets"
64- ) ;
65- } ) ;
66-
67- // 3. Switch to Graphics & Media multipalette group tab
68- cy . get ( '#palette [role="tab"]' ) . first ( ) . click ( ) ;
67+ openPalette ( "Rhythm" , "rhythm" ) ;
68+ closePalette ( ) ;
69+ openPalette ( "Widgets" , "widgets" ) ;
70+ closePalette ( ) ;
6971
70- // 4. Navigate to Turtle palette (row index 1 in Graphics & Media group)
71- cy . get ( '[width="126"] tbody tr' ) . eq ( 1 ) . find ( "img" ) . click ( ) ;
72- cy . get ( "#PaletteBody" , { timeout : 15000 } ) . should ( "be.visible" ) ;
73- cy . get ( "#PaletteBody thead" , { timeout : 15000 } ) . should ( "contain.text" , "Turtle" ) ;
74- cy . get ( "#PaletteBody_items tr" , { timeout : 15000 } ) . should ( "have.length.greaterThan" , 0 ) ;
75- cy . window ( ) . should ( win => {
76- const activity = win . ActivityContext
77- ? win . ActivityContext . getActivity ( )
78- : win . globalActivity ;
79- expect ( activity . palettes . activePalette , "activePalette should be turtle" ) . to . equal (
80- "turtle"
81- ) ;
82- } ) ;
72+ selectPaletteGroup ( 1 ) ;
73+ openPalette ( "Flow" , "flow" ) ;
74+ closePalette ( ) ;
75+ openPalette ( "Number" , "number" ) ;
76+ closePalette ( ) ;
8377
84- // 5. Navigate to Numbers palette (row index 2 in Graphics & Media group)
85- cy . get ( '[width="126"] tbody tr' ) . eq ( 2 ) . find ( "img" ) . click ( ) ;
86- cy . get ( "#PaletteBody" , { timeout : 15000 } ) . should ( "be.visible" ) ;
87- cy . get ( "#PaletteBody thead" , { timeout : 15000 } ) . should ( "contain.text" , "Numbers" ) ;
88- cy . get ( "#PaletteBody_items tr" , { timeout : 15000 } ) . should ( "have.length.greaterThan" , 0 ) ;
89- cy . window ( ) . should ( win => {
90- const activity = win . ActivityContext
91- ? win . ActivityContext . getActivity ( )
92- : win . globalActivity ;
93- expect ( activity . palettes . activePalette , "activePalette should be numbers" ) . to . equal (
94- "numbers"
95- ) ;
96- } ) ;
97-
98- // 6. Navigate to Flow palette (row index 3 in Graphics & Media group)
99- cy . get ( '[width="126"] tbody tr' ) . eq ( 3 ) . find ( "img" ) . click ( ) ;
100- cy . get ( "#PaletteBody" , { timeout : 15000 } ) . should ( "be.visible" ) ;
101- cy . get ( "#PaletteBody thead" , { timeout : 15000 } ) . should ( "contain.text" , "Flow" ) ;
102- cy . get ( "#PaletteBody_items tr" , { timeout : 15000 } ) . should ( "have.length.greaterThan" , 0 ) ;
103- cy . window ( ) . should ( win => {
104- const activity = win . ActivityContext
105- ? win . ActivityContext . getActivity ( )
106- : win . globalActivity ;
107- expect ( activity . palettes . activePalette , "activePalette should be flow" ) . to . equal (
108- "flow"
109- ) ;
110- } ) ;
111-
112- // 7. Verify close button dismisses #PaletteBody
113- cy . get ( '#PaletteBody img[alt="Close"]' ) . click ( ) ;
114- cy . get ( "#PaletteBody" ) . should ( "not.exist" ) ;
78+ selectPaletteGroup ( 2 ) ;
79+ openPalette ( "Graphics" , "graphics" ) ;
80+ closePalette ( ) ;
11581 } ) ;
11682} ) ;
0 commit comments