Files
kandev/apps/web/lib/diff/walkthrough-match.test.ts
José Almeida 3e237e177a feat: add agent-authored code walkthroughs (#1647)
* feat: add code-walkthrough backend (MCP tool, service, persistence, WS events)

* feat: render agent code walkthroughs as line-anchored cards + editor window

* test: add code-walkthrough re-emit mock-agent scenario

* fix: rework code-walkthrough UX (floating card, line reveal, minimize, clickable file)

* fix: improve code walkthrough editor UX

* fix: backfill walkthrough launcher after websocket connect

* fix: improve walkthrough requests and editor anchors

* fix: clear walkthrough highlights on close

* feat: add walkthrough discard and prompt customization

* fix: send walkthrough requests through saved prompt

* fix: support postgres built-in prompt seeding

* fix: address walkthrough review feedback

* fix: address walkthrough review follow-ups

* fix: harden walkthrough lifecycle races

* fix: reuse walkthrough notification cleanup

* fix: guard stale walkthrough file opens

* fix: abort stale file opens before paint

* fix: stabilize github settings e2e readiness

* fix: use stable github settings e2e selector
2026-07-10 08:34:57 +01:00

55 lines
1.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { walkthroughFileMatches, walkthroughStepMatchesFile } from "./walkthrough-match";
const WEB_MAIN = "apps/web/main.ts";
const FRONTEND = "frontend";
describe("walkthroughFileMatches", () => {
it("matches exact paths", () => {
expect(walkthroughFileMatches(WEB_MAIN, WEB_MAIN)).toBe(true);
});
it("matches path suffixes only on segment boundaries", () => {
expect(walkthroughFileMatches(WEB_MAIN, "main.ts")).toBe(true);
expect(walkthroughFileMatches("apps/web/domain.ts", "main.ts")).toBe(false);
expect(walkthroughFileMatches("apps/web/foobar.ts", "bar.ts")).toBe(false);
});
it("uses repository names when the step supplies one", () => {
expect(
walkthroughStepMatchesFile(
{ path: WEB_MAIN, repository_name: FRONTEND },
{ file: "main.ts", repo: FRONTEND },
),
).toBe(true);
expect(
walkthroughStepMatchesFile(
{ path: WEB_MAIN, repository_name: "backend" },
{ file: "main.ts", repo: FRONTEND },
),
).toBe(false);
expect(
walkthroughStepMatchesFile({ path: WEB_MAIN }, { file: "main.ts", repo: FRONTEND }),
).toBe(false);
});
it("does not match repo-scoped files when the step omits repo", () => {
expect(walkthroughStepMatchesFile({ path: WEB_MAIN }, { file: "main.ts" })).toBe(true);
expect(
walkthroughStepMatchesFile(
{ path: WEB_MAIN, repository_name: FRONTEND },
{ file: "main.ts" },
),
).toBe(false);
});
it("rejects repo-less matches when the same suffix exists in multiple repos", () => {
const files = [
{ path: WEB_MAIN, repository_name: FRONTEND },
{ path: WEB_MAIN, repository_name: "docs" },
];
expect(walkthroughStepMatchesFile(files[0], { file: "main.ts" }, files)).toBe(false);
});
});