mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-08-11 23:38:44 +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
68 lines
2.2 KiB
TypeScript
68 lines
2.2 KiB
TypeScript
import { readdirSync } from "node:fs";
|
|
import { join, relative } from "node:path";
|
|
|
|
import { describe, expect, it } from "@rstest/core";
|
|
|
|
import {
|
|
DEMO_THREAD_IDS,
|
|
resolveStaticDemoArtifact,
|
|
STATIC_DEMO_ARTIFACTS,
|
|
} from "@/core/threads/static-demo";
|
|
|
|
function listFiles(root: string, directory = root): string[] {
|
|
return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
|
|
const path = join(directory, entry.name);
|
|
return entry.isDirectory()
|
|
? listFiles(root, path)
|
|
: [relative(root, path).replaceAll("\\", "/")];
|
|
});
|
|
}
|
|
|
|
describe("resolveStaticDemoArtifact", () => {
|
|
const threadId = "7cfa5f8f-a2f8-47ad-acbd-da7137baf990";
|
|
|
|
it("resolves a manifest-owned artifact", () => {
|
|
expect(
|
|
resolveStaticDemoArtifact(threadId, [
|
|
"mnt",
|
|
"user-data",
|
|
"outputs",
|
|
"index.html",
|
|
]),
|
|
).toBe(`/demo/threads/${threadId}/user-data/outputs/index.html`);
|
|
});
|
|
|
|
it.each([
|
|
["unknown", ["mnt", "user-data", "outputs", "index.html"]],
|
|
[threadId, ["mnt", "user-data", "outputs", "missing.txt"]],
|
|
[threadId, ["mnt", "user-data", "outputs", "..", "thread.json"]],
|
|
[threadId, ["mnt", "user-data", "outputs", "%2e%2e", "thread.json"]],
|
|
[threadId, ["mnt", "user-data", "outputs%2F..%2Fthread.json"]],
|
|
])("rejects an unknown or unsafe path", (candidateThreadId, segments) => {
|
|
expect(resolveStaticDemoArtifact(candidateThreadId, segments)).toBeNull();
|
|
});
|
|
|
|
it("keeps the deterministic manifest in sync with the checked-in fixtures", () => {
|
|
const threadsRoot = join(
|
|
import.meta.dirname,
|
|
"../../../../public/demo/threads",
|
|
);
|
|
const fixtureThreadIds = readdirSync(threadsRoot, { withFileTypes: true })
|
|
.filter((entry) => entry.isDirectory())
|
|
.map((entry) => entry.name)
|
|
.sort();
|
|
|
|
expect([...DEMO_THREAD_IDS].sort()).toEqual(fixtureThreadIds);
|
|
expect(Object.keys(STATIC_DEMO_ARTIFACTS).sort()).toEqual(fixtureThreadIds);
|
|
|
|
for (const fixtureThreadId of fixtureThreadIds) {
|
|
const fixtureFiles = listFiles(join(threadsRoot, fixtureThreadId))
|
|
.filter((path) => path !== "thread.json")
|
|
.sort();
|
|
expect(
|
|
[...(STATIC_DEMO_ARTIFACTS[fixtureThreadId] ?? [])].sort(),
|
|
).toEqual(fixtureFiles);
|
|
}
|
|
});
|
|
});
|