@@ -55,8 +55,8 @@ function resetStore() {
5555 selectedNodeId : null ,
5656 selectedNodeIds : [ ] ,
5757 hoveredNodeId : null ,
58- settingsModalOpen : false ,
59- settingsModalSection : 'pages' ,
58+ isSettingsOpen : false ,
59+ activeSection : 'pages' ,
6060 domTreePanel : { collapsed : false , x : 0 , y : 0 , width : 280 } ,
6161 propertiesPanel : { collapsed : false , x : 0 , y : 0 , width : 280 } ,
6262 focusedPanel : 'canvas' ,
@@ -76,8 +76,8 @@ function openModal(section = 'pages', withSite = false) {
7676 useEditorStore . setState ( { site, activePageId : 'page-1' } as Parameters < typeof useEditorStore . setState > [ 0 ] )
7777 }
7878 useEditorStore . setState ( {
79- settingsModalOpen : true ,
80- settingsModalSection : section ,
79+ isSettingsOpen : true ,
80+ activeSection : section ,
8181 } as Parameters < typeof useEditorStore . setState > [ 0 ] )
8282}
8383
@@ -89,13 +89,13 @@ afterEach(cleanup)
8989// ---------------------------------------------------------------------------
9090
9191describe ( 'SettingsModal — render gating' , ( ) => {
92- it ( 'renders nothing when settingsModalOpen is false' , ( ) => {
92+ it ( 'renders nothing when isSettingsOpen is false' , ( ) => {
9393 render ( < SettingsModal /> )
9494 // null render — no dialog in the DOM
9595 expect ( document . querySelector ( '[role="dialog"]' ) ) . toBeNull ( )
9696 } )
9797
98- it ( 'renders the dialog when settingsModalOpen is true' , ( ) => {
98+ it ( 'renders the dialog when isSettingsOpen is true' , ( ) => {
9999 openModal ( )
100100 render ( < SettingsModal /> )
101101 expect ( document . querySelector ( '[role="dialog"]' ) ) . not . toBeNull ( )
@@ -106,7 +106,7 @@ describe('SettingsModal — render gating', () => {
106106 const { unmount } = render ( < SettingsModal /> )
107107 expect ( document . querySelector ( '[role="dialog"]' ) ) . not . toBeNull ( )
108108 act ( ( ) => {
109- useEditorStore . setState ( { settingsModalOpen : false } as Parameters < typeof useEditorStore . setState > [ 0 ] )
109+ useEditorStore . setState ( { isSettingsOpen : false } as Parameters < typeof useEditorStore . setState > [ 0 ] )
110110 } )
111111 unmount ( )
112112 expect ( document . querySelector ( '[role="dialog"]' ) ) . toBeNull ( )
@@ -194,15 +194,15 @@ describe('SettingsModal — backdrop', () => {
194194 expect ( backdrop ) . not . toBeNull ( )
195195 } )
196196
197- it ( 'clicking the backdrop closes the modal (calls closeSettingsModal )' , ( ) => {
197+ it ( 'clicking the backdrop closes the modal (calls closeSettings )' , ( ) => {
198198 openModal ( )
199199 render ( < SettingsModal /> )
200200 // Find the backdrop — it has aria-hidden="true" and the onClick handler
201201 const backdrop = document . querySelector ( '[aria-hidden="true"]' ) as HTMLElement
202202 expect ( backdrop ) . not . toBeNull ( )
203203 fireEvent . click ( backdrop )
204- // After click, store should have settingsModalOpen : false
205- expect ( useEditorStore . getState ( ) . settingsModalOpen ) . toBe ( false )
204+ // After click, store should have isSettingsOpen : false
205+ expect ( useEditorStore . getState ( ) . isSettingsOpen ) . toBe ( false )
206206 } )
207207} )
208208
@@ -367,15 +367,15 @@ describe('SettingsModal — close behaviours', () => {
367367 render ( < SettingsModal /> )
368368 const closeBtn = screen . getByLabelText ( 'Close settings' )
369369 fireEvent . click ( closeBtn )
370- expect ( useEditorStore . getState ( ) . settingsModalOpen ) . toBe ( false )
370+ expect ( useEditorStore . getState ( ) . isSettingsOpen ) . toBe ( false )
371371 } )
372372
373373 it ( 'pressing Escape closes the modal' , ( ) => {
374374 openModal ( )
375375 render ( < SettingsModal /> )
376376 const dialog = screen . getByRole ( 'dialog' )
377377 fireEvent . keyDown ( dialog , { key : 'Escape' , code : 'Escape' } )
378- expect ( useEditorStore . getState ( ) . settingsModalOpen ) . toBe ( false )
378+ expect ( useEditorStore . getState ( ) . isSettingsOpen ) . toBe ( false )
379379 } )
380380
381381 it ( 'pressing Tab does NOT close the modal' , ( ) => {
@@ -384,7 +384,7 @@ describe('SettingsModal — close behaviours', () => {
384384 const dialog = screen . getByRole ( 'dialog' )
385385 fireEvent . keyDown ( dialog , { key : 'Tab' , code : 'Tab' } )
386386 // Modal should still be open
387- expect ( useEditorStore . getState ( ) . settingsModalOpen ) . toBe ( true )
387+ expect ( useEditorStore . getState ( ) . isSettingsOpen ) . toBe ( true )
388388 } )
389389} )
390390
@@ -400,7 +400,7 @@ describe('SettingsModal — focus trap keyboard logic', () => {
400400 // The dialog should handle keydown (for Esc + Tab trap).
401401 // We verify the Escape path works as a proxy for the handler being present.
402402 fireEvent . keyDown ( dialog , { key : 'Escape' } )
403- expect ( useEditorStore . getState ( ) . settingsModalOpen ) . toBe ( false )
403+ expect ( useEditorStore . getState ( ) . isSettingsOpen ) . toBe ( false )
404404 } )
405405
406406 it ( 'pressing Escape on a child element inside the dialog closes the modal' , ( ) => {
@@ -409,7 +409,7 @@ describe('SettingsModal — focus trap keyboard logic', () => {
409409 const closeBtn = screen . getByLabelText ( 'Close settings' )
410410 // Escape on a child — should bubble to dialog's onKeyDown
411411 fireEvent . keyDown ( closeBtn , { key : 'Escape' } )
412- expect ( useEditorStore . getState ( ) . settingsModalOpen ) . toBe ( false )
412+ expect ( useEditorStore . getState ( ) . isSettingsOpen ) . toBe ( false )
413413 } )
414414} )
415415
@@ -598,14 +598,14 @@ describe('SettingsModal — Guideline #225 focus return (source enforcement)', (
598598// uiSlice.ts store default — FIXED by Performance Engineer (#358) ✅
599599// ---------------------------------------------------------------------------
600600
601- describe ( 'SettingsButton + uiSlice — section ID alignment (source enforcement)' , ( ) => {
601+ describe ( 'SettingsButton + settingsSlice — section ID alignment (source enforcement)' , ( ) => {
602602 const btnSrc = readFileSync (
603603 new URL ( '../../admin/pages/site/toolbar/SettingsButton.tsx' , import . meta. url ) ,
604604 'utf-8' ,
605605 )
606606
607- const uiSliceSrc = readFileSync (
608- new URL ( '../../admin/pages/site/store/slices/uiSlice .ts' , import . meta. url ) ,
607+ const settingsSliceSrc = readFileSync (
608+ new URL ( '../../admin/pages/site/store/slices/settingsSlice .ts' , import . meta. url ) ,
609609 'utf-8' ,
610610 )
611611
@@ -615,10 +615,12 @@ describe('SettingsButton + uiSlice — section ID alignment (source enforcement)
615615 expect ( btnSrc ) . not . toContain ( "openSettings('general')" )
616616 } )
617617
618- it ( 'uiSlice settingsModalSection default is a valid section ID (not "general")' , ( ) => {
619- // Fixed in Contribution #358: settingsModalSection: 'general' → 'pages'.
620- // Also openSettingsModal default parameter: section = 'general' → 'pages'.
621- expect ( uiSliceSrc ) . not . toContain ( "settingsModalSection: 'general'" )
618+ it ( 'settingsSlice activeSection default is a valid section ID' , ( ) => {
619+ // The default literal must be one of the NAV_ITEMS ids — picking an
620+ // invalid one (e.g. retired "typography" / "colors") would silently
621+ // fall through to "general" via `normalizeSection` in SettingsModal,
622+ // hiding what the user is supposed to see on first open.
623+ expect ( settingsSliceSrc ) . toMatch ( / D E F A U L T _ S E C T I O N : S e t t i n g s S e c t i o n = ' ( g e n e r a l | p a g e s | b r e a k p o i n t s | s h o r t c u t s | p u b l i s h i n g | p r e f e r e n c e s | m o d u l e s ) ' / )
622624 } )
623625} )
624626
0 commit comments