8237e9f483
Shared helpers (admin sign-in fixture, watch, downloaded) live in e2e/support.ts. Conectar checks the EDF reader among the node kinds; CaCu and CaMa show their four tabs over a platform without their data; the training-inputs 404 of a domain without training files is the one allowed response.
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { statSync } from 'node:fs';
|
|
import { expect, Locator, Page, test as base } from '@playwright/test';
|
|
|
|
export const test = base.extend<{ admin: void }>({
|
|
admin: [
|
|
async ({ page }, use) => {
|
|
const signed = await page.request.post('/api/auth/login', {
|
|
form: { username: 'admin@isssteleon.mx', password: 'solo-para-pruebas' },
|
|
});
|
|
expect(signed.status()).toBe(204);
|
|
await use();
|
|
},
|
|
{ auto: true },
|
|
],
|
|
});
|
|
|
|
export function watch(page: Page): string[] {
|
|
const problems: string[] = [];
|
|
page.on('console', (m) => m.type() === 'error' && problems.push(`console: ${m.text()}`));
|
|
page.on('response', (r) => r.status() >= 400 && problems.push(`${r.status()} ${r.url()}`));
|
|
page.on('pageerror', (e) => problems.push(`page: ${e.message}`));
|
|
return problems;
|
|
}
|
|
|
|
export async function downloaded(
|
|
page: Page,
|
|
button: Locator,
|
|
kind: 'pdf' | 'xlsx',
|
|
): Promise<string> {
|
|
const [file] = await Promise.all([page.waitForEvent('download'), button.click()]);
|
|
const name = file.suggestedFilename();
|
|
expect(name).toMatch(new RegExp(`^tea-[a-z]+-\\d{4}-\\d{2}-\\d{2}\\.${kind}$`));
|
|
expect(name).not.toMatch(/N-?\d{4}/);
|
|
expect(statSync(await file.path()).size).toBeGreaterThan(0);
|
|
return name;
|
|
}
|