Skip to content

Commit 1b81dda

Browse files
committed
Fix Assets upload file writes and uploaded asset preview - PR_26163_075-assets-upload-write-and-view-fix
1 parent 71bfb58 commit 1b81dda

9 files changed

Lines changed: 3865 additions & 846 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# PR_26163_075-assets-upload-write-and-view-fix
2+
3+
## Branch Validation
4+
- PASS - Current branch: `main`
5+
- PASS - Expected branch: `main`
6+
7+
## Requirement Checklist
8+
- PASS - Uploaded files are physically written under `projects/<projectId>/<asset-type>/` for upload-capable Assets types. Evidence: `tests/playwright/tools/AssetToolMockRepository.spec.mjs` verifies `projects/01K8M3K0EX7V5A3W9Q2Y6R4T1B/image/write-view-image.png` exists after upload.
9+
- PASS - Uploads are not marked OK until the file exists on disk after write. Evidence: `assets-mock-repository.js` writes with `writeFileSync`, then checks `existsSync` before creating the asset record.
10+
- PASS - Missing project asset folders are created. Evidence: Playwright removes the image folder before upload and verifies it is recreated.
11+
- PASS - Asset records store project-relative paths. Evidence: asset records now store `storedPath`, `path`, `targetFilePath`, and `viewPath`.
12+
- PASS - Image View previews the written file. Evidence: Playwright checks the View preview image `src` and `naturalWidth`.
13+
- PASS - Audio, Font, and Data View use the stored project-relative path. Evidence: Playwright checks `src`/`href` for `audio`, `font`, and `data` uploaded records.
14+
- PASS - Unsupported browser/runtime file writes fail visibly and create no records. Evidence: `?uploadWrite=unsupported` test shows visible FAIL/SKIP diagnostics and count remains `0`.
15+
- PASS - Diagnostics show project id, target folder, target file path, write result, and view path. Evidence: View metadata and batch dialog/status rows include those fields.
16+
- PASS - Multi-file upload diagnostics from PR074 are preserved. Evidence: targeted Playwright checks dialog progress, bytes, BPS, speed, ETA, elapsed, per-file statuses, and batch summary.
17+
- PASS - Uploads remain scoped only to `projects/`. Evidence: repository path resolver rejects paths outside `projects/<projectId>/`.
18+
- PASS - Sprite, Vector, and Palette References remain Reference-only. Evidence: targeted Playwright verifies no upload file input for those asset types.
19+
- PASS - `codex_review.diff` is readable UTF-8 text. Evidence: existing Playwright check passes after artifact generation.
20+
21+
## Changed Files
22+
- `src/dev-runtime/persistence/tool-repositories/assets-mock-repository.js`
23+
- `src/dev-runtime/server/local-api-server.mjs`
24+
- `tests/helpers/playwrightRepoServer.mjs`
25+
- `tests/playwright/tools/AssetToolMockRepository.spec.mjs`
26+
- `toolbox/assets/assets.js`
27+
- `docs_build/dev/reports/playwright_v8_coverage_report.txt`
28+
- `docs_build/dev/reports/PR_26163_075-assets-upload-write-and-view-fix.md`
29+
- `docs_build/dev/reports/codex_review.diff`
30+
- `docs_build/dev/reports/codex_changed_files.txt`
31+
32+
## File-Write Evidence
33+
- PASS - Folder creation: Playwright removes `projects/01K8M3K0EX7V5A3W9Q2Y6R4T1B/image/`, uploads `write-view-image.png`, then verifies the folder exists.
34+
- PASS - File write: Playwright verifies `projects/01K8M3K0EX7V5A3W9Q2Y6R4T1B/image/write-view-image.png` exists and equals the selected PNG bytes.
35+
- PASS - Record gating: Playwright verifies unsupported write mode reports FAIL and creates no asset record.
36+
37+
## View-Preview Evidence
38+
- PASS - Image View renders the written image path and verifies `naturalWidth > 0`.
39+
- PASS - Audio View uses the uploaded `projects/<projectId>/audio/...` path.
40+
- PASS - Font View uses the uploaded `projects/<projectId>/font/...` path.
41+
- PASS - Data View uses the uploaded `projects/<projectId>/data/...` path.
42+
43+
## Impacted Lanes
44+
- Assets tool runtime lane.
45+
- Assets mock repository/dev-runtime upload persistence lane.
46+
- Local/static file serving lane for uploaded asset content types.
47+
- Targeted Assets Playwright lane.
48+
- Workspace V2 contract lane.
49+
50+
## Skipped Lanes
51+
- Full samples smoke: SKIP - explicitly out of scope for this PR; this change is limited to Assets upload/write/view behavior and targeted workspace validation was run.
52+
- Production DB/auth/account lanes: SKIP - no production DB, auth, or account behavior changed.
53+
54+
## Validation Performed
55+
- PASS - `node --check toolbox/assets/assets.js`
56+
- PASS - `node --check src/dev-runtime/persistence/tool-repositories/assets-mock-repository.js`
57+
- PASS - `node --check src/dev-runtime/server/local-api-server.mjs`
58+
- PASS - `node --check tests/helpers/playwrightRepoServer.mjs`
59+
- PASS - `node --check tests/playwright/tools/AssetToolMockRepository.spec.mjs`
60+
- PASS - `git diff --check` before generating review artifacts; final source/report check used `git diff --check -- . ':!docs_build/dev/reports/codex_review.diff'` because raw diff artifacts can contain trailing whitespace from the captured patch.
61+
- PASS - `npx playwright test tests/playwright/tools/AssetToolMockRepository.spec.mjs --workers=1 --reporter=list` -> 8 passed
62+
- PASS - `npm run test:workspace-v2` -> 5 passed in workspace-contract lane
63+
64+
## Playwright Result
65+
- PASS - Targeted Assets Playwright: 8 passed.
66+
- PASS - Workspace V2: 5 passed.
67+
68+
## V8 Coverage
69+
- WARN/PASS - `docs_build/dev/reports/playwright_v8_coverage_report.txt` refreshed from targeted Assets Playwright.
70+
- PASS - Browser runtime `toolbox/assets/assets.js`: 96% advisory V8 coverage.
71+
- WARN - Node-side changed JS (`assets-mock-repository.js`, local server files, Playwright helpers/specs) is not collected by browser V8 coverage; covered by targeted Playwright behavior and `node --check`.
72+
73+
## Manual Validation Steps
74+
1. Open `toolbox/assets/index.html` through the local API-backed server.
75+
2. Add an Image upload with a real image file.
76+
3. Confirm the status/metadata shows Project ID, Target folder, Target file path, Write result, and View path.
77+
4. Confirm the file exists under `projects/<projectId>/image/`.
78+
5. Click View and confirm the image preview renders from the stored project-relative path.
79+
6. Repeat for Audio, Font, and Data and confirm View uses the stored project path.
80+
7. Open `toolbox/assets/index.html?uploadWrite=unsupported`, upload images, and confirm visible FAIL/SKIP diagnostics with no created records.
81+
82+
## Samples Decision
83+
- SKIP - Full samples smoke was not run because the request explicitly said not to run it and no sample runtime behavior was changed.

docs_build/dev/reports/codex_changed_files.txt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@ M docs_build/dev/reports/codex_changed_files.txt
33
M docs_build/dev/reports/codex_review.diff
44
M docs_build/dev/reports/playwright_v8_coverage_report.txt
55
M src/dev-runtime/persistence/tool-repositories/assets-mock-repository.js
6+
M src/dev-runtime/server/local-api-server.mjs
7+
M tests/helpers/playwrightRepoServer.mjs
68
M tests/playwright/tools/AssetToolMockRepository.spec.mjs
79
M toolbox/assets/assets.js
8-
M toolbox/assets/index.html
9-
?? docs_build/dev/reports/PR_26163_074-assets-multi-file-upload-project-write.md
10+
?? docs_build/dev/reports/PR_26163_075-assets-upload-write-and-view-fix.md
1011

1112
# git ls-files --others --exclude-standard
12-
docs_build/dev/reports/PR_26163_074-assets-multi-file-upload-project-write.md
13+
docs_build/dev/reports/PR_26163_075-assets-upload-write-and-view-fix.md
1314

1415
# git diff --stat
15-
docs_build/dev/reports/codex_changed_files.txt | 26 +-
16-
docs_build/dev/reports/codex_review.diff | Bin 39852 -> 53126 bytes
17-
.../dev/reports/playwright_v8_coverage_report.txt | 43 ++-
18-
.../tool-repositories/assets-mock-repository.js | 22 +-
19-
.../tools/AssetToolMockRepository.spec.mjs | 186 ++++++++++++
20-
toolbox/assets/assets.js | 330 ++++++++++++++++++++-
21-
toolbox/assets/index.html | 42 +++
22-
7 files changed, 620 insertions(+), 29 deletions(-)
16+
docs_build/dev/reports/codex_changed_files.txt | 26 +-
17+
docs_build/dev/reports/codex_review.diff | 1872 +++++++++++---------
18+
.../dev/reports/playwright_v8_coverage_report.txt | 10 +-
19+
.../tool-repositories/assets-mock-repository.js | 305 +++-
20+
src/dev-runtime/server/local-api-server.mjs | 14 +
21+
tests/helpers/playwrightRepoServer.mjs | 14 +
22+
.../tools/AssetToolMockRepository.spec.mjs | 114 +-
23+
toolbox/assets/assets.js | 214 ++-
24+
8 files changed, 1720 insertions(+), 849 deletions(-)

0 commit comments

Comments
 (0)