@@ -17,6 +17,7 @@ import {
1717 MOCK_CMS_INFO_HEADER_LOGO_WITH_OTHER_PROPS ,
1818} from './mocks' ;
1919import { MOCK_CMS_INFO } from '../../pages/mocks' ;
20+ import { useDynamicLocalization } from '../../contexts/DynamicLocalizationContext' ;
2021
2122// Mock the useConfig hook
2223jest . mock ( '../../models/hooks' , ( ) => ( {
@@ -30,6 +31,17 @@ jest.mock('../../models/hooks', () => ({
3031 } ) ,
3132} ) ) ;
3233
34+ jest . mock ( '../../contexts/DynamicLocalizationContext' , ( ) => ( {
35+ useDynamicLocalization : jest . fn ( ( ) => ( {
36+ currentLocale : 'en' ,
37+ switchLanguage : jest . fn ( ) ,
38+ clearLanguagePreference : jest . fn ( ) ,
39+ isLoading : false ,
40+ } ) ) ,
41+ } ) ) ;
42+
43+ const mockUseDynamicLocalization = useDynamicLocalization as jest . Mock ;
44+
3345describe ( '<AppLayout />' , ( ) => {
3446 it ( 'renders as expected with children' , async ( ) => {
3547 renderWithLocalizationProvider (
@@ -379,4 +391,46 @@ describe('<AppLayout />', () => {
379391 expect ( headerBackground ) . toMatchSnapshot ( 'header background' ) ;
380392 } ) ;
381393 } ) ;
394+
395+ describe ( 'splitLayout with locale restrictions (temp hack)' , ( ) => {
396+ it ( 'renders split layout when splitLayout is true and locale is English' , ( ) => {
397+ mockUseDynamicLocalization . mockReturnValue ( {
398+ currentLocale : 'en-US' ,
399+ switchLanguage : jest . fn ( ) ,
400+ clearLanguagePreference : jest . fn ( ) ,
401+ isLoading : false ,
402+ } ) ;
403+
404+ const { container } = renderWithLocalizationProvider (
405+ < AppLayout splitLayout = { true } >
406+ < p > Split layout content</ p >
407+ </ AppLayout >
408+ ) ;
409+
410+ // Split layout does not render the card wrapper
411+ expect ( container . querySelector ( '.card' ) ) . not . toBeInTheDocument ( ) ;
412+ screen . getByText ( 'Split layout content' ) ;
413+ } ) ;
414+
415+ it ( 'renders default layout when splitLayout is true but locale is not English' , ( ) => {
416+ mockUseDynamicLocalization . mockReturnValue ( {
417+ currentLocale : 'fr' ,
418+ switchLanguage : jest . fn ( ) ,
419+ clearLanguagePreference : jest . fn ( ) ,
420+ isLoading : false ,
421+ } ) ;
422+
423+ const { container } = renderWithLocalizationProvider (
424+ < AppLayout splitLayout = { true } cmsInfo = { MOCK_CMS_INFO_HEADER_LOGO } >
425+ < p > Default layout content</ p >
426+ </ AppLayout >
427+ ) ;
428+
429+ // Default layout renders with card wrapper
430+ expect ( container . querySelector ( '.card' ) ) . toBeInTheDocument ( ) ;
431+ screen . getByText ( 'Default layout content' ) ;
432+ // CMS info is still applied even when split layout is disabled
433+ expect ( screen . getByAltText ( 'CMS Custom Logo' ) ) . toBeInTheDocument ( ) ;
434+ } ) ;
435+ } ) ;
382436} ) ;
0 commit comments