Restored the `REPO_OVERRIDE_RE` regex export from core and aligned the dashboard's `githubTracking` component to consume it, fixing the export contract that was broken in FN-3921. Added tests in both core and dashboard packages to cover the regex behavior. Fusion-Task-Id: FN-3921
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { REPO_OVERRIDE_RE as CORE_REPO_OVERRIDE_RE } from "@fusion/core";
|
|
import { describe, expect, it } from "vitest";
|
|
import { REPO_OVERRIDE_RE, resolveEffectiveGithubRepoDefault } from "../githubTracking";
|
|
|
|
describe("githubTracking helper", () => {
|
|
it("reuses the shared core regex export", () => {
|
|
expect(REPO_OVERRIDE_RE).toBe(CORE_REPO_OVERRIDE_RE);
|
|
});
|
|
|
|
it("accepts valid owner/repo values and rejects malformed values", () => {
|
|
expect(REPO_OVERRIDE_RE.test("owner/repo")).toBe(true);
|
|
expect(REPO_OVERRIDE_RE.test("org.name/repo_name-1")).toBe(true);
|
|
|
|
expect(REPO_OVERRIDE_RE.test("owner")).toBe(false);
|
|
expect(REPO_OVERRIDE_RE.test("owner/repo/extra")).toBe(false);
|
|
expect(REPO_OVERRIDE_RE.test("owner repo/repo")).toBe(false);
|
|
expect(REPO_OVERRIDE_RE.test(" owner/repo ")).toBe(false);
|
|
});
|
|
|
|
it("prefers project repo, then global repo, then empty string", () => {
|
|
expect(
|
|
resolveEffectiveGithubRepoDefault(
|
|
{ githubTrackingDefaultRepo: "project/repo" },
|
|
{ githubTrackingDefaultRepo: "global/repo" },
|
|
),
|
|
).toBe("project/repo");
|
|
|
|
expect(
|
|
resolveEffectiveGithubRepoDefault(
|
|
{ githubTrackingDefaultRepo: " " },
|
|
{ githubTrackingDefaultRepo: "global/repo" },
|
|
),
|
|
).toBe("global/repo");
|
|
|
|
expect(resolveEffectiveGithubRepoDefault({}, {})).toBe("");
|
|
});
|
|
});
|