import { beforeEach, describe, expect, it } from 'vitest'; import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { renderApp, mockGuest } from '@/test/utils'; import { _resetSetupStatusCache } from '@/router'; beforeEach(() => { _resetSetupStatusCache(); }); describe('NotFoundPage', () => { it('renders for an unknown route', async () => { renderApp('/this-route-does-not-exist'); expect(await screen.findByTestId('not-found-title', {}, { timeout: 10000 })).toBeInTheDocument(); expect(screen.getByTestId('not-found-message')).toBeInTheDocument(); }); it('renders the back to dashboard button', async () => { renderApp('/some/nonexistent/path'); expect(await screen.findByTestId('not-found-back-button', {}, { timeout: 10000 })).toBeInTheDocument(); }); it('navigates to login when back button is clicked as guest', async () => { mockGuest(); renderApp('/this-does-not-exist'); const button = await screen.findByTestId('not-found-back-button', {}, { timeout: 10000 }); await userEvent.click(button); expect(await screen.findByTestId('login-form-submit-button')).toBeInTheDocument(); }); });