1import { describe, expect, it } from "vite-plus/test";
2import { nativePullRequestDestination } from "../../lib/pullRequestNavigation";
3const context = { environmentId: "remote", projectId: "project" };
4describe("native PR entry points", () => {
5 it("keeps a thread link in its own environment and handles renamed host path shapes", () => {
6 expect(
7 nativePullRequestDestination("https://github.com/org/repo/pull/12/files#diff", context),
8 ).toEqual({ ...context, host: "github.com", repository: "org/repo", number: 12 });
9 expect(
10 nativePullRequestDestination("https://git.example/group/sub/repo/-/merge_requests/9", context)
11 ?.repository,
12 ).toBe("group/sub/repo");
13 expect(
14 nativePullRequestDestination("http://forgejo.test:3000/org/repo/pulls/3", context)?.host,
15 ).toBe("forgejo.test:3000");
16 });
17 it("leaves issues, unknown sites, and unscoped links to the external opener", () => {
18 expect(
19 nativePullRequestDestination("https://github.com/org/repo/issues/12", context),
20 ).toBeNull();
21 expect(
22 nativePullRequestDestination("https://example.com/org/repo/pull/12", context),
23 ).toBeNull();
24 expect(nativePullRequestDestination("https://github.com/org/repo/pull/12", null)).toBeNull();
25 });
26});