Skip to content

Add frontend lint and build to CI and fix lint errors - #1

Merged
kris7011 merged 1 commit into
mainfrom
ci/add-frontend-validation
Oct 16, 2026
Merged

kris7011 merged 1 commit into
mainfrom
ci/add-frontend-validation

Conversation

@kris7011

Copy link
Copy Markdown
Owner

Problem

  • CI only covered .NET. .github/workflows/dotnet.yml restored, built and tested the backend. The React/TypeScript frontend (about 2,100 lines) was never installed, type-checked, linted or built in CI.
  • npm run lint failed on main with 2 × react-hooks/set-state-in-effect (in App.tsx and WeeklyScheduleTable.tsx), so lint could not simply be added to CI.
  • Two UX bugs were tied to the same loading pattern:
    • After "Generér vagtplan" or "Nulstil demo-data", loadOverview() set isLoading = true. The whole dashboard was replaced by "Henter data..." and the weekly schedule was unmounted and remounted.
    • After "Nulstil demo-data", employee preference profiles were never reloaded. Reset creates new employees with new IDs, so the Medarbejdere → Præferencer view showed stale IDs, or stayed empty on a fresh database, until the browser was reloaded.

Solution

  • CI (same workflow file, renamed to CI):
    • New frontend job: npm ci → npm run lint → npm run build (tsc -b + Vite), Node 24 with npm cache.
    • The .NET job is unchanged apart from updated action versions.
    • pull_request now runs for every base branch, so stacked PRs are validated too. Added permissions: contents: read and concurrency.
  • App.tsx:
    • The initial load calls the API in the effect and only sets state in promise callbacks. The loading flags start as true.
    • Generate and reset call refreshAfterDataChange(), which updates the data without the full-page loading state and still bumps the schedule refresh key.
    • Reset also reloads preference profiles.
    • The "Opdater data" and "Prøv igen" buttons keep the full reload exactly as before.
  • WeeklyScheduleTable.tsx: data is loaded in the effect (keyed on refreshKey plus a retry counter). The current week stays visible while it refreshes, and "Prøv igen" still shows the loading state.
  • README CI Pipeline section updated.

No changes to the scheduling logic, API or backend.

Test results

dotnet test        → 59 passed
npm run lint       → 0 problems (main: 2 errors)
npm run build      → OK

GitHub Actions: see the checks on this PR (backend + frontend jobs).

Limitations

  • The frontend has no automated tests yet. The follow-up PR (stacked on this one) adds Vitest + React Testing Library and covers the refresh and reset behaviour above.
  • The API base URL is still hard-coded to http://localhost:5026 in each api/*.ts file. The follow-up PR centralizes it.

🤖 Generated with Claude Code

CI only built and tested the .NET solution; the React frontend was
never validated, and npm run lint failed with two
react-hooks/set-state-in-effect errors.

- Add a frontend job (npm ci, lint, build) next to the .NET job and
  run CI on pull requests to any base branch
- Load initial dashboard and weekly schedule data in effects that only
  set state in promise callbacks
- Refresh after generating or resetting a schedule without replacing
  the dashboard with the full-page loading state
- Reload employee preference profiles after a demo reset; previously
  they stayed empty or stale until a browser reload

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant