Refactor E2E tests to use ID selectors and enhance mock auth injection

- Updated E2E selectors for input fields to use stable IDs instead of `name` attributes, improving reliability and alignment with form field guarantees.
- Refined mock auth state injection in Playwright to establish test store state prior to page load.
- Optimized test clarity and consistency by consolidating selector logic and introducing stabilization steps where necessary.
- Removed redundant `AuthInitializer` mocks and refactored related tests to align with the updated `AuthContext` pattern.
- Enhanced readability and maintainability across affected test suites.
This commit is contained in:
Felipe Cardoso
2025-11-04 00:32:07 +01:00
parent 26d43ff9e1
commit 7c98ceb5b9
6 changed files with 152 additions and 91 deletions

View File

@@ -13,10 +13,6 @@ jest.mock('@/components/theme', () => ({
),
}));
jest.mock('@/components/auth', () => ({
AuthInitializer: () => <div data-testid="auth-initializer" />,
}));
// Mock TanStack Query
jest.mock('@tanstack/react-query', () => ({
QueryClient: jest.fn().mockImplementation(() => ({})),
@@ -56,16 +52,6 @@ describe('Providers', () => {
expect(screen.getByTestId('query-provider')).toBeInTheDocument();
});
it('renders AuthInitializer', () => {
render(
<Providers>
<div>Test Content</div>
</Providers>
);
expect(screen.getByTestId('auth-initializer')).toBeInTheDocument();
});
it('renders children', () => {
render(
<Providers>