| 1 | import test from "node:test"; |
| 2 | import assert from "node:assert/strict"; |
| 3 | import { readFileSync } from "node:fs"; |
| 4 | import path from "node:path"; |
| 5 | import { fileURLToPath } from "node:url"; |
| 6 | import { memoryAffected, memoryMode } from "./app-memory-paths.mjs"; |
| 7 | |
| 8 | const benchDir = path.dirname(fileURLToPath(import.meta.url)); |
| 9 | test("all frontend consumers, configuration and tests trigger the soak", () => { |
| 10 | for (const path of ["desktop/frontend/src/App.tsx", "desktop/frontend/src/lib/types.ts", "desktop/frontend/pnpm-lock.yaml", "desktop/frontend/bench/fixture.json", ".github/workflows/app-memory.yml"]) |
| 11 | assert.equal(memoryAffected([path]), true, path); |
| 12 | }); |
| 13 | test("known independent backend and documentation changes skip only this mock frontend soak", () => { |
| 14 | assert.equal(memoryAffected(["internal/control/turn.go", "desktop/app.go", "sdk/types.ts", "docs/guide.md", "README.md", "desktop/AGENTS.md"]), false); |
| 15 | }); |
| 16 | test("repository tooling, workflows and the Electron shell do not reach the browser-mocked bundle", () => { |
| 17 | for (const path of [".github/actions/go-build-cache/action.yml", "scripts/release-stable.sh", "tools/desktopinventory/sources.go", |
| 18 | "workers/crash-report/src/index.ts", "docs/desktop-migration/inventory.json", "desktop/electron/src/main/dialogs.ts", "desktop/packaging/smoke.mjs", |
| 19 | "desktop/build/windows/installer/project.nsi", "desktop/go.sum", "go.mod", ".golangci.yml", "Makefile"]) |
| 20 | assert.equal(memoryAffected([path]), false, path); |
| 21 | }); |
| 22 | test("unknown paths fail closed and cannot be hidden by a documentation change", () => { |
| 23 | for (const path of [".npmrc", "shared/new-loader.js", "desktop/package.json", "desktop/pnpm-lock.yaml", "desktop/frontend/scripts/shell-css.mjs"]) |
| 24 | assert.equal(memoryAffected(["README.md", path]), true, path); |
| 25 | }); |
| 26 | test("ordinary frontend changes use the short screen and lifecycle changes use the full screen", () => { |
| 27 | assert.equal(memoryMode(["desktop/frontend/src/components/Button.tsx"]), "short"); |
| 28 | assert.equal(memoryMode(["desktop/frontend/src/App.tsx"]), "full"); |
| 29 | assert.equal(memoryMode(["desktop/frontend/src/lib/subscriptionScope.ts"]), "full"); |
| 30 | assert.equal(memoryMode(["docs/guide.md"]), "off"); |
| 31 | assert.equal(memoryMode(["shared/new-loader.js"]), "full"); |
| 32 | }); |
| 33 | |
| 34 | test("local session benchmarks navigate through the shared layout-independent contract", () => { |
| 35 | for (const name of ["app-memory.mjs", "app-browser.mjs", "composer-transcript-stability.mjs", "dock-view-state.mjs", "run.mjs", "runtime-state.mjs"]) { |
| 36 | const source = readFileSync(path.join(benchDir, name), "utf8"); |
| 37 | assert.doesNotMatch(source, /project-tree__topic-main:has-text\(["'`]bench:/, name); |
| 38 | } |
| 39 | }); |
| 40 |