|
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, |
6 | 10 | legacyThreadPullRequestKey, |
| 11 | + threadPullRequestSearchTerms, |
7 | 12 | resolveThreadCurrentPullRequest, |
8 | 13 | resolveThreadPullRequestChains, |
9 | 14 | resolveThreadPullRequestBadge, |
@@ -349,3 +354,34 @@ describe("chain selection and badge state", () => { |
349 | 354 | ); |
350 | 355 | }); |
351 | 356 | }); |
| 357 | + |
| 358 | +describe("threadPullRequestSearchTerms", () => { |
| 359 | + it("includes completed and unsynced links but excludes dismissed links", () => { |
| 360 | + const terms = threadPullRequestSearchTerms({ |
| 361 | + pullRequests: [ |
| 362 | + link(12, { snapshot: snapshot({ title: "Fix login", state: "merged" }) }), |
| 363 | + link(34), |
| 364 | + link(56, { source: "stack-dismissed" }), |
| 365 | + ], |
| 366 | + }); |
| 367 | + expect(terms).toContain("#12"); |
| 368 | + expect(terms).toContain("pingdotgg/t3code#12"); |
| 369 | + expect(terms).toContain("https://github.com/pingdotgg/t3code/pull/12"); |
| 370 | + expect(terms).toContain("Fix login"); |
| 371 | + expect(terms).toContain("#34"); |
| 372 | + expect(terms.join(" ")).not.toContain("56"); |
| 373 | + }); |
| 374 | +}); |
| 375 | + |
| 376 | +it("searches the legacy projection when old environments decode to an empty links list", () => { |
| 377 | + const linkedPullRequest = { |
| 378 | + projectId: ProjectId.make("project"), |
| 379 | + repository: "pingdotgg/t3code", |
| 380 | + number: 12, |
| 381 | + url: "https://github.com/pingdotgg/t3code/pull/12", |
| 382 | + }; |
| 383 | + expect(threadPullRequestSearchTerms({ pullRequests: [], linkedPullRequest })).toContain("#12"); |
| 384 | + expect( |
| 385 | + threadPullRequestSearchTerms({ pullRequests: [link(34)], linkedPullRequest }), |
| 386 | + ).not.toContain("#12"); |
| 387 | +}); |
0 commit comments