feat: modernize dashboard widgets
This commit is contained in:
1 parent
f3048f4804
commit
a2763d1f6f
261 files changed
+9392
-2697
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { Response } from "undici";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { fetchWithTrustedCertificatesAsync } from "@homarr/core/infrastructure/http";
|
||||
|
||||
import { TraefikIntegration } from "./traefik-integration";
|
||||
|
||||
vi.mock("@homarr/core/infrastructure/http", () => ({ fetchWithTrustedCertificatesAsync: vi.fn() }));
|
||||
|
||||
const mockFetch = vi.mocked(fetchWithTrustedCertificatesAsync);
|
||||
const integration = new TraefikIntegration({
|
||||
id: "traefik-1",
|
||||
name: "Traefik",
|
||||
url: "https://traefik.example.com",
|
||||
externalUrl: null,
|
||||
decryptedSecrets: [],
|
||||
});
|
||||
|
||||
describe("TraefikIntegration response bounds", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockFetch.mockImplementation((url) => {
|
||||
const path = new URL(url.toString()).pathname;
|
||||
if (path === "/api/version") return Promise.resolve(jsonResponse({ Version: "3.0.0" }));
|
||||
if (path === "/api/http/routers") {
|
||||
return Promise.resolve(
|
||||
jsonResponse(Array.from({ length: 250 }, (_, index) => ({ name: `router-${index}`, status: "enabled" }))),
|
||||
);
|
||||
}
|
||||
return Promise.resolve(jsonResponse([]));
|
||||
});
|
||||
});
|
||||
|
||||
it("caps detailed resource allocation while retaining bounded summary counts", async () => {
|
||||
const result = await integration.getDashboardDataAsync();
|
||||
|
||||
expect(result.resources).toHaveLength(200);
|
||||
expect(result.resources.at(-1)?.name).toBe("router-199");
|
||||
expect(result.http.routers.total).toBe(250);
|
||||
});
|
||||
});
|
||||
|
||||
const jsonResponse = (body: unknown) => new Response(JSON.stringify(body), { status: 200 });
|
||||
Reference in new issue
Block a user