All 4 badge test files had identical ~35-line beforeEach blocks (pageerror listener,
inline V3 route mocks, addInitScript localStorage seed). Replaced with two helpers
in minimal_v3_mocks.ts:
seed_trusted_session(page, event_id, account_id?)
— seeds ae_loc localStorage with trusted/manager auth via addInitScript;
account_id defaults to testing_account_id
setup_badge_test_page(page, event_id)
— one-call beforeEach: pageerror listener + attach_minimal_v3_routes +
seed_trusted_session
Each test file's beforeEach is now 1-3 lines. All 12 tests still pass.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { testing_event_id } from './_helpers/env';
|
|
import { setup_badge_test_page } from './_helpers/minimal_v3_mocks';
|
|
|
|
const event_id = testing_event_id;
|
|
|
|
test.describe('Event Badge — smoke', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
page.on('console', (msg) => {
|
|
if (msg.type() === 'error' || msg.type() === 'warning') console.error(`BROWSER [${msg.type().toUpperCase()}]: ${msg.text()}`);
|
|
});
|
|
await setup_badge_test_page(page, event_id);
|
|
});
|
|
|
|
test('loads badges list without console errors', async ({ page }) => {
|
|
const errors: string[] = [];
|
|
page.on('pageerror', (err) => errors.push(err.message));
|
|
|
|
await page.goto(`/events/${event_id}/badges`);
|
|
await page.waitForResponse((r) => r.url().includes('site_domain/search') && r.status() === 200);
|
|
|
|
expect(errors).toHaveLength(0);
|
|
// smoke: ensure the page responded to initial handshake
|
|
const resp = await page.request.get('/v3/health', { failOnStatusCode: false });
|
|
// not asserting 200; just ensure request helper works
|
|
expect(resp.ok() || resp.status() >= 400).toBeTruthy();
|
|
});
|
|
});
|