Files
pikasTech-unidesk/scripts/src/hwlab-node-web-observe-runner-sampling-source.test.ts
T

50 lines
1.5 KiB
TypeScript

import assert from "node:assert/strict";
import { test } from "bun:test";
import {
MDTODO_TASK_TREE_PANE_CONTENT_SELECTOR,
nodeWebObserveRunnerSamplingSource,
} from "./hwlab-node-web-observe-runner-sampling-source";
test("MDTODO task tree pane gap treats the pinned facts footer as content", async () => {
assert.match(
MDTODO_TASK_TREE_PANE_CONTENT_SELECTOR,
/\[data-testid="mdtodo-task-tree-facts"\]/u,
);
assert.match(
MDTODO_TASK_TREE_PANE_CONTENT_SELECTOR,
/\[data-testid="mdtodo-task-page-fact"\]/u,
);
const source = nodeWebObserveRunnerSamplingSource();
assert.ok(
source.includes(
`measurePaneGap("task-tree", '[data-testid="mdtodo-task-tree"]', ${JSON.stringify(MDTODO_TASK_TREE_PANE_CONTENT_SELECTOR)})`,
),
);
assert.match(
source,
/semanticTaskCandidates\.length > 0 \? semanticTaskCandidates : fallbackTaskCandidates/u,
);
assert.match(
source,
/taskCandidates\.filter\(\(candidate\) => !taskRefElement\(candidate\)\)\.length/u,
);
assert.doesNotMatch(source, /taskCandidates\.length - taskItems\.length/u);
assert.match(source, /mdtodo-body-read/u);
assert.match(source, /mdtodo-launch-workbench/u);
const child = Bun.spawn(["node", "--input-type=module", "--check", "-"], {
stdin: "pipe",
stdout: "pipe",
stderr: "pipe",
});
child.stdin.write(source);
child.stdin.end();
const [stderr, exitCode] = await Promise.all([
new Response(child.stderr).text(),
child.exited,
]);
assert.equal(exitCode, 0, stderr);
});