fix: enhance login navigation flow with improved error handling and visibility checks

This commit is contained in:
GitHub Actions
2026-02-13 19:09:48 +00:00
parent c369f4f2b8
commit 2aaa27cfec
+14 -1
View File
@@ -157,8 +157,15 @@ async function navigateToLogin(page: import('@playwright/test').Page): Promise<v
const logoutButton = page.getByRole('button', { name: /logout/i }).first();
if (await logoutButton.isVisible().catch(() => false)) {
await logoutButton.click();
await page.waitForURL(/\/login/, { timeout: 15000 }).catch(() => undefined);
} else {
await page.goto('/login', { waitUntil: 'domcontentloaded' });
try {
await page.goto('/login', { waitUntil: 'domcontentloaded' });
} catch (error) {
if (!(error instanceof Error) || !error.message.includes('interrupted by another navigation')) {
throw error;
}
}
}
const emailInput = page.locator('input[type="email"]').or(page.getByLabel(/email/i)).first();
@@ -173,6 +180,11 @@ async function loginWithCredentials(
const emailInput = page.locator('input[type="email"]').or(page.getByLabel(/email/i)).first();
const passwordInput = page.locator('input[type="password"]').or(page.getByLabel(/password/i)).first();
const hasEmailInput = await emailInput.isVisible().catch(() => false);
if (!hasEmailInput) {
await navigateToLogin(page);
}
await expect(emailInput).toBeVisible({ timeout: 15000 });
await expect(passwordInput).toBeVisible({ timeout: 15000 });
await emailInput.fill(email);
@@ -344,6 +356,7 @@ test.describe('Admin-User E2E Workflow', () => {
}
// Login as admin
await navigateToLogin(page);
await loginWithCredentials(page, adminEmail, TEST_PASSWORD);
const token = await getAuthToken(page);