test(ui): retire 33 duplicate executions and share render setup (#16072)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip authored and GitHub committed 2026-10-14 23:12:34 -05:00
1 parent f64d05adf4
commit ccbfefef5f
59 files changed
+6112 -1038

No files matched your search

@@ -974,6 +974,8 @@ describe("AgentConfigForm environment selector", () => {
]);
roots.push(result.root);
expect(result.container.textContent).not.toContain("Secret access");
expect(result.container.textContent).not.toContain("Environment override");
expect(result.container.querySelector('[aria-label="Environment override"]')).toBeNull();
});
@@ -1067,15 +1069,6 @@ describe("AgentConfigForm environment selector", () => {
expect(existing.onSave).not.toHaveBeenCalled();
});
it("keeps secret access out of the main Configuration content", async () => {
const result = await renderForm([
makeEnvironment({ id: "local-1", name: "Local", driver: "local" }),
]);
roots.push(result.root);
expect(result.container.textContent).not.toContain("Secret access");
});
it("renders secret access as dedicated form content", async () => {
const result = await renderForm(
[makeEnvironment({ id: "local-1", name: "Local", driver: "local" })],
@@ -1704,21 +1697,6 @@ describe("AgentConfigForm environment selector", () => {
expect(findButton(result.container, "Sign in")).toBeFalsy();
});
it("starts a login session for the effective sandbox and shows the code and the authentication URL", async () => {
mockAgentsApi.testEnvironment.mockResolvedValue(AUTH_MISSING_RESULT);
const result = await renderCodexSandbox();
roots.push(result.root);
await runTest(result.container);
await startLogin(result.container);
expect(mockAgentsApi.startAdapterAuthLogin).toHaveBeenCalledWith("company-1", "codex_local", {
environmentId: "sandbox-1",
});
expect(result.container.textContent).toContain("WXYZ-1234");
expect(result.container.textContent).toContain("https://auth.example.test/device");
});
it("shows the loading state while the session starts and the prompt is not ready", async () => {
mockAgentsApi.testEnvironment.mockResolvedValue(AUTH_MISSING_RESULT);
mockAgentsApi.getAdapterAuthLoginStatus.mockResolvedValue({
@@ -1817,6 +1795,12 @@ describe("AgentConfigForm environment selector", () => {
await runTest(result.container);
await startLogin(result.container);
expect(mockAgentsApi.startAdapterAuthLogin).toHaveBeenCalledWith("company-1", "codex_local", {
environmentId: "sandbox-1",
});
expect(result.container.textContent).toContain("WXYZ-1234");
expect(result.container.textContent).toContain("https://auth.example.test/device");
// The Cancel button appears while the session is active.
expect(findButton(result.container, "Cancel")).toBeTruthy();
@@ -2558,31 +2542,6 @@ describe("AgentConfigForm environment selector", () => {
expect(findButton(result.container, "Sign in")).toBeFalsy();
});
it("shows the authorization URL and a browser-code input for a Claude sandbox", async () => {
mockAgentsApi.testEnvironment.mockResolvedValue(CLAUDE_AUTH_MISSING_RESULT);
const result = await renderClaudeSandbox();
roots.push(result.root);
await runTest(result.container);
await startLogin(result.container);
await flushUntil(() =>
(result.container.textContent ?? "").includes("https://claude.example.test/authorize"),
);
expect(mockAgentsApi.startClaudeSetupTokenLogin).toHaveBeenCalledWith("company-1", {
environmentId: "sandbox-1",
});
// The panel shows the authorization URL and a browser-code input. It never
// shows a server-displayed code.
expect(result.container.textContent).toContain("https://claude.example.test/authorize");
expect(
result.container.querySelector('input[aria-label="Browser code"]'),
).toBeTruthy();
// The default prompt carries no advisory: a confidential transport. So the
// panel shows no disclaimer.
expect(result.container.textContent).not.toContain("not encrypted");
});
it("shows a non-blocking disclaimer when the transport advisory is present", async () => {
mockAgentsApi.testEnvironment.mockResolvedValue(CLAUDE_AUTH_MISSING_RESULT);
// The guarded prompt read reports a non-confidential transport. The server
@@ -3017,6 +2976,19 @@ describe("AgentConfigForm environment selector", () => {
(result.container.textContent ?? "").includes("https://claude.example.test/authorize"),
);
expect(mockAgentsApi.startClaudeSetupTokenLogin).toHaveBeenCalledWith("company-1", {
environmentId: "sandbox-1",
});
// The panel shows the authorization URL and a browser-code input. It never
// shows a server-displayed code.
expect(result.container.textContent).toContain("https://claude.example.test/authorize");
expect(
result.container.querySelector('input[aria-label="Browser code"]'),
).toBeTruthy();
// The default prompt carries no advisory: a confidential transport. So the
// panel shows no disclaimer.
expect(result.container.textContent).not.toContain("not encrypted");
expect(findButton(result.container, "Cancel")).toBeTruthy();
await clickByText(result.container, "Cancel");
@@ -3820,6 +3792,9 @@ describe("AgentConfigForm managed-sandbox-only host surfaces", () => {
});
await flushReact();
const labels = fieldLabels(result.container);
expect(labels).toContain("ACP session mode");
expect(labels).toContain("ACP non-interactive permissions");
expect(labels).not.toContain("Working directory (deprecated)");
expect(labels).not.toContain("Command");
expect(labels).not.toContain("Execution engine");
@@ -3831,25 +3806,6 @@ describe("AgentConfigForm managed-sandbox-only host surfaces", () => {
expect(result.container.textContent).not.toContain("/srv/agents/cody");
});
it("keeps the non-path ACP controls visible when the policy hides the engine choice", async () => {
setManagedSandboxOnly(true);
const result = await renderForm(
[makeEnvironment({ id: "managed-1", name: "Managed", driver: "sandbox", config: { provider: "daytona" } })],
{ adapterType: "claude_local", adapterConfig: MANAGED_AGENT_CONFIG },
);
roots.push(result.root);
await act(async () => {
for (const button of result.container.querySelectorAll("button")) {
if (["Advanced", "Advanced Run Policy"].includes(button.textContent?.trim() ?? "")) button.click();
}
});
await flushReact();
const labels = fieldLabels(result.container);
expect(labels).toContain("ACP session mode");
expect(labels).toContain("ACP non-interactive permissions");
});
it("keeps the host-path fields hidden while the policy is still loading", async () => {
// A cold cache resolves the policy to false on the first render. The gate
// fails closed so a managed instance never flashes a stored host path.
+3 -23
View File
@@ -50,6 +50,9 @@ describe("AppErrorBoundary", () => {
);
});
expect(container.textContent).toContain("Paperclip hit an error");
expect(container.textContent).toContain("Maximum update depth exceeded");
expect(captureBrowserExceptionMock).toHaveBeenCalledTimes(1);
expect(captureBrowserExceptionMock).toHaveBeenCalledWith(expect.any(Error), {
boundary: "app", componentStack: expect.stringContaining("BoomRender"),
@@ -65,29 +68,6 @@ describe("AppErrorBoundary", () => {
});
});
it("renders a reload prompt instead of a blank page when the shell throws in render", () => {
const root = createRoot(container);
act(() => {
root.render(
<AppErrorBoundary>
<BoomRender />
</AppErrorBoundary>,
);
});
expect(container.textContent).toContain("Paperclip hit an error");
expect(container.textContent).toContain("Maximum update depth exceeded");
expect(
Array.from(container.querySelectorAll("button")).some(
(button) => button.textContent === "Reload page",
),
).toBe(true);
act(() => {
root.unmount();
});
});
it("catches errors thrown from effects, not just render", () => {
const root = createRoot(container);
act(() => {
+3 -18
View File
@@ -207,24 +207,6 @@ describe("InlineEditor", () => {
});
});
it("marks multiline preview textboxes as multiline", () => {
const onSave = vi.fn().mockResolvedValue(undefined);
const root = createRoot(container);
act(() => {
root.render(<InlineEditor value="Hello world" multiline onSave={onSave} />);
});
const preview = container.querySelector<HTMLElement>('[role="textbox"]');
expect(preview).not.toBeNull();
expect(preview?.getAttribute("aria-multiline")).toBe("true");
expect(preview?.tabIndex).toBe(0);
act(() => {
root.unmount();
});
});
it("enters multiline edit mode from the keyboard preview surface", () => {
const onSave = vi.fn().mockResolvedValue(undefined);
const root = createRoot(container);
@@ -236,6 +218,9 @@ describe("InlineEditor", () => {
const preview = container.querySelector<HTMLElement>('[role="textbox"]');
expect(preview).not.toBeNull();
expect(preview?.getAttribute("aria-multiline")).toBe("true");
expect(preview?.tabIndex).toBe(0);
act(() => {
preview!.dispatchEvent(new KeyboardEvent("keydown", { bubbles: true, key: "Enter" }));
});
@@ -180,33 +180,6 @@ describe("IssueAttachmentsSection", () => {
expect(fetchSpy).not.toHaveBeenCalled();
});
it("renders video attachments through the same player used for artifact outputs", async () => {
const attachment = makeAttachment({
id: "video-attachment",
originalFilename: "demo.webm",
contentType: "video/webm",
contentPath: "/api/attachments/video-attachment/content",
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<IssueAttachmentsSection
attachments={[attachment]}
onDelete={vi.fn()}
onImageClick={vi.fn()}
/>
</QueryClientProvider>,
);
});
await flushReact();
const video = container.querySelector("video");
expect(video?.getAttribute("src")).toBe("/api/attachments/video-attachment/content");
expect(video?.getAttribute("controls")).not.toBeNull();
expect(fetchSpy).not.toHaveBeenCalled();
});
it("lets video attachments open the shared media gallery", async () => {
const attachment = makeAttachment({
id: "video-attachment",
@@ -229,6 +202,11 @@ describe("IssueAttachmentsSection", () => {
});
await flushReact();
const video = container.querySelector("video");
expect(video?.getAttribute("src")).toBe("/api/attachments/video-attachment/content");
expect(video?.getAttribute("controls")).not.toBeNull();
expect(fetchSpy).not.toHaveBeenCalled();
const browse = container.querySelector<HTMLButtonElement>(
'button[aria-label="Browse demo.webm in gallery"]',
);
@@ -1210,56 +1210,6 @@ describe("IssueChatThread", () => {
// PAP-12003: initial page load must not jump to the latest comment. If a
// user wants the newest message, the explicit Jump to latest control owns it.
it("does not auto-scroll to the latest comment on initial load", () => {
vi.useFakeTimers();
container.remove();
const scrollHost = document.createElement("main");
scrollHost.id = "main-content";
scrollHost.style.overflowY = "auto";
scrollHost.style.overflow = "auto";
scrollHost.style.height = "640px";
document.body.appendChild(scrollHost);
container = document.createElement("div");
scrollHost.appendChild(container);
const elementScrollToMock = vi.fn();
scrollHost.scrollTo =
elementScrollToMock as unknown as typeof scrollHost.scrollTo;
const originalScrollIntoView = Element.prototype.scrollIntoView;
const scrollIntoViewMock = vi.fn();
Element.prototype.scrollIntoView =
scrollIntoViewMock as unknown as typeof Element.prototype.scrollIntoView;
const root = createRoot(container);
act(() => {
renderIssueThread(root, {
comments: issueChatLongThreadComments,
linkedRuns: issueChatLongThreadLinkedRuns,
timelineEvents: issueChatLongThreadEvents,
agentMap: issueChatLongThreadAgentMap,
currentUserId: "user-board",
transcriptsByRunId: issueChatLongThreadTranscriptsByRunId,
hasOutputForRun: (runId) =>
issueChatLongThreadTranscriptsByRunId.has(runId),
});
});
// No jump click: initial render should preserve the page position.
act(() => {
vi.advanceTimersByTime(500);
});
expect(elementScrollToMock).not.toHaveBeenCalled();
expect(scrollIntoViewMock).not.toHaveBeenCalled();
Element.prototype.scrollIntoView = originalScrollIntoView;
act(() => {
root.unmount();
});
scrollHost.remove();
vi.useRealTimers();
});
it("can keep the page at the top on initial load while preserving manual jump-to-latest", () => {
vi.useFakeTimers();
container.remove();
+3 -25
View File
@@ -72,6 +72,9 @@ describe("IssueFiltersPopover", () => {
const popoverContent = container.querySelector("[data-testid='popover-content']");
expect(popoverContent).not.toBeNull();
expect(popoverContent?.textContent).toContain("Status");
expect(popoverContent?.textContent).not.toContain("Priority");
expect(popoverContent?.querySelector('[data-filter-options="workspaces"]')).toBeNull();
expect(popoverContent?.textContent).not.toContain("Workspace");
expect(popoverContent?.className).toContain("overflow-y-auto");
@@ -83,31 +86,6 @@ describe("IssueFiltersPopover", () => {
);
expect(layoutGrid?.className).toContain("grid-cols-1");
expect(popoverContent?.textContent).toContain("Live runs only");
});
it("hides the Priority filter section while priority UI is off (PAP-411)", () => {
const root = createRoot(container);
act(() => {
root.render(
<IssueFiltersPopover
presentation="streamlined"
state={defaultIssueFilterState}
onChange={vi.fn()}
activeFilterCount={0}
agents={[{ id: "agent-1", name: "Agent One" }]}
projects={[{ id: "project-1", name: "Project One" }]}
labels={[{ id: "label-1", name: "Bug", color: "#ff0000" }]}
enableAgentCreatedVisibilityFilter
/>,
);
});
const popoverContent = container.querySelector("[data-testid='popover-content']");
expect(popoverContent).not.toBeNull();
// Status section still renders, Priority section is gated off (PAP-411).
expect(popoverContent?.textContent).toContain("Status");
expect(popoverContent?.textContent).not.toContain("Priority");
const creationToggle = Array.from(popoverContent?.querySelectorAll("label") ?? []).find((label) => label.textContent?.includes("show agent-created tasks"));
expect(creationToggle?.textContent).toBe("show agent-created tasks");
expect(creationToggle?.querySelector("input")?.checked).toBe(false);
+34 -130
View File
@@ -295,6 +295,14 @@ async function flushReact() {
});
}
function renderLayoutView(root: ReturnType<typeof createRoot>, queryClient: QueryClient) {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
}
describe("Layout", () => {
let container: HTMLDivElement;
@@ -346,11 +354,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -382,11 +386,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -426,11 +426,7 @@ describe("Layout", () => {
const renderLayout = async () => {
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
};
@@ -489,11 +485,7 @@ describe("Layout", () => {
defaultOptions: { queries: { retry: false } },
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
@@ -554,11 +546,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -589,11 +577,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -617,11 +601,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -656,11 +636,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -685,11 +661,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -711,11 +683,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -740,11 +708,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -768,11 +732,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -793,11 +753,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -822,11 +778,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -853,11 +805,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -880,11 +828,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -908,11 +852,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -937,11 +877,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -997,11 +933,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1030,11 +962,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1061,11 +989,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1113,11 +1037,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1169,11 +1089,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1236,11 +1152,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1308,11 +1220,7 @@ describe("Layout", () => {
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1334,11 +1242,7 @@ describe("Layout", () => {
defaultOptions: { queries: { retry: false } },
});
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<Layout />
</QueryClientProvider>,
);
renderLayoutView(root, queryClient);
});
await flushReact();
const rootEl = container.firstElementChild as HTMLElement;
@@ -293,15 +293,6 @@ describe("OnboardingWizard — which step it lands on", () => {
expect(currentStep()).toBe("agent");
});
it("opens on the agent step when the goals lookup fails outright", async () => {
routerState.pathname = "/PC1/onboarding";
mockGoalsApi.list.mockRejectedValue(new Error("goals unavailable"));
await render();
await settle();
expect(currentStep()).toBe("agent");
});
it("does not move an open wizard when a later refetch finds a mission", async () => {
// The defect this file exists for, in its current form. A refetch landing
// mid-flow used to flip the derived step from 2 to 3 and move the customer
+28 -84
View File
@@ -457,19 +457,6 @@ describe("OnboardingWizard restore-gate (stale localStorage across accounts)", (
await flushReact();
}
it("creates the organization on Continue and lands on the agent step, no mission", async () => {
mockCompaniesApi.create.mockResolvedValue({ id: "company-new", issuePrefix: "INI" });
const { root } = await openStepOne();
await clickByText((t) => t.startsWith("Continue"));
expect(mockCompaniesApi.create).toHaveBeenCalledWith({ name: "Initech" });
expect(document.body.textContent).toContain("Create your first agent");
expect(document.body.textContent).not.toContain("Define your mission");
expect(document.body.textContent).not.toContain("Tell us about your team");
await act(async () => root.unmount());
});
it("shows no environment-check card on the model step, and no Mission row on review", async () => {
// Round-3 walk feedback: the adapter environment check still runs —
// Connect probes before hiring and blocks on a fail — but its idle card
@@ -480,6 +467,10 @@ describe("OnboardingWizard restore-gate (stale localStorage across accounts)", (
mockCompaniesApi.create.mockResolvedValue({ id: "company-new", issuePrefix: "INI" });
const { root } = await openStepOne();
await clickByText((t) => t.startsWith("Continue"));
expect(mockCompaniesApi.create).toHaveBeenCalledWith({ name: "Initech" });
expect(document.body.textContent).not.toContain("Define your mission");
expect(document.body.textContent).not.toContain("Tell us about your team");
expect(document.body.textContent).toContain("Create your first agent");
// Step 3 → 4 needs an agent name — the one field the step has now.
@@ -1059,12 +1050,28 @@ describe("OnboardingWizard restore-gate (stale localStorage across accounts)", (
// Selecting the provider automatically verifies the saved subscription.
await flushReact();
expect(mockAgentsApi.testEnvironment).toHaveBeenCalled();
const testArgs = mockAgentsApi.testEnvironment.mock.calls.at(-1) as unknown[];
const testBody = testArgs[2] as { adapterConfig: { env?: Record<string, unknown> } };
expect(testBody.adapterConfig.env?.[CLAUDE_OAUTH_TOKEN_ENV_KEY]).toEqual({
type: "user_secret_ref",
key: CLAUDE_OAUTH_TOKEN_ENV_KEY,
version: "latest",
required: true,
});
expect(mockAgentsApi.hire).toHaveBeenCalled();
const hireArgs = mockAgentsApi.hire.mock.calls.at(-1) as unknown[];
const hireBody = hireArgs[1] as {
adapterConfig: { env?: Record<string, unknown> };
applyStoredClaudeLogin?: boolean;
};
const binding = hireBody.adapterConfig.env?.[CLAUDE_OAUTH_TOKEN_ENV_KEY] as
| { type: string }
| undefined;
expect(binding?.type).toBe("user_secret_ref");
expect(JSON.stringify(hireBody)).not.toContain("secretId");
expect(hireBody.applyStoredClaudeLogin).toBe(true);
expect(hireBody.adapterConfig.env?.[CLAUDE_OAUTH_TOKEN_ENV_KEY]).toEqual({
type: "user_secret_ref",
@@ -1084,6 +1091,11 @@ describe("OnboardingWizard restore-gate (stale localStorage across accounts)", (
await clickByText((t) => isArcPrimary(t));
expect(mockAgentsApi.testEnvironment).toHaveBeenCalled();
const testArgs = mockAgentsApi.testEnvironment.mock.calls.at(-1) as unknown[];
const testBody = testArgs[2] as { adapterConfig: { env?: Record<string, unknown> } };
expect(testBody.adapterConfig.env?.[CLAUDE_OAUTH_TOKEN_ENV_KEY]).toBeUndefined();
expect(mockAgentsApi.hire).toHaveBeenCalled();
const hireArgs = mockAgentsApi.hire.mock.calls.at(-1) as unknown[];
const hireBody = hireArgs[1] as {
@@ -1124,68 +1136,6 @@ describe("OnboardingWizard restore-gate (stale localStorage across accounts)", (
await act(async () => root.unmount());
});
it("carries no token value in the hire payload", async () => {
mockAgentsApi.getClaudeOAuthTokenStatus.mockReset();
mockAgentsApi.getClaudeOAuthTokenStatus.mockResolvedValue({
secretId: "11111111-1111-1111-1111-111111111111",
latestVersion: 1,
});
const { root } = await openConnectStep();
// Selecting the provider automatically verifies the saved subscription.
await flushReact();
expect(mockAgentsApi.hire).toHaveBeenCalled();
const hireArgs = mockAgentsApi.hire.mock.calls.at(-1) as unknown[];
const hireBody = hireArgs[1] as { adapterConfig: { env?: Record<string, unknown> } };
const binding = hireBody.adapterConfig.env?.[CLAUDE_OAUTH_TOKEN_ENV_KEY] as
| { type: string }
| undefined;
// A reference, never a value: no `value` field, no `secretId` field
// either — the fixed binding names the env var, not the status
// response's secret id.
expect(binding?.type).toBe("user_secret_ref");
expect(JSON.stringify(hireBody)).not.toContain("secretId");
await act(async () => root.unmount());
});
it("sends the fixed binding in the environment test request when the status route returns 200", async () => {
mockAgentsApi.getClaudeOAuthTokenStatus.mockReset();
mockAgentsApi.getClaudeOAuthTokenStatus.mockResolvedValue({
secretId: "11111111-1111-1111-1111-111111111111",
latestVersion: 1,
});
const { root } = await openConnectStep();
// Selecting the provider automatically verifies the saved subscription.
await flushReact();
expect(mockAgentsApi.testEnvironment).toHaveBeenCalled();
const testArgs = mockAgentsApi.testEnvironment.mock.calls.at(-1) as unknown[];
const testBody = testArgs[2] as { adapterConfig: { env?: Record<string, unknown> } };
expect(testBody.adapterConfig.env?.[CLAUDE_OAUTH_TOKEN_ENV_KEY]).toEqual({
type: "user_secret_ref",
key: CLAUDE_OAUTH_TOKEN_ENV_KEY,
version: "latest",
required: true,
});
await act(async () => root.unmount());
});
it("sends no binding in the environment test request when the status route returns 404", async () => {
// The default `beforeEach` mock already rejects with a 404 `ApiError`.
const { root, clickByText } = await openConnectStep();
await clickByText((t) => isArcPrimary(t));
expect(mockAgentsApi.testEnvironment).toHaveBeenCalled();
const testArgs = mockAgentsApi.testEnvironment.mock.calls.at(-1) as unknown[];
const testBody = testArgs[2] as { adapterConfig: { env?: Record<string, unknown> } };
expect(testBody.adapterConfig.env?.[CLAUDE_OAUTH_TOKEN_ENV_KEY]).toBeUndefined();
await act(async () => root.unmount());
});
it("hires when a stored login exists, even though a probe without the binding would warn adapter_auth_missing", async () => {
mockAgentsApi.getClaudeOAuthTokenStatus.mockReset();
mockAgentsApi.getClaudeOAuthTokenStatus.mockResolvedValue({
@@ -3004,6 +2954,9 @@ describe("OnboardingWizard restore-gate (stale localStorage across accounts)", (
const { root } = await openStep4({ adapterType: "claude_local" });
await pickSource(/Claude/);
expect(document.body.textContent).toContain("Sign in to Claude then come back and enter authorization code");
expect(document.body.textContent).not.toContain("Use saved login");
expect(mockAgentsApi.startClaudeSetupTokenLogin).toHaveBeenCalledTimes(1);
const back = [...document.body.querySelectorAll("button")].find((b) =>
@@ -3042,15 +2995,6 @@ describe("OnboardingWizard restore-gate (stale localStorage across accounts)", (
await act(async () => root.unmount());
});
it("renders no 'Use saved login' control", async () => {
mockAgentsApi.getAdapterAuthSignal.mockResolvedValue({ status: "absent" });
const { root } = await openStep4({ adapterType: "claude_local" });
await pickSource(/Claude/);
expect(document.body.textContent).toContain("Sign in to Claude then come back and enter authorization code");
expect(document.body.textContent).not.toContain("Use saved login");
await act(async () => root.unmount());
});
it("reads the signal again after an adapter change", async () => {
mockAdapterRegistry.list = [{ type: "claude_local" }, { type: "codex_local" }];
mockAgentsApi.getAdapterAuthSignal.mockResolvedValue({ status: "absent" });
+13 -44
View File
@@ -41,50 +41,6 @@ describe("RouteErrorBoundary", () => {
captureBrowserExceptionMock.mockClear();
});
it("reports one captured error and keeps the recovery button", () => {
const root = createRoot(container);
act(() => {
root.render(
<RouteErrorBoundary>
<Boom />
</RouteErrorBoundary>,
);
});
expect(captureBrowserExceptionMock).toHaveBeenCalledTimes(1);
expect(captureBrowserExceptionMock).toHaveBeenCalledWith(expect.any(Error), {
boundary: "route", componentStack: expect.stringContaining("Boom"),
});
expect(
Array.from(container.querySelectorAll("button")).some(
(button) => button.textContent === "Go back",
),
).toBe(true);
act(() => {
root.unmount();
});
});
it("renders a recoverable error card instead of a blank page when a child throws", () => {
const root = createRoot(container);
act(() => {
root.render(
<RouteErrorBoundary>
<Boom />
</RouteErrorBoundary>,
);
});
expect(container.textContent).toContain("This page hit an error");
expect(container.textContent).toContain("Maximum update depth exceeded");
expect(container.querySelector("pre")).not.toBeNull();
act(() => {
root.unmount();
});
});
it("navigates back when the user clicks Go back", () => {
const root = createRoot(container);
act(() => {
@@ -120,7 +76,20 @@ describe("RouteErrorBoundary", () => {
</RouteErrorBoundary>,
);
});
expect(captureBrowserExceptionMock).toHaveBeenCalledTimes(1);
expect(captureBrowserExceptionMock).toHaveBeenCalledWith(expect.any(Error), {
boundary: "route", componentStack: expect.stringContaining("Boom"),
});
expect(
Array.from(container.querySelectorAll("button")).some(
(button) => button.textContent === "Go back",
),
).toBe(true);
expect(container.textContent).toContain("This page hit an error");
expect(container.textContent).toContain("Maximum update depth exceeded");
expect(container.querySelector("pre")).not.toBeNull();
// Simulate back-navigation to a different route, then re-render with a
// healthy child — the boundary should reset off the new resetKey.
+5 -45
View File
@@ -267,6 +267,11 @@ describe("Sidebar", () => {
expect(navLabels).toContain("Projects");
expect(navLabels).toContain("Agents");
expect(container.textContent).not.toContain("Organization");
expect(container.textContent).not.toContain("Workspaces");
expect([...container.querySelectorAll("nav a")].map((a) => a.textContent?.trim())).not.toContain("Goals");
expect(container.querySelector('[data-testid="sidebar-goals-placeholder"]')).not.toBeNull();
expect(container.textContent).not.toContain("Conference Room");
expect(container.textContent).not.toContain("Pipelines");
flushSync(() => {
root.unmount();
@@ -464,17 +469,6 @@ describe("Sidebar", () => {
});
});
it("does not flash the Workspaces link while experimental settings are loading", async () => {
mockInstanceSettingsApi.getExperimental.mockImplementation(() => new Promise(() => {}));
const root = await renderSidebar();
expect(container.textContent).not.toContain("Workspaces");
flushSync(() => {
root.unmount();
});
});
it("does not poll attention until Decisions is enabled", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableDecisions: false });
const root = await renderSidebar();
@@ -549,18 +543,6 @@ describe("Sidebar", () => {
});
});
it("reserves the Goals nav slot while experimental settings are loading", async () => {
mockInstanceSettingsApi.getExperimental.mockImplementation(() => new Promise(() => {}));
const root = await renderSidebar();
expect([...container.querySelectorAll("nav a")].map((a) => a.textContent?.trim())).not.toContain("Goals");
expect(container.querySelector('[data-testid="sidebar-goals-placeholder"]')).not.toBeNull();
flushSync(() => {
root.unmount();
});
});
it("shows the Goals nav item when the experimental setting is enabled", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableIsolatedWorkspaces: false,
@@ -625,17 +607,6 @@ describe("Sidebar", () => {
});
});
it("does not flash the Conference Room item while experimental settings are loading (PAP-137)", async () => {
mockInstanceSettingsApi.getExperimental.mockImplementation(() => new Promise(() => {}));
const root = await renderSidebar();
expect(container.textContent).not.toContain("Conference Room");
flushSync(() => {
root.unmount();
});
});
it("hides the Pipelines nav item when pipelines are disabled", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableIsolatedWorkspaces: false,
@@ -685,17 +656,6 @@ describe("Sidebar", () => {
});
});
it("does not flash the Pipelines nav item while experimental settings are loading", async () => {
mockInstanceSettingsApi.getExperimental.mockImplementation(() => new Promise(() => {}));
const root = await renderSidebar();
expect(container.textContent).not.toContain("Pipelines");
flushSync(() => {
root.unmount();
});
});
it("shows the Workspaces link when isolated workspaces are enabled", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: true });
const root = await renderSidebar();
+13 -41
View File
@@ -248,47 +248,6 @@ describe("SidebarCompanyMenu", () => {
});
});
it("uses company-centric create copy without the chat flag", async () => {
const root = createRoot(container);
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false } },
});
act(() => {
root.render(
<QueryClientProvider client={queryClient}>
<SidebarCompanyMenu />
</QueryClientProvider>,
);
});
await flushReact();
await flushReact();
const trigger = container.querySelector('button[aria-label="Open Acme Labs organization switcher"]');
expect(trigger).not.toBeNull();
expect(trigger?.classList).toContain("px-4");
expect(trigger?.classList).toContain("has-[>svg]:px-4");
expect(trigger?.classList).toContain("hover:bg-sidebar-accent");
expect(trigger?.classList).toContain("hover:text-sidebar-accent-foreground");
expect(trigger?.classList).toContain("dark:hover:bg-sidebar-accent");
expect(trigger?.classList).toContain("dark:hover:text-sidebar-accent-foreground");
expect(trigger?.classList).not.toContain("hover:bg-background");
expect(trigger?.classList).not.toContain("dark:hover:bg-background");
expect(trigger?.classList).not.toContain("dark:hover:bg-accent/50");
act(() => {
trigger?.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true, button: 0 }));
trigger?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
});
await flushReact();
expect(document.body.textContent).toContain("Create organization");
expect(document.body.textContent).not.toContain("Add company...");
act(() => {
root.unmount();
});
});
it("shows the requested company actions and signs out through the dropdown", async () => {
const root = createRoot(container);
const queryClient = new QueryClient({
@@ -467,12 +426,25 @@ describe("SidebarCompanyMenu", () => {
const trigger = container.querySelector('button[aria-label="Open Acme Labs organization switcher"]');
expect(trigger).not.toBeNull();
expect(trigger?.classList).toContain("px-4");
expect(trigger?.classList).toContain("has-[>svg]:px-4");
expect(trigger?.classList).toContain("hover:bg-sidebar-accent");
expect(trigger?.classList).toContain("hover:text-sidebar-accent-foreground");
expect(trigger?.classList).toContain("dark:hover:bg-sidebar-accent");
expect(trigger?.classList).toContain("dark:hover:text-sidebar-accent-foreground");
expect(trigger?.classList).not.toContain("hover:bg-background");
expect(trigger?.classList).not.toContain("dark:hover:bg-background");
expect(trigger?.classList).not.toContain("dark:hover:bg-accent/50");
act(() => {
trigger?.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true, button: 0 }));
trigger?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
});
await flushReact();
expect(document.body.textContent).toContain("Create organization");
expect(document.body.textContent).not.toContain("Add company...");
const editButton = Array.from(document.body.querySelectorAll("button"))
.find((element) => element.textContent === "Edit");
expect(editButton).toBeTruthy();
@@ -662,36 +662,6 @@ describe("EnvironmentVariablesEditor", () => {
expect(secretValueField?.value).toBe("supersecretvalue");
});
it("opens the create-secret popover from the picker's + Create item (§6.4, PAP-12476)", async () => {
// Regression: selecting the picker's `+ Create secret` item closes the
// combobox popover and (in the same tick) opens the anchored create-secret
// popover. The two Radix popovers must not race — the create popover has to
// survive the combobox's focus-return instead of being dismissed instantly.
render(
<EnvironmentVariablesEditor
value={{ GH: { type: "secret_ref", secretId: "s1", version: 2 } }}
secrets={secrets}
onChange={() => {}}
onCreateSecret={async () => secrets[0]}
/>,
);
const combobox = container.querySelector<HTMLElement>('[role="combobox"]')!;
combobox.focus();
await flush();
const createItem = [...document.querySelectorAll<HTMLElement>("[cmdk-item]")].find((el) =>
el.textContent?.includes("Create"),
);
expect(createItem, "create item should be present in the open picker").toBeTruthy();
createItem!.click();
await flush();
// The create-secret popover is open (heading rendered) and stays open.
expect(document.body.textContent, "create-secret popover should open").toContain("Create secret");
expect(
document.querySelector('input[aria-label="Secret name"]'),
"create-secret name field should render",
).toBeTruthy();
});
it("keeps the create-secret popover open when focus returns to a control inside the value cell (§6.4, PAP-12492)", async () => {
// Regression for the *fragile* part of the picker → create transition.
// The picker's combobox and the anchored create popover share the value
@@ -724,6 +694,11 @@ describe("EnvironmentVariablesEditor", () => {
await flush();
expect(document.body.textContent, "create-secret popover should open").toContain("Create secret");
expect(
document.querySelector('input[aria-label="Secret name"]'),
"create-secret name field should render",
).toBeTruthy();
// Simulate the picker's animation-delayed focus-return landing on a control
// that lives inside the value cell (the source-switch trigger is a stable
// in-anchor target that doesn't reopen the picker). Moving focus fires a
@@ -1715,14 +1715,6 @@ describe("interstitial self-talk classification (PAP-355)", () => {
if (m.kind !== "message") continue;
expect(m.interstitial).toBe(true);
}
});
it("marks only the message still open at the tail as streaming", () => {
const items = transcriptToTaskChatItems(stream, {
runId: "run-1",
running: true,
});
const messages = items.filter((it) => it.kind === "message");
if (messages[0].kind !== "message" || messages[1].kind !== "message")
return;
// The first message was closed by the tool call — finished self-talk.
@@ -1751,13 +1743,6 @@ describe("interstitial self-talk classification (PAP-355)", () => {
expect(m.interstitial).toBe(true);
expect(m.streaming).toBe(false);
}
});
it("stamps atMs from the first streamed chunk", () => {
const messages = transcriptToTaskChatItems(stream, {
runId: "run-1",
running: false,
}).filter((it) => it.kind === "message");
if (messages[0].kind !== "message" || messages[1].kind !== "message")
return;
expect(messages[0].atMs).toBe(Date.parse(TS));
-10
View File
@@ -86,16 +86,6 @@ describe("startServiceWorkerUpdates", () => {
expect(reload).toHaveBeenCalledTimes(1);
});
it("does not reload on a first-ever install", async () => {
const { container, emit } = fakeContainer({ controlled: false });
const { doc } = fakeDocument("hidden");
const reload = vi.fn();
startServiceWorkerUpdates({ container, documentRef: doc, reload });
emit("controllerchange");
expect(reload).not.toHaveBeenCalled();
});
it("reloads when a later deploy replaces the worker a first-visit tab installed", async () => {
const { container, emit } = fakeContainer({ controlled: false });
const { doc } = fakeDocument("hidden");
+39 -175
View File
@@ -294,6 +294,16 @@ function findAgentRow(container: HTMLElement, agentName: string): HTMLElement |
return Array.from(container.querySelectorAll("a")).find((row) => row.textContent?.includes(agentName)) ?? null;
}
function renderAgentsView(root: ReturnType<typeof createRoot> | null, queryClient: QueryClient) {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
}
describe("Agents", () => {
let container: HTMLDivElement;
let root: ReturnType<typeof createRoot> | null;
@@ -396,13 +406,7 @@ describe("Agents", () => {
it("shows the configured model beside the adapter on the all agents page", async () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -420,13 +424,7 @@ describe("Agents", () => {
it("switches between the preserved list and the interactive org chart with icon buttons", async () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
@@ -489,13 +487,7 @@ describe("Agents", () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -522,57 +514,7 @@ describe("Agents", () => {
expect(row?.textContent).not.toContain("Pause");
});
it("uses the built-in agents route segment as the built-in filter", async () => {
mockRouterState.pathname = "/agents/builtin";
mockInstanceSettingsApi.get.mockResolvedValue(makeInstanceSettings({ enableBuiltInAgents: true }));
const builtInAgent = makeAgent({
id: "built-in-agent",
name: "Briefs Agent",
urlKey: "briefs-agent",
});
const regularAgent = makeAgent({
id: "regular-agent",
name: "Regular Agent",
urlKey: "regular-agent",
});
mockAgentsApi.list.mockResolvedValue([builtInAgent, regularAgent]);
mockAgentsApi.org.mockResolvedValue([
{
id: "built-in-agent",
name: "Briefs Agent",
role: "engineer",
status: "active",
reports: [],
},
{
id: "regular-agent",
name: "Regular Agent",
role: "engineer",
status: "active",
reports: [],
},
]);
mockBuiltInAgentsApi.list.mockResolvedValue([
makeBuiltInAgentState({ agentId: "built-in-agent", agent: builtInAgent }),
]);
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
});
await flushReact();
await flushReact();
expect(container.textContent).toContain("1 agent");
expect(container.textContent).toContain("Briefs Agent");
expect(container.textContent).not.toContain("Regular Agent");
});
it("shows effective environment and sandbox provider beside agents", async () => {
mockAgentsApi.list.mockResolvedValue([
@@ -592,13 +534,7 @@ describe("Agents", () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -625,13 +561,7 @@ describe("Agents", () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -653,13 +583,7 @@ describe("Agents", () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -692,13 +616,7 @@ describe("Agents", () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -751,13 +669,7 @@ describe("Agents", () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -815,13 +727,7 @@ describe("Agents", () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -859,13 +765,7 @@ describe("Agents", () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -877,13 +777,7 @@ describe("Agents", () => {
it("does not show environment filter or grouping controls yet", async () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -897,13 +791,7 @@ describe("Agents", () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -916,18 +804,17 @@ describe("Agents", () => {
it("shows and filters built-in agents when the experimental flag is enabled", async () => {
mockRouterState.pathname = "/agents/builtin";
mockInstanceSettingsApi.get.mockResolvedValue(makeInstanceSettings({ enableBuiltInAgents: true }));
mockAgentsApi.list.mockResolvedValue([
makeAgent({
id: "built-in-agent",
name: "Briefs Agent",
urlKey: "briefs-agent",
}),
makeAgent({
id: "regular-agent",
name: "Regular Agent",
urlKey: "regular-agent",
}),
]);
const builtInAgent = makeAgent({
id: "built-in-agent",
name: "Briefs Agent",
urlKey: "briefs-agent",
});
const regularAgent = makeAgent({
id: "regular-agent",
name: "Regular Agent",
urlKey: "regular-agent",
});
mockAgentsApi.list.mockResolvedValue([builtInAgent, regularAgent]);
mockAgentsApi.org.mockResolvedValue([
{
id: "built-in-agent",
@@ -945,22 +832,17 @@ describe("Agents", () => {
},
]);
mockBuiltInAgentsApi.list.mockResolvedValue([
makeBuiltInAgentState({ agentId: "built-in-agent" }),
makeBuiltInAgentState({ agentId: "built-in-agent", agent: builtInAgent }),
]);
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
expect(container.textContent).toContain("1 agent");
expect(mockBuiltInAgentsApi.list).toHaveBeenCalledWith("company-1");
expect(container.textContent).toContain("Built-in");
expect(container.textContent).toContain("Briefs Agent");
@@ -972,13 +854,7 @@ describe("Agents", () => {
it("gives list-view rows a fixed-width title so meta columns align (PAP-86)", async () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1066,13 +942,7 @@ describe("Agents", () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1090,13 +960,7 @@ describe("Agents", () => {
root = createRoot(container);
await act(async () => {
root!.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<Agents />
</ToastProvider>
</QueryClientProvider>,
);
renderAgentsView(root, queryClient);
});
await flushReact();
await flushReact();
@@ -316,16 +316,11 @@ describe("InstanceExperimentalSettings — Conference Room Chat card (PAP-11233)
await renderPage();
const headings = [...container.querySelectorAll("section h2")].map((h) => h.textContent);
expect(headings).not.toContain("Conference Room Chat");
expect(container.querySelector(CONFERENCE_TOGGLE_SELECTOR)).toBeNull();
});
it("does not render the Pipelines experimental setting for now", async () => {
await renderPage();
const headings = [...container.querySelectorAll("section h2")].map((h) => h.textContent);
expect(headings).not.toContain("Pipelines");
expect(container.querySelector('button[aria-label="Toggle pipelines experimental setting"]')).toBeNull();
expect(headings).not.toContain("Conference Room Chat");
expect(container.querySelector(CONFERENCE_TOGGLE_SELECTOR)).toBeNull();
});
it("does not render the toggle even when the stored flag is currently enabled", async () => {
@@ -596,6 +591,14 @@ describe("InstanceExperimentalSettings — Conference Room Chat card (PAP-11233)
setWorktreeRuntimeMeta(true);
await renderPage();
expect(container.textContent).toContain(
"Only tasks created after enabling will run automatically",
);
expect(container.textContent).toContain("Toggling off and on resets the cutoff.");
// Off => no armed banner and no fail-closed hint.
expect(container.textContent).not.toContain("Running tasks created after");
expect(container.textContent).not.toContain("Execution is suppressed");
expect(container.textContent).toContain("Run tasks in this worktree");
expect(container.textContent).toContain(
"isolated git-worktree preview instance",
@@ -615,19 +618,6 @@ describe("InstanceExperimentalSettings — Conference Room Chat card (PAP-11233)
expect(toggle?.getAttribute("aria-checked")).toBe("true");
});
it("shows the cutoff-copy for the worktree run-execution toggle when off", async () => {
setWorktreeRuntimeMeta(true);
await renderPage();
expect(container.textContent).toContain(
"Only tasks created after enabling will run automatically",
);
expect(container.textContent).toContain("Toggling off and on resets the cutoff.");
// Off => no armed banner and no fail-closed hint.
expect(container.textContent).not.toContain("Running tasks created after");
expect(container.textContent).not.toContain("Execution is suppressed");
});
it("shows the armed timestamp when the flag matches the current instance", async () => {
setWorktreeRuntimeMeta(true);
setWorktreeInstanceIdMeta("inst-current");
+30 -162
View File
@@ -78,6 +78,18 @@ async function flushReact() {
flushSync(() => {});
}
function renderInviteLanding(root: ReturnType<typeof createRoot>, queryClient: QueryClient) {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
}
describe("InviteLandingPage", () => {
let container: HTMLDivElement;
@@ -148,15 +160,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -187,15 +191,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -265,15 +261,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -322,15 +310,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -397,15 +377,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -488,15 +460,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -573,15 +537,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -656,15 +612,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -702,15 +650,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -744,15 +684,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -857,15 +789,7 @@ describe("InviteLandingPage", () => {
const queryClient = createAppLikeQueryClient("user-1");
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -943,15 +867,7 @@ describe("InviteLandingPage", () => {
const queryClient = createAppLikeQueryClient("user-1");
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -978,15 +894,7 @@ describe("InviteLandingPage", () => {
const queryClient = createAppLikeQueryClient("user-1");
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1010,15 +918,7 @@ describe("InviteLandingPage", () => {
const queryClient = createAppLikeQueryClient(null);
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1051,15 +951,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1093,15 +985,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1149,15 +1033,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
await flushReact();
@@ -1201,15 +1077,7 @@ describe("InviteLandingPage", () => {
});
await act(async () => {
root.render(
<MemoryRouter initialEntries={["/invite/pcp_invite_test"]}>
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/invite/:token" element={<InviteLandingPage />} />
</Routes>
</QueryClientProvider>
</MemoryRouter>,
);
renderInviteLanding(root, queryClient);
});
await flushReact();
+3 -14
View File
@@ -4341,23 +4341,12 @@ describe("IssueDetail", () => {
await flushReact();
await flushReact();
expect(container.textContent).not.toContain("Plan decomposition");
expect(mockIssuesApi.listAcceptedPlanDecompositions).not.toHaveBeenCalled();
});
it("hides file viewer entry points by default", async () => {
mockIssuesApi.get.mockResolvedValue(createIssue());
await act(async () => {
renderIssueView();
});
await flushReact();
await flushReact();
expect(
container.querySelector('[aria-label="Open file in this issue"]'),
).toBeNull();
expect(container.textContent).not.toContain("Plan decomposition");
expect(mockIssuesApi.listAcceptedPlanDecompositions).not.toHaveBeenCalled();
});
it("shows file viewer entry points when the experimental flag is enabled", async () => {
+12 -38
View File
@@ -143,21 +143,6 @@ describe("Timeline", () => {
vi.clearAllMocks();
});
it("requests the collapsed app sidebar by default", async () => {
root = createRoot(container);
flushSync(() => {
root?.render(
<QueryClientProvider client={queryClient}>
<Timeline />
</QueryClientProvider>,
);
});
await flushReact();
expect(container.querySelector('[data-testid="request-collapsed-sidebar"]')).not.toBeNull();
});
it("applies project scope from the project Timeline control", async () => {
mockLocation.search = "?projectId=11111111-1111-4111-8111-111111111111";
root = createRoot(container);
@@ -198,6 +183,18 @@ describe("Timeline", () => {
expect(container.textContent).not.toContain("Everyone");
expect(container.textContent).not.toContain("work kicked off");
expect(container.textContent).not.toContain("visible");
expect(container.querySelector('[data-testid="request-collapsed-sidebar"]')).not.toBeNull();
expect(mockWorkTimelineApi.get).toHaveBeenCalledWith(
"company-1",
expect.objectContaining({
from: expect.any(String),
to: expect.any(String),
}),
{ signal: expect.any(AbortSignal) },
);
expect(mockWorkTimelineApi.get.mock.calls[0]?.[1]).not.toHaveProperty("userId");
});
it("renders top timeline stats and keeps range controls in the chart footer", async () => {
@@ -357,27 +354,4 @@ describe("Timeline", () => {
totalTokens: 1_250,
});
});
it("requests the company timeline without a user lens parameter", async () => {
root = createRoot(container);
flushSync(() => {
root?.render(
<QueryClientProvider client={queryClient}>
<Timeline />
</QueryClientProvider>,
);
});
await flushReact();
expect(mockWorkTimelineApi.get).toHaveBeenCalledWith(
"company-1",
expect.objectContaining({
from: expect.any(String),
to: expect.any(String),
}),
{ signal: expect.any(AbortSignal) },
);
expect(mockWorkTimelineApi.get.mock.calls[0]?.[1]).not.toHaveProperty("userId");
});
});
+3 -10
View File
@@ -926,6 +926,9 @@ describe("AppDetail", () => {
await renderAppDetail();
expect(container.textContent).toContain("Which agents can use this connection?");
expect(container.textContent).not.toContain("Always installed");
expect(putConnectionInstallsMock).not.toHaveBeenCalled();
expect(container.textContent).toContain("Read (1)");
expect(container.textContent).toContain("Write (1)");
expect(container.textContent).toContain("Read repo");
@@ -1030,16 +1033,6 @@ describe("AppDetail", () => {
});
});
it("removes the separate always-installed controls from Permissions", async () => {
mockParams.tab = "permissions";
await renderAppDetail();
expect(container.textContent).toContain("Which agents can use this connection?");
expect(container.textContent).not.toContain("Always installed");
expect(putConnectionInstallsMock).not.toHaveBeenCalled();
});
it("shows and removes task-granted access without changing the connection's default permissions", async () => {
const grant = {
id: "task-grant", status: "active", profileKey: "connection-intent:conn-1:agent-1",