Ben Senescu 638f5a6602 refactor: move lighthouse audits to dataforseo (#43)
* refactor: move lighthouse audits to dataforseo

* chore: remove obsolete audit settings modal

* refactor: rename psi flows to lighthouse

* save

* refactor: simplify audit lighthouse storage flow

* fix: separate lighthouse metrics from actionable audits

* refactor: remove redundant audit project inputs

* feat: redesign lighthouse issues screen with score gauges and table layout

Replace flat score cards with circular SVG gauges, condense metrics into
a compact grid, and switch issue list from cards to an expandable table
with fixed column widths.

* test: harden lighthouse regression coverage

* fix: restore project-scoped audit inputs

* refactor: simplify lighthouse payload handling

* refactor: inline lighthouse server handlers

* refactor: share audit workflow types

* refactor: simplify lighthouse payload flows

* save

* refactor: drop project pagespeed api key

* fix: restore lighthouse issues loading with resilient project context

* fix: restore audit issues back navigation

* refactor: simplify project context and lighthouse error handling

* fix: tolerate DataForSEO lighthouse payload drift

* refactor: route audit lighthouse through dataforseo client
2026-03-26 20:25:27 -04:00

59 lines
1.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
clampAuditMaxPages,
getEstimatedAuditCapacity,
MAX_USER_AUDIT_USAGE,
} from "@/server/features/audit/services/audit-capacity";
describe("audit capacity helpers", () => {
it("clamps max pages into the supported range", () => {
expect(clampAuditMaxPages()).toBe(50);
expect(clampAuditMaxPages(1)).toBe(10);
expect(clampAuditMaxPages(500)).toBe(500);
expect(clampAuditMaxPages(20_000)).toBe(10_000);
});
it("estimates capacity for each lighthouse strategy", () => {
expect(
getEstimatedAuditCapacity({ maxPages: 100, lighthouseStrategy: "none" }),
).toEqual({
pagesTotal: 100,
lighthouseTotal: 0,
total: 100,
});
expect(
getEstimatedAuditCapacity({
maxPages: 100,
lighthouseStrategy: "manual",
}),
).toEqual({
pagesTotal: 100,
lighthouseTotal: 0,
total: 100,
});
expect(
getEstimatedAuditCapacity({ maxPages: 100, lighthouseStrategy: "auto" }),
).toEqual({
pagesTotal: 100,
lighthouseTotal: 20,
total: 120,
});
expect(
getEstimatedAuditCapacity({ maxPages: 100, lighthouseStrategy: "all" }),
).toEqual({
pagesTotal: 100,
lighthouseTotal: 200,
total: 300,
});
});
it("stays within the global capacity limit for the maximum auto audit", () => {
expect(
getEstimatedAuditCapacity({
maxPages: 10_000,
lighthouseStrategy: "auto",
}).total,
).toBeLessThan(MAX_USER_AUDIT_USAGE);
});
});