mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 18:07:00 +01:00
test(ui): retire 33 duplicate executions and share render setup (#16072)
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
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.
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" });
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in new issue
Block a user