Refactor E2E tests and mock APIs for improved reliability and maintainability
- Updated E2E tests to use specific role-based heading selectors for better robustness. - Enhanced mock routes in `auth.ts` to handle detailed organization endpoints more effectively. - Improved test flow by adding `waitUntil: 'networkidle'` to navigation steps. - Refined `admin-access.spec.ts` interactions to use optimized wait and click implementations for better performance. - Updated dialog texts and field labels to match latest UI changes.
This commit is contained in:
@@ -20,13 +20,13 @@ test.describe('Settings Navigation', () => {
|
||||
await expect(page).toHaveURL('/');
|
||||
|
||||
// Navigate to settings/profile
|
||||
await page.goto('/settings/profile');
|
||||
await page.goto('/settings/profile', { waitUntil: 'networkidle' });
|
||||
|
||||
// Verify navigation successful
|
||||
await expect(page).toHaveURL('/settings/profile');
|
||||
|
||||
// Verify page loaded
|
||||
await expect(page.locator('h2')).toContainText('Profile');
|
||||
// Verify page loaded - use specific heading selector
|
||||
await expect(page.getByRole('heading', { name: 'Profile' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('should navigate from home to settings password', async ({ page }) => {
|
||||
@@ -34,49 +34,49 @@ test.describe('Settings Navigation', () => {
|
||||
await expect(page).toHaveURL('/');
|
||||
|
||||
// Navigate to settings/password
|
||||
await page.goto('/settings/password');
|
||||
await page.goto('/settings/password', { waitUntil: 'networkidle' });
|
||||
|
||||
// Verify navigation successful
|
||||
await expect(page).toHaveURL('/settings/password');
|
||||
|
||||
// Verify page loaded
|
||||
await expect(page.locator('h2')).toContainText('Password');
|
||||
// Verify page loaded - use specific heading selector
|
||||
await expect(page.getByRole('heading', { name: 'Password' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('should navigate between settings pages', async ({ page }) => {
|
||||
// Start at profile page
|
||||
await page.goto('/settings/profile');
|
||||
await expect(page.locator('h2')).toContainText('Profile');
|
||||
await page.goto('/settings/profile', { waitUntil: 'networkidle' });
|
||||
await expect(page.getByRole('heading', { name: 'Profile' })).toBeVisible();
|
||||
|
||||
// Navigate to password page
|
||||
await page.goto('/settings/password');
|
||||
await expect(page.locator('h2')).toContainText('Password');
|
||||
await page.goto('/settings/password', { waitUntil: 'networkidle' });
|
||||
await expect(page.getByRole('heading', { name: 'Password' })).toBeVisible();
|
||||
|
||||
// Navigate back to profile page
|
||||
await page.goto('/settings/profile');
|
||||
await expect(page.locator('h2')).toContainText('Profile');
|
||||
await page.goto('/settings/profile', { waitUntil: 'networkidle' });
|
||||
await expect(page.getByRole('heading', { name: 'Profile' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('should redirect from /settings to /settings/profile', async ({ page }) => {
|
||||
// Navigate to base settings page
|
||||
await page.goto('/settings');
|
||||
await page.goto('/settings', { waitUntil: 'networkidle' });
|
||||
|
||||
// Should redirect to profile page
|
||||
await expect(page).toHaveURL('/settings/profile');
|
||||
|
||||
// Verify profile page loaded
|
||||
await expect(page.locator('h2')).toContainText('Profile');
|
||||
// Verify profile page loaded - use specific heading selector
|
||||
await expect(page.getByRole('heading', { name: 'Profile' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('should display preferences page placeholder', async ({ page }) => {
|
||||
// Navigate to preferences page
|
||||
await page.goto('/settings/preferences');
|
||||
await page.goto('/settings/preferences', { waitUntil: 'networkidle' });
|
||||
|
||||
// Verify navigation successful
|
||||
await expect(page).toHaveURL('/settings/preferences');
|
||||
|
||||
// Verify page loaded with placeholder content
|
||||
await expect(page.locator('h2')).toContainText('Preferences');
|
||||
await expect(page.getByRole('heading', { name: 'Preferences' })).toBeVisible();
|
||||
await expect(page.getByText(/coming in task/i)).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user