feat(01-13): wave-1 — promote c647f61 prototype to production paths; A6 GREEN

Move the three load-bearing prototype files from `tests/uat/prototype/`
to their production paths under `tests/uat/`, leaving the architectural
narrative (research findings, BLOCKER citations, falsification table
references) intact. No behavioral changes — A6 still PASSES 5/5 in ~7s
end-to-end from the new paths.

File moves (git mv preserves history):
  - tests/uat/prototype/extension-page-harness.html
      → tests/uat/extension-page-harness.html
  - tests/uat/prototype/extension-page-harness.ts
      → tests/uat/extension-page-harness.ts
  - tests/uat/prototype/a6.test.ts
      → tests/uat/a6.test.ts

The `tests/uat/prototype/` directory is now empty (git does not track
empty directories; will not appear in subsequent `git status`).

Path-reference updates inside the moved files:
  - tests/uat/extension-page-harness.html: `<p>` line referencing the
    chrome-extension:// URL updated to drop `/prototype/`.
  - tests/uat/extension-page-harness.ts: file-header docstring rewritten
    to cite Plan 01-13 / Approach B / inheritance from c647f61. The
    load-bearing architectural-finding comment block (MV3 SW dynamic-
    import block falsification, Approach-B chrome.* surface summary)
    is REWORDED but its semantic content + research citations are
    PRESERVED — every load-bearing fact survives the rename.
  - tests/uat/a6.test.ts:
      * File-header rewritten to position the file as Plan 01-13's
        standalone single-assertion entry point (preserves the future-
        proof rationale: this entry stays around forever for fast TDD
        iteration on A6 even after Wave 3 folds A6 into the orchestrator
        harness.test.ts).
      * REPO_ROOT resolvePath chain corrected from `..,..,..` to `..,..`
        — the file is now two directory levels above the repo root
        instead of three. Without this fix DIST_TEST_DIR would resolve
        to a path one level above the actual repo root and
        assertBundlePresent would throw. **VERIFIED by running the
        driver: build path resolves correctly.**
      * harnessUrl constant updated to drop `/prototype/` from the
        chrome-extension://<id>/tests/uat/extension-page-harness.html
        URL — must match the rollup emission path in dist-test/.
      * Stdout labels updated: 'PROTOTYPE A6 result' → 'A6 result',
        'Plan 01-11 PROTOTYPE — A6 ... feasibility test' → 'Plan 01-13
        — A6 (Bug B canonical) standalone driver'. Inside the docstrings
        the historical 'originally landed as 01-11 prototype' provenance
        is preserved per the plan's contract.

vite.test.config.ts:
  - `rollupOptions.input` renamed `prototype_harness` → `extension_page_harness`
    pointing at the new production path. crxjs emits the harness HTML
    to `dist-test/tests/uat/extension-page-harness.html` (verified by
    `ls dist-test/tests/uat/`).
  - The `modulePreload: { polyfill: false }` line is PRESERVED — this
    is the CRITICAL SW FIX per 01-11-SUMMARY (disabling the polyfill
    is what makes the test bundle's offscreen-side dynamic import work
    without crashing in non-DOM contexts that incorrectly try to call
    document.querySelector).
  - File-header comment §4 and the inline `define.__MOKOSH_UAT__` comment
    are PRESERVED — load-bearing rationale for the dedicated build-time
    token (vs `import.meta.env.MODE === 'test'` which collides with
    vitest).

Verification (all GREEN):
  - `npm run build:test` — exit 0; dist-test/ emits
    `tests/uat/extension-page-harness.html` and `assets/extension_page_harness-*.js`.
  - `npx tsx tests/uat/a6.test.ts` — exits 0 with "A6 result: PASS";
    5/5 checks GREEN (SETUP: badge becomes REC; A6.1 badge==''; A6.2
    popup==''; A6.3 notif delta==0; A6.4 isRecording=false). End-to-end
    runtime ~7s headless on this workstation.
  - `npx tsc --noEmit` — exit 0 (root tsconfig + tests/uat/tsconfig.json).
  - `npx vitest run` — 92/92 GREEN; the moves do not touch any vitest-
    discovered files.
  - `npm run build` — exit 0; Tier-1 grep gate stays GREEN
    (the moves do not touch production code).

Wave 2 (next): build out `tests/uat/lib/{launch,assertions,harness-page-
driver}.ts` around the extension-page architecture; rewrite
`tests/uat/a6.test.ts` to use the shared lib (still PASSES 5/5).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-18 15:01:58 +02:00
parent a63066a289
commit eb2258a880
4 changed files with 84 additions and 49 deletions

View File

@@ -33,10 +33,15 @@
// with it disabled, the SW initializes and chrome.runtime.onMessage
// handlers respond. See Plan 01-11 PROTOTYPE research session.
//
// PROTOTYPE addition: the prototype harness page at
// `tests/uat/prototype/extension-page-harness.html` is added as a
// Rollup input so the test build emits it. Production builds do NOT
// include the prototype page (vite.config.ts has no such input).
// Plan 01-13 Wave 1: the extension-internal harness page at
// `tests/uat/extension-page-harness.html` is added as a Rollup input
// so the test build emits it under that path in `dist-test/`. The
// Puppeteer driver navigates the in-browser tab to
// `chrome-extension://<id>/tests/uat/extension-page-harness.html` and
// invokes `window.__mokoshHarness.*` from the host side via CDP. The
// page itself has full chrome.* extension privileges (Approach B
// architectural anchor). Production builds (vite.config.ts) do NOT
// include this input — the page ships only in the test bundle.
//
// References:
// - Vite mergeConfig: https://vite.dev/guide/api-javascript.html#mergeconfig
@@ -76,10 +81,13 @@ export default defineConfig(({ command, mode }) =>
modulePreload: { polyfill: false },
rollupOptions: {
input: {
// Add the prototype harness page so it lands in dist-test/
// and becomes reachable as
// chrome-extension://<id>/tests/uat/prototype/extension-page-harness.html
prototype_harness: 'tests/uat/prototype/extension-page-harness.html',
// Plan 01-13 Wave 1: emit the extension-internal harness
// page at its production path so it becomes reachable as
// chrome-extension://<id>/tests/uat/extension-page-harness.html
// The crxjs vite plugin will copy this HTML into dist-test/
// and rewrite the <script type="module" src> reference to
// the bundled chunk's hashed filename.
extension_page_harness: 'tests/uat/extension-page-harness.html',
},
},
},