M8-R19: use unique thermal pagination fixtures
frontend / frontend (push) Successful in 1m0s
pytest / test (push) Successful in 4m18s

This commit is contained in:
2026-08-28 15:25:06 +02:00
parent 7d46cb96d3
commit 35691e08eb
+7 -2
View File
@@ -462,12 +462,17 @@ describe('CostView', () => {
it('paginates the complete thermal ledger and resets offset when its range or scope changes', async () => { it('paginates the complete thermal ledger and resets offset when its range or scope changes', async () => {
const user = userEvent.setup() const user = userEvent.setup()
const lastRow = { ...THERMAL_ROW, period_start: '2026-06-22T12:00:00Z', quantity: '501' } const firstPageRows = Array.from({ length: 500 }, (_, index) => {
const periodStart = new Date(Date.UTC(2026, 5, 22, 10, index * 15))
const periodEnd = new Date(Date.UTC(2026, 5, 22, 10, (index + 1) * 15))
return { ...THERMAL_ROW, period_start: periodStart.toISOString(), period_end: periodEnd.toISOString() }
})
const lastRow = { ...THERMAL_ROW, period_start: '2026-06-27T15:00:00Z', period_end: '2026-06-27T15:15:00Z', quantity: '501' }
mockGet.mockImplementation((path: string, options?: { params?: { query?: { offset?: number } } }) => { mockGet.mockImplementation((path: string, options?: { params?: { query?: { offset?: number } } }) => {
if (path === '/api/energy/meters') return Promise.resolve({ data: { items: [ACTIVE_HEATING_METER, ACTIVE_HOT_WATER_METER], total: 2 } }) if (path === '/api/energy/meters') return Promise.resolve({ data: { items: [ACTIVE_HEATING_METER, ACTIVE_HOT_WATER_METER], total: 2 } })
if (path === '/api/energy/meter-costs') { if (path === '/api/energy/meter-costs') {
const offset = options?.params?.query?.offset ?? 0 const offset = options?.params?.query?.offset ?? 0
return Promise.resolve({ data: offset === 0 ? { items: Array.from({ length: 500 }, () => THERMAL_ROW), total: 501 } : { items: [lastRow], total: 501 } }) return Promise.resolve({ data: offset === 0 ? { items: firstPageRows, total: 501 } : { items: [lastRow], total: 501 } })
} }
if (path === '/api/energy/meter-costs/summary') return Promise.resolve({ data: THERMAL_SUMMARY }) if (path === '/api/energy/meter-costs/summary') return Promise.resolve({ data: THERMAL_SUMMARY })
if (path === '/api/energy/costs/summary') return Promise.resolve({ data: SUMMARY }) if (path === '/api/energy/costs/summary') return Promise.resolve({ data: SUMMARY })