Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ const App: React.FC = () => {
const [viewBasis, setViewBasis] = useState<Basis>(Basis.Bell);
const [drawerOpen, setDrawerOpen] = useState(false);
const [infoOpen, setInfoOpen] = useState(false);

// Show the educational panel automatically on first run
useEffect(() => {
if (!localStorage.getItem('infoWindowSeen')) {
setInfoOpen(true);
}
}, []);

useEffect(() => {
// Initialize controller with default parameters
Expand Down Expand Up @@ -44,6 +51,11 @@ const App: React.FC = () => {
setEngineType(type);
};

const handleInfoClose = () => {
setInfoOpen(false);
localStorage.setItem('infoWindowSeen', 'true');
};

return (
<div className="app-container">
<header>
Expand Down Expand Up @@ -101,9 +113,9 @@ const App: React.FC = () => {
</div>
</main>

<InfoWindow
<InfoWindow
isOpen={infoOpen}
onClose={() => setInfoOpen(false)}
onClose={handleInfoClose}
/>

<Attribution />
Expand Down
22 changes: 21 additions & 1 deletion tests/components/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ describe('App', () => {

beforeEach(() => {
vi.clearAllMocks();
localStorage.clear();
localStorage.setItem('infoWindowSeen', 'true');

// Setup the controller mock to provide immediate state
(SimulationController as unknown as ReturnType<typeof vi.fn>).mockImplementation(
Expand Down Expand Up @@ -328,4 +330,22 @@ describe('App', () => {
// Verify the header contains the title
expect(header).toContainElement(headerTitle);
});
});

test('shows info window on first run when not previously seen', () => {
localStorage.clear();

render(<App />);

expect(screen.getByTestId('info-window')).toBeInTheDocument();
});

test('closing info window sets localStorage flag', () => {
localStorage.clear();

render(<App />);

fireEvent.click(screen.getByLabelText('Close information window'));

expect(localStorage.getItem('infoWindowSeen')).toBe('true');
});
});