From 88fc41c1b90ff21a7d30d69e0ebffbc0c3511b9c Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sat, 5 Sep 2026 16:13:50 -0700 Subject: [PATCH] refactor(web): test file cache identity through its public helpers (#10219) --- .../components/files/fileContentRevision.test.ts | 16 ++++------------ .../src/components/files/fileContentRevision.ts | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/apps/web/src/components/files/fileContentRevision.test.ts b/apps/web/src/components/files/fileContentRevision.test.ts index e2ec7f9f1cad1b896974d40457c478f413624ee0..4a8bb3d5522b59f2f878347292b406def2652fb6 100644 --- a/apps/web/src/components/files/fileContentRevision.test.ts +++ b/apps/web/src/components/files/fileContentRevision.test.ts @@ -1,19 +1,11 @@ import { describe, expect, it } from "vite-plus/test"; -import { - fileContentRevision, - projectFileCacheKey, - projectFileEditorCacheKey, -} from "./fileContentRevision"; +import { projectFileCacheKey, projectFileEditorCacheKey } from "./fileContentRevision"; -describe("fileContentRevision", () => { +describe("file cache identity", () => { it("changes for same-length edits", () => { - expect(fileContentRevision("nodeVersion")).not.toBe(fileContentRevision("nodeVeasdrs")); - }); - - it("keeps identical contents stable", () => { - expect(projectFileCacheKey("/repo", "file.json", "contents")).toBe( - projectFileCacheKey("/repo", "file.json", "contents"), + expect(projectFileCacheKey("/repo", "file.json", "nodeVersion")).not.toBe( + projectFileCacheKey("/repo", "file.json", "nodeVeasdrs"), ); }); diff --git a/apps/web/src/components/files/fileContentRevision.ts b/apps/web/src/components/files/fileContentRevision.ts index e51d464925bd639028942e1cf22c3201280b1099..b4e1698a34dc8710fa5778882b7ce179dec75049 100644 --- a/apps/web/src/components/files/fileContentRevision.ts +++ b/apps/web/src/components/files/fileContentRevision.ts @@ -1,4 +1,4 @@ -export function fileContentRevision(contents: string): string { +function fileContentRevision(contents: string): string { let hash = 2_166_136_261; for (let index = 0; index < contents.length; index += 1) { hash ^= contents.charCodeAt(index); -- 2.54.0