fix: correct MCP citation links and add DiscussionPanel tests

- DiscussionPanel: update MCP link to anthropic.com/engineering/code-execution-with-mcp
- DiscussionPanel: update Cloudflare link to blog.cloudflare.com/code-mode-mcp/
- Add DiscussionPanel.test.tsx covering title, badge, onClose, hosted-automation
  detail, and mcp-agent-scale link targets
This commit is contained in:
lda
2026-07-05 01:28:10 +07:00 Verified
parent 9b0f9658f9
commit 6049d8a3b8
2 changed files with 51 additions and 2 deletions
@@ -0,0 +1,49 @@
import { cleanup, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { afterEach, describe, expect, it, vi } from "vitest";
import { DiscussionPanel } from "./DiscussionPanel.js";
afterEach(() => cleanup());
describe("DiscussionPanel", () => {
const onClose = vi.fn();
it("renders the branch title and claim class", () => {
render(<DiscussionPanel branchId="hosted-automation" onClose={onClose} />);
expect(screen.getByRole("dialog")).toHaveAttribute("aria-label", "Hosted automation");
expect(screen.getByText("Hosted automation")).toBeDefined();
expect(screen.getByText("future-work")).toBeDefined();
});
it("returns null for an unknown branch", () => {
const { container } = render(
<DiscussionPanel branchId="nonexistent" onClose={onClose} />,
);
expect(container.firstChild).toBeNull();
});
it("calls onClose when the return button is clicked", async () => {
render(<DiscussionPanel branchId="hosted-automation" onClose={onClose} />);
await userEvent.click(screen.getByRole("button", { name: /return/i }));
expect(onClose).toHaveBeenCalledTimes(1);
});
it("shows hosted-automation detail paragraph", () => {
render(<DiscussionPanel branchId="hosted-automation" onClose={onClose} />);
expect(screen.getByText(/future scheduler/)).toBeDefined();
});
it("shows mcp-agent-scale links to Anthropic and Cloudflare", () => {
render(<DiscussionPanel branchId="mcp-agent-scale" onClose={onClose} />);
const anthropic = screen.getByText("Anthropic MCP");
const cloudflare = screen.getByText("Cloudflare Code Mode");
expect(anthropic).toBeDefined();
expect(cloudflare).toBeDefined();
expect((anthropic as HTMLAnchorElement).href).toBe(
"https://www.anthropic.com/engineering/code-execution-with-mcp",
);
expect((cloudflare as HTMLAnchorElement).href).toBe(
"https://blog.cloudflare.com/code-mode-mcp/",
);
});
});
@@ -28,8 +28,8 @@ export const DiscussionPanel = ({ branchId, onClose }: DiscussionPanelProps) =>
)}
{branchId === "mcp-agent-scale" && (
<p className="discussion-panel__detail">
<a href="https://modelcontextprotocol.io/" target="_blank" rel="noopener noreferrer">Anthropic MCP</a> ·{" "}
<a href="https://developers.cloudflare.com/workers-ai/configuration/code-mode/" target="_blank" rel="noopener noreferrer">Cloudflare Code Mode</a>
<a href="https://www.anthropic.com/engineering/code-execution-with-mcp" target="_blank" rel="noopener noreferrer">Anthropic MCP</a> ·{" "}
<a href="https://blog.cloudflare.com/code-mode-mcp/" target="_blank" rel="noopener noreferrer">Cloudflare Code Mode</a>
{" "} both are external context.
</p>
)}