This commit is contained in:
2026-06-09 21:28:53 +12:00
parent daa6e60a69
commit 349e4a4b5b
61 changed files with 6404 additions and 1382 deletions
+11 -6
View File
@@ -11,6 +11,7 @@ const apiMocks = vi.hoisted(() => ({
productCosts: vi.fn(),
scenarios: vi.fn(),
dataQuality: vi.fn(),
dashboardSummary: vi.fn(),
clientAccess: vi.fn(),
clientAccessExport: vi.fn()
}));
@@ -61,6 +62,13 @@ describe('route loaders use the SvelteKit fetch argument', () => {
apiMocks.productCosts.mockResolvedValue([{ id: 4 }]);
apiMocks.scenarios.mockResolvedValue([{ id: 5 }]);
apiMocks.dataQuality.mockResolvedValue([{ id: 6 }]);
apiMocks.dashboardSummary.mockResolvedValue({
raw_materials: null,
mixes: null,
products: null,
trend_seeds: { raw_material_cost_per_kg: [], mix_cost_per_kg: [], product_finished_delivered: [] },
operations: null
});
apiMocks.clientAccess.mockResolvedValue([{ id: 7 }]);
apiMocks.clientAccessExport.mockResolvedValue({
generated_at: '',
@@ -74,13 +82,10 @@ describe('route loaders use the SvelteKit fetch argument', () => {
});
it('passes fetch through the home page loader', async () => {
await homeLoad({ fetch: fetcher } as never);
const result = homeLoad({ fetch: fetcher } as never);
await result.summary;
expect(apiMocks.rawMaterials).toHaveBeenCalledWith(fetcher);
expect(apiMocks.mixes).toHaveBeenCalledWith(fetcher);
expect(apiMocks.productCosts).toHaveBeenCalledWith(fetcher);
expect(apiMocks.scenarios).toHaveBeenCalledWith(fetcher);
expect(apiMocks.dataQuality).toHaveBeenCalledWith(fetcher);
expect(apiMocks.dashboardSummary).toHaveBeenCalledWith(fetcher);
});
it('passes fetch through the raw materials loader', async () => {