test(performance): add authenticated local benchmarks
This commit is contained in:
1 parent
f8d8a09c56
commit
440626ba00
8 files changed
+389
-2
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
countDuplicateTrpcPaths,
|
||||
normalizeTrpcPath,
|
||||
summarize,
|
||||
validateBrowserMeasurement,
|
||||
} from "./dev-benchmark-lib.mts";
|
||||
|
||||
describe("development benchmark measurements", () => {
|
||||
it("normalizes tRPC input payloads before counting duplicates", () => {
|
||||
const first = "/api/trpc/board.get?batch=1&input=%7B%22json%22%3A1%7D";
|
||||
const second = "/api/trpc/board.get?batch=1&input=%7B%22json%22%3A2%7D";
|
||||
|
||||
expect(normalizeTrpcPath(first)).toBe("/api/trpc/board.get?batch=1");
|
||||
expect(countDuplicateTrpcPaths([first, second, "/api/trpc/user.get"])).toBe(1);
|
||||
});
|
||||
|
||||
it("reports median, p95, deviation, and high outliers", () => {
|
||||
expect(summarize([1, 2, 3, 4, 5, 6, 100])).toEqual({
|
||||
count: 7,
|
||||
medianMs: 4,
|
||||
p95Ms: 100,
|
||||
standardDeviationMs: 34,
|
||||
outliersMs: [100],
|
||||
});
|
||||
});
|
||||
|
||||
it("requires a successful authenticated board hydration and interaction", () => {
|
||||
expect(
|
||||
validateBrowserMeasurement({
|
||||
responseStatus: 307,
|
||||
domContentLoadedMs: 120,
|
||||
boardHydratedMs: null,
|
||||
firstInteractionMs: null,
|
||||
}),
|
||||
).toEqual([
|
||||
"browser navigation returned HTTP 307",
|
||||
"board hydration marker is missing",
|
||||
"first interaction timing is missing",
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user