addition of new dashboard

This commit is contained in:
2026-08-20 15:08:32 +00:00
parent 0622018d95
commit bf59249ed7
161 changed files with 13170 additions and 119 deletions

View File

@@ -0,0 +1,37 @@
import { jest } from "@jest/globals";
const query = jest.fn();
const release = jest.fn(async () => {});
jest.unstable_mockModule("../../db/index.js", () => ({ getPool: async () => ({ query, release }) }));
const { getSeries } = await import("./series.js");
beforeEach(() => {
query.mockReset();
release.mockClear();
});
describe("getSeries (combined usage + storage, one query)", () => {
it("splits one result set into usage counts and storage byte totals with computed totals", async () => {
query.mockResolvedValue({
rows: [
{ date: "2026-06-01", core: 3, audit: 5, core_disk: "100", audit_disk: "50" },
{ date: "2026-06-02", core: 0, audit: 0, core_disk: "100", audit_disk: "50" },
],
});
const out = await getSeries(7, { from: "2026-06-01", to: "2026-06-02" });
expect(query).toHaveBeenCalledTimes(1); // single round-trip
expect(query.mock.calls[0][1]).toEqual([7, "2026-06-01", "2026-06-02"]);
expect(out.usage).toEqual([
{ date: "2026-06-01", core: 3, audit: 5, total: 8 },
{ date: "2026-06-02", core: 0, audit: 0, total: 0 },
]);
expect(out.storage).toEqual([
{ date: "2026-06-01", coreDisk: 100, auditDisk: 50, totalDisk: 150 },
{ date: "2026-06-02", coreDisk: 100, auditDisk: 50, totalDisk: 150 },
]);
expect(release).toHaveBeenCalledTimes(1);
});
});