test(e2e): add 14 new web E2E test files for critical user flows
Cover auth (login, register, OAuth callbacks), search with filters, listing detail, dashboard, analytics, create listing form, admin dashboard/users/moderation/KYC, navigation routing, and responsive design. Total 91 test cases using Playwright with API route mocking. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
57
e2e/web/auth-oauth-callback.spec.ts
Normal file
57
e2e/web/auth-oauth-callback.spec.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('OAuth Callback Pages', () => {
|
||||
test.describe('Google callback', () => {
|
||||
test('shows loading state while processing', async ({ page }) => {
|
||||
// Intercept token exchange to keep it pending
|
||||
await page.route('**/auth/google/callback**', (route) =>
|
||||
new Promise(() => {
|
||||
// Never resolve — keeps loading state visible
|
||||
}),
|
||||
);
|
||||
|
||||
await page.goto('/auth/callback/google?code=test-code');
|
||||
// Should show a loading/spinner state
|
||||
await expect(page.locator('.animate-spin').first()).toBeVisible({ timeout: 5000 });
|
||||
});
|
||||
|
||||
test('redirects to login with error on failure', async ({ page }) => {
|
||||
await page.route('**/auth/google/callback**', (route) =>
|
||||
route.fulfill({
|
||||
status: 401,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({ message: 'OAuth failed' }),
|
||||
}),
|
||||
);
|
||||
|
||||
await page.goto('/auth/callback/google?code=bad-code');
|
||||
await expect(page).toHaveURL(/\/login\?error=/, { timeout: 10000 });
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Zalo callback', () => {
|
||||
test('shows loading state while processing', async ({ page }) => {
|
||||
await page.route('**/auth/zalo/callback**', (route) =>
|
||||
new Promise(() => {
|
||||
// Never resolve
|
||||
}),
|
||||
);
|
||||
|
||||
await page.goto('/auth/callback/zalo?code=test-code');
|
||||
await expect(page.locator('.animate-spin').first()).toBeVisible({ timeout: 5000 });
|
||||
});
|
||||
|
||||
test('redirects to login with error on failure', async ({ page }) => {
|
||||
await page.route('**/auth/zalo/callback**', (route) =>
|
||||
route.fulfill({
|
||||
status: 401,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({ message: 'OAuth failed' }),
|
||||
}),
|
||||
);
|
||||
|
||||
await page.goto('/auth/callback/zalo?code=bad-code');
|
||||
await expect(page).toHaveURL(/\/login\?error=/, { timeout: 10000 });
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user