Repository navigation
Add frontend tests, centralize API URL and fix coverage rate translation - #2
Merged
Merged
Conversation
- Replace nine hard-coded API_BASE_URL constants with api/config.ts, configurable through VITE_API_BASE_URL (default unchanged) - translateRiskMessage removed the first '.' in 'Schedule coverage is 78.57%.', showing '7857%' whenever the API runs with an English or invariant culture (e.g. in the Docker image). Only strip the sentence-ending period. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests use fixtures captured from the real API after a demo reset and cover the overview, error/retry, refresh behaviour after generation, preference reload after reset and the weekly schedule table. CI now runs npm test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 16, 2026
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.
Problem
"Schedule coverage is {coverageRate}%."with the server's culture.translateRiskMessagethen called.replace(".", ""), which removes the first period. On a Danish machine (78,57%.) that happens to be the final period. With an English or invariant culture, for example in the Docker image or on a typical Linux/cloud host, the decimal point is removed and the dashboard shows "Vagtplanens dækningsgrad er 7857%."API_BASE_URL = "http://localhost:5026"was duplicated in 9 API modules and could not be configured.Solution
/\.$/). It works for both78,57%and78.57%.src/api/config.ts: oneAPI_BASE_URL, configurable viaVITE_API_BASE_URL(with a new.env.example). The default is unchanged.fetchis stubbed with fixtures captured from the real API afterPOST /api/demo/reset(src/test/fixtures/*.json). The coverage message uses invariant formatting (78.57%), as on CI.App.test.tsx: overview rendering and Danish translations, error page with "Prøv igen", dashboard staying visible while refreshing after "Generér vagtplan", preference profiles reloaded after "Nulstil demo-data".WeeklyScheduleTable.test.tsx: shifts per weekday and assigned names, 14/4/10 counts, weekend label, "Kun ubesatte" / "Kun tildelte" filters, week staying visible on refresh, error and retry.npm testbetween lint and build.VITE_API_BASE_URL, frontend check commands.Test results
I checked that the tests are meaningful: run against the
mainversions ofApp.tsxandWeeklyScheduleTable.tsx, 4 of 8 fail (coverage translation, refresh flicker in two places, missing preference reload).Limitations
SimulationPaneland the unassigned-shift and employee detail panels are only covered indirectly. Simulation and the API layer get more coverage in the backend integration test PR.ScheduleOverviewServiceformats with the current culture). Changing the message format would affect API consumers, so I left it as is and made the frontend robust instead.🤖 Generated with Claude Code