Skip to content

Commit dced288

Browse files
committed
Fix local Admin Notes menu route without production header changes - PR_26158_047-admin-notes-menu-route-fix
1 parent 4f6f58c commit dced288

10 files changed

Lines changed: 339 additions & 41 deletions
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# PR_26158_047 Admin Notes Menu Route Fix Report
2+
3+
## Summary
4+
5+
PR_26158_047 fixes the Admin Notes menu visibility path for the API-backed local server. The production `assets/theme-v2/partials/header-nav.html` stays clean, and the local server now serves a dedicated dev-only header partial from `src/dev-runtime/admin/header-nav.local.html` when local pages request the normal header partial.
6+
7+
## Implementation
8+
9+
| File | Change |
10+
| --- | --- |
11+
| `src/dev-runtime/admin/header-nav.local.html` | Added dev/local-only header partial containing `Admin Notes (Local Dev)` under Admin. |
12+
| `src/dev-runtime/admin/admin-notes-menu.mjs` | Replaced runtime string replacement with `localAdminNotesHeaderPartialPath(...)`, which maps the normal header partial request to the dev-only partial path. |
13+
| `src/dev-runtime/server/local-api-server.mjs` | Serves the dev-only Admin Notes header partial through the API-backed local server. |
14+
| `tests/helpers/playwrightRepoServer.mjs` | Mirrors the local server partial routing for targeted Playwright validation. |
15+
| `tests/dev-runtime/AdminNotesBoundary.test.mjs` | Updated boundary coverage to validate dedicated partial routing and production-clean header behavior. |
16+
| `tests/playwright/tools/LoginSessionMode.spec.mjs` | Added fixed-port `http://127.0.0.1:5501/login.html` Admin menu validation. |
17+
18+
## Requirement Checklist
19+
20+
| Requirement | Status | Evidence |
21+
| --- | --- | --- |
22+
| Read `docs_build/dev/PROJECT_INSTRUCTIONS.md` first. | PASS | Read before implementation. |
23+
| Fix Admin Notes not appearing from `http://127.0.0.1:5501/login.html`. | PASS | Fixed-port Playwright test opens that exact URL and validates the Admin Notes item. |
24+
| Do not rely on fragile string replacement against `assets/theme-v2/partials/header-nav.html`. | PASS | Removed the string replacement injector; local server maps the normal partial request to `src/dev-runtime/admin/header-nav.local.html`. |
25+
| Add a dev/local-only served header partial or local-only menu route that includes Admin Notes. | PASS | Added `src/dev-runtime/admin/header-nav.local.html`. |
26+
| Ensure local pages load the dev/local header partial when running the API-backed local server. | PASS | `src/dev-runtime/server/local-api-server.mjs` routes the normal header partial request to the dev-only partial. |
27+
| Keep `assets/theme-v2/partials/header-nav.html` production-clean with no hardcoded Admin Notes link. | PASS | Static header check found no Admin Notes strings. |
28+
| Admin Notes menu item is visible under Admin as `Admin Notes (Local Dev)`. | PASS | Fixed-port Playwright validates visible link text under Admin. |
29+
| Admin Notes opens `/src/dev-runtime/admin/admin-notes.html`. | PASS | Fixed-port Playwright clicks the link and verifies the viewer route and loaded `index.txt` status. |
30+
| Do not expose Admin Notes in UAT/PROD. | PASS | Public exposure and dev-runtime admin import audits returned no matches in production-facing paths. |
31+
| Do not modify `start_of_day` folders. | PASS | `git diff --name-only \| rg "(^|/)start_of_day(/|$)"` returned no matches. |
32+
33+
## Validation
34+
35+
| Validation | Status | Evidence |
36+
| --- | --- | --- |
37+
| Changed-file syntax checks. | PASS | `node --check` passed for changed JS/MJS files; `node --test tests/dev-runtime/AdminNotesBoundary.test.mjs` passed 5/5. |
38+
| AdminNotesLocalViewer Playwright. | PASS | Targeted run passed the viewer test. |
39+
| Admin menu Playwright against `http://127.0.0.1:5501/login.html`. | PASS | Targeted run passed the fixed-port Admin menu test. |
40+
| Production/public header partial remains clean. | PASS | `Select-String` found no Admin Notes strings in the production header partial. |
41+
| UAT/PROD paths do not expose `src/dev-runtime/admin/`. | PASS | Static `rg` audits returned no matches. |
42+
43+
## Rerun Notes
44+
45+
- Initial Playwright run hit `EADDRINUSE` on `127.0.0.1:5501`. The fixed-port test harness now uses an already-running API-backed local server when present and still validates the exact 5501 URL.
46+
- Second run corrected a test expectation from absolute URL to raw `href="/src/dev-runtime/admin/admin-notes.html"`; click-through still validates the full page URL.
47+
48+
## Skipped Lanes
49+
50+
| Lane | Decision | Reason |
51+
| --- | --- | --- |
52+
| Full samples smoke | SKIP | No sample loader/framework, sample data, or game runtime changed. |
53+
| Full Playwright suite | SKIP | Targeted Admin Notes viewer and local Admin menu lanes cover the changed behavior. |
54+
55+
## Result
56+
57+
PASS. All requested PR_26158_047 requirements are implemented and validated.

docs_build/dev/reports/coverage_changed_js_guardrail.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Source: Playwright/Chromium built-in V8 coverage from the active Playwright run.
77

88
Changed runtime JS files considered:
99
(0%) src/dev-runtime/admin/admin-notes-menu.mjs - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
10+
(0%) src/dev-runtime/server/local-api-server.mjs - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
1011

1112
Guardrail warnings:
1213
(0%) src/dev-runtime/admin/admin-notes-menu.mjs - WARNING: changed runtime JS file missing from coverage; advisory only
14+
(0%) src/dev-runtime/server/local-api-server.mjs - WARNING: changed runtime JS file missing from coverage; advisory only

docs_build/dev/reports/playwright_v8_coverage_report.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,27 @@ Note: coverage entries are aggregated across every page/tool where coverageRepor
1414
Exercised tool entry points detected:
1515
(0%) Toolbox Index - not exercised by this Playwright run
1616
(0%) Tool Template V2 - not exercised by this Playwright run
17-
(75%) Theme V2 Shared JS - exercised 1 runtime JS files
17+
(68%) Theme V2 Shared JS - exercised 2 runtime JS files
1818

1919
Changed runtime JS files covered:
2020
(0%) src/dev-runtime/admin/admin-notes-menu.mjs - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
21+
(0%) src/dev-runtime/server/local-api-server.mjs - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
2122

2223
Files with executed line/function counts where available:
23-
(75%) assets/theme-v2/js/gamefoundry-partials.js - executed lines 441/441; executed functions 30/40
24+
(20%) src/engine/api/mock-db-api-client.js - executed lines 19/19; executed functions 1/5
25+
(29%) src/engine/api/server-api-client.js - executed lines 159/159; executed functions 4/14
26+
(62%) assets/theme-v2/js/login-session.js - executed lines 357/357; executed functions 16/26
27+
(63%) src/engine/api/session-api-client.js - executed lines 34/34; executed functions 5/8
28+
(73%) assets/theme-v2/js/gamefoundry-partials.js - executed lines 441/441; executed functions 29/40
2429
(96%) src/dev-runtime/admin/admin-notes-viewer.js - executed lines 501/501; executed functions 47/49
2530

2631
Uncovered or low-coverage changed JS files:
2732
(0%) src/dev-runtime/admin/admin-notes-menu.mjs - WARNING: uncovered changed runtime JS file; advisory only
33+
(0%) src/dev-runtime/server/local-api-server.mjs - WARNING: uncovered changed runtime JS file; advisory only
2834

2935
Changed JS files considered:
3036
(0%) src/dev-runtime/admin/admin-notes-menu.mjs - changed JS file not collected as browser runtime coverage
37+
(0%) src/dev-runtime/server/local-api-server.mjs - changed JS file not collected as browser runtime coverage
3138
(0%) tests/dev-runtime/AdminNotesBoundary.test.mjs - changed JS file not collected as browser runtime coverage
39+
(0%) tests/helpers/playwrightRepoServer.mjs - changed JS file not collected as browser runtime coverage
3240
(0%) tests/playwright/tools/LoginSessionMode.spec.mjs - changed JS file not collected as browser runtime coverage
Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,44 @@
1-
# PR_26158_046 Testing Lane Execution Report
1+
# PR_26158_047 Testing Lane Execution Report
22

33
## Lanes Run
44

55
| Lane | Command | Result |
66
| --- | --- | --- |
77
| Changed-file syntax checks | `node --check src/dev-runtime/admin/admin-notes-menu.mjs`; `node --check src/dev-runtime/server/local-api-server.mjs`; `node --check tests/helpers/playwrightRepoServer.mjs`; `node --check tests/dev-runtime/AdminNotesBoundary.test.mjs`; `node --check tests/playwright/tools/LoginSessionMode.spec.mjs`; `node --test tests/dev-runtime/AdminNotesBoundary.test.mjs` | PASS, AdminNotesBoundary 5/5 |
8-
| Admin Notes local viewer Playwright | `npx playwright test tests/playwright/tools/AdminNotesLocalViewer.spec.mjs tests/playwright/tools/LoginSessionMode.spec.mjs --grep "Admin Notes local viewer loads\|Local users unlock" --workers=1` | PASS, 2/2 |
8+
| AdminNotesLocalViewer Playwright | `npx playwright test tests/playwright/tools/AdminNotesLocalViewer.spec.mjs tests/playwright/tools/LoginSessionMode.spec.mjs --grep "Admin Notes local viewer loads\|API-backed 5501 login page shows" --workers=1` | PASS, 2/2 |
9+
| Production header partial clean check | `Select-String -Path assets/theme-v2/partials/header-nav.html -Pattern "Admin Notes\|data-admin-notes-local-menu\|admin-notes\|docs_build/dev/admin-notes"`; `Test-Path admin/notes.html` | PASS, no header matches; `admin/notes.html` returned `False` |
910
| Public navigation exposure audit | `rg -n "docs_build/dev/admin-notes\|docs_build\\dev\\admin-notes\|admin-notes-dev\|data-admin-notes-local-menu\|Admin Notes" account admin assets toolbox src/engine src/shared --glob '!archive/v1-v2/**' --glob '!tmp/**'` | PASS, no matches |
1011
| UAT/PROD dev-runtime admin import audit | `rg -n "src/dev-runtime/admin\|src\\dev-runtime\\admin" account admin assets toolbox src/engine src/shared --glob '!archive/v1-v2/**' --glob '!tmp/**'` | PASS, no matches |
11-
| Production header partial clean check | `Select-String -Path assets/theme-v2/partials/header-nav.html -Pattern "Admin Notes\|data-admin-notes-local-menu\|admin-notes\|docs_build/dev/admin-notes"` | PASS, no matches |
12-
| Production route absence check | `Test-Path admin/notes.html` | PASS, returned `False` |
1312
| Changed-file whitespace/static validation | `git diff --check` | PASS, Git line-ending warnings only |
1413
| start_of_day protection check | `git diff --name-only \| rg "(^|/)start_of_day(/|$)"` | PASS, no matches |
1514

1615
## Validation Notes
1716

1817
| Check | Evidence | Result |
1918
| --- | --- | --- |
20-
| Admin Notes is visible in the Admin menu during local API-backed testing. | LoginSessionMode Playwright hovers the Admin menu and asserts `data-admin-notes-local-menu` is visible. | PASS |
21-
| Admin Notes menu item opens `/src/dev-runtime/admin/admin-notes.html`. | LoginSessionMode Playwright clicks the local menu item and validates the Admin Notes viewer heading and loaded `index.txt` status. | PASS |
22-
| Dev-only viewer remains available. | AdminNotesLocalViewer Playwright loads `/src/dev-runtime/admin/admin-notes.html` and opens note files. | PASS |
23-
| Local server renders the menu consistently. | `src/dev-runtime/admin/admin-notes-menu.mjs` injects normal `data-nav-link` markup into the served header copy; AdminNotesBoundary validates the served copy. | PASS |
24-
| Static 5500 is not used for Admin Notes menu injection. | Injection is wired through `src/dev-runtime/server/local-api-server.mjs` and the Playwright local API-backed server helper. | PASS |
25-
| Checked-in Theme V2 header partial is production-clean. | Static partial check and exposure audit found no Admin Notes strings. | PASS |
26-
| UAT/PROD candidate paths do not expose or import Admin Notes. | Static exposure/import audits returned no matches. | PASS |
19+
| Admin Notes local viewer works. | AdminNotesLocalViewer Playwright opened `/src/dev-runtime/admin/admin-notes.html`, loaded `index.txt`, listed folders/files, and opened notes. | PASS |
20+
| Admin Notes appears from `http://127.0.0.1:5501/login.html`. | LoginSessionMode Playwright opened the exact fixed-port URL, selected the Admin session, hovered Admin, and found `Admin Notes (Local Dev)`. | PASS |
21+
| Admin Notes opens the dev viewer route. | The fixed-port Playwright test clicked the menu item and verified `/src/dev-runtime/admin/admin-notes.html`, the `Admin Notes` heading, and loaded `index.txt` status. | PASS |
22+
| Dedicated local header partial replaces fragile string replacement. | `node --test tests/dev-runtime/AdminNotesBoundary.test.mjs` verifies the server maps the normal header partial path to `src/dev-runtime/admin/header-nav.local.html` and leaves the production partial unchanged. | PASS |
23+
| Production/public header remains clean. | Static partial check and public exposure audit returned no matches. | PASS |
24+
| UAT/PROD-facing paths do not expose Admin Notes implementation. | Static import audit returned no matches under public/admin/account/toolbox/engine/shared paths. | PASS |
25+
26+
## Rerun Notes
27+
28+
| Attempt | Result | Resolution |
29+
| --- | --- | --- |
30+
| First targeted Playwright attempt | FAIL | `127.0.0.1:5501` was already in use. The fixed-port test harness now uses an existing API-backed local server when one is already running, while still validating the exact 5501 URL. |
31+
| Second targeted Playwright attempt | FAIL | Test expected the resolved absolute URL in the raw `href` attribute. The assertion was corrected to expect `/src/dev-runtime/admin/admin-notes.html`, and click-through still validates the full 5501 URL. |
32+
| Final targeted Playwright attempt | PASS | AdminNotesLocalViewer and fixed-port Admin menu tests passed 2/2. |
2733

2834
## Skipped Lanes
2935

3036
| Lane | Decision | Reason |
3137
| --- | --- | --- |
32-
| Full samples smoke | SKIP | No sample loader/framework, game runtime, or sample data changed. |
33-
| Full Playwright suite | SKIP | PR scope is limited to local API-backed Admin menu visibility and the existing Admin Notes local viewer; targeted lanes passed. |
38+
| Full samples smoke | SKIP | No samples, sample loader/framework, or game runtime changed. |
39+
| Full Playwright suite | SKIP | Scope is limited to local API-backed Admin Notes menu routing and the existing Admin Notes local viewer; targeted lanes cover the changed behavior. |
3440

3541
## Notes
3642

37-
- `git diff --check` emitted line-ending warnings only.
3843
- Playwright emitted existing SQLite experimental and seed-only audit fallback warnings; they did not fail the targeted lanes.
39-
- Runtime coverage is advisory; the changed local menu injector executes in the Node local server path, so browser V8 lists it as uncovered.
44+
- Runtime coverage is advisory; changed server-side files are not collected by browser V8 coverage.

src/dev-runtime/admin/admin-notes-menu.mjs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,15 @@ export const ADMIN_NOTES_LOCAL_VIEWER_PATH = "/src/dev-runtime/admin/admin-notes
44
export const ADMIN_NOTES_LOCAL_MENU_LABEL = "Admin Notes (Local Dev)";
55

66
const HEADER_PARTIAL_PATH = "assets/theme-v2/partials/header-nav.html";
7-
const INSERT_BEFORE = ' <a data-nav-link data-route="admin-analytics" href="admin/analytics.html">Analytics</a>';
8-
const LOCAL_MENU_LINK = ` <a data-nav-link data-admin-notes-local-menu href="${ADMIN_NOTES_LOCAL_VIEWER_PATH}">${ADMIN_NOTES_LOCAL_MENU_LABEL}</a>`;
7+
const LOCAL_HEADER_PARTIAL_PATH = "src/dev-runtime/admin/header-nav.local.html";
98

109
function repoRelativePath(repoRoot, targetPath) {
1110
return path.relative(repoRoot, targetPath).replaceAll(path.sep, "/");
1211
}
1312

14-
export function localAdminNotesMenuContent(repoRoot, targetPath, fileContents) {
13+
export function localAdminNotesHeaderPartialPath(repoRoot, targetPath) {
1514
if (repoRelativePath(repoRoot, targetPath) !== HEADER_PARTIAL_PATH) {
16-
return fileContents;
15+
return targetPath;
1716
}
18-
const source = fileContents.toString("utf8");
19-
if (source.includes("data-admin-notes-local-menu")) {
20-
return fileContents;
21-
}
22-
if (!source.includes(INSERT_BEFORE)) {
23-
return fileContents;
24-
}
25-
return Buffer.from(source.replace(INSERT_BEFORE, `${LOCAL_MENU_LINK}\n${INSERT_BEFORE}`), "utf8");
17+
return path.join(repoRoot, LOCAL_HEADER_PARTIAL_PATH);
2618
}

0 commit comments

Comments
 (0)