50 lines
1.9 KiB
TypeScript
50 lines
1.9 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
|
import { copySentryInstances } from "@/lib/api/domains/sentry-api";
|
|
import { copyAzureDevOpsConfig } from "@/lib/api/domains/azure-devops-api";
|
|
import { copyIntegrationConfig, integrationFromPathname } from "./integration-copy-config";
|
|
|
|
vi.mock("@/lib/api/domains/sentry-api", () => ({
|
|
copySentryInstances: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("@/lib/api/domains/azure-devops-api", () => ({
|
|
copyAzureDevOpsConfig: vi.fn(),
|
|
}));
|
|
|
|
afterEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
describe("integrationFromPathname", () => {
|
|
it("recognizes global integration settings routes", () => {
|
|
expect(integrationFromPathname("/settings/integrations/github")).toBe("github");
|
|
expect(integrationFromPathname("/settings/integrations/linear")).toBe("linear");
|
|
expect(integrationFromPathname("/settings/integrations/azure-devops")).toBe("azure-devops");
|
|
});
|
|
|
|
it("recognizes workspace-scoped integration settings routes", () => {
|
|
expect(integrationFromPathname("/settings/workspace/ws-1/integrations/github")).toBe("github");
|
|
expect(integrationFromPathname("/settings/workspace/ws-1/integrations/linear")).toBe("linear");
|
|
});
|
|
|
|
it("ignores non-copyable integration routes", () => {
|
|
expect(integrationFromPathname("/settings/workspace/ws-1/integrations/gitlab")).toBeNull();
|
|
expect(integrationFromPathname("/settings/workspace/ws-1/integrations")).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("copyIntegrationConfig", () => {
|
|
it("scopes Sentry copies to the source workspace and sends only the target", async () => {
|
|
await copyIntegrationConfig("sentry", "ws-source", "ws-target");
|
|
|
|
expect(copySentryInstances).toHaveBeenCalledWith("ws-target", { workspaceId: "ws-source" });
|
|
});
|
|
|
|
it("copies Azure DevOps credentials between workspaces", async () => {
|
|
await copyIntegrationConfig("azure-devops", "ws-source", "ws-target");
|
|
|
|
expect(copyAzureDevOpsConfig).toHaveBeenCalledWith("ws-source", "ws-target");
|
|
});
|
|
});
|