Files
edgeever/packages/shared/src/github-feedback.test.mjs
T

33 lines
1.4 KiB
JavaScript

import { describe, expect, test } from "bun:test";
import { buildGitHubFeedbackUrl } from "./github-feedback";
describe("GitHub feedback URL", () => {
test("includes optional diagnostics before system information", () => {
const url = new URL(buildGitHubFeedbackUrl({
contentHeading: "What happened",
contentPrompt: "Describe the problem.",
diagnostics: {
heading: "Diagnostics",
notice: "Review before submitting.",
text: JSON.stringify({ errorCode: "memo_not_found" }),
},
privacyNotice: "Public report.",
systemInfo: [{ label: "Version", value: "v1.46.0" }],
systemInfoHeading: "System information",
systemInfoNotice: "Generated locally.",
titlePrefix: "[Sync] ",
}));
expect(url.origin + url.pathname).toBe("https://github.com/tianma-if/edgeever/issues/new");
expect(url.searchParams.get("title")).toBe("[Sync] ");
const body = url.searchParams.get("body");
expect(body).toContain("## Diagnostics");
expect(body).toContain('"errorCode":"memo_not_found"');
expect(body).toContain("- Version: v1.46.0");
expect(url.searchParams.get("system-info")).toContain("- Version: v1.46.0");
expect(url.searchParams.get("template")).toBe("bug.yml");
expect(url.searchParams.get("diagnostics")).toContain('"errorCode":"memo_not_found"');
expect(body.indexOf("## Diagnostics")).toBeLessThan(body.indexOf("## System information"));
});
});