forked from cardosofelipe/fast-next-template
Refactor useAuth hook, settings components, and docs for formatting and readability improvements
- Consolidated multi-line arguments into single lines where appropriate in `useAuth`. - Improved spacing and readability in data processing across components (`ProfileSettingsForm`, `PasswordChangeForm`, `SessionCard`). - Applied consistent table and markdown formatting in design system docs (e.g., `README.md`, `08-ai-guidelines.md`, `00-quick-start.md`). - Updated code snippets to ensure adherence to Prettier rules and streamlined JSX structures.
This commit is contained in:
@@ -63,6 +63,7 @@ npm run test:e2e -- --debug
|
||||
**Test Results:** 34/43 passing (79% pass rate)
|
||||
|
||||
### Passing Tests ✅
|
||||
|
||||
- All AuthGuard tests (8/8)
|
||||
- Most Login tests (6/8)
|
||||
- Most Registration tests (7/11)
|
||||
@@ -83,6 +84,7 @@ The 9 failing tests are due to minor validation message text mismatches between
|
||||
### Recommendations
|
||||
|
||||
These failures can be fixed by:
|
||||
|
||||
1. Inspecting the actual error messages rendered by forms
|
||||
2. Updating test assertions to match exact wording
|
||||
3. Adding more specific selectors to avoid strict mode violations
|
||||
@@ -98,6 +100,7 @@ The core functionality is working - the failures are only assertion mismatches,
|
||||
## Configuration
|
||||
|
||||
See `playwright.config.ts` for:
|
||||
|
||||
- Browser targets (Chromium, Firefox, WebKit)
|
||||
- Base URL configuration
|
||||
- Screenshot and video settings
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
*/
|
||||
|
||||
import { test, expect } from '@playwright/test';
|
||||
import {
|
||||
setupAuthenticatedMocks,
|
||||
setupSuperuserMocks,
|
||||
} from './helpers/auth';
|
||||
import { setupAuthenticatedMocks, setupSuperuserMocks } from './helpers/auth';
|
||||
|
||||
test.describe('Admin Access Control', () => {
|
||||
test('regular user should not see admin link in header', async ({ page }) => {
|
||||
@@ -25,9 +22,7 @@ test.describe('Admin Access Control', () => {
|
||||
expect(visibleAdminLinks).toBe(0);
|
||||
});
|
||||
|
||||
test('regular user should be redirected when accessing admin page directly', async ({
|
||||
page,
|
||||
}) => {
|
||||
test('regular user should be redirected when accessing admin page directly', async ({ page }) => {
|
||||
// Set up mocks for regular user
|
||||
await setupAuthenticatedMocks(page);
|
||||
// Auth already cached in storage state (loginViaUI removed for performance)
|
||||
@@ -60,9 +55,7 @@ test.describe('Admin Access Control', () => {
|
||||
await expect(headerAdminLink).toHaveAttribute('href', '/admin');
|
||||
});
|
||||
|
||||
test('superuser should be able to access admin dashboard', async ({
|
||||
page,
|
||||
}) => {
|
||||
test('superuser should be able to access admin dashboard', async ({ page }) => {
|
||||
// Set up mocks for superuser
|
||||
await setupSuperuserMocks(page);
|
||||
// Auth already cached in storage state (loginViaUI removed for performance)
|
||||
@@ -110,23 +103,15 @@ test.describe('Admin Dashboard', () => {
|
||||
await expect(statTitles.filter({ hasText: 'Total Users' })).toBeVisible();
|
||||
await expect(statTitles.filter({ hasText: 'Active Users' })).toBeVisible();
|
||||
await expect(statTitles.filter({ hasText: 'Organizations' })).toBeVisible();
|
||||
await expect(
|
||||
statTitles.filter({ hasText: 'Active Sessions' })
|
||||
).toBeVisible();
|
||||
await expect(statTitles.filter({ hasText: 'Active Sessions' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('should display quick action cards', async ({ page }) => {
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Quick Actions', exact: true })
|
||||
).toBeVisible();
|
||||
await expect(page.getByRole('heading', { name: 'Quick Actions', exact: true })).toBeVisible();
|
||||
|
||||
// Should have three action cards (use unique descriptive text to avoid sidebar matches)
|
||||
await expect(
|
||||
page.getByText('View, create, and manage user accounts')
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByText('Manage organizations and their members')
|
||||
).toBeVisible();
|
||||
await expect(page.getByText('View, create, and manage user accounts')).toBeVisible();
|
||||
await expect(page.getByText('Manage organizations and their members')).toBeVisible();
|
||||
await expect(page.getByText('Configure system-wide settings')).toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -222,9 +207,7 @@ test.describe('Admin Navigation', () => {
|
||||
await expect(page.getByText('Admin Panel')).toBeVisible();
|
||||
});
|
||||
|
||||
test('should navigate back to dashboard from users page', async ({
|
||||
page,
|
||||
}) => {
|
||||
test('should navigate back to dashboard from users page', async ({ page }) => {
|
||||
await page.goto('/admin/users');
|
||||
|
||||
// Click dashboard link in sidebar
|
||||
@@ -275,10 +258,7 @@ test.describe('Admin Breadcrumbs', () => {
|
||||
// Click 'Admin' breadcrumb to go back to dashboard
|
||||
const adminBreadcrumb = page.getByTestId('breadcrumb-admin');
|
||||
|
||||
await Promise.all([
|
||||
page.waitForURL('/admin'),
|
||||
adminBreadcrumb.click()
|
||||
]);
|
||||
await Promise.all([page.waitForURL('/admin'), adminBreadcrumb.click()]);
|
||||
|
||||
await expect(page).toHaveURL('/admin');
|
||||
});
|
||||
|
||||
@@ -74,18 +74,19 @@ test.describe('Admin Dashboard - Quick Actions', () => {
|
||||
const quickActionsSection = page.locator('h2:has-text("Quick Actions")').locator('..');
|
||||
|
||||
// Use heading role to match only the card titles, not descriptions
|
||||
await expect(quickActionsSection.getByRole('heading', { name: 'User Management' })).toBeVisible();
|
||||
await expect(
|
||||
quickActionsSection.getByRole('heading', { name: 'User Management' })
|
||||
).toBeVisible();
|
||||
await expect(quickActionsSection.getByRole('heading', { name: 'Organizations' })).toBeVisible();
|
||||
await expect(quickActionsSection.getByRole('heading', { name: 'System Settings' })).toBeVisible();
|
||||
await expect(
|
||||
quickActionsSection.getByRole('heading', { name: 'System Settings' })
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('should navigate to users page when clicking user management', async ({ page }) => {
|
||||
const userManagementLink = page.getByRole('link', { name: /User Management/i });
|
||||
|
||||
await Promise.all([
|
||||
page.waitForURL('/admin/users'),
|
||||
userManagementLink.click()
|
||||
]);
|
||||
await Promise.all([page.waitForURL('/admin/users'), userManagementLink.click()]);
|
||||
|
||||
await expect(page).toHaveURL('/admin/users');
|
||||
});
|
||||
@@ -95,10 +96,7 @@ test.describe('Admin Dashboard - Quick Actions', () => {
|
||||
const quickActionsSection = page.locator('h2:has-text("Quick Actions")').locator('..');
|
||||
const organizationsLink = quickActionsSection.getByRole('link', { name: /Organizations/i });
|
||||
|
||||
await Promise.all([
|
||||
page.waitForURL('/admin/organizations'),
|
||||
organizationsLink.click()
|
||||
]);
|
||||
await Promise.all([page.waitForURL('/admin/organizations'), organizationsLink.click()]);
|
||||
|
||||
await expect(page).toHaveURL('/admin/organizations');
|
||||
});
|
||||
|
||||
@@ -15,7 +15,9 @@ test.describe('Admin Organization Members - Navigation from Organizations List',
|
||||
await page.waitForSelector('table tbody tr');
|
||||
});
|
||||
|
||||
test('should navigate to members page when clicking view members in action menu', async ({ page }) => {
|
||||
test('should navigate to members page when clicking view members in action menu', async ({
|
||||
page,
|
||||
}) => {
|
||||
// Click first organization's action menu
|
||||
const actionButton = page.getByRole('button', { name: /Actions for/i }).first();
|
||||
await actionButton.click();
|
||||
@@ -23,7 +25,7 @@ test.describe('Admin Organization Members - Navigation from Organizations List',
|
||||
// Click "View Members"
|
||||
await Promise.all([
|
||||
page.waitForURL(/\/admin\/organizations\/[^/]+\/members/),
|
||||
page.getByText('View Members').click()
|
||||
page.getByText('View Members').click(),
|
||||
]);
|
||||
|
||||
// Should be on members page
|
||||
@@ -38,7 +40,7 @@ test.describe('Admin Organization Members - Navigation from Organizations List',
|
||||
// Click on member count
|
||||
await Promise.all([
|
||||
page.waitForURL(/\/admin\/organizations\/[^/]+\/members/),
|
||||
memberButton.click()
|
||||
memberButton.click(),
|
||||
]);
|
||||
|
||||
// Should be on members page
|
||||
@@ -59,7 +61,7 @@ test.describe('Admin Organization Members - Page Structure', () => {
|
||||
|
||||
await Promise.all([
|
||||
page.waitForURL(/\/admin\/organizations\/[^/]+\/members/),
|
||||
page.getByText('View Members').click()
|
||||
page.getByText('View Members').click(),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -74,7 +76,9 @@ test.describe('Admin Organization Members - Page Structure', () => {
|
||||
});
|
||||
|
||||
test('should display page description', async ({ page }) => {
|
||||
await expect(page.getByText('Manage members and their roles within the organization')).toBeVisible();
|
||||
await expect(
|
||||
page.getByText('Manage members and their roles within the organization')
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('should display add member button', async ({ page }) => {
|
||||
@@ -87,7 +91,6 @@ test.describe('Admin Organization Members - Page Structure', () => {
|
||||
await expect(backButton).toBeVisible();
|
||||
});
|
||||
|
||||
|
||||
test('should have proper heading hierarchy', async ({ page }) => {
|
||||
// Wait for page to load
|
||||
await page.waitForSelector('table');
|
||||
@@ -129,7 +132,7 @@ test.describe('Admin Organization Members - AddMemberDialog E2E Tests', () => {
|
||||
|
||||
await Promise.all([
|
||||
page.waitForURL(/\/admin\/organizations\/[^/]+\/members/),
|
||||
page.getByText('View Members').click()
|
||||
page.getByText('View Members').click(),
|
||||
]);
|
||||
|
||||
// Open Add Member dialog
|
||||
@@ -150,7 +153,9 @@ test.describe('Admin Organization Members - AddMemberDialog E2E Tests', () => {
|
||||
});
|
||||
|
||||
test('should display dialog description', async ({ page }) => {
|
||||
await expect(page.getByText(/Add a user to this organization and assign them a role/i)).toBeVisible();
|
||||
await expect(
|
||||
page.getByText(/Add a user to this organization and assign them a role/i)
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('should display user email select field', async ({ page }) => {
|
||||
|
||||
@@ -193,7 +193,7 @@ test.describe('Admin Organization Management - Action Menu', () => {
|
||||
// Click view members - use Promise.all for Next.js Link navigation
|
||||
await Promise.all([
|
||||
page.waitForURL(/\/admin\/organizations\/[^/]+\/members/),
|
||||
page.getByText('View Members').click()
|
||||
page.getByText('View Members').click(),
|
||||
]);
|
||||
|
||||
// Should navigate to members page
|
||||
@@ -220,7 +220,9 @@ test.describe('Admin Organization Management - Action Menu', () => {
|
||||
await page.getByText('Delete Organization').click();
|
||||
|
||||
// Warning should be shown
|
||||
await expect(page.getByText(/This action cannot be undone and will remove all associated data/i)).toBeVisible();
|
||||
await expect(
|
||||
page.getByText(/This action cannot be undone and will remove all associated data/i)
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('should close delete dialog when clicking cancel', async ({ page }) => {
|
||||
@@ -307,7 +309,7 @@ test.describe('Admin Organization Management - Member Count Interaction', () =>
|
||||
// Click on member count - use Promise.all for Next.js Link navigation
|
||||
await Promise.all([
|
||||
page.waitForURL(/\/admin\/organizations\/[^/]+\/members/),
|
||||
memberButton.click()
|
||||
memberButton.click(),
|
||||
]);
|
||||
|
||||
// Should navigate to members page
|
||||
|
||||
@@ -132,10 +132,13 @@ test.describe('Admin User Management - Search and Filters', () => {
|
||||
await searchInput.fill('admin');
|
||||
|
||||
// Wait for debounce and URL to update
|
||||
await page.waitForFunction(() => {
|
||||
const url = new URL(window.location.href);
|
||||
return url.searchParams.has('search');
|
||||
}, { timeout: 2000 });
|
||||
await page.waitForFunction(
|
||||
() => {
|
||||
const url = new URL(window.location.href);
|
||||
return url.searchParams.has('search');
|
||||
},
|
||||
{ timeout: 2000 }
|
||||
);
|
||||
|
||||
// Check that URL contains search parameter
|
||||
expect(page.url()).toContain('search=admin');
|
||||
@@ -144,51 +147,66 @@ test.describe('Admin User Management - Search and Filters', () => {
|
||||
// Note: Active status filter URL parameter behavior is tested in the unit tests
|
||||
// (UserManagementContent.test.tsx). Skipping E2E test due to flaky URL timing.
|
||||
|
||||
test('should filter users by inactive status (adds active=false param to URL)', async ({ page }) => {
|
||||
test('should filter users by inactive status (adds active=false param to URL)', async ({
|
||||
page,
|
||||
}) => {
|
||||
const statusFilter = page.getByRole('combobox').first();
|
||||
await statusFilter.click();
|
||||
|
||||
// Click on "Inactive" option and wait for URL update
|
||||
await Promise.all([
|
||||
page.waitForFunction(() => {
|
||||
const url = new URL(window.location.href);
|
||||
return url.searchParams.get('active') === 'false';
|
||||
}, { timeout: 2000 }),
|
||||
page.getByRole('option', { name: 'Inactive' }).click()
|
||||
page.waitForFunction(
|
||||
() => {
|
||||
const url = new URL(window.location.href);
|
||||
return url.searchParams.get('active') === 'false';
|
||||
},
|
||||
{ timeout: 2000 }
|
||||
),
|
||||
page.getByRole('option', { name: 'Inactive' }).click(),
|
||||
]);
|
||||
|
||||
// Check that URL contains active=false parameter
|
||||
expect(page.url()).toContain('active=false');
|
||||
});
|
||||
|
||||
test('should filter users by superuser status (adds superuser param to URL)', async ({ page }) => {
|
||||
test('should filter users by superuser status (adds superuser param to URL)', async ({
|
||||
page,
|
||||
}) => {
|
||||
const userTypeFilter = page.getByRole('combobox').nth(1);
|
||||
await userTypeFilter.click();
|
||||
|
||||
// Click on "Superusers" option and wait for URL update
|
||||
await Promise.all([
|
||||
page.waitForFunction(() => {
|
||||
const url = new URL(window.location.href);
|
||||
return url.searchParams.get('superuser') === 'true';
|
||||
}, { timeout: 2000 }),
|
||||
page.getByRole('option', { name: 'Superusers' }).click()
|
||||
page.waitForFunction(
|
||||
() => {
|
||||
const url = new URL(window.location.href);
|
||||
return url.searchParams.get('superuser') === 'true';
|
||||
},
|
||||
{ timeout: 2000 }
|
||||
),
|
||||
page.getByRole('option', { name: 'Superusers' }).click(),
|
||||
]);
|
||||
|
||||
// Check that URL contains superuser parameter
|
||||
expect(page.url()).toContain('superuser=true');
|
||||
});
|
||||
|
||||
test('should filter users by regular user status (adds superuser=false param to URL)', async ({ page }) => {
|
||||
test('should filter users by regular user status (adds superuser=false param to URL)', async ({
|
||||
page,
|
||||
}) => {
|
||||
const userTypeFilter = page.getByRole('combobox').nth(1);
|
||||
await userTypeFilter.click();
|
||||
|
||||
// Click on "Regular" option and wait for URL update
|
||||
await Promise.all([
|
||||
page.waitForFunction(() => {
|
||||
const url = new URL(window.location.href);
|
||||
return url.searchParams.get('superuser') === 'false';
|
||||
}, { timeout: 2000 }),
|
||||
page.getByRole('option', { name: 'Regular' }).click()
|
||||
page.waitForFunction(
|
||||
() => {
|
||||
const url = new URL(window.location.href);
|
||||
return url.searchParams.get('superuser') === 'false';
|
||||
},
|
||||
{ timeout: 2000 }
|
||||
),
|
||||
page.getByRole('option', { name: 'Regular' }).click(),
|
||||
]);
|
||||
|
||||
// Check that URL contains superuser=false parameter
|
||||
@@ -208,10 +226,13 @@ test.describe('Admin User Management - Search and Filters', () => {
|
||||
const searchInput = page.getByPlaceholder(/Search by name or email/i);
|
||||
await searchInput.fill('test');
|
||||
|
||||
await page.waitForFunction(() => {
|
||||
const url = new URL(window.location.href);
|
||||
return url.searchParams.has('search');
|
||||
}, { timeout: 2000 });
|
||||
await page.waitForFunction(
|
||||
() => {
|
||||
const url = new URL(window.location.href);
|
||||
return url.searchParams.has('search');
|
||||
},
|
||||
{ timeout: 2000 }
|
||||
);
|
||||
|
||||
// URL should have page=1 or no page param (defaults to 1)
|
||||
const newUrl = page.url();
|
||||
@@ -502,9 +523,7 @@ test.describe('Admin User Management - Edit User Dialog', () => {
|
||||
await page.getByText('Edit User').click();
|
||||
|
||||
// Password field should indicate it's optional
|
||||
await expect(
|
||||
page.getByLabel(/Password.*\(leave blank to keep current\)/i)
|
||||
).toBeVisible();
|
||||
await expect(page.getByLabel(/Password.*\(leave blank to keep current\)/i)).toBeVisible();
|
||||
});
|
||||
|
||||
test('should have placeholder for password in edit mode', async ({ page }) => {
|
||||
|
||||
@@ -11,9 +11,7 @@ test.describe('AuthGuard - Route Protection', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('should redirect to login when accessing protected route without auth', async ({
|
||||
page,
|
||||
}) => {
|
||||
test('should redirect to login when accessing protected route without auth', async ({ page }) => {
|
||||
// Try to access a protected route (if you have one)
|
||||
// For now, we'll test the root if it's protected
|
||||
// Adjust the route based on your actual protected routes
|
||||
|
||||
@@ -162,10 +162,7 @@ test.describe('Login Flow', () => {
|
||||
// Click forgot password link - use Promise.all to wait for navigation
|
||||
const forgotLink = page.getByRole('link', { name: 'Forgot password?' });
|
||||
|
||||
await Promise.all([
|
||||
page.waitForURL('/password-reset'),
|
||||
forgotLink.click()
|
||||
]);
|
||||
await Promise.all([page.waitForURL('/password-reset'), forgotLink.click()]);
|
||||
|
||||
// Should be on password reset page
|
||||
await expect(page).toHaveURL('/password-reset');
|
||||
@@ -176,10 +173,7 @@ test.describe('Login Flow', () => {
|
||||
// Click sign up link - use Promise.all to wait for navigation
|
||||
const signupLink = page.getByRole('link', { name: 'Sign up' });
|
||||
|
||||
await Promise.all([
|
||||
page.waitForURL('/register'),
|
||||
signupLink.click()
|
||||
]);
|
||||
await Promise.all([page.waitForURL('/register'), signupLink.click()]);
|
||||
|
||||
// Should be on register page
|
||||
await expect(page).toHaveURL('/register');
|
||||
|
||||
@@ -55,10 +55,7 @@ test.describe('Password Reset Request Flow', () => {
|
||||
// Click back to login link - use Promise.all to wait for navigation
|
||||
const loginLink = page.getByRole('link', { name: 'Back to login' });
|
||||
|
||||
await Promise.all([
|
||||
page.waitForURL('/login', ),
|
||||
loginLink.click()
|
||||
]);
|
||||
await Promise.all([page.waitForURL('/login'), loginLink.click()]);
|
||||
|
||||
// Should be on login page
|
||||
await expect(page).toHaveURL('/login');
|
||||
@@ -196,10 +193,7 @@ test.describe('Password Reset Confirm Flow', () => {
|
||||
// Click request new reset link - use Promise.all to wait for navigation
|
||||
const resetLink = page.getByRole('link', { name: 'Request new reset link' });
|
||||
|
||||
await Promise.all([
|
||||
page.waitForURL('/password-reset', ),
|
||||
resetLink.click()
|
||||
]);
|
||||
await Promise.all([page.waitForURL('/password-reset'), resetLink.click()]);
|
||||
|
||||
// Should be on password reset request page
|
||||
await expect(page).toHaveURL('/password-reset');
|
||||
|
||||
@@ -222,10 +222,7 @@ test.describe('Registration Flow', () => {
|
||||
const loginLink = page.getByRole('link', { name: 'Sign in' });
|
||||
|
||||
// Use Promise.all to wait for navigation
|
||||
await Promise.all([
|
||||
page.waitForURL('/login'),
|
||||
loginLink.click()
|
||||
]);
|
||||
await Promise.all([page.waitForURL('/login'), loginLink.click()]);
|
||||
|
||||
// Should be on login page
|
||||
await expect(page).toHaveURL('/login');
|
||||
|
||||
@@ -95,7 +95,11 @@ export const MOCK_ORGANIZATIONS = [
|
||||
* @param email User email (defaults to mock user email)
|
||||
* @param password User password (defaults to mock password)
|
||||
*/
|
||||
export async function loginViaUI(page: Page, email = 'test@example.com', password = 'Password123!'): Promise<void> {
|
||||
export async function loginViaUI(
|
||||
page: Page,
|
||||
email = 'test@example.com',
|
||||
password = 'Password123!'
|
||||
): Promise<void> {
|
||||
// Navigate to login page
|
||||
await page.goto('/login');
|
||||
|
||||
@@ -104,10 +108,7 @@ export async function loginViaUI(page: Page, email = 'test@example.com', passwor
|
||||
await page.locator('input[name="password"]').fill(password);
|
||||
|
||||
// Submit and wait for navigation to home
|
||||
await Promise.all([
|
||||
page.waitForURL('/'),
|
||||
page.locator('button[type="submit"]').click(),
|
||||
]);
|
||||
await Promise.all([page.waitForURL('/'), page.locator('button[type="submit"]').click()]);
|
||||
|
||||
// Wait for auth to settle
|
||||
await page.waitForTimeout(500);
|
||||
@@ -136,8 +137,10 @@ export async function setupAuthenticatedMocks(page: Page): Promise<void> {
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({
|
||||
user: MOCK_USER,
|
||||
access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDEiLCJleHAiOjk5OTk5OTk5OTl9.signature',
|
||||
refresh_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDIiLCJleHAiOjk5OTk5OTk5OTl9.signature',
|
||||
access_token:
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDEiLCJleHAiOjk5OTk5OTk5OTl9.signature',
|
||||
refresh_token:
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDIiLCJleHAiOjk5OTk5OTk5OTl9.signature',
|
||||
expires_in: 3600,
|
||||
token_type: 'bearer',
|
||||
}),
|
||||
@@ -239,8 +242,10 @@ export async function setupSuperuserMocks(page: Page): Promise<void> {
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({
|
||||
user: MOCK_SUPERUSER,
|
||||
access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDMiLCJleHAiOjk5OTk5OTk5OTl9.signature',
|
||||
refresh_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDQiLCJleHAiOjk5OTk5OTk5OTl9.signature',
|
||||
access_token:
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDMiLCJleHAiOjk5OTk5OTk5OTl9.signature',
|
||||
refresh_token:
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDQiLCJleHAiOjk5OTk5OTk5OTl9.signature',
|
||||
expires_in: 3600,
|
||||
token_type: 'bearer',
|
||||
}),
|
||||
@@ -376,7 +381,7 @@ export async function setupSuperuserMocks(page: Page): Promise<void> {
|
||||
if (route.request().method() === 'GET' && isSingleOrgEndpoint) {
|
||||
// Extract org ID from URL
|
||||
const orgId = url.match(/organizations\/([^/]+)/)?.[1]?.replace(/\/$/, ''); // Remove trailing slash if any
|
||||
const org = MOCK_ORGANIZATIONS.find(o => o.id === orgId) || MOCK_ORGANIZATIONS[0];
|
||||
const org = MOCK_ORGANIZATIONS.find((o) => o.id === orgId) || MOCK_ORGANIZATIONS[0];
|
||||
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
|
||||
@@ -55,7 +55,7 @@ export async function startCoverage(
|
||||
}
|
||||
|
||||
try {
|
||||
await page.coverage.startJSCoverage({
|
||||
await page.coverage.startJSCoverage({
|
||||
resetOnNavigation: options?.resetOnNavigation ?? false,
|
||||
// @ts-expect-error - includeRawScriptCoverage is not in official types but supported by Playwright
|
||||
includeRawScriptCoverage: options?.includeRawScriptCoverage ?? false,
|
||||
@@ -201,9 +201,9 @@ export const withCoverage = {
|
||||
function sanitizeFilename(name: string): string {
|
||||
return name
|
||||
.replace(/[^a-z0-9\s-]/gi, '') // Remove special chars
|
||||
.replace(/\s+/g, '_') // Replace spaces with underscores
|
||||
.replace(/\s+/g, '_') // Replace spaces with underscores
|
||||
.toLowerCase()
|
||||
.substring(0, 100); // Limit length
|
||||
.substring(0, 100); // Limit length
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,16 +70,16 @@ test.describe('Homepage - Desktop Navigation', () => {
|
||||
const header = page.locator('header').first();
|
||||
const headerLoginLink = header.getByRole('link', { name: /^Login$/i });
|
||||
|
||||
await Promise.all([
|
||||
page.waitForURL('/login'),
|
||||
headerLoginLink.click()
|
||||
]);
|
||||
await Promise.all([page.waitForURL('/login'), headerLoginLink.click()]);
|
||||
|
||||
await expect(page).toHaveURL('/login');
|
||||
});
|
||||
|
||||
test.skip('should open demo credentials modal when clicking Try Demo', async ({ page }) => {
|
||||
await page.getByRole('button', { name: /Try Demo/i }).first().click();
|
||||
await page
|
||||
.getByRole('button', { name: /Try Demo/i })
|
||||
.first()
|
||||
.click();
|
||||
|
||||
// Dialog should be visible (wait longer for React to render with animations)
|
||||
const dialog = page.getByRole('dialog');
|
||||
@@ -204,10 +204,7 @@ test.describe('Homepage - Mobile Menu Interactions', () => {
|
||||
const loginLink = mobileMenu.getByRole('link', { name: /Login/i });
|
||||
await loginLink.waitFor({ state: 'visible' });
|
||||
|
||||
await Promise.all([
|
||||
page.waitForURL('/login'),
|
||||
loginLink.click()
|
||||
]);
|
||||
await Promise.all([page.waitForURL('/login'), loginLink.click()]);
|
||||
|
||||
await expect(page).toHaveURL('/login');
|
||||
});
|
||||
@@ -230,7 +227,9 @@ test.describe('Homepage - Hero Section', () => {
|
||||
});
|
||||
|
||||
test('should display main headline', async ({ page }) => {
|
||||
await expect(page.getByRole('heading', { name: /Everything You Need to Build/i }).first()).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole('heading', { name: /Everything You Need to Build/i }).first()
|
||||
).toBeVisible();
|
||||
await expect(page.getByText(/Modern Web Applications/i).first()).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -274,7 +273,10 @@ test.describe('Homepage - Demo Credentials Modal', () => {
|
||||
});
|
||||
|
||||
test.skip('should display regular and admin credentials', async ({ page }) => {
|
||||
await page.getByRole('button', { name: /Try Demo/i }).first().click();
|
||||
await page
|
||||
.getByRole('button', { name: /Try Demo/i })
|
||||
.first()
|
||||
.click();
|
||||
|
||||
const dialog = page.getByRole('dialog');
|
||||
await dialog.waitFor({ state: 'visible' });
|
||||
@@ -292,7 +294,10 @@ test.describe('Homepage - Demo Credentials Modal', () => {
|
||||
// Grant clipboard permissions
|
||||
await context.grantPermissions(['clipboard-read', 'clipboard-write']);
|
||||
|
||||
await page.getByRole('button', { name: /Try Demo/i }).first().click();
|
||||
await page
|
||||
.getByRole('button', { name: /Try Demo/i })
|
||||
.first()
|
||||
.click();
|
||||
|
||||
const dialog = page.getByRole('dialog');
|
||||
await dialog.waitFor({ state: 'visible' });
|
||||
@@ -306,23 +311,26 @@ test.describe('Homepage - Demo Credentials Modal', () => {
|
||||
});
|
||||
|
||||
test.skip('should navigate to login page from modal', async ({ page }) => {
|
||||
await page.getByRole('button', { name: /Try Demo/i }).first().click();
|
||||
await page
|
||||
.getByRole('button', { name: /Try Demo/i })
|
||||
.first()
|
||||
.click();
|
||||
|
||||
const dialog = page.getByRole('dialog');
|
||||
await dialog.waitFor({ state: 'visible' });
|
||||
|
||||
const loginLink = dialog.getByRole('link', { name: /Go to Login/i });
|
||||
|
||||
await Promise.all([
|
||||
page.waitForURL('/login'),
|
||||
loginLink.click()
|
||||
]);
|
||||
await Promise.all([page.waitForURL('/login'), loginLink.click()]);
|
||||
|
||||
await expect(page).toHaveURL('/login');
|
||||
});
|
||||
|
||||
test.skip('should close modal when clicking close button', async ({ page }) => {
|
||||
await page.getByRole('button', { name: /Try Demo/i }).first().click();
|
||||
await page
|
||||
.getByRole('button', { name: /Try Demo/i })
|
||||
.first()
|
||||
.click();
|
||||
|
||||
const dialog = page.getByRole('dialog');
|
||||
await dialog.waitFor({ state: 'visible' });
|
||||
@@ -343,7 +351,9 @@ test.describe('Homepage - Animated Terminal', () => {
|
||||
// Scroll to terminal section
|
||||
await page.locator('text=Get Started in Seconds').first().scrollIntoViewIfNeeded();
|
||||
|
||||
await expect(page.getByRole('heading', { name: /Get Started in Seconds/i }).first()).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole('heading', { name: /Get Started in Seconds/i }).first()
|
||||
).toBeVisible();
|
||||
await expect(page.getByText(/Clone, run, and start building/i).first()).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -434,7 +444,9 @@ test.describe('Homepage - Feature Sections', () => {
|
||||
});
|
||||
|
||||
test('should display tech stack section', async ({ page }) => {
|
||||
await expect(page.getByRole('heading', { name: /Modern, Type-Safe, Production-Grade Stack/i })).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole('heading', { name: /Modern, Type-Safe, Production-Grade Stack/i })
|
||||
).toBeVisible();
|
||||
|
||||
// Check for key technologies
|
||||
await expect(page.getByText('FastAPI').first()).toBeVisible();
|
||||
|
||||
Reference in New Issue
Block a user