From ff4757eb557532279ca9989dd5da7cc6a6c8a95e Mon Sep 17 00:00:00 2001 From: Aaron Queen Date: Mon, 12 Oct 2026 10:53:25 -0600 Subject: [PATCH] test: rename fixture identifiers built on a private product's abbreviation Replace the abbreviation in the window-message and near-duplicate test fixtures and in one doc comment with neutral names. The renamed copy sorts after dsUrlOf, so no expected value changes. --- __tests__/near-duplicates.test.ts | 14 +++++++------- __tests__/window-message-synthesizer.test.ts | 20 ++++++++++---------- src/graph/near-duplicates.ts | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/__tests__/near-duplicates.test.ts b/__tests__/near-duplicates.test.ts index 0695206101..ecd69ddf0e 100644 --- a/__tests__/near-duplicates.test.ts +++ b/__tests__/near-duplicates.test.ts @@ -42,7 +42,7 @@ const unrelated = [ describe('signature', () => { it('matches copies that differ only in names and literals, not unrelated code', () => { const a = signature(urlOf('fpUrlOf', 'fp'), 'fpUrlOf')!; - const b = signature(urlOf('ttdUrlOf', 'ttd'), 'ttdUrlOf')!; + const b = signature(urlOf('webUrlOf', 'web'), 'webUrlOf')!; expect(similarity(a, b)).toBeGreaterThanOrEqual(0.8); expect(similarity(a, signature(unrelated)!)).toBeLessThan(0.3); }); @@ -71,7 +71,7 @@ describe('near-duplicates in the index', () => { beforeEach(async () => { dir = fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph-near-dups-')); write('src/fp.ts', urlOf('fpUrlOf', 'fp')); - write('src/ttd.ts', urlOf('ttdUrlOf', 'ttd')); + write('src/web.ts', urlOf('webUrlOf', 'web')); write('src/ds.ts', urlOf('dsUrlOf', 'ds')); write('src/points.ts', unrelated); // Copies in tests and vendored code are expected and stay out. @@ -87,7 +87,7 @@ describe('near-duplicates in the index', () => { }); it('pairs the copies and leaves out tests, vendored code and unrelated functions', () => { - expect(dupsOf('fpUrlOf')).toEqual(['dsUrlOf', 'ttdUrlOf']); + expect(dupsOf('fpUrlOf')).toEqual(['dsUrlOf', 'webUrlOf']); expect(dupsOf('totalPoints')).toEqual([]); }); @@ -95,7 +95,7 @@ describe('near-duplicates in the index', () => { const explore = await tool('codegraph_explore', { query: 'fpUrlOf' }); expect(explore).toMatch(/- `fpUrlOf` \(src\/fp\.ts:1\) — no callers; near-duplicates \(update together\): .*`dsUrlOf` \(src\/ds\.ts:1, \d+% similar\)/); const node = await tool('codegraph_node', { symbol: 'fpUrlOf', includeCode: false }); - expect(node).toMatch(/\*\*Near-duplicates \(update together\) ≈\*\* .*`ttdUrlOf` \(src\/ttd\.ts:1/); + expect(node).toMatch(/\*\*Near-duplicates \(update together\) ≈\*\* .*`webUrlOf` \(src\/web\.ts:1/); }); it('re-scores only the pairs a changed body is in, and matches a full recompute', async () => { @@ -114,7 +114,7 @@ describe('near-duplicates in the index', () => { }, isExcluded: (p: string) => p.startsWith('test/') || p.startsWith('vendor/'), }; - const snapshot = () => ['fpUrlOf', 'ttdUrlOf', 'dsUrlOf', 'totalPoints', 'totalPoints2'].map((n) => [n, dupsOf(n)]); + const snapshot = () => ['fpUrlOf', 'webUrlOf', 'dsUrlOf', 'totalPoints', 'totalPoints2'].map((n) => [n, dupsOf(n)]); const before = snapshot(); expect(dupsOf('totalPoints')).toEqual(['totalPoints2']); @@ -171,13 +171,13 @@ describe('near-duplicates in the index', () => { cg = await CodeGraph.open(dir); write('src/ds.ts', unrelated.replace('totalPoints', 'dsTotals')); await cg.sync(); - expect(dupsOf('fpUrlOf')).toEqual(['ttdUrlOf']); + expect(dupsOf('fpUrlOf')).toEqual(['webUrlOf']); expect(dupsOf('totalPoints')).toEqual(['dsTotals']); }); it('follows edits and deletions on sync', async () => { write('src/ds.ts', unrelated.replace('totalPoints', 'dsTotals')); - fs.rmSync(path.join(dir, 'src/ttd.ts')); + fs.rmSync(path.join(dir, 'src/web.ts')); await cg.sync(); expect(dupsOf('fpUrlOf')).toEqual([]); expect(dupsOf('totalPoints')).toEqual(['dsTotals']); diff --git a/__tests__/window-message-synthesizer.test.ts b/__tests__/window-message-synthesizer.test.ts index 8c9bb565ab..7da9a4c96f 100644 --- a/__tests__/window-message-synthesizer.test.ts +++ b/__tests__/window-message-synthesizer.test.ts @@ -20,23 +20,23 @@ describe('window-message synthesizer', () => { it('links a publisher to the listener that checks the same source discriminator', async () => { fs.writeFileSync(path.join(dir, 'constants.ts'), - 'export const MESSAGES = { TTD_AJAX_EVENT: "DEMO_AJAX", OTHER_EVENT: "DEMO_OTHER" };\n'); + 'export const MESSAGES = { DEMO_AJAX_EVENT: "DEMO_AJAX", OTHER_EVENT: "DEMO_OTHER" };\n'); fs.writeFileSync(path.join(dir, 'publish.ts'), `import { MESSAGES } from "./constants"; -export function publishTtdLivewire() { - window.postMessage({ source: MESSAGES.TTD_AJAX_EVENT, payload: {} }, "*"); +export function publishDemoLivewire() { + window.postMessage({ source: MESSAGES.DEMO_AJAX_EVENT, payload: {} }, "*"); } export function publishOther() { window.postMessage({ source: MESSAGES.OTHER_EVENT, payload: {} }, "*"); } `); fs.writeFileSync(path.join(dir, 'listen.ts'), `import { MESSAGES } from "./constants"; -export function listenForTtdLivewireAjax() { +export function listenForDemoLivewireAjax() { window.addEventListener("message", (ev) => { - if (ev.data.source !== MESSAGES.TTD_AJAX_EVENT) return; - receiveTtdSnapshot(ev.data.payload); + if (ev.data.source !== MESSAGES.DEMO_AJAX_EVENT) return; + receiveDemoSnapshot(ev.data.payload); }); } -export function receiveTtdSnapshot(payload: unknown) { return payload; } +export function receiveDemoSnapshot(payload: unknown) { return payload; } export function listenWithoutCheck() { window.addEventListener("message", (ev) => { console.log(ev.data); }); } @@ -46,11 +46,11 @@ export function listenWithoutCheck() { await cg.indexAll(); const edges = synthEdges(cg); expect(edges).toEqual([ - expect.objectContaining({ source: 'publishTtdLivewire', target: 'listenForTtdLivewireAjax', event: 'TTD_AJAX_EVENT' }), + expect.objectContaining({ source: 'publishDemoLivewire', target: 'listenForDemoLivewireAjax', event: 'DEMO_AJAX_EVENT' }), ]); expect(edges.some((e) => e.source === 'publishOther')).toBe(false); expect(edges.some((e) => e.target === 'listenWithoutCheck')).toBe(false); - expect(edges.some((e) => e.target === 'receiveTtdSnapshot')).toBe(false); + expect(edges.some((e) => e.target === 'receiveDemoSnapshot')).toBe(false); cg.close?.(); }); @@ -61,7 +61,7 @@ export function listenWithoutCheck() { `); fs.writeFileSync(path.join(dir, 'b.ts'), `export function listen() { window.addEventListener("message", (ev) => { - if (ev.data.source !== OtherHub.TTD_OTHER_EVENT) return; + if (ev.data.source !== OtherHub.DEMO_OTHER_EVENT) return; }); } `); diff --git a/src/graph/near-duplicates.ts b/src/graph/near-duplicates.ts index 7bacf69c1f..68393d397e 100644 --- a/src/graph/near-duplicates.ts +++ b/src/graph/near-duplicates.ts @@ -76,7 +76,7 @@ export function tokenize(body: string): string[] { /** * A body's shingle hashes, or null when it is too small to compare. The * function's own name is masked: copies are usually renamed (`fpUrlOf`, - * `ttdUrlOf`), and the name alone moves several shingles. + * `webUrlOf`), and the name alone moves several shingles. */ export function shingles(body: string, ownName?: string): Set | null { const tokens = tokenize(body).map((t) => (t === ownName ? '\u0000self' : t));