feat(application): expose peak time calendar contexts

This commit is contained in:
2026-03-31 22:46:19 +02:00
parent ba2bf00712
commit 5097ceab7e
2 changed files with 302 additions and 6 deletions
@@ -931,6 +931,74 @@ describe("dashboard use-cases", () => {
]);
});
it("exposes calendar context summaries in peak times derivation", async () => {
const db = {
assignment: {
findMany: vi.fn().mockResolvedValue([]),
},
resource: {
findMany: vi.fn().mockResolvedValue([
{
id: "res_by",
displayName: "Bruce",
chapter: "CGI",
availability: { monday: 8, tuesday: 8, wednesday: 8, thursday: 8, friday: 8 },
countryId: "country_de",
federalState: "BY",
metroCityId: "city_munich",
country: { code: "DE", name: "Germany" },
metroCity: { name: "Munich" },
},
{
id: "res_hh",
displayName: "Harvey",
chapter: "CGI",
availability: { monday: 8, tuesday: 8, wednesday: 8, thursday: 8, friday: 8 },
countryId: "country_de",
federalState: "HH",
metroCityId: "city_hamburg",
country: { code: "DE", name: "Germany" },
metroCity: { name: "Hamburg" },
},
]),
},
};
const result = await getDashboardPeakTimes(db as never, {
startDate: new Date("2026-01-05T00:00:00.000Z"),
endDate: new Date("2026-01-06T00:00:00.000Z"),
granularity: "month",
groupBy: "chapter",
});
expect(result).toEqual([
expect.objectContaining({
period: "2026-01",
derivation: expect.objectContaining({
calendarContextCount: 2,
calendarLocations: [
expect.objectContaining({
countryCode: "DE",
countryName: "Germany",
federalState: "HH",
metroCityName: "Hamburg",
resourceCount: 1,
effectiveAvailableHours: 16,
}),
expect.objectContaining({
countryCode: "DE",
countryName: "Germany",
federalState: "BY",
metroCityName: "Munich",
resourceCount: 1,
effectiveAvailableHours: 8,
}),
],
}),
}),
]);
});
it("does not burn budget on regional public holidays", async () => {
const db = {
project: {