Skip to content

Commit c79891c

Browse files
OpenStaxClaudeclaude
authored andcommitted
Add test coverage for PortalColumn2 when window is undefined
Added test case "handles portal footer when window is not defined" to verify that the Footer component renders correctly in SSR/test environments where window is not defined. This test covers the typeof window !== 'undefined' check on line 491 in Footer/index.tsx, ensuring that the component gracefully handles the absence of the window object without crashing. Addresses Review 13 from RoyEJohnson. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent d28619f commit c79891c

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

src/app/components/Footer/Footer.spec.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,35 @@ describe('Footer', () => {
112112
expect(focusManager.captureOpeningElement).toHaveBeenCalledWith('contactdialog');
113113
});
114114

115+
it('handles portal footer when window is not defined', () => {
116+
// Save the original window
117+
const originalWindow = global.window;
118+
119+
// Mock window as undefined to simulate SSR/test environment
120+
// @ts-expect-error Testing window undefined scenario
121+
delete global.window;
122+
123+
const portalName = 'portalName';
124+
const params = { portalName };
125+
const state = {
126+
navigation: {
127+
match: { params },
128+
},
129+
} as unknown as AppState;
130+
const store = createTestStore(state);
131+
132+
// Should render without crashing even when window is undefined
133+
expect(() => {
134+
const component = renderer.create(<TestContainer store={store}>
135+
<Footer />
136+
</TestContainer>);
137+
component.unmount();
138+
}).not.toThrow();
139+
140+
// Restore window
141+
global.window = originalWindow;
142+
});
143+
115144
});
116145

117146
describe('useContactDialog', () => {

0 commit comments

Comments
 (0)