droboticflow/tests/frontend/capture-responsive-layout.test.mjs

37 lines
2.0 KiB
JavaScript

import assert from "node:assert/strict";
import fs from "node:fs";
import test from "node:test";
const read = (path) => fs.readFileSync(new URL(`../../${path}`, import.meta.url), "utf8");
const page = read("src/pages/AnnotationOperations.tsx");
const workbench = read("src/components/CaptureAnnotationWorkbench.tsx");
const css = read("src/styles/capture-workspace.css");
test("adaptive layout is opt-in for annotation slicing, not a global role redesign", () => {
assert.match(page, /workspaceMode === "annotate" && tab === "queue" && combinedEditorPhase === "slice"/);
assert.match(workbench, /adaptiveLayout = false/);
assert.match(workbench, /adaptiveLayout && phase === "slice" && !mediaOnly && !isQualityReview/);
assert.match(css, /\.capture-workbench-body\s*\{\s*display: contents/);
assert.doesNotMatch(css, /(?:^|\n)(?:body|html|main)\s*\{/);
});
test("layout uses actual container space, limits the pool and keeps an independent footer", () => {
assert.match(css, /container: annotation-slice-page \/ inline-size/);
assert.match(css, /@container annotation-slice-page \(max-width: 899px\)/);
assert.match(css, /max-height: 150px/);
assert.match(css, /grid-template-rows: auto minmax\(min-content, 1fr\) auto/);
assert.match(css, /object-fit: contain/);
assert.match(css, /contain: size/);
assert.match(css, /grid-template-rows: max-content minmax\(640px, 1fr\)/);
assert.match(workbench, /<\/div>\s*\)}\s*\{phase !== "materializing" && !mediaOnly && \(\s*<footer/);
assert.doesNotMatch(css, /footer[^}]*position:\s*(fixed|absolute)/s);
assert.match(css, /order: 2;\s*flex-basis: 100%/);
});
test("responsive changes do not remount media or alter timeline calculations", () => {
assert.doesNotMatch(workbench, /key=\{[^}]*adaptiveLayout/);
assert.doesNotMatch(page, /key=\{[^}]*adaptiveSliceLayout/);
assert.match(workbench, /stepFrameBoundary\(frameBoundaries, currentTime, direction\)/);
assert.match(workbench, /onSliceBoundaryChange\?\.\(current.id, "end", next\)/);
});