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('AccessDeniedPage', () => { it('renders the 403 title and message', async () => { renderApp('/403'); expect(await screen.findByTestId('access-denied-title', {}, { timeout: 10000 })).toBeInTheDocument(); expect(screen.getByTestId('access-denied-message')).toBeInTheDocument(); }); it('renders the back to dashboard button', async () => { renderApp('/403'); expect(await screen.findByTestId('access-denied-back-button', {}, { timeout: 10000 })).toBeInTheDocument(); }); it('navigates to login when back button is clicked as guest', async () => { mockGuest(); renderApp('/403'); const button = await screen.findByTestId('access-denied-back-button', {}, { timeout: 10000 }); await userEvent.click(button); expect(await screen.findByTestId('login-form-submit-button')).toBeInTheDocument(); }); });