mirror of
https://github.com/bretzel-app/crumbs.git
synced 2026-10-14 12:28:18 +02:00
test: consolidate E2E tests — remove duplicates, fix timeouts, parallelize sharing
- Remove duplicate bold formatting test from notes-crud.spec.ts - Trim formatting.spec.ts from 9 to 5 tests (remove italic, inline code, toolbar bold, toolbar visibility — same mechanism as bold shortcut) - Remove hardcoded waitForTimeout(500) from search.spec.ts (Playwright assertions already retry with built-in timeouts) - Restructure sharing.spec.ts: 9 serial tests → 5 parallel self-contained tests using collabPage fixture and API-based setup - Add collabPage fixture to helpers/fixtures.ts for sharing tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Fred Cabassut
co-authored by
Claude Opus 4.6
parent
914b4fc772
commit
0b417bef0e
@@ -5,6 +5,10 @@ const TEST_EMAIL = 'admin@test.com';
|
||||
const TEST_PASSWORD = 'testpassword123';
|
||||
const TEST_DISPLAY_NAME = 'Test Admin';
|
||||
|
||||
const COLLAB_EMAIL = 'collab@test.com';
|
||||
const COLLAB_PASSWORD = 'collabpass123';
|
||||
const COLLAB_NAME = 'Collaborator User';
|
||||
|
||||
/** Find a specific note card by its title text */
|
||||
export function noteCard(page: Page, title: string): Locator {
|
||||
return page.locator('[data-testid="note-card"]', { hasText: title });
|
||||
@@ -13,13 +17,39 @@ export function noteCard(page: Page, title: string): Locator {
|
||||
/**
|
||||
* Extended test fixture that handles setup/auth.
|
||||
*/
|
||||
export const test = base.extend<{ authenticatedPage: Page }>({
|
||||
export const test = base.extend<{ authenticatedPage: Page; collabPage: Page }>({
|
||||
authenticatedPage: async ({ page }, use, testInfo) => {
|
||||
// Setup: create user and login
|
||||
await setupAndLogin(page);
|
||||
await use(page);
|
||||
// Teardown: collect coverage data from the browser
|
||||
await collectCoverage(page, testInfo.title);
|
||||
},
|
||||
collabPage: async ({ browser, authenticatedPage }, use, testInfo) => {
|
||||
// Create collab user via admin API (idempotent)
|
||||
const res = await authenticatedPage.request.post('/api/admin/users', {
|
||||
data: {
|
||||
email: COLLAB_EMAIL,
|
||||
displayName: COLLAB_NAME,
|
||||
password: COLLAB_PASSWORD,
|
||||
role: 'user'
|
||||
}
|
||||
});
|
||||
// Ignore 409 — user already exists
|
||||
|
||||
// Login as collaborator in a new browser context
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
await page.goto('/login');
|
||||
await page.getByTestId('email-input').fill(COLLAB_EMAIL);
|
||||
await page.getByTestId('password-input').fill(COLLAB_PASSWORD);
|
||||
await page.getByTestId('login-btn').click();
|
||||
await page.waitForURL('/');
|
||||
await page.waitForLoadState('networkidle');
|
||||
await use(page);
|
||||
// Teardown: collect coverage data from the browser
|
||||
await collectCoverage(page, testInfo.title + '-collab');
|
||||
await context.close();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -60,4 +90,4 @@ export async function setupAndLogin(page: Page) {
|
||||
await page.waitForLoadState('networkidle');
|
||||
}
|
||||
|
||||
export { expect, TEST_EMAIL, TEST_PASSWORD };
|
||||
export { expect, TEST_EMAIL, TEST_PASSWORD, COLLAB_EMAIL, COLLAB_PASSWORD, COLLAB_NAME };
|
||||
|
||||
Reference in New Issue
Block a user