Open History to see the last commit
1import { EnvironmentId } from "@t3tools/contracts";
2import { expect, it } from "vite-plus/test";
3
4import { threadLinkCandidates, threadLinkMatcher } from "./ThreadLinkPicker.logic";
5
6it.each([
7 ["cafe", "Café planning", undefined],
8 ["café", "Cafe\u0301 planning", undefined],
9 ["ışık", "Işık planı", "tr-TR"],
10 ["ΒΑΣ", "ΒΑΣΗ", undefined],
11])("matches %s against %s", (query, text, locale) => {
12 expect(threadLinkMatcher(query, locale)(text)).toBe(true);
13});
14
15it("tells when the only matching active threads are on other environments", () => {
16 const here = EnvironmentId.make("environment-here");
17 const remote = EnvironmentId.make("environment-remote");
18 const thread = (environmentId: EnvironmentId, title: string, archivedAt: string | null) => ({
19 environmentId,
20 title,
21 archivedAt,
22 updatedAt: "2026-12-01T00:00:00.000Z",
23 });
24 const threads = [
25 thread(here, "Release notes", null),
26 thread(here, "Deploy fix", "2026-12-01T00:00:00.000Z"),
27 thread(remote, "Deploy fix", null),
28 thread(remote, "Old plan", "2026-12-01T00:00:00.000Z"),
29 ];
30 const search = (query: string) => {
31 const matches = threadLinkMatcher(query);
32 return threadLinkCandidates(threads, here, (candidate) => matches(candidate.title));
33 };
34
35 expect(search("deploy")).toEqual({ candidates: [], matchesElsewhere: true });
36 expect(search("old plan")).toEqual({ candidates: [], matchesElsewhere: false });
37 expect(search("release")).toEqual({ candidates: [threads[0]], matchesElsewhere: false });
38});