- Delete src/features/reference-feature/presentation/reference-feature-runtime.tsx: it only re-exported the same-named .ts and nothing imported it by the .tsx path. - Move promotion-readiness.ts and performance-budgets.ts from src/application/policies to scripts/lib: only scripts and their unit tests import them. Imports updated in 5 scripts and 2 tests. config/testing/risk-coverage.json lists only src modules, so their two criticalModules/highRiskPaths entries are removed; the synthetic 14-file summary fixture now names two other existing src modules. - installed-feature-messages.ts composes one catalog per locale the installed features declare (composeInstalledMessageCatalogs) instead of a fixed ko-KR/en-US list that silently dropped other catalogs. The exported type still maps each declared locale to its exact key set. Verified: tests/unit/installed-feature-messages.test.ts (ko-KR/en-US content pinned first; derived-locale and duplicate-key cases RED before); app typecheck also passes with a zero-feature generated index; all gates PASS; check:ci PASS; check-bundle resolves the moved module (stops later on the absent artifacts/performance/bundle.json). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
78 lines
2.0 KiB
TypeScript
78 lines
2.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
evaluateBundleBudget,
|
|
evaluateFieldBudget,
|
|
evaluateLabBudget,
|
|
percentile75,
|
|
} from "../../scripts/lib/performance-budgets.ts";
|
|
|
|
describe("performance budgets", () => {
|
|
it("rejects initial and lazy JavaScript above their named limits", () => {
|
|
const thresholds = {
|
|
initialJsGzipBytes: 200,
|
|
lazyChunkGzipBytes: 120,
|
|
};
|
|
expect(
|
|
evaluateBundleBudget(
|
|
{ initialJsGzipBytes: 201, lazyChunks: [] },
|
|
thresholds,
|
|
).passed,
|
|
).toBe(false);
|
|
expect(
|
|
evaluateBundleBudget(
|
|
{
|
|
initialJsGzipBytes: 100,
|
|
lazyChunks: [{ path: "lazy.js", gzipBytes: 121 }],
|
|
},
|
|
thresholds,
|
|
).passed,
|
|
).toBe(false);
|
|
});
|
|
|
|
it("fails lab evidence when context is absent or a metric is over budget", () => {
|
|
const thresholds = { lcpMs: 2500, cls: 0.1, namedInteractionMs: 200 };
|
|
expect(
|
|
evaluateLabBudget(
|
|
{ metrics: { lcpMs: 1000, cls: 0, namedInteractionMs: 50 } },
|
|
thresholds,
|
|
),
|
|
).toMatchObject({ passed: false });
|
|
expect(
|
|
evaluateLabBudget(
|
|
{
|
|
context: {
|
|
runner: {},
|
|
browser: {},
|
|
viewport: {},
|
|
network: {},
|
|
cpu: {},
|
|
cache: {},
|
|
build: {},
|
|
},
|
|
metrics: { lcpMs: 2501, cls: 0, namedInteractionMs: 50 },
|
|
},
|
|
thresholds,
|
|
).passed,
|
|
).toBe(false);
|
|
});
|
|
|
|
it("uses the nearest-rank p75 and fails closed while sample minimum is deferred", () => {
|
|
expect(percentile75([4, 1, 3, 2])).toBe(3);
|
|
expect(
|
|
evaluateFieldBudget(
|
|
{
|
|
metrics: { p75LcpMs: 1000, p75Cls: 0.01, p75InpMs: 50 },
|
|
eligibleSamples: 100,
|
|
},
|
|
{
|
|
p75LcpMs: 2500,
|
|
p75Cls: 0.1,
|
|
p75InpMs: 200,
|
|
minimumEligibleSamples: null,
|
|
},
|
|
),
|
|
).toEqual({ status: "FAIL_UNVERIFIED", passed: false });
|
|
});
|
|
});
|