summaryrefslogtreecommitdiff
path: root/test/web_harness.mjs
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-08-16 15:49:12 -0300
committerGabriel Schneider <[email protected]>2026-08-18 23:44:42 -0300
commit1551e409c31992437cb2fa864f576d45c8433801 (patch)
treee2fae8451f87b735a1360c7c2e383fdc40165789 /test/web_harness.mjs
parentbe2a9957708cbf0c478ca861c4a1f0f227bbfe10 (diff)
downloadpardes-1551e409c31992437cb2fa864f576d45c8433801.tar.gz
pardes-1551e409c31992437cb2fa864f576d45c8433801.zip
big slow change: prebuilt shaders (SPIR-V/Metal), core gui reflow, docs, web + snapshot refresh
Diffstat (limited to 'test/web_harness.mjs')
-rw-r--r--test/web_harness.mjs38
1 files changed, 36 insertions, 2 deletions
diff --git a/test/web_harness.mjs b/test/web_harness.mjs
index b9243435..087dd91b 100644
--- a/test/web_harness.mjs
+++ b/test/web_harness.mjs
@@ -22,7 +22,8 @@ async function main() {
for (const name of [
"memory", "pardes_init", "pardes_frame", "pardes_frame_ptr", "pardes_key",
- "pardes_mouse", "pardes_output", "pardes_lsp_response", "pardes_pipe_response", "pardes_file_changed",
+ "pardes_mouse", "pardes_pointer_leave", "pardes_gui_tagline_font_percent", "pardes_output",
+ "pardes_lsp_response", "pardes_pipe_response", "pardes_file_changed",
"pardes_effect_next", "pardes_deinit",
]) assert.ok(wasm[name], `missing wasm export ${name}`);
@@ -30,7 +31,7 @@ async function main() {
assert.equal(wasm.pardes_frame(), 80 * 24);
assert.ok(wasm.pardes_frame_ptr() > 0);
- const { DomRenderer } = await import(pathToFileURL(path.join(webDir, "app.mjs")));
+ const { DomRenderer, animationTicks } = await import(pathToFileURL(path.join(webDir, "app.mjs")));
const document = new FakeDocument();
const root = document.createElement("main");
root.ownerDocument = document;
@@ -43,12 +44,45 @@ async function main() {
assert.equal(root.children[0].children.length, 80);
assert.ok(first.cells.some((cell) => cell.text !== " "), "dump rendered an empty frame");
assert.ok(root.walk().every((node) => node.tagName !== "CANVAS"), "renderer created a canvas");
+ const taglineIndex = first.cells.findIndex((cell) => cell.attrs & (1 << 7));
+ const bodyIndex = first.cells.findIndex((cell) => !(cell.attrs & (1 << 7)) && cell.text !== " ");
+ assert.ok(taglineIndex >= 0, "frame ABI did not mark a tagline font role");
+ assert.ok(bodyIndex >= 0, "fixture has no body glyph to compare with tagline");
+ assert.ok(renderer.cells[taglineIndex].classList.names.has("is-tagline"), "DOM tagline class was not applied");
+ assert.ok(!renderer.cells[bodyIndex].classList.names.has("is-tagline"), "DOM inferred tagline role for body text");
+ assert.equal(
+ root.style["--pardes-tagline-font-size"],
+ `${wasm.pardes_gui_tagline_font_percent()}%`,
+ "DOM did not use the build-time tagline percentage",
+ );
+
+ for (const hz of [60, 120, 144]) {
+ const clock = { last: null, lag: 0 };
+ let ticks = 0;
+ for (let frame = 0; frame <= hz; frame += 1) {
+ ticks += animationTicks(clock, frame * 1000 / hz);
+ }
+ assert.equal(ticks, 60, `${hz} Hz rAF did not produce 60 core ticks per second`);
+ }
+ const stalled = { last: null, lag: 0 };
+ assert.equal(animationTicks(stalled, 0), 0);
+ assert.equal(animationTicks(stalled, 60_000), 4, "suspended tab catch-up was not bounded");
const firstCell = renderer.cells[0];
const second = renderer.render();
assert.equal(renderer.cells[0], firstCell, "stable frames should reuse DOM nodes");
assert.equal(second.cells.length, 80 * 24);
+ // A replay follows the terminal cursor at the bottom. Deliberately
+ // over-scroll (the core clamps at row zero) so adding more source files does
+ // not silently move the hard-coded build.zig click onto some later path.
+ for (let tick = 0; tick < 128; tick += 1) wasm.pardes_mouse(3, 0, 5, 3, 0);
+ const listingTop = renderer.render();
+ assert.match(
+ listingTop.cells.map((cell) => cell.text).join(""),
+ /git ls-files --cached --others --exclude-standard.*build\.zig/,
+ "working-tree source listing did not scroll to its first row",
+ );
wasm.pardes_mouse(2, 0, 5, 3, 0);
wasm.pardes_mouse(2, 1, 5, 3, 0);
const looked = renderer.render();