- 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
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
// Copyright (C) 2026 Bryan Joshua Pedini
|
|
|
|
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { ApiError, handleError } from '../../static/js/common.js';
|
|
|
|
class Element {
|
|
children = [];
|
|
attributes = {};
|
|
handlers = {};
|
|
|
|
constructor(tag) {
|
|
this.tag = tag;
|
|
}
|
|
|
|
append(...nodes) {
|
|
this.children.push(...nodes);
|
|
}
|
|
|
|
prepend(node) {
|
|
this.children.unshift(node);
|
|
}
|
|
|
|
querySelector(selector) {
|
|
return this.children.find((node) => node.className?.split(' ').includes(selector.slice(1)));
|
|
}
|
|
|
|
setAttribute(name, value) {
|
|
this.attributes[name] = value;
|
|
}
|
|
|
|
addEventListener(name, callback) {
|
|
this.handlers[name] = callback;
|
|
}
|
|
}
|
|
|
|
test('a stale edit puts a usable reload button inside its form', () => {
|
|
globalThis.Node = Element;
|
|
globalThis.document = { createElement: (tag) => new Element(tag) };
|
|
const form = new Element('form');
|
|
let reloads = 0;
|
|
handleError(new ApiError(412, { error: 'Stale record.' }), { form, reload: () => reloads++ });
|
|
const alert = form.querySelector('.form-error');
|
|
assert.equal(alert.attributes.role, 'alert');
|
|
assert.equal(alert.textContent, 'Stale record. Reload to see the current data.');
|
|
const button = alert.children.find((node) => node.tag === 'button');
|
|
assert.equal(button.textContent, 'Reload');
|
|
assert.equal(button.attributes.type, 'button');
|
|
button.handlers.click();
|
|
assert.equal(reloads, 1);
|
|
});
|