- Replace mock Nitro routes with server-side proxies to the Go API - /plan reads Go /api/staffing; local assumption edits are a labeled preview - /simulate reads base and scenario staffing from Go instead of local multipliers - Route train upload and scenario POST through Nitro with server-only credentials - Keep NUXT_PUBLIC_USE_MOCK=1 as an explicit dev fallback only - Match Go's global-peak flat schedule and add a captured Go parity fixture - Run the web runtime as numeric UID/GID 10001:10001 - Add make check, Gitea CI workflow and a proxy smoke script
40 lines
1.6 KiB
TypeScript
40 lines
1.6 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { berlinParts, buildStaffing } from '../shared/staffing'
|
|
import type { StaffingResponse } from '../shared/types'
|
|
|
|
// Captured from the real Go API:
|
|
// curl 'http://localhost:8080/api/staffing?sensor=hn-stadtgalerie-01&scenario=base&standard=standard'
|
|
// with api-go.git/main/testdata/data as DATA_DIR.
|
|
const fixture = JSON.parse(
|
|
readFileSync(new URL('./fixtures/go-staffing.json', import.meta.url), 'utf8'),
|
|
) as StaffingResponse
|
|
|
|
describe('Go /api/staffing parity', () => {
|
|
it('rebuilds the API plan from its own hourly forecast', () => {
|
|
const firstHour = fixture.hours[0]
|
|
expect(firstHour).toBeDefined()
|
|
|
|
const build = buildStaffing({
|
|
sensor: fixture.sensor,
|
|
scenario: fixture.scenario,
|
|
standard: fixture.standard,
|
|
points: fixture.hours.map((hour) => ({ t: hour.t, v: hour.footfall })),
|
|
weekStart: berlinParts(firstHour!.t).date,
|
|
data_version: fixture.data_version,
|
|
model_version: fixture.model_version,
|
|
context_version: fixture.context_version,
|
|
})
|
|
|
|
expect(build.response.assumptions).toEqual(fixture.assumptions)
|
|
expect(build.response.summary).toEqual(fixture.summary)
|
|
expect(build.response.shifts).toEqual(fixture.shifts)
|
|
|
|
// The API returns float footfall; the local display type rounds it. Every
|
|
// decision field must still be identical.
|
|
const decision = (hours: StaffingResponse['hours']) =>
|
|
hours.map(({ footfall: _footfall, ...rest }) => rest)
|
|
expect(decision(build.response.hours)).toEqual(decision(fixture.hours))
|
|
})
|
|
})
|