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,52 @@
|
||||
// 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);
|
||||
});
|
||||
Reference in new issue
Block a user