Skip to content

Commit ae695c1

Browse files
author
DavidQ
committed
Log real repo root and verify Preview Generator V2 writes before reporting success - PR_26128_031-preview-generator-real-root-path
1 parent 3a97a03 commit ae695c1

5 files changed

Lines changed: 271 additions & 13 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Playwright Preview Generator V2 Real Root Path
2+
3+
## Commands
4+
- `node --check tools/preview-generator-v2/PreviewGeneratorV2App.js`
5+
- `node --check tests/playwright/tools/WorkspaceManagerV2.spec.mjs`
6+
- `npx playwright test tests/playwright/tools/WorkspaceManagerV2.spec.mjs --project=playwright --workers=1 --reporter=list -g "exports manifests and launches tools from fixed Workspace Manager V2 tiles|logs actionable Preview Generator V2 output path resolution failures|loads Gravity Well and Pong manifests"`
7+
- `npm run test:workspace-v2`
8+
- `git diff --check`
9+
10+
## Results
11+
- JavaScript syntax checks: passed.
12+
- Focused Preview Generator V2 real-root-path coverage: passed 3/3.
13+
- Workspace Manager V2 suite: passed 17/17.
14+
- Diff whitespace check: passed.
15+
16+
## Targeted Coverage
17+
- Generated a Pong preview with Force rewrite enabled.
18+
- Verified the log shows the actual repo root:
19+
- `Repo root: C:\Users\davidq\Documents\GitHub\HTML-JavaScript-Gaming`
20+
- Verified the log shows:
21+
- `Resolved relative output path: games/Pong/assets/images/preview.svg`
22+
- `Full absolute output path: C:\Users\davidq\Documents\GitHub\HTML-JavaScript-Gaming\games\Pong\assets\images\preview.svg`
23+
- Verified `OK WRITE Pong` appears only after write verification passes.
24+
- Verified Force rewrite logs replacement verification after write read-back succeeds.
25+
- Verified summary `Written: 1` appears only for the verified write path.
26+
- Verified missing repo root state logs `FAIL` and does not log `OK WRITE`.
27+
28+
## Skipped
29+
- Full samples smoke test was skipped by request. The required Preview Generator V2 path, verification, force-rewrite, failure, and Workspace launch paths are covered by `tests/playwright/tools/WorkspaceManagerV2.spec.mjs`.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Preview Generator V2 Real Root Path
2+
3+
## Scope
4+
- Updated Preview Generator V2 output path resolution so logged absolute paths are built from the selected repo root plus the resolved relative output path.
5+
- Workspace launch hydration now preserves the actual repo root path from `workspace.repo.reference`.
6+
- Execution logs the selected repo root before batch processing.
7+
- Each successful write logs:
8+
- resolved relative output path
9+
- repo root path
10+
- full absolute output path
11+
- source resolution context
12+
13+
## Verification Behavior
14+
- If the repo root path is unavailable, Preview Generator V2 logs `FAIL Repo root path resolution` and does not claim `OK WRITE`.
15+
- Write success is counted only after `writePreview` returns a verified successful write result.
16+
- When file read-back is available, the written `preview.svg` is read back and compared to the generated SVG before `OK WRITE` is logged.
17+
- Force rewrite logs verification only after the replacement write passes read-back verification.
18+
- Verification failures log `FAIL` with the expected full absolute output path and do not increment `Written`.
19+
20+
## Pong Target
21+
- Force rewrite validation covers Pong.
22+
- Expected repo root:
23+
- `C:\Users\davidq\Documents\GitHub\HTML-JavaScript-Gaming`
24+
- Expected full absolute output path:
25+
- `C:\Users\davidq\Documents\GitHub\HTML-JavaScript-Gaming\games\Pong\assets\images\preview.svg`
26+
- The resolved relative output path remains:
27+
- `games/Pong/assets/images/preview.svg`
28+
29+
## Guardrails
30+
- No hidden fallback output paths were added.
31+
- No sample JSON was modified.
32+
- No roadmap content was modified.
33+
- Source resolution context logging was preserved.
34+
35+
## Skipped
36+
- Full samples smoke test was skipped by request. The changed surface is Preview Generator V2 path logging and write verification, covered by the targeted Pong generation path plus the full Workspace V2 Playwright suite.

tests/playwright/tools/WorkspaceManagerV2.spec.mjs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ function manifestRepoPath(server) {
4343
return server.repoRoot.replaceAll("\\", "/");
4444
}
4545

46+
function displayRepoRootPath(server) {
47+
return server.repoRoot.replaceAll("/", "\\").replace(/\\+$/, "");
48+
}
49+
50+
function displayAbsoluteOutputPath(server, relativePath) {
51+
return `${displayRepoRootPath(server)}\\${relativePath.replaceAll("/", "\\")}`;
52+
}
53+
4654
async function installMockRepoPicker(page) {
4755
await page.addInitScript(() => {
4856
const defaultManifestPaths = [
@@ -1894,12 +1902,15 @@ test.describe("Workspace Manager V2 bootstrap", () => {
18941902
expect(previewStatusHeaderOrder).toEqual(["Status", "+", "Clear"]);
18951903
await page.locator("#executeBtn").click();
18961904
await expect(page.locator("#log")).toContainText("Starting execution...", { timeout: 20000 });
1905+
await expect(page.locator("#log")).toContainText(`Repo root: ${displayRepoRootPath(server)}`, { timeout: 20000 });
18971906
await expect(page.locator("#log")).toContainText("RUN Asteroids", { timeout: 20000 });
18981907
await expect(page.locator("#log")).toContainText("OUT games\\Asteroids\\assets\\images\\preview.svg", { timeout: 20000 });
18991908
await expect(page.locator("#log")).toContainText("OK WRITE Asteroids", { timeout: 20000 });
19001909
await expect(page.locator("#log")).toContainText("Resolved relative output path: games/Asteroids/assets/images/preview.svg", { timeout: 20000 });
1901-
await expect(page.locator("#log")).toContainText("Absolute output path: HTML-JavaScript-Gaming/games/Asteroids/assets/images/preview.svg", { timeout: 20000 });
1910+
await expect(page.locator("#log")).toContainText(`Repo root: ${displayRepoRootPath(server)}`, { timeout: 20000 });
1911+
await expect(page.locator("#log")).toContainText(`Full absolute output path: ${displayAbsoluteOutputPath(server, "games/Asteroids/assets/images/preview.svg")}`, { timeout: 20000 });
19021912
await expect(page.locator("#log")).toContainText("Source resolution context: workspace.tools.preview-generator-v2.data; selected game: Asteroids; resolved assets/images target: assets/images; target type: games", { timeout: 20000 });
1913+
await expect(page.locator("#log")).toContainText(`Write verification passed: file exists at ${displayAbsoluteOutputPath(server, "games/Asteroids/assets/images/preview.svg")}.`, { timeout: 20000 });
19031914
await expect(page.locator("#log")).toContainText("OK Asteroids", { timeout: 20000 });
19041915
await expect(page.locator("#log")).toContainText("Done.", { timeout: 20000 });
19051916
await expect(page.locator("#lastGeneratedImageMeta")).toHaveText("Last generated: Asteroids");
@@ -2127,11 +2138,15 @@ test.describe("Workspace Manager V2 bootstrap", () => {
21272138

21282139
await page.locator("#executeBtn").click();
21292140
const log = page.locator("#log");
2141+
await expect(log).toContainText("Repo root: unavailable", { timeout: 10000 });
2142+
await expect(log).toContainText("FAIL Repo root path resolution: Repo root path is unavailable; cannot resolve a full absolute output path.", { timeout: 10000 });
21302143
await expect(log).toContainText("FAIL PATH MissingGame", { timeout: 10000 });
2131-
await expect(log).toContainText("Unable to resolve target directory: Missing directory: HTML-JavaScript-Gaming/games/MissingGame", { timeout: 10000 });
2144+
await expect(log).toContainText("Repo root path is unavailable; cannot resolve a full absolute output path.", { timeout: 10000 });
21322145
await expect(log).toContainText("relative output path: games/MissingGame/assets/images/preview.svg", { timeout: 10000 });
2133-
await expect(log).toContainText("absolute output path: HTML-JavaScript-Gaming/games/MissingGame/assets/images/preview.svg", { timeout: 10000 });
2146+
await expect(log).toContainText("repo root: (unavailable)", { timeout: 10000 });
2147+
await expect(log).toContainText("full absolute output path: (unavailable)", { timeout: 10000 });
21342148
await expect(log).toContainText("source resolution context: preview-generator-v2 form controls; selected game: MissingGame; resolved assets/images target: assets/images; target type: games", { timeout: 10000 });
2149+
await expect(log).not.toContainText("OK WRITE MissingGame");
21352150
await expect(log).toContainText("Written: 0", { timeout: 10000 });
21362151
await expect(log).toContainText("Failed: 1", { timeout: 10000 });
21372152
await expect(log).toContainText("Skipped: 0", { timeout: 10000 });
@@ -2247,6 +2262,24 @@ test.describe("Workspace Manager V2 bootstrap", () => {
22472262
await expect(page.locator("#log")).toContainText("OK Workspace repo session reference loaded from workspace.repo.reference for HTML-JavaScript-Gaming.");
22482263
await expect(page.locator("#log")).toContainText("Workspace launch repo context resolved from session storage; independent repo selection is not required.");
22492264
await expect(page.locator("#log")).toContainText("Generated preview target: games/Pong/assets/images/preview.svg");
2265+
await page.locator("#forceRewrite").check();
2266+
await expect(page.locator("#executeBtn")).toBeEnabled();
2267+
await page.locator("#executeBtn").click();
2268+
await expect(page.locator("#log")).toContainText("Force rewrite: true", { timeout: 20000 });
2269+
await expect(page.locator("#log")).toContainText(`Repo root: ${displayRepoRootPath(server)}`, { timeout: 20000 });
2270+
await expect(page.locator("#log")).toContainText("RUN Pong", { timeout: 20000 });
2271+
await expect(page.locator("#log")).toContainText("OK WRITE Pong", { timeout: 20000 });
2272+
await expect(page.locator("#log")).toContainText("Resolved relative output path: games/Pong/assets/images/preview.svg", { timeout: 20000 });
2273+
await expect(page.locator("#log")).toContainText(`Full absolute output path: ${displayAbsoluteOutputPath(server, "games/Pong/assets/images/preview.svg")}`, { timeout: 20000 });
2274+
await expect(page.locator("#log")).toContainText("Source resolution context: workspace.tools.preview-generator-v2.data; selected game: Pong; resolved assets/images target: assets/images; target type: games", { timeout: 20000 });
2275+
await expect(page.locator("#log")).toContainText(`Write verification passed: file exists at ${displayAbsoluteOutputPath(server, "games/Pong/assets/images/preview.svg")}.`, { timeout: 20000 });
2276+
await expect(page.locator("#log")).toContainText(`Force rewrite verification passed for ${displayAbsoluteOutputPath(server, "games/Pong/assets/images/preview.svg")}.`, { timeout: 20000 });
2277+
await expect(page.locator("#log")).toContainText("Written: 1", { timeout: 20000 });
2278+
await expect(page.locator("#log")).toContainText("Failed: 0", { timeout: 20000 });
2279+
await expect(page.locator("#log")).toContainText("Done.", { timeout: 20000 });
2280+
const pongPreviewWrites = await page.evaluate(() => JSON.parse(sessionStorage.getItem("workspace.repo.writes") || "[]"));
2281+
expect(pongPreviewWrites.at(-1).path).toBe("HTML-JavaScript-Gaming/games/Pong/assets/images/preview.svg");
2282+
expect(pongPreviewWrites.at(-1).contents).toContain("<svg");
22502283
await page.locator("#returnToWorkspaceButton").click();
22512284
await expect(page).toHaveURL(/workspace-manager-v2\/index\.html\?hostContextId=workspace-manager-v2-/);
22522285

0 commit comments

Comments
 (0)