- Wrap `DiffPanel` in `WorkerPoolContextProvider` and add a dedicated diffs worker - Use content-based patch cache keys to stabilize `parsePatchFiles` caching - Add tests for cache key stability, whitespace normalization, and content changes
24 lines
852 B
TypeScript
24 lines
852 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildPatchCacheKey } from "./diffRendering";
|
|
|
|
describe("buildPatchCacheKey", () => {
|
|
it("returns a stable cache key for identical content", () => {
|
|
const patch = "diff --git a/a.ts b/a.ts\n+console.log('hello')";
|
|
|
|
expect(buildPatchCacheKey(patch)).toBe(buildPatchCacheKey(patch));
|
|
});
|
|
|
|
it("normalizes outer whitespace before hashing", () => {
|
|
const patch = "diff --git a/a.ts b/a.ts\n+console.log('hello')";
|
|
|
|
expect(buildPatchCacheKey(`\n${patch}\n`)).toBe(buildPatchCacheKey(patch));
|
|
});
|
|
|
|
it("changes when diff content changes", () => {
|
|
const before = "diff --git a/a.ts b/a.ts\n+console.log('hello')";
|
|
const after = "diff --git a/a.ts b/a.ts\n+console.log('hello world')";
|
|
|
|
expect(buildPatchCacheKey(before)).not.toBe(buildPatchCacheKey(after));
|
|
});
|
|
});
|