mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-08-06 21:08:43 +00:00
* docs: design frontend performance remediation * docs: plan frontend performance remediation * test(frontend): add route asset performance budgets * perf(nginx): compress textual responses safely * perf(frontend): lazy load case study media * perf(frontend): bound static demo file tracing * perf(frontend): restore static locale boundaries * perf(frontend): defer closed workspace panels * perf(frontend): split editors and deduplicate highlighting * perf(frontend): index incremental message derivation * perf(frontend): stabilize paged history cache policy * perf(frontend): bound streaming markdown renders * perf(frontend): virtualize message history * perf(frontend): bound and virtualize chat lists * perf(frontend): suspend inactive decorative animation * perf(browser): stream latest frames as binary * perf(artifacts): stream bounded text previews * docs: finalize performance runtime boundaries * style(backend): apply test formatting * fix(frontend): keep translation functions client-side * perf(frontend): defer decorative animation bundles * test(frontend): lock optimized route budgets * fix: harden frontend performance boundaries * test(frontend): update i18n provider fixture * fix(frontend): preserve sidebar pagination position * style(backend): format artifact range test
70 lines
1.9 KiB
TypeScript
70 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "@rstest/core";
|
|
|
|
import {
|
|
createBuildEnvironment,
|
|
evaluateBudgets,
|
|
extractAssetPaths,
|
|
formatMeasurementSummary,
|
|
ROUTES,
|
|
} from "../../../scripts/measure-route-assets.mjs";
|
|
|
|
describe("route asset measurement", () => {
|
|
it("covers every approved representative route", () => {
|
|
expect(ROUTES).toContain("/login");
|
|
});
|
|
|
|
it("removes an inherited static-mode flag from the normal build", () => {
|
|
expect(
|
|
createBuildEnvironment(false, {
|
|
KEEP_ME: "yes",
|
|
NEXT_PUBLIC_STATIC_WEBSITE_ONLY: "true",
|
|
}),
|
|
).toEqual({ KEEP_ME: "yes" });
|
|
expect(createBuildEnvironment(true, {})).toEqual({
|
|
NEXT_PUBLIC_STATIC_WEBSITE_ONLY: "true",
|
|
});
|
|
});
|
|
|
|
it("extracts unique Next.js scripts and styles", () => {
|
|
const html = `
|
|
<link rel="stylesheet" href="/_next/static/css/app.css?dpl=1">
|
|
<script src="/_next/static/chunks/app.js"></script>
|
|
<script src="/_next/static/chunks/app.js"></script>
|
|
<script src="https://cdn.example.com/external.js"></script>
|
|
`;
|
|
|
|
expect(extractAssetPaths(html)).toEqual({
|
|
css: ["css/app.css"],
|
|
js: ["chunks/app.js"],
|
|
});
|
|
});
|
|
|
|
it("reports every route budget overage with exact values", () => {
|
|
const result = evaluateBudgets(
|
|
{
|
|
"/": { css: 101, js: 200 },
|
|
"/en/docs": { css: 50, js: 301 },
|
|
},
|
|
{
|
|
"/": { css: 100, js: 200 },
|
|
"/en/docs": { css: 50, js: 300 },
|
|
},
|
|
);
|
|
|
|
expect(result).toEqual([
|
|
"/ css: 101 bytes exceeds 100 bytes by 1 byte",
|
|
"/en/docs js: 301 bytes exceeds 300 bytes by 1 byte",
|
|
]);
|
|
});
|
|
|
|
it("formats a stable human-readable route summary", () => {
|
|
expect(
|
|
formatMeasurementSummary({
|
|
"/": { css: 12, js: 345, html: 67, buildMode: "static-demo" },
|
|
}),
|
|
).toBe(
|
|
"Route asset summary\n/ [static-demo] JS 345 B | CSS 12 B | HTML 67 B",
|
|
);
|
|
});
|
|
});
|