// SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2026 Bryan Joshua Pedini import { test, expect } from '../harness/fixtures'; import { createZone } from '../harness/personas'; test.use({ group: 'session' }); test('an idle session expires with an open record form', async ({ world }) => { test.setTimeout(world.g.idleTimeoutMs + 90_000); const account = await world.bootstrapAdmin(); const client = await world.apiAs(account); const user = await world.uiAs(account); const zone = world.zoneName(); const zonePath = await createZone(client, zone); await user.openZone(zone); await user.page.click('#record-add'); await user.page.selectOption('#rec-type', 'A'); await user.page.fill('#rec-name', 'pending'); await user.page.fill('#rec-f-ip', '192.0.2.30'); await world.ledger.settle(); const auditMark = await world.db.auditMaxId(); await new Promise((resolve) => setTimeout(resolve, world.g.idleTimeoutMs + 1000)); const refused = user.page.waitForResponse((res) => res.url().endsWith(`/api/v1${zonePath}/records`) && res.request().method() === 'POST'); await user.page.click('#rec-submit'); expect((await refused).status()).toBe(401); await expect(user.page).toHaveURL(/\/login\?next=/); expect(await world.db.auditSince(auditMark)).toEqual([]); expect((await world.db.records(zone)).map((row) => row.record_type).sort()).toEqual(['NS', 'SOA']); await user.login(account.username, account.password); await expect(user.page).toHaveURL(new RegExp(zonePath.replaceAll('.', '\\.'))); });