fix: delete-account timezone resilience test + timezone admin UI #289

Merged
owlburtoe merged 2 commits from worktree-fix+timezone-test-and-ui into main 2026-06-03 11:23:35 -04:00
Owner

Summary

  • Backend test (apps/backend/src/lib/jobs/__tests__/delete-account.test.ts): Integration test for executeDeleteAccount that seeds a department with an invalid IANA timezone via direct DB write (bypassing the API validator), creates a future shift + assignment, and asserts the job completes without throwing (UTC fallback kicks in). Also adds a no-op/cancellation path test.
  • Frontend UI (apps/frontend/src/components/settings/OrganizationSection.tsx): Adds a department timezone select to Settings → Organization. Uses Intl.supportedValuesOf('timeZone') grouped by region, wired into both handleLocationSave and handleDefaultsSave. Timezone is now editable by admin/department_admin and tracked in isLocationDirty. Backend already validates the IANA value (PUT /api/config/departmenttimezoneSchema).

Closes two open bugs from TODO.md:

  • delete-account job-path resilience test for invalid dept timezone
  • Department timezone admin UI in Settings

Test plan

  • pnpm test:backend:db -- --testPathPattern=delete-account — 2 new tests pass
  • pnpm --filter icu-schedule-app check-types — no TS errors
  • Settings → Organization as admin: timezone select appears, changing it and saving sends the value to PUT /api/config/department, success toast fires
  • Settings → Organization as non-admin: timezone select is disabled
  • Changing timezone to an invalid value (direct API) returns 400
## Summary - **Backend test** (`apps/backend/src/lib/jobs/__tests__/delete-account.test.ts`): Integration test for `executeDeleteAccount` that seeds a department with an invalid IANA timezone via direct DB write (bypassing the API validator), creates a future shift + assignment, and asserts the job completes without throwing (UTC fallback kicks in). Also adds a no-op/cancellation path test. - **Frontend UI** (`apps/frontend/src/components/settings/OrganizationSection.tsx`): Adds a department timezone select to Settings → Organization. Uses `Intl.supportedValuesOf('timeZone')` grouped by region, wired into both `handleLocationSave` and `handleDefaultsSave`. Timezone is now editable by `admin`/`department_admin` and tracked in `isLocationDirty`. Backend already validates the IANA value (`PUT /api/config/department` → `timezoneSchema`). Closes two open bugs from `TODO.md`: - `delete-account` job-path resilience test for invalid dept timezone - Department timezone admin UI in Settings ## Test plan - [ ] `pnpm test:backend:db -- --testPathPattern=delete-account` — 2 new tests pass - [ ] `pnpm --filter icu-schedule-app check-types` — no TS errors - [ ] Settings → Organization as admin: timezone select appears, changing it and saving sends the value to `PUT /api/config/department`, success toast fires - [ ] Settings → Organization as non-admin: timezone select is disabled - [ ] Changing timezone to an invalid value (direct API) returns 400
fix: add delete-account timezone resilience test and timezone admin UI
Some checks failed
Code Scanning / Gitleaks secret scan (pull_request) Successful in 8s
Code Scanning / Semgrep OSS source scan (pull_request) Successful in 34s
Security, Type Check & Runtime / Dependency Audit (pull_request) Successful in 9m48s
Security, Type Check & Runtime / Migration Guardrails (pull_request) Successful in 9m40s
Security, Type Check & Runtime / Backend Runtime Smoke (pull_request) Successful in 10m14s
Security, Type Check & Runtime / Type Check (pull_request) Successful in 10m25s
Release Artifacts / Validate release candidate (pull_request) Successful in 10m58s
Release Artifacts / Build and push Docker release images (pull_request) Has been skipped
Release Artifacts / Deploy to staging (pull_request) Has been skipped
E2E Tests / e2e (pull_request) Has been cancelled
42dc4a9580
- Add integration test for executeDeleteAccount that seeds a dept with
  an invalid IANA timezone via direct DB write (bypassing API validator),
  creates a future shift+assignment, and asserts the job completes without
  throwing. Also adds a no-op test for the cancellation path.
- Add department timezone select to OrganizationSection (Settings → Dept)
  using Intl.supportedValuesOf grouped by region. Timezone is now editable
  by admins and wired into both save handlers; isLocationDirty tracks changes.

Closes two open bugs from TODO:
- delete-account job-path resilience test for invalid dept timezone
- Department timezone admin UI in Settings
refactor(settings): fix set-state-in-effect lint warning in OrganizationSection
All checks were successful
Code Scanning / Semgrep OSS source scan (pull_request) Successful in 39s
Code Scanning / Gitleaks secret scan (pull_request) Successful in 6s
Android / Android Validation (pull_request) Successful in 5m42s
Release Artifacts / Validate release candidate (pull_request) Successful in 10m52s
Release Artifacts / Build and push Docker release images (pull_request) Has been skipped
Security, Type Check & Runtime / Dependency Audit (pull_request) Successful in 9m49s
E2E Tests / e2e (pull_request) Successful in 14m48s
Release Artifacts / Deploy to staging (pull_request) Has been skipped
Security, Type Check & Runtime / Type Check (pull_request) Successful in 10m13s
Security, Type Check & Runtime / Backend Runtime Smoke (pull_request) Successful in 10m12s
Security, Type Check & Runtime / Migration Guardrails (pull_request) Successful in 9m44s
f22aa14deb
Split OrganizationSection into a loading shell and OrganizationForm inner
component. The inner component receives config as a prop and initializes
state via the useState lazy initializer, eliminating the useEffect setState
sync that triggered react-hooks/set-state-in-effect.

Also consolidates the 7 individual form state variables into a single
FormState object with a configToForm helper.
owlburtoe deleted branch worktree-fix+timezone-test-and-ui 2026-06-03 11:23:35 -04:00
Sign in to join this conversation.
No description provided.