History

feat(pull-requests): link multiple pull requests to threads (#10839)

Julius Marminge committed 2 months ago

Commit afb84891 parent 383cc40172 files · +12057 −908Browse files

Showing the changes to packages/shared/src/sourceControl.test.ts (1 of 172 files). Show all

Unified · Split

packages/shared/src/sourceControl.test.ts+32−0
@@ -1,6 +1,7 @@
11 import { describe, expect, it } from "vite-plus/test";
22
33 import {
4+ sourceControlRepositorySelector,
45 detectSourceControlProviderFromRemoteUrl,
56 getChangeRequestTerminologyForKind,
67 isSshRemoteUrl,
@@ -160,3 +161,34 @@ describe("isSshRemoteUrl", () => { · 153 unmodified lines
160161 expect(isSshRemoteUrl("deploy@github.com/project/repo")).toBe(false);
161162 });
162163 });
164+
165+it("names an Azure DevOps repository by its own name, not its project path", () => {
166+ // `az repos pr list --repository` takes a name and detects the organisation and project from
167+ // the checkout; the recorded `org/project/_git/repo` path is refused, and the repository then
168+ // reads as unavailable on the page.
169+ const selector = sourceControlRepositorySelector({
170+ provider: "azure-devops",
171+ displayName: "contoso/payments/_git/checkout",
172+ owner: "contoso",
173+ name: "checkout",
174+ });
175+ expect(selector).toBe("checkout");
176+});
177+
178+it("falls back to the path's last segment where an Azure identity has no name", () => {
179+ const selector = sourceControlRepositorySelector({
180+ provider: "azure-devops",
181+ displayName: "contoso/payments/_git/checkout",
182+ });
183+ expect(selector).toBe("checkout");
184+});
185+
186+it("keeps a GitLab identity's whole path, because a nested group is part of the name", () => {
187+ const selector = sourceControlRepositorySelector({
188+ provider: "gitlab",
189+ displayName: "group/subgroup/service",
190+ owner: "group",
191+ name: "service",
192+ });
193+ expect(selector).toBe("group/subgroup/service");
194+});