authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-05 16:13:50-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-05 16:13:50-07:00
log88fc41c1b90ff21a7d30d69e0ebffbc0c3511b9c
tree8a232ab2f5da45fb98d40289cb03630e6b6eacb1
parentc2cfe59ac356768deb2a7d3e3461c715aa50a7a1
signature Signed by PGP key B5690EEEBB952194

refactor(web): test file cache identity through its public helpers (#10219)


2 files changed, 5 insertions(+), 13 deletions(-)

apps/web/src/components/files/fileContentRevision.test.ts+4-12
......@@ -1,19 +1,11 @@
11import { describe, expect, it } from "vite-plus/test";
22
3import {
4 fileContentRevision,
5 projectFileCacheKey,
6 projectFileEditorCacheKey,
7} from "./fileContentRevision";
3import { projectFileCacheKey, projectFileEditorCacheKey } from "./fileContentRevision";
84
9describe("fileContentRevision", () => {
5describe("file cache identity", () => {
106 it("changes for same-length edits", () => {
11 expect(fileContentRevision("nodeVersion")).not.toBe(fileContentRevision("nodeVeasdrs"));
12 });
13
14 it("keeps identical contents stable", () => {
15 expect(projectFileCacheKey("/repo", "file.json", "contents")).toBe(
16 projectFileCacheKey("/repo", "file.json", "contents"),
7 expect(projectFileCacheKey("/repo", "file.json", "nodeVersion")).not.toBe(
8 projectFileCacheKey("/repo", "file.json", "nodeVeasdrs"),
179 );
1810 });
1911
apps/web/src/components/files/fileContentRevision.ts+1-1
......@@ -1,4 +1,4 @@
1export function fileContentRevision(contents: string): string {
1function fileContentRevision(contents: string): string {
22 let hash = 2_166_136_261;
33 for (let index = 0; index < contents.length; index += 1) {
44 hash ^= contents.charCodeAt(index);