Milestone v1 (v2.0.0): Mokosh — Session Capture #1
45
tests/build/cursor-visibility.test.ts
Normal file
45
tests/build/cursor-visibility.test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
// tests/build/cursor-visibility.test.ts — Plan 04-06 cursor-visibility
|
||||
// defensive regression pin (RESEARCH Finding 4 closure).
|
||||
//
|
||||
// Pins that src/offscreen/recorder.ts:285 carries the `cursor: 'always'`
|
||||
// getDisplayMedia constraint — the original Phase-5 deferral was lifted
|
||||
// opportunistically in Plan 01-09 (recorder.ts:285) and the back-patched
|
||||
// Plan 04-06 closes the audit loop by both (a) re-verifying the literal
|
||||
// via this defensive grep test and (b) flipping the stale "deferred to
|
||||
// Phase 5" lines in .planning/phases/01-stabilize-video-pipeline/
|
||||
// 01-07-SUMMARY.md (Task 3 of Plan 04-06).
|
||||
//
|
||||
// Polarity at land: GREEN-on-arrival — the literal already exists at
|
||||
// recorder.ts:285 (verified at 04-06 re-plan iter-2; confirmed via
|
||||
// `grep -n "cursor: 'always'" src/offscreen/recorder.ts`).
|
||||
//
|
||||
// SCOPE: node-env file-grep regression pin. Does NOT instantiate the
|
||||
// MediaStream pipeline (out of scope for unit tests; the runtime visibility
|
||||
// behavior is operator-empirical and out of the automated test loop —
|
||||
// per UI-SPEC § the operator confirms the cursor appears in
|
||||
// `video/last_30sec.webm` playback after a SAVE).
|
||||
//
|
||||
// References:
|
||||
// - .planning/phases/04-harden-clean-up-optional/04-RESEARCH.md
|
||||
// §Finding 4 (cursor visibility verification scope).
|
||||
// - .planning/phases/01-stabilize-video-pipeline/01-07-SUMMARY.md
|
||||
// (back-patched in Plan 04-06 Task 3 to remove the stale Phase-5
|
||||
// deferral framing — the constraint shipped in Plan 01-09).
|
||||
// - https://www.w3.org/TR/screen-capture/#dom-mediatrackconstraintset-cursor
|
||||
// (W3C Screen Capture spec — `cursor` constraint values).
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve as resolvePath } from 'node:path';
|
||||
|
||||
const RECORDER_PATH = resolvePath(
|
||||
process.cwd(),
|
||||
'src/offscreen/recorder.ts',
|
||||
);
|
||||
|
||||
describe("cursor visibility constraint shipped (Plan 01-09 -> verified Plan 04-06)", () => {
|
||||
it("src/offscreen/recorder.ts contains the cursor: 'always' getDisplayMedia constraint literal", () => {
|
||||
const text = readFileSync(RECORDER_PATH, 'utf8');
|
||||
expect(text).toContain("cursor: 'always'");
|
||||
});
|
||||
});
|
||||
67
tests/welcome/inline-svg.test.ts
Normal file
67
tests/welcome/inline-svg.test.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
// tests/welcome/inline-svg.test.ts — Plan 04-06 Wave 0 RED → GREEN unit test
|
||||
// for the UI-SPEC dark-logo `currentColor` strategy (Option A).
|
||||
//
|
||||
// SCOPE — source-contract pin only (node-env file-read + string assertions).
|
||||
//
|
||||
// vitest is configured with `environment: 'node'` (vitest.config.ts:18) and
|
||||
// the project ships no DOM-emulation library — neither jsdom, happy-dom nor
|
||||
// linkedom is in node_modules. This test pins the SOURCE TEXT contract of
|
||||
// the inline-SVG injection strategy (the SVG source carries the
|
||||
// `currentColor` stroke, welcome.ts uses the `?raw` import + DOMParser +
|
||||
// replaceChildren, globals.d.ts declares the `*.svg?raw` ambient module).
|
||||
//
|
||||
// It does NOT instantiate any document, does NOT call populateMark, does
|
||||
// NOT invoke DOMParser at runtime. The runtime behavior (live <svg>
|
||||
// injection into the welcome page DOM and the currentColor CSS cascade
|
||||
// through `.welcome-hero__mark { color: var(--mks-fg-inverse); }`) is
|
||||
// verified by the host-side UAT harness assertion A35 (driveA35 in
|
||||
// tests/uat/lib/harness-page-driver.ts) — A35 opens welcome.html as a real
|
||||
// Puppeteer tab so populateMark() actually runs, then reads
|
||||
// `getComputedStyle().stroke` on the injected <svg> to prove the cascade
|
||||
// resolves. This split mirrors the project's two-layer test approach
|
||||
// (source contract under vitest + live-DOM behavior under the Puppeteer
|
||||
// harness) — verified at re-plan iter-2 (BLOCKER 1 resolution).
|
||||
//
|
||||
// References:
|
||||
// - .planning/phases/04-harden-clean-up-optional/04-UI-SPEC.md
|
||||
// §"Implementation amendment" (currentColor + inline <svg> technique)
|
||||
// - .planning/phases/04-harden-clean-up-optional/04-RESEARCH.md
|
||||
// §SVG currentColor cascade (W3C SVG2 §13.3)
|
||||
// - tests/i18n/manifest-i18n.test.ts (the canonical node-env file-read
|
||||
// + string-assertion scaffold this test mirrors).
|
||||
// - https://vite.dev/guide/assets.html#importing-asset-as-string
|
||||
// (Vite `?raw` query suffix returns module content as a string).
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve as resolvePath } from 'node:path';
|
||||
|
||||
const MARK_SVG_PATH = resolvePath(
|
||||
process.cwd(),
|
||||
'src/shared/brand/mokosh-mark.svg',
|
||||
);
|
||||
const WELCOME_TS_PATH = resolvePath(process.cwd(), 'src/welcome/welcome.ts');
|
||||
const GLOBALS_DTS_PATH = resolvePath(process.cwd(), 'globals.d.ts');
|
||||
|
||||
describe('UI-SPEC dark-logo currentColor strategy — source-level contract', () => {
|
||||
it('mokosh-mark.svg: root <svg> uses stroke="currentColor" + canonical viewBox; legacy #181b2a stroke removed', () => {
|
||||
const text = readFileSync(MARK_SVG_PATH, 'utf8');
|
||||
expect(text).toContain('stroke="currentColor"');
|
||||
expect(text).toContain('viewBox="0 0 32 32"');
|
||||
expect(text).not.toContain('stroke="#181b2a"');
|
||||
});
|
||||
|
||||
it('welcome.ts: uses `?raw` import + DOMParser + replaceChildren; no `?url` import, no innerHTML (MV3 CSP discipline / T-04-06-01)', () => {
|
||||
const text = readFileSync(WELCOME_TS_PATH, 'utf8');
|
||||
expect(text).toContain('mokosh-mark.svg?raw');
|
||||
expect(text).toContain('DOMParser');
|
||||
expect(text).toContain('replaceChildren');
|
||||
expect(text).not.toContain('mokosh-mark.svg?url');
|
||||
expect(text).not.toContain('innerHTML');
|
||||
});
|
||||
|
||||
it('globals.d.ts: declares the `*.svg?raw` ambient module (mirror of the existing `*.svg?url` block)', () => {
|
||||
const text = readFileSync(GLOBALS_DTS_PATH, 'utf8');
|
||||
expect(text).toContain("declare module '*.svg?raw'");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user