Panel: switch all five API modules from mock to the real server #113
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage#113
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Blocks MVP acceptance #29 (product owner test week from 11-20).
What
On
dev(6554d98) every panel API module still hasconst USE_MOCK = true:frontend-web/src/api/sessionApi.ts,devicesApi.ts,ipRulesApi.ts,mediaApi.ts,playlistsApi.ts.The panel therefore talks to no server: setup, login, approve, upload and playlists change nothing. The HTTP implementations (
http*Api.ts) and the server routes all exist and are merged.Done when
USE_MOCK = trueleft infrontend-web/src/api/for production builds (mocks may stay for tests).plan/operations/deployment.mdsection "The panel's device and IP-rules screens are not wired" is removed (stale: PR #103 merged).Depends on nothing. Pair with the panel-serving issue for the server.
Scope change from the product owner (GRI-1884): no hard-coded
USE_MOCK. Mock mode and the server address come from configuration.Shape to build:
VITE_API_MODE=mock|http, read in one place (e.g.src/api/mode.ts) and used by all five modules. The default ishttp.npm run dev:mock(or.env.development.local) turns the mocks on. A production build (npm run build) must not contain the mock modules: guard withimport.meta.envso Vite drops them, and check this in the PR (grepdist/for a mock fixture string).VITE_DEV_API_TARGET=http://<host>:<port>in.env.development.local;vite.config.tsproxies/apiand the WebSocket path to it. The panel code keeps calling the relative/api/v1, so the session cookie stays same-origin and the server needs no CORS.apiBasesetting: it needs CORS and cross-site cookies, and it gives one more value an installer can get wrong..env.examplethat names both variables, and add two lines tofrontend-web/README(ordeployment.md) on how to point a dev panel at the test server.Done when (added): no
USE_MOCKconstant left;dev:mockworks;npm run devwithVITE_DEV_API_TARGETset talks to a real server; the production bundle holds no mock code.PR: #118
USE_MOCKis off in all five modules (import.meta.env.MODE === 'test'picks the mock now, so
vitestis unaffected and the QA suite isunedited). Devices, IP rules, media and playlists are verified by hand
against a real
server+ Postgres — see the PR body for the exact routesand responses. Two real server-side defects turned up doing that, both
blocking:
1. Setup/login don't work against the real server.
POST /setupandPOST /sessionrequireemail(+namefor setup) — theuserstablehas no
usernamecolumn. The panel's Login/Setup screens, andApp.test.tsx, model username+password, matchingplan/server/rest-api.md'sown "Logs in: username and password in" — which the server never
implemented. I can't fix this myself: the UI side would need
App.test.tsxchanged (not mine to do), the server side isn't my crate.For the back-end engineer: is
usernamemeant to come back, or isemail+namethe real model and the doc/UI/test are what's stale? Forthe QA engineer: flagging in case the test needs to move either way.
2. PDF upload 500s, every time.
convert_pdf_upload(
crates/server/src/media/handlers.rs) deletes its render directory rightafter
render_pagesreturns, then reads the rendered pages' bytes out ofthat now-gone directory in the next loop — reproduced by hand with a real
2-page PDF. Also leaves an orphaned
documentcatalog row (inserted beforethe crash) with no page rows behind it. Image and video upload both work
fine. For the back-end engineer.
Given these, I'm treating devices/IP-rules/media(image,video,url)/playlists
as done, and session + PDF-upload as blocked pending the above. Leaving
the issue open rather than closing —
plan/operations/deployment.md'sstale section is removed either way (that part's unconditionally done).
Pushed the scope-change work to #118 (commit
8efced9):src/api/mode.tsis the single place that resolvesapiMode:'mock'under vitest (unconditional) or when
VITE_API_MODE=mock, else'http'.All five modules now import it instead of inlining
import.meta.env.MODE === 'test'.and grepped
dist/assets/*.jsfor mock-only fixture strings(
mock-admin,lobby-screen,cafe-south) — absent from a plainnpm run build, present fromvite build --mode mock. Rollup'scross-module constant folding is doing the drop since
apiModeisstatically known at build time.
vite.config.tsproxies/apitoVITE_DEV_API_TARGETwhen that env varis set (dev-only; production stays same-origin, nothing added there).
package.jsongetsdev:mock(vite --mode mock, loading the new.env.mock), alongside the existingdev..env.exampledocuments both variables; README has two lines on pointinga dev panel at a real server.
USE_MOCKleft anywhere (grep -rn USE_MOCKis empty).npm run checkandlocal-gates.sh --frontend-onlyare green, no tests touched.CI on #118 is queued (position 0), will report when it lands.
The two blockers from the earlier comment are unchanged by this scope
change: session wiring still needs the username-vs-email/name decision,
and PDF upload still 500s server-side (
convert_pdf_upload). Both stillneed the back-end engineer.
CI on PR #118 is green:
fj civerdict is "CI passed" on8efced90(the rollupCI / CIjob succeeded). One unrelated job,cargo deny advisories, is failing — that's the same flaky/pre-existing advisories check GRI-1886 is retriggering CI for on another PR right now, not something introduced by this change.PR #118 is open, mergeable, not draft: #118
Status unchanged from before: devices, IP rules, media (image/video/url), and playlists are done and verified against a real server. Session wiring and the panel's PDF upload remain blocked on the two server-side defects reported on forge #113 (no
usernamecolumn vs. the panel/QA test's username+password model;convert_pdf_upload500ing). Those need the CTO/back-end engineer, not frontend work.Handing to the chief of staff to merge #118 into dev on this CI result (I don't merge my own PR).
Landed in dev with PR #118 (CI green). The panel now uses the real server by default; the mock is opt-in with VITE_API_MODE=mock.
Username-vs-email decision taken on GRI-1937: the panel adopts the server contract (email, name, password for setup; email, password for login). PR #142.