M8-R19: use unique thermal pagination fixtures
This commit is contained in:
@@ -462,12 +462,17 @@ describe('CostView', () => {
|
||||
|
||||
it('paginates the complete thermal ledger and resets offset when its range or scope changes', async () => {
|
||||
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 } } }) => {
|
||||
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') {
|
||||
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/costs/summary') return Promise.resolve({ data: SUMMARY })
|
||||
|
||||
Reference in New Issue
Block a user