|
1 | | -import type { ThreadPullRequestLink, ThreadPullRequestSnapshot } from "@t3tools/contracts"; |
| 1 | +import { |
| 2 | + ProjectId, |
| 3 | + type ThreadPullRequestLink, |
| 4 | + type ThreadPullRequestSnapshot, |
| 5 | +} from "@t3tools/contracts"; |
2 | 6 | import { describe, expect, it } from "vite-plus/test"; |
3 | 7 |
|
4 | 8 | import { |
5 | 9 | legacyLinkedPullRequestOf, |
| 10 | + threadPullRequestSearchTerms, |
6 | 11 | resolveThreadCurrentPullRequest, |
7 | 12 | resolveThreadPullRequestChains, |
8 | 13 | resolveThreadPullRequestBadge, |
@@ -274,3 +279,29 @@ describe("chain selection and badge state", () => { |
274 | 279 | ); |
275 | 280 | }); |
276 | 281 | }); |
| 282 | + |
| 283 | +describe("threadPullRequestSearchTerms", () => { |
| 284 | + it("includes completed and unsynced links but excludes dismissed links", () => { |
| 285 | + const terms = threadPullRequestSearchTerms({ |
| 286 | + pullRequests: [ |
| 287 | + link(12, { snapshot: snapshot({ title: "Fix login", state: "merged" }) }), |
| 288 | + link(34), |
| 289 | + link(56, { source: "stack-dismissed" }), |
| 290 | + ], |
| 291 | + }); |
| 292 | + expect(terms).toContain("#12"); |
| 293 | + expect(terms).toContain("pingdotgg/t3code#12"); |
| 294 | + expect(terms).toContain("https://github.com/pingdotgg/t3code/pull/12"); |
| 295 | + expect(terms).toContain("Fix login"); |
| 296 | + expect(terms).toContain("#34"); |
| 297 | + expect(terms.join(" ")).not.toContain("56"); |
| 298 | + }); |
| 299 | +}); |
| 300 | + |
| 301 | +it("searches the legacy projection when old environments decode to an empty links list", () => { |
| 302 | + const linkedPullRequest = legacyLinkedPullRequestOf([link(12)], ProjectId.make("project")); |
| 303 | + expect(threadPullRequestSearchTerms({ pullRequests: [], linkedPullRequest })).toContain("#12"); |
| 304 | + expect( |
| 305 | + threadPullRequestSearchTerms({ pullRequests: [link(34)], linkedPullRequest }), |
| 306 | + ).not.toContain("#12"); |
| 307 | +}); |
0 commit comments