refactor: collapse App.js's 5-way route-path duplication into one ROUTES constant - #386
Merged
Merged
Conversation
App.js spelled out the same route paths in five separate places (Route JSX, nav items, page titles, search placeholders, serve.json) with nothing keeping them in sync -- the exact gap that caused #383. Now frontend/src/routes.js is the single source of truth that App.js derives its Route table, sidebar nav, keyboard shortcuts, header title, and search placeholder from, and App.routes.test.js validates that data against serve.json structurally instead of regex-scraping App.js's source. Closes #384 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QCHg8DX1rzgPDCm5CsHF7g
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
frontend/src/App.jsspelled out the same route paths in five separate places (<Route>JSX,ALL_NAV_ITEMS,PAGE_TITLE,SEARCH_PLACEHOLDER, plusserve.jsonin a different file) with nothing keeping them in sync — that gap is what caused bug: /groups route 404s on direct navigation (missing serve.json rewrite) #383 (/groupsadded to the JSX and nav but never toserve.json, so direct navigation 404'd).frontend/src/routes.jsexports oneROUTESarray;App.jsnow derives its<Route>table, sidebar nav, keyboard shortcuts, header title, and search placeholder from it instead of hand-maintaining six parallel lists (a sixth duplication site — the keyboard-shortcutif/elsechain — was found and collapsed too).App.routes.test.js(added by fix: add missing /groups serve.json rewrite causing direct-nav 404 #385 as an interim regex-over-source guard) is rewritten to validate the realROUTESdata againstserve.jsonstructurally, and now also asserts no hand-written<Route path="...">can bypassROUTESin the first place (any literal-path spelling — double/single-quoted or{...}-wrapped) — closing the exact bypass bug: /groups route 404s on direct navigation (missing serve.json rewrite) #383 exploited.Related issue
Closes #384
Type of change
Checklist
App.routes.test.jsas a structural guard, addedApp.test.jsrender smoke testdocs/decisions.mdTest plan
cd frontend && npm test -- --watchAll=false— 8 suites / 99 tests passing (up from 92 on baselinemain)cd frontend && npm run build— compiles cleanly, output 388B smaller gzippedcd backend && python3 -m pytest tests/ --ignore=tests/integration -v— 503 passed (unaffected by this change, run to confirm)./scripts/run-integration-tests.sh(CI-equivalent flags) — 33 passed, 3 skipped, 0 faileddocker compose up -d --build, exercising the actualservebinary +serve.json): hard navigation to/,/measures,/jobs,/groups,/results,/results/:jobId,/validation,/settingsall load the app shell (not a 404) with correct header title, search placeholder, and sidebar order; feature-flag gating (Groups/Validation nav visibility) and keyboard shortcuts (M/J/E navigate, G/V suppressed when flags off, all suppressed while the search box is focused) verified/codexreview — found two real gaps (bypass-guard regex missed single-quoted/expression-literal paths; kbd-uniqueness check wasn't case-normalized to matchApp.js's case-insensitive matching) — both fixed and re-verifiedCo-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01QCHg8DX1rzgPDCm5CsHF7g