feat(FN-3918): restore github tracking regex helper and tests

Restores a local GitHub tracking regex helper in the dashboard and adds regression tests to prevent future regressions. The feature restores functionality that was previously removed, with tests covering the helper's behavior.

Fusion-Task-Id: FN-3918
This commit is contained in:
Fusion
2026-05-10 04:21:50 -07:00
committed by gsxdsm
parent 956a4af940
commit 7850edfcb0
2 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import { describe, expect, it } from "vitest";
import { REPO_OVERRIDE_RE, resolveEffectiveGithubRepoDefault } from "../githubTracking";
describe("githubTracking helper", () => {
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("");
});
});