M8-T19: add scope-aware energy contract and cost UI

This commit is contained in:
2026-08-23 21:22:06 +02:00
parent 963e43e3e4
commit 5b9d60e80a
10 changed files with 532 additions and 51 deletions
+11
View File
@@ -150,6 +150,17 @@ describe('useCreateContract', () => {
expect(mockPost).toHaveBeenCalledWith('/api/energy/contracts', { body })
})
it('preserves the caller-selected thermal scope in the typed create payload', async () => {
mockPost.mockResolvedValue({ data: { id: 9 } })
const { Wrapper } = makeWrapper()
const { useCreateContract } = await import('./hooks')
const { result } = renderHook(() => useCreateContract(), { wrapper: Wrapper })
await act(async () => {
await result.current.mutateAsync({ name: 'Heat', kind: 'district_heating', scope: 'thermal', currency: 'EUR', values: {} })
})
expect(mockPost).toHaveBeenCalledWith('/api/energy/contracts', expect.objectContaining({ body: expect.objectContaining({ scope: 'thermal' }) }))
})
})
describe('useEnergyPrices', () => {