test(e2e): add playwright harness and test stack
- test(e2e): add playwright harness and test stack - test(e2e): add core flow - fix(ui): preserve same-origin browser form submissions - fix(ui): offer reload inside stale edit dialogs - test(e2e): add persona session and accessibility suites - test(e2e): preserve per-run artifacts and clean pulled images - test(e2e): verify import and audit state across navigation - test(e2e): tighten verification helpers and persona checks - test(e2e): bound response body reads of the browser observer - test: recover review compatibility assertions - test: stabilize audit and user flow assertions
This commit is contained in:
1 parent
a7ba01fc77
commit
57a005c19f
48 files changed
+6239
-6
No files matched your search
@@ -0,0 +1,103 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright (C) 2026 Bryan Joshua Pedini
|
||||
|
||||
import { test, expect } from '../harness/fixtures';
|
||||
import { up, zp } from '../harness/api';
|
||||
import { importApplyBody } from '../harness/decisions';
|
||||
import { waitForZone } from '../harness/dig';
|
||||
import { address, addAddress, createZone, restartWithSessions, zoneInput } from '../harness/personas';
|
||||
import { begin, storedRow, threeWay } from '../harness/verify';
|
||||
|
||||
test.use({ group: 'power' });
|
||||
|
||||
test('a power user operates a large installation, with restart and edit conflicts', async ({ world }, info) => {
|
||||
test.setTimeout(240_000);
|
||||
const admin = await world.bootstrapAdmin();
|
||||
const api = await world.apiAs(admin);
|
||||
const zones = Array.from({ length: 24 }, (_, i) => world.zoneName(`z${i}-`));
|
||||
for (const zone of zones) await createZone(api, zone);
|
||||
for (let i = 0; i < 24; i++) {
|
||||
const account = await world.createUser(api, 'user');
|
||||
for (const zone of [zones[i], zones[(i + 1) % zones.length]]) {
|
||||
expect((await api.put(`${zp(zone)}${up(account.username)}`)).status).toBe(204);
|
||||
}
|
||||
}
|
||||
const [large, imports] = zones;
|
||||
await world.db.insertMany(Array.from({ length: 9998 }, (_, i) => ({
|
||||
zone: large, name: `seed-${String(i).padStart(4, '0')}`, ttl: 300, record_type: 'A',
|
||||
content: JSON.stringify({ ip: `192.0.2.${i % 254 + 1}` }),
|
||||
})));
|
||||
const first = await world.uiAs(admin);
|
||||
const second = await world.uiAs(admin);
|
||||
const startZones = performance.now();
|
||||
await first.page.goto('/');
|
||||
await expect(first.page.getByRole('link', { name: large, exact: true })).toBeVisible();
|
||||
const zonesMs = performance.now() - startZones;
|
||||
const startZone = performance.now();
|
||||
await first.page.getByRole('link', { name: large, exact: true }).click();
|
||||
await expect(first.page.getByRole('rowheader', { name: 'seed-0000', exact: true })).toBeVisible();
|
||||
const editButton = first.page.getByRole('row', { name: /seed-0000/ }).getByRole('button', { name: /^Edit / });
|
||||
await editButton.click();
|
||||
await expect(first.page.locator('#rec-f-ip')).toHaveValue('192.0.2.1');
|
||||
const editMs = performance.now() - startZone;
|
||||
await info.attach('performance.json', {
|
||||
body: JSON.stringify({ zones: zones.length, records: 10000, zonesMs, editMs, budgetMs: 2000 }),
|
||||
contentType: 'application/json',
|
||||
});
|
||||
expect(zonesMs, 'zones page renders its links within 2 seconds').toBeLessThan(2000);
|
||||
expect(editMs, '10,000-record zone is interactive within 2 seconds').toBeLessThan(2000);
|
||||
await second.openZone(large);
|
||||
await second.openEdit({ name: 'seed-0000', type: 'A' });
|
||||
await restartWithSessions(world, first, second);
|
||||
expect((await api.get('/account')).json.username).toBe(admin.username);
|
||||
const submit = async (ui: typeof first, ip: string) => {
|
||||
await ui.page.fill('#rec-f-ip', ip);
|
||||
const response = ui.page.waitForResponse((res) => res.request().method() === 'PUT' && /\/records\/\d+$/.test(new URL(res.url()).pathname));
|
||||
await ui.page.click('#rec-submit');
|
||||
return (await response).status();
|
||||
};
|
||||
const change = await begin(world, large);
|
||||
expect(await submit(first, '192.0.2.240')).toBe(200);
|
||||
expect(await submit(second, '192.0.2.241')).toBe(412);
|
||||
await second.page.getByRole('button', { name: 'Reload', exact: true }).click();
|
||||
await waitForZone(world.g, large, { recorder: world.recorder });
|
||||
await threeWay(world, first, large, address('seed-0000', '192.0.2.240'), change, 'first editor wins');
|
||||
await second.expectRow({ name: 'seed-0000', type: 'A', value: '192.0.2.240' });
|
||||
expect(await world.db.recordCount()).toBe(10000 + 23 * 2);
|
||||
expect(await world.db.delegations()).toHaveLength(48);
|
||||
|
||||
const ip = '198.51.100.40';
|
||||
const file = Array.from({ length: 1200 }, (_, i) => `load-${i} 300 IN A ${ip}`).join('\n') + '\n';
|
||||
expect((await first.importPreview(imports, file, 'merge')).json.added).toHaveLength(1200);
|
||||
const importChange = await begin(world, imports);
|
||||
expect((await first.importApply()).json).toEqual(importApplyBody(1200, 0, 0));
|
||||
await first.openZone(imports);
|
||||
await waitForZone(world.g, imports, { recorder: world.recorder });
|
||||
await threeWay(world, first, imports, { ...address('load-0', ip), type: 'A' }, importChange, 'large import');
|
||||
expect(await world.db.records(imports)).toHaveLength(1202);
|
||||
await storedRow(world, imports, { ...address('load-1199', ip), type: 'A' });
|
||||
expect((await api.get(`${zp(imports)}/check`)).json.problems).toEqual([]);
|
||||
});
|
||||
|
||||
test('a power user imports the supported types in one transaction', async ({ world }) => {
|
||||
const admin = await world.bootstrapAdmin();
|
||||
const api = await world.apiAs(admin);
|
||||
const zone = world.zoneName();
|
||||
const zonePath = await createZone(api, zone);
|
||||
await addAddress(api, zonePath, 'www', '192.0.2.5');
|
||||
const ui = await world.uiAs(admin);
|
||||
const soa = zoneInput(zone);
|
||||
const entries = [
|
||||
['@', 'SOA', `${soa.ns} ${soa.mbox} 0 3600 600 604800 300`],
|
||||
['@', 'NS', 'ns2.example.net.'],
|
||||
['www', 'AAAA', '2001:db8::50'],
|
||||
['*.alias', 'CNAME', `www.${zone}`],
|
||||
['@', 'MX', '0 .'],
|
||||
['@', 'TXT', '"test"'],
|
||||
['_tcp._svc', 'SRV', '0 0 0 .'],
|
||||
['@', 'CAA', '0 issue "ca.example.net"'],
|
||||
];
|
||||
expect((await ui.importPreview(zone, entries.map(([n, t, v]) => `${n} 300 IN ${t} ${v}\n`).join(''), 'merge')).status).toBe(200);
|
||||
expect((await ui.importApply()).status).toBe(200);
|
||||
expect((await world.db.records(zone)).map((row) => row.record_type).sort()).toEqual(['A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'NS', 'SOA', 'SRV', 'TXT']);
|
||||
});
|
||||
Reference in new issue
Block a user