forked from cardosofelipe/fast-next-template
Refactor to enforce AuthContext usage over useAuthStore and improve test stability
- Replaced `useAuthStore` with `useAuth` from `AuthContext` across frontend components and tests to ensure dependency injection compliance. - Enhanced E2E test stability by delaying navigation until the auth context is fully initialized. - Updated Playwright configuration to use a single worker to prevent mock conflicts. - Refactored test setup to consistently inject `AuthProvider` for improved isolation and mocking. - Adjusted comments and documentation to clarify dependency injection and testability patterns.
This commit is contained in:
@@ -11,9 +11,15 @@ test.describe('Sessions Management', () => {
|
||||
// Set up API mocks for authenticated user
|
||||
await setupAuthenticatedMocks(page);
|
||||
|
||||
// Delay to ensure auth store injection completes before navigation
|
||||
await page.waitForTimeout(200);
|
||||
|
||||
// Navigate to sessions settings
|
||||
await page.goto('/settings/sessions');
|
||||
await expect(page).toHaveURL('/settings/sessions');
|
||||
|
||||
// Wait for page to fully load with auth context
|
||||
await page.waitForSelector('h2', { timeout: 10000 });
|
||||
});
|
||||
|
||||
test('should display sessions management page', async ({ page }) => {
|
||||
@@ -132,9 +138,15 @@ test.describe('Sessions Management - Revocation', () => {
|
||||
// Set up API mocks for authenticated user
|
||||
await setupAuthenticatedMocks(page);
|
||||
|
||||
// Delay to ensure auth store injection completes before navigation
|
||||
await page.waitForTimeout(200);
|
||||
|
||||
// Navigate to sessions settings
|
||||
await page.goto('/settings/sessions');
|
||||
await expect(page).toHaveURL('/settings/sessions');
|
||||
|
||||
// Wait for page to fully load with auth context
|
||||
await page.waitForSelector('h2', { timeout: 10000 });
|
||||
});
|
||||
|
||||
test('should show confirmation dialog before individual revocation', async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user