mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-20 18:26:40 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents need API keys and tokens. People manage them in Settings →
Secrets.
> - The page showed every credential in one table. Tokens that Paperclip
saved for connections, chat channels and model sign-ins sat beside the
few secrets a person added, many with record IDs as names.
> - Each row repeated an always-true status, a version and a key. New
secret opened on two stacked mode switches and two storage pickers.
> - A person could not see which agents use a secret without opening it,
and had to open it again after creation to give an agent access.
> - This pull request redesigns the page, the New secret dialog, the
details panel, the Vaults tab, the import dialog, the Proposals tab and
My secrets. It keeps the existing data and API calls.
> - The benefit is a list that shows what a person manages, a create
flow with two fields, and a secret that an agent can use as soon as it
is saved.
## Linked Issues or Issue Description
**What existing behavior does this improve?**
The Settings → Secrets page, its New secret dialog, the secret details
panel, the Vaults tab, the import-from-vault dialog, the Proposals tab
and the My secrets tab.
**Subsystem affected**
UI: `ui/src/pages/Secrets.tsx` and `ui/src/pages/secrets/*`.
**Current behavior**
- One table lists all secrets. On a busy organization most rows are
credentials that Paperclip saved itself, and many have record IDs as
names.
- Each row shows Active, a version, a chip and the key. The row does not
show which agents use the secret.
- A three-line help banner is always visible.
- New secret starts with two mode switches (Organization / Each user,
Managed value / External reference), then a provider picker and a vault
picker. The Create button is disabled without a reason.
- The details panel has Details, Usage and Access events tabs.
- The Vaults tab has one section per provider, with empty placeholder
boxes and a status picker in the form.
**Proposed behavior**
- The list shows the secrets that the team added. Each row shows who
provides the value (Organization, or Each user with a count) and which
agents use it.
- Credentials that Paperclip saved collapse into "Managed by Paperclip".
They are grouped by origin and have readable names.
- One Filter menu covers provided-by, storage and status. Active filters
show as chips. Archived secrets stay hidden until a person asks for
them.
- New secret has a name, one explicit Organization / Each user choice, a
masked value, an optional list of agents, and "Stored in" only when more
than one storage place exists. Create stays enabled and says what is
missing. A `NAME=value` pasted into Name fills both fields.
- The details panel is one scrolling view: agents, other places the
secret is set, details, and recent activity.
- The Vaults tab is one flat list with health and secret counts. The
connect dialog has two required fields. Paperclip checks a new vault
immediately after it is saved.
**Reason and benefit**
A person can find their own secrets, see if a secret is used, and create
a secret that an agent can use in one step.
**Breaking changes**
None. The API gains one optional query parameter (`order` on the board
proposals list). The default order is unchanged. See Risks for the UI
behaviors that changed.
## What Changed
- **List.** Rewrote the Secrets tab in `Secrets.tsx`. Added
`secret-list-parts.tsx` for the Provided by and Used by cells, the help
popover and the managed groups. The Folders / Flat toggle is removed.
Folders are always on and search covers all folders.
- **Managed grouping.** Added `secret-origin.ts`. It infers the origin
of a secret from the name and key conventions of the server modules that
create secrets (`tool_app.*`, `tool_oauth.*`, `slack_manager.*`,
`chat.*`, `ai_*`, `routine-*`, `agent-observability.*`). It is used for
presentation only.
- **Agent usage.** Added `agent-secret-access.ts`. It holds the grant
and revoke logic that was inside the details panel, and builds one usage
index from the agents list for all rows.
- **New secret.** Rewrote the dialog. Added `buildCreateVaultOptions`
and `parseEnvAssignment`. Agents selected in the dialog get an
environment variable binding after the secret is saved. A failed grant
shows an error and keeps the secret.
- **Details.** Replaced the tabs with sections. "Also set in" lists the
bindings that are not agents. Activity shows agent names and the last
five entries, with "Show all activity".
- **Vaults.** Flat list with a built-in Paperclip row, a Default badge
that follows `getSelectableProviderConfig`, Check again, Enable, and an
Add vault menu. The dialog has Name and AWS region, with naming and tags
in a disclosure. The Status picker is removed.
- **Import, Proposals, My secrets.** Restyled to the same design.
Proposals adds a Recently decided list. The board list endpoint `GET
/api/companies/{companyId}/secret-proposals` takes a new optional
`order=resolved` to sort by decision time.
- **Copy.** "Provider vault" is "vault". "Local encrypted" is
"Paperclip" or "Paperclip-encrypted". Toasts and block reasons use plain
words.
- **Stories.** `secrets.stories.tsx` has new stories for the managed
section, a folder, New secret, the details panel and Vaults. The
Storybook usage fixture now returns the `target` field that the API
returns.
- **Tests.** Updated the page, import, proposals and My secrets tests.
Added `secret-origin.test.ts`. Updated the runner E2E vault-reference
journey and the Storybook visual render-state copy for the new labels.
- **Docs.** `Secrets → Provider vaults` is now `Secrets → Vaults` in
three documents.
`Secrets.tsx` was 4,855 lines and is 4,951 lines. The redesign edits the
page in place to keep its queries, mutations and deep links. Splitting
the file is a separate change.
## Verification
- `cd ui && node ../scripts/run-tsc.mjs -b`: no errors.
- `cd ui && pnpm vitest run src/pages/secrets src/pages/Secrets.test.ts
src/pages/Secrets.render.test.tsx
src/components/AgentSecretAccessEditor.test.tsx
src/components/AgentConfigForm src/components/IssueThreadInteractionCard
storybook/map-tooling.test.ts`: 14 files, 467 tests passed.
- `cd server && pnpm vitest run
src/__tests__/secret-proposals-routes.test.ts -t "decision time"`:
passed.
- `pnpm vitest run --config tests/runner-e2e/vitest.config.ts
chat-catalog-domains/external-vault-reference
chat-catalog-domains/external-personal-secret-menu
chat-catalog-domains/external-personal-secret-entry-dialog
chat-catalog-domains/external-personal-secret.test`: 32 passed, 2
skipped.
- `node scripts/check-token-gates.mjs`, `node scripts/check-maps.mjs`,
`node scripts/check-module-boundaries.mjs`, `node
scripts/storybook-catalog.mjs`: clean.
- `pnpm verify`: exit 2. It asks for broader coverage because a runner
E2E source file changed. Required CI supplies that coverage.
- All 22 Secrets stories render and their play functions pass in
headless Chromium against a local Storybook.
- End to end, on an isolated local instance (`paperclipai worktree init
--empty`, one company, two agents), with a headless Chromium script. 16
of 16 steps passed, with no page errors:
- Empty state. Create explains missing fields.
- Create an organization secret and give an agent access. The agent's
saved config has the `secret_ref` binding.
- Paste `NAME=value`. Create an each-user secret. Add a value in My
secrets. The list shows "1 of 1 added".
- Create a folder, create a secret in it, search across folders.
- In details: add an agent, replace the value, remove the agent. The
agent's saved config changes each time.
- Disable, archive, and the Archived filter.
- Managed secrets leave the team list and show under their groups.
- Add a Paperclip-encrypted vault and an AWS vault. New secret then
shows "Stored in".
- The import dialog explains a denied vault. The Proposals tab shows its
empty state. The list at 390 px width.
- Not run: the paid runner E2E journeys. I updated
`external-vault-reference.ts` for the new labels and could not execute
it. A live AWS import, and a proposal from a real agent run, were not
exercised.
## Risks
- **Origin grouping is a heuristic.** It reads naming conventions that
live in server modules. If a module changes its naming, its secrets show
in the team list again. Nothing is hidden or blocked by it. A recorded
origin on each secret is the durable fix.
- **Removed UI.** The Folders / Flat toggle, the "View references"
dialog, the vault Status picker, and creating draft GCP or HashiCorp
vault entries from the Add vault menu. Existing draft vaults still show
and can be edited. A disabled vault now has an Enable action.
- **Default status filter.** The list now shows active and disabled
secrets. Before, it showed active secrets only.
- **Built-in storage in "Stored in".** A provider's built-in storage is
not offered once that provider has a usable vault. The form already
replaced that choice with the vault before this change.
- **Agent access at creation.** Access is a second request for each
agent after the secret is saved. If one fails, the secret exists without
that access and an error says so.
- **Automation contracts.** Labels that agents and the runner E2E
journeys depend on are kept: the key in each My secrets row, "Set
value", "Set my value", "Update my value", "Save value", and the import
dialog test IDs. The import entry point moved into the "More secret
actions" menu and the journey is updated for it.
- **Value masking** uses `-webkit-text-security`. A browser without it
shows the value as typed.
## Model Used
- Claude Fable 5.2 (`claude-fable-5-2`) through Claude Code, with tool
use, code execution and browser automation. Three delegated agents on
the same model restyled the import dialog, the Proposals tab and My
secrets.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [ ] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
1025 lines
33 KiB
TypeScript
1025 lines
33 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { act } from "react";
|
|
import { createRoot } from "react-dom/client";
|
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
import type {
|
|
CompanySecret,
|
|
CompanySecretProviderConfig,
|
|
RemoteSecretImportCandidate,
|
|
RemoteSecretImportPreviewResult,
|
|
RemoteSecretImportResult,
|
|
} from "@paperclipai/shared";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { ApiError } from "../../api/client";
|
|
|
|
const mockSecretsApi = vi.hoisted(() => ({
|
|
remoteImportPreview: vi.fn(),
|
|
remoteImport: vi.fn(),
|
|
}));
|
|
|
|
const mockPushToast = vi.hoisted(() => vi.fn());
|
|
|
|
vi.mock("../../api/secrets", () => ({
|
|
secretsApi: mockSecretsApi,
|
|
}));
|
|
|
|
vi.mock("../../context/ToastContext", () => ({
|
|
useToastActions: () => ({
|
|
pushToast: mockPushToast,
|
|
dismissToast: vi.fn(),
|
|
clearToasts: vi.fn(),
|
|
}),
|
|
}));
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;
|
|
|
|
import { ImportFromVaultDialog } from "./ImportFromVaultDialog";
|
|
|
|
const awsVault: CompanySecretProviderConfig = {
|
|
id: "vault-aws",
|
|
companyId: "company-1",
|
|
provider: "aws_secrets_manager",
|
|
displayName: "AWS production",
|
|
status: "ready",
|
|
isDefault: true,
|
|
config: { region: "us-east-1" },
|
|
healthStatus: null,
|
|
healthCheckedAt: null,
|
|
healthMessage: null,
|
|
healthDetails: null,
|
|
disabledAt: null,
|
|
createdByAgentId: null,
|
|
createdByUserId: null,
|
|
createdAt: new Date(),
|
|
updatedAt: new Date(),
|
|
};
|
|
|
|
function makeCandidate(
|
|
overrides: Partial<RemoteSecretImportCandidate> = {},
|
|
): RemoteSecretImportCandidate {
|
|
return {
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:prod/foo-AbCdEf",
|
|
remoteName: "prod/foo",
|
|
name: "prod/foo",
|
|
key: "prod-foo",
|
|
providerVersionRef: null,
|
|
providerMetadata: { name: "prod/foo" },
|
|
status: "ready",
|
|
importable: true,
|
|
conflicts: [],
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
function makePreview(
|
|
candidates: RemoteSecretImportCandidate[],
|
|
nextToken: string | null = null,
|
|
): RemoteSecretImportPreviewResult {
|
|
return {
|
|
providerConfigId: awsVault.id,
|
|
provider: "aws_secrets_manager",
|
|
nextToken,
|
|
candidates,
|
|
};
|
|
}
|
|
|
|
async function flush() {
|
|
await act(async () => {
|
|
await Promise.resolve();
|
|
await new Promise((resolve) => window.setTimeout(resolve, 0));
|
|
});
|
|
}
|
|
|
|
async function flushDebounce() {
|
|
await act(async () => {
|
|
await new Promise((resolve) => window.setTimeout(resolve, 300));
|
|
});
|
|
}
|
|
|
|
function findButton(predicate: (text: string) => boolean) {
|
|
return Array.from(document.querySelectorAll("button")).find((btn) =>
|
|
predicate(btn.textContent ?? ""),
|
|
) as HTMLButtonElement | undefined;
|
|
}
|
|
|
|
async function click(element: Element | null | undefined) {
|
|
expect(element).toBeTruthy();
|
|
await act(async () => {
|
|
(element as HTMLElement).click();
|
|
});
|
|
await flush();
|
|
}
|
|
|
|
function makeWrapper() {
|
|
const queryClient = new QueryClient({
|
|
defaultOptions: { queries: { retry: false } },
|
|
});
|
|
return { queryClient };
|
|
}
|
|
|
|
describe("ImportFromVaultDialog", () => {
|
|
let container: HTMLDivElement;
|
|
|
|
beforeEach(() => {
|
|
container = document.createElement("div");
|
|
document.body.appendChild(container);
|
|
});
|
|
|
|
afterEach(() => {
|
|
container.remove();
|
|
document.body.innerHTML = "";
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("loads candidates and selects rows, persisting through pagination", async () => {
|
|
mockSecretsApi.remoteImportPreview
|
|
.mockResolvedValueOnce(
|
|
makePreview(
|
|
[
|
|
makeCandidate({
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:prod/stripe-ABC",
|
|
remoteName: "prod/stripe",
|
|
name: "prod/stripe",
|
|
key: "prod-stripe",
|
|
}),
|
|
makeCandidate({
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:prod/openai-XYZ",
|
|
remoteName: "prod/openai",
|
|
name: "prod/openai",
|
|
key: "prod-openai",
|
|
}),
|
|
],
|
|
"page-2",
|
|
),
|
|
)
|
|
.mockResolvedValueOnce(
|
|
makePreview(
|
|
[
|
|
makeCandidate({
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:prod/sendgrid-Q9",
|
|
remoteName: "prod/sendgrid",
|
|
name: "prod/sendgrid",
|
|
key: "prod-sendgrid",
|
|
}),
|
|
],
|
|
null,
|
|
),
|
|
);
|
|
|
|
const { queryClient } = makeWrapper();
|
|
const root = createRoot(container);
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<ImportFromVaultDialog
|
|
open
|
|
onOpenChange={vi.fn()}
|
|
companyId="company-1"
|
|
providerConfigs={[awsVault]}
|
|
existingSecrets={[]}
|
|
/>
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
const list = document.querySelector('[data-testid="vault-list"]');
|
|
expect(list).not.toBeNull();
|
|
expect(document.body.textContent).toContain("Import secrets from a vault");
|
|
expect(document.body.textContent).toContain("Their values stay in your vault.");
|
|
// One usable vault: no vault picker.
|
|
expect(document.querySelector('[aria-label="Vault"]')).toBeNull();
|
|
expect(document.body.textContent).toContain("prod/stripe");
|
|
expect(document.body.textContent).toContain("prod/openai");
|
|
|
|
// Select stripe via row click
|
|
const stripeRow = document.querySelector(
|
|
'[data-testid="vault-row-arn:aws:secretsmanager:us-east-1:1:secret:prod/stripe-ABC"]',
|
|
) as HTMLElement | null;
|
|
expect(stripeRow).not.toBeNull();
|
|
await act(async () => {
|
|
stripeRow?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
});
|
|
await flush();
|
|
expect(findButton((text) => text === "Continue with 1")).toBeTruthy();
|
|
|
|
// Load more page
|
|
const loadMore = document.querySelector('[data-testid="vault-load-more"]') as HTMLButtonElement | null;
|
|
expect(loadMore).not.toBeNull();
|
|
await act(async () => {
|
|
loadMore!.click();
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
expect(document.body.textContent).toContain("prod/sendgrid");
|
|
// Selection persisted through pagination.
|
|
expect(findButton((text) => text === "Continue with 1")).toBeTruthy();
|
|
|
|
await act(async () => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("shows secrets already in Paperclip as not selectable and explains conflicts", async () => {
|
|
mockSecretsApi.remoteImportPreview.mockResolvedValueOnce(
|
|
makePreview([
|
|
makeCandidate({
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:prod/sendgrid-Q9",
|
|
remoteName: "prod/sendgrid",
|
|
name: "prod/sendgrid",
|
|
key: "prod-sendgrid",
|
|
status: "duplicate",
|
|
importable: false,
|
|
conflicts: [
|
|
{ type: "exact_reference", message: "Already imported", existingSecretId: "secret-sg" },
|
|
],
|
|
}),
|
|
makeCandidate({
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:prod/openai-XYZ",
|
|
remoteName: "prod/openai",
|
|
name: "prod/openai",
|
|
key: "prod-openai",
|
|
status: "conflict",
|
|
importable: true,
|
|
conflicts: [
|
|
{ type: "name", message: "Name already in use" },
|
|
],
|
|
}),
|
|
]),
|
|
);
|
|
|
|
const { queryClient } = makeWrapper();
|
|
const root = createRoot(container);
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<ImportFromVaultDialog
|
|
open
|
|
onOpenChange={vi.fn()}
|
|
companyId="company-1"
|
|
providerConfigs={[awsVault]}
|
|
existingSecrets={[]}
|
|
/>
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
const duplicateRow = document.querySelector(
|
|
'[data-testid="vault-row-arn:aws:secretsmanager:us-east-1:1:secret:prod/sendgrid-Q9"]',
|
|
);
|
|
expect(duplicateRow?.getAttribute("data-row-state")).toBe("duplicate");
|
|
const duplicateCheckbox = duplicateRow?.querySelector(
|
|
'button[role="checkbox"]',
|
|
) as HTMLButtonElement | null;
|
|
expect(duplicateCheckbox?.getAttribute("data-disabled")).not.toBeNull();
|
|
|
|
expect(duplicateRow?.textContent).toContain("Already in Paperclip");
|
|
|
|
// Clicking the row does not select it either.
|
|
await act(async () => {
|
|
duplicateRow?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
});
|
|
await flush();
|
|
expect(findButton((text) => text === "Continue")).toBeTruthy();
|
|
|
|
const conflictRow = document.querySelector(
|
|
'[data-testid="vault-row-arn:aws:secretsmanager:us-east-1:1:secret:prod/openai-XYZ"]',
|
|
);
|
|
expect(conflictRow?.getAttribute("data-row-state")).toBe("conflict");
|
|
expect(conflictRow?.textContent).toContain("Name already in use");
|
|
expect(conflictRow?.textContent).not.toContain("Already in Paperclip");
|
|
// Raw references are never shown.
|
|
expect(document.body.textContent).not.toContain("arn:aws");
|
|
|
|
await act(async () => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("blocks import when a review row collides with an existing Paperclip secret", async () => {
|
|
const conflictCandidate = makeCandidate({
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:prod/openai-XYZ",
|
|
remoteName: "prod/openai",
|
|
name: "OPENAI_API_KEY",
|
|
key: "openai_api_key",
|
|
status: "conflict",
|
|
conflicts: [{ type: "key", message: "Key already in use" }],
|
|
});
|
|
mockSecretsApi.remoteImportPreview.mockResolvedValueOnce(
|
|
makePreview([conflictCandidate]),
|
|
);
|
|
|
|
const existing: CompanySecret[] = [
|
|
{
|
|
id: "secret-existing",
|
|
companyId: "company-1",
|
|
scope: "company",
|
|
ownerUserId: null,
|
|
userSecretDefinitionId: null,
|
|
key: "openai_api_key",
|
|
name: "OPENAI_API_KEY",
|
|
provider: "aws_secrets_manager",
|
|
status: "active",
|
|
managedMode: "external_reference",
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:other-XYZ",
|
|
providerConfigId: awsVault.id,
|
|
providerMetadata: null,
|
|
latestVersion: 1,
|
|
description: null,
|
|
lastResolvedAt: null,
|
|
lastRotatedAt: null,
|
|
deletedAt: null,
|
|
createdByAgentId: null,
|
|
createdByUserId: null,
|
|
createdAt: new Date(),
|
|
updatedAt: new Date(),
|
|
},
|
|
];
|
|
|
|
const { queryClient } = makeWrapper();
|
|
const root = createRoot(container);
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<ImportFromVaultDialog
|
|
open
|
|
onOpenChange={vi.fn()}
|
|
companyId="company-1"
|
|
providerConfigs={[awsVault]}
|
|
existingSecrets={existing}
|
|
/>
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
// Select the conflict row
|
|
const row = document.querySelector(
|
|
'[data-testid="vault-row-arn:aws:secretsmanager:us-east-1:1:secret:prod/openai-XYZ"]',
|
|
) as HTMLElement | null;
|
|
await act(async () => {
|
|
row?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
});
|
|
await flush();
|
|
|
|
// Continue to the naming step.
|
|
const continueBtn = Array.from(document.querySelectorAll("button")).find(
|
|
(btn) => btn.textContent?.includes("Continue"),
|
|
);
|
|
expect(continueBtn).toBeTruthy();
|
|
await act(async () => {
|
|
continueBtn!.click();
|
|
});
|
|
await flush();
|
|
|
|
// Naming step: the error is shown under the row. The Import button stays
|
|
// enabled, but pressing it explains what to fix instead of importing.
|
|
expect(document.body.textContent).toContain("Name 1 secret");
|
|
expect(document.body.textContent?.toLowerCase()).toContain("a paperclip secret already uses this");
|
|
|
|
const importBtn = findButton((text) => text.startsWith("Import "));
|
|
expect(importBtn).toBeTruthy();
|
|
expect(importBtn?.disabled).toBe(false);
|
|
expect(document.querySelector('[data-testid="import-blocked-message"]')).toBeNull();
|
|
await click(importBtn);
|
|
expect(mockSecretsApi.remoteImport).not.toHaveBeenCalled();
|
|
expect(
|
|
document.querySelector('[data-testid="import-blocked-message"]')?.textContent,
|
|
).toContain("Fix the 1 secret marked above");
|
|
|
|
await act(async () => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("requires lowercase operator-entered keys during review", async () => {
|
|
const externalRef = "arn:aws:secretsmanager:us-east-1:1:secret:prod/openai-XYZ";
|
|
mockSecretsApi.remoteImportPreview.mockResolvedValueOnce(
|
|
makePreview([
|
|
makeCandidate({
|
|
externalRef,
|
|
remoteName: "prod/openai",
|
|
name: "OpenAI API key",
|
|
key: "openai-api-key",
|
|
}),
|
|
]),
|
|
);
|
|
|
|
const { queryClient } = makeWrapper();
|
|
const root = createRoot(container);
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<ImportFromVaultDialog
|
|
open
|
|
onOpenChange={vi.fn()}
|
|
companyId="company-1"
|
|
providerConfigs={[awsVault]}
|
|
existingSecrets={[]}
|
|
/>
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
const row = document.querySelector(
|
|
`[data-testid="vault-row-${externalRef}"]`,
|
|
) as HTMLElement | null;
|
|
await act(async () => {
|
|
row?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
});
|
|
await flush();
|
|
|
|
const continueBtn = Array.from(document.querySelectorAll("button")).find(
|
|
(btn) => btn.textContent?.includes("Continue"),
|
|
);
|
|
await act(async () => {
|
|
continueBtn!.click();
|
|
});
|
|
await flush();
|
|
|
|
// Keys sit behind a disclosure until they are needed.
|
|
expect(document.querySelector(`[data-testid="review-key-${externalRef}"]`)).toBeNull();
|
|
await click(document.querySelector('[data-testid="review-details-toggle"]'));
|
|
|
|
const keyInput = document.querySelector(
|
|
`[data-testid="review-key-${externalRef}"]`,
|
|
) as HTMLInputElement | null;
|
|
const valueSetter = Object.getOwnPropertyDescriptor(
|
|
window.HTMLInputElement.prototype,
|
|
"value",
|
|
)?.set;
|
|
await act(async () => {
|
|
valueSetter?.call(keyInput, "MY_KEY");
|
|
keyInput!.dispatchEvent(new Event("input", { bubbles: true }));
|
|
});
|
|
await flush();
|
|
|
|
expect(document.body.textContent).toContain("lowercase letters");
|
|
// The key field stays visible while it has a problem, even with the disclosure closed.
|
|
await click(document.querySelector('[data-testid="review-details-toggle"]'));
|
|
expect(document.querySelector(`[data-testid="review-key-${externalRef}"]`)).not.toBeNull();
|
|
|
|
await click(findButton((text) => text.startsWith("Import ")));
|
|
expect(mockSecretsApi.remoteImport).not.toHaveBeenCalled();
|
|
expect(document.querySelector('[data-testid="import-blocked-message"]')).not.toBeNull();
|
|
|
|
await act(async () => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("submits the operator-entered review description", async () => {
|
|
const externalRef = "arn:aws:secretsmanager:us-east-1:1:secret:prod/openai-XYZ";
|
|
mockSecretsApi.remoteImportPreview.mockResolvedValueOnce(
|
|
makePreview([
|
|
makeCandidate({
|
|
externalRef,
|
|
remoteName: "prod/openai",
|
|
name: "OpenAI API key",
|
|
key: "openai-api-key",
|
|
providerMetadata: {
|
|
description: "Raw AWS description should not seed the review field",
|
|
},
|
|
}),
|
|
]),
|
|
);
|
|
mockSecretsApi.remoteImport.mockResolvedValueOnce({
|
|
providerConfigId: awsVault.id,
|
|
provider: "aws_secrets_manager",
|
|
importedCount: 1,
|
|
skippedCount: 0,
|
|
errorCount: 0,
|
|
results: [
|
|
{
|
|
externalRef,
|
|
name: "OpenAI API key",
|
|
key: "openai-api-key",
|
|
status: "imported",
|
|
reason: null,
|
|
secretId: "secret-openai",
|
|
conflicts: [],
|
|
},
|
|
],
|
|
});
|
|
|
|
const { queryClient } = makeWrapper();
|
|
const root = createRoot(container);
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<ImportFromVaultDialog
|
|
open
|
|
onOpenChange={vi.fn()}
|
|
companyId="company-1"
|
|
providerConfigs={[awsVault]}
|
|
existingSecrets={[]}
|
|
/>
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
const row = document.querySelector(
|
|
`[data-testid="vault-row-${externalRef}"]`,
|
|
) as HTMLElement | null;
|
|
await act(async () => {
|
|
row?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
});
|
|
await flush();
|
|
|
|
const continueBtn = Array.from(document.querySelectorAll("button")).find(
|
|
(btn) => btn.textContent?.includes("Continue"),
|
|
);
|
|
await act(async () => {
|
|
continueBtn!.click();
|
|
});
|
|
await flush();
|
|
|
|
await click(document.querySelector('[data-testid="review-details-toggle"]'));
|
|
const descriptionInput = document.querySelector(
|
|
`[data-testid="review-description-${externalRef}"]`,
|
|
) as HTMLInputElement | null;
|
|
expect(descriptionInput?.value).toBe("");
|
|
const valueSetter = Object.getOwnPropertyDescriptor(
|
|
window.HTMLInputElement.prototype,
|
|
"value",
|
|
)?.set;
|
|
await act(async () => {
|
|
valueSetter?.call(descriptionInput, "Operator-entered OpenAI key");
|
|
descriptionInput!.dispatchEvent(new Event("input", { bubbles: true }));
|
|
});
|
|
await flush();
|
|
|
|
const importBtn = Array.from(document.querySelectorAll("button")).find(
|
|
(btn) => btn.textContent?.startsWith("Import "),
|
|
) as HTMLButtonElement | undefined;
|
|
await act(async () => {
|
|
importBtn!.click();
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
expect(mockSecretsApi.remoteImport).toHaveBeenCalledWith("company-1", {
|
|
providerConfigId: awsVault.id,
|
|
secrets: [
|
|
expect.objectContaining({
|
|
externalRef,
|
|
description: "Operator-entered OpenAI key",
|
|
providerMetadata: null,
|
|
}),
|
|
],
|
|
});
|
|
|
|
// Everything imported: a short confirmation with one Done action.
|
|
expect(document.body.textContent).toContain("1 secret imported");
|
|
expect(
|
|
document.querySelector(`[data-testid="result-row-${externalRef}"]`)?.getAttribute("data-row-status"),
|
|
).toBe("imported");
|
|
expect(findButton((text) => text === "Done")).toBeTruthy();
|
|
|
|
await act(async () => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("keeps failed secrets listed with their reason after a mixed import and retries only those", async () => {
|
|
mockSecretsApi.remoteImportPreview.mockResolvedValueOnce(
|
|
makePreview([
|
|
makeCandidate({
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:a-AAA",
|
|
remoteName: "alpha",
|
|
name: "alpha",
|
|
key: "alpha",
|
|
}),
|
|
makeCandidate({
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:b-BBB",
|
|
remoteName: "beta",
|
|
name: "beta",
|
|
key: "beta",
|
|
}),
|
|
makeCandidate({
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:c-CCC",
|
|
remoteName: "gamma",
|
|
name: "gamma",
|
|
key: "gamma",
|
|
}),
|
|
]),
|
|
);
|
|
|
|
const result: RemoteSecretImportResult = {
|
|
providerConfigId: awsVault.id,
|
|
provider: "aws_secrets_manager",
|
|
importedCount: 1,
|
|
skippedCount: 1,
|
|
errorCount: 1,
|
|
results: [
|
|
{
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:a-AAA",
|
|
name: "alpha",
|
|
key: "alpha",
|
|
status: "imported",
|
|
reason: null,
|
|
secretId: "secret-alpha",
|
|
conflicts: [],
|
|
},
|
|
{
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:b-BBB",
|
|
name: "beta",
|
|
key: "beta",
|
|
status: "skipped",
|
|
reason: "exact reference already imported",
|
|
secretId: null,
|
|
conflicts: [
|
|
{ type: "exact_reference", message: "exact reference already imported" },
|
|
],
|
|
},
|
|
{
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:c-CCC",
|
|
name: "gamma",
|
|
key: "gamma",
|
|
status: "error",
|
|
reason: "AWS Secrets Manager denied the request. Check IAM permissions for this provider vault.",
|
|
secretId: null,
|
|
conflicts: [],
|
|
},
|
|
],
|
|
};
|
|
mockSecretsApi.remoteImport.mockResolvedValueOnce(result);
|
|
|
|
const { queryClient } = makeWrapper();
|
|
const root = createRoot(container);
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<ImportFromVaultDialog
|
|
open
|
|
onOpenChange={vi.fn()}
|
|
companyId="company-1"
|
|
providerConfigs={[awsVault]}
|
|
existingSecrets={[]}
|
|
/>
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
// Select all loaded
|
|
const headerCheckbox = document.querySelector(
|
|
'[data-testid="vault-select-all"]',
|
|
) as HTMLButtonElement | null;
|
|
expect(headerCheckbox).toBeTruthy();
|
|
await act(async () => {
|
|
headerCheckbox!.click();
|
|
});
|
|
await flush();
|
|
|
|
// Continue
|
|
const continueBtn = Array.from(document.querySelectorAll("button")).find(
|
|
(btn) => btn.textContent?.includes("Continue"),
|
|
);
|
|
await act(async () => {
|
|
continueBtn!.click();
|
|
});
|
|
await flush();
|
|
|
|
// Import
|
|
const importBtn = Array.from(document.querySelectorAll("button")).find(
|
|
(btn) => btn.textContent?.startsWith("Import "),
|
|
) as HTMLButtonElement | undefined;
|
|
expect(importBtn).toBeTruthy();
|
|
await act(async () => {
|
|
importBtn!.click();
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
expect(mockSecretsApi.remoteImport).toHaveBeenCalledTimes(1);
|
|
const summary = document.querySelector('[data-testid="result-summary"]');
|
|
expect(summary?.textContent).toContain("1 imported.");
|
|
expect(summary?.textContent).toContain("1 already in Paperclip.");
|
|
expect(summary?.textContent).toContain("1 could not be linked and is listed below.");
|
|
|
|
// Only the failure stays in the list, with its reason.
|
|
const gammaRef = "arn:aws:secretsmanager:us-east-1:1:secret:c-CCC";
|
|
expect(document.querySelectorAll('[data-testid^="review-row-"]').length).toBe(1);
|
|
expect(
|
|
document.querySelector(`[data-testid="review-failure-${gammaRef}"]`)?.textContent,
|
|
).toContain("AWS Secrets Manager denied the request");
|
|
expect(document.body.textContent).not.toContain("AccessDeniedException");
|
|
expect(document.body.textContent).not.toContain("123456789012");
|
|
expect(document.body.textContent).not.toContain("arn:aws");
|
|
|
|
// The finished rows are one click away, each with its own outcome.
|
|
await click(document.querySelector('[data-testid="result-done-toggle"]'));
|
|
expect(
|
|
document
|
|
.querySelector('[data-testid="result-row-arn:aws:secretsmanager:us-east-1:1:secret:a-AAA"]')
|
|
?.getAttribute("data-row-status"),
|
|
).toBe("imported");
|
|
const skippedRow = document.querySelector(
|
|
'[data-testid="result-row-arn:aws:secretsmanager:us-east-1:1:secret:b-BBB"]',
|
|
);
|
|
expect(skippedRow?.getAttribute("data-row-status")).toBe("skipped");
|
|
expect(skippedRow?.textContent).toContain("exact reference already imported");
|
|
|
|
// Footer: Close on the left, Try again on the right; closing needs no discard prompt.
|
|
expect(findButton((text) => text === "Close")).toBeTruthy();
|
|
expect(findButton((text) => text === "Back")).toBeUndefined();
|
|
|
|
mockSecretsApi.remoteImport.mockResolvedValueOnce({
|
|
providerConfigId: awsVault.id,
|
|
provider: "aws_secrets_manager",
|
|
importedCount: 1,
|
|
skippedCount: 0,
|
|
errorCount: 0,
|
|
results: [
|
|
{
|
|
externalRef: gammaRef,
|
|
name: "gamma",
|
|
key: "gamma",
|
|
status: "imported",
|
|
reason: null,
|
|
secretId: "secret-gamma",
|
|
conflicts: [],
|
|
},
|
|
],
|
|
} satisfies RemoteSecretImportResult);
|
|
await click(findButton((text) => text === "Try again"));
|
|
await flush();
|
|
|
|
expect(mockSecretsApi.remoteImport).toHaveBeenCalledTimes(2);
|
|
const retryInput = mockSecretsApi.remoteImport.mock.calls[1]?.[1];
|
|
expect(retryInput.secrets.map((secret: { externalRef: string }) => secret.externalRef)).toEqual([
|
|
gammaRef,
|
|
]);
|
|
expect(document.body.textContent).toContain("2 secrets imported");
|
|
expect(document.querySelectorAll('[data-testid^="result-row-"]').length).toBe(3);
|
|
expect(findButton((text) => text === "Done")).toBeTruthy();
|
|
|
|
await act(async () => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("shows an empty state when no AWS vault is configured", async () => {
|
|
const { queryClient } = makeWrapper();
|
|
const root = createRoot(container);
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<ImportFromVaultDialog
|
|
open
|
|
onOpenChange={vi.fn()}
|
|
companyId="company-1"
|
|
providerConfigs={[]}
|
|
existingSecrets={[]}
|
|
onManageVaults={vi.fn()}
|
|
/>
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flush();
|
|
|
|
const empty = document.querySelector('[data-testid="select-empty-vaults"]');
|
|
expect(empty?.textContent).toContain("No vault is connected yet.");
|
|
expect(findButton((text) => text === "Connect one in Vaults")).toBeTruthy();
|
|
expect(findButton((text) => text.startsWith("Continue"))).toBeUndefined();
|
|
expect(mockSecretsApi.remoteImportPreview).not.toHaveBeenCalled();
|
|
|
|
await act(async () => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("shows a permission-error banner when AWS denies ListSecrets", async () => {
|
|
const error = Object.assign(new Error("AccessDeniedException"), {
|
|
name: "ApiError",
|
|
status: 403,
|
|
body: null,
|
|
});
|
|
mockSecretsApi.remoteImportPreview.mockRejectedValueOnce(error);
|
|
|
|
const { queryClient } = makeWrapper();
|
|
const root = createRoot(container);
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<ImportFromVaultDialog
|
|
open
|
|
onOpenChange={vi.fn()}
|
|
companyId="company-1"
|
|
providerConfigs={[awsVault]}
|
|
existingSecrets={[]}
|
|
/>
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
const banner = document.querySelector('[data-testid="preview-error-banner"]');
|
|
expect(banner).not.toBeNull();
|
|
expect(banner?.textContent).toContain("Paperclip couldn't load the secrets in this vault.");
|
|
expect(findButton((text) => text === "Try again")).toBeTruthy();
|
|
|
|
await act(async () => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("renders sanitized preview provider errors without raw AWS exception text", async () => {
|
|
const onManageVaults = vi.fn();
|
|
const rawProviderMessage =
|
|
"AccessDeniedException: User: arn:aws:sts::123456789012:assumed-role/prod/Paperclip is not authorized";
|
|
mockSecretsApi.remoteImportPreview.mockRejectedValueOnce(
|
|
new ApiError(
|
|
"AWS Secrets Manager denied the request. Check IAM permissions for this provider vault.",
|
|
403,
|
|
{ error: "AWS Secrets Manager denied the request. Check IAM permissions for this provider vault.", details: { code: "access_denied" } },
|
|
),
|
|
);
|
|
|
|
const { queryClient } = makeWrapper();
|
|
const root = createRoot(container);
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<ImportFromVaultDialog
|
|
open
|
|
onOpenChange={vi.fn()}
|
|
companyId="company-1"
|
|
providerConfigs={[awsVault]}
|
|
existingSecrets={[]}
|
|
onManageVaults={onManageVaults}
|
|
/>
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
const banner = document.querySelector('[data-testid="preview-error-banner"]');
|
|
expect(banner).not.toBeNull();
|
|
expect(banner?.textContent).toContain("AWS denied access. Paperclip's role can't list the secrets in this vault.");
|
|
expect(banner?.textContent).toContain("secretsmanager:ListSecrets");
|
|
await click(findButton((text) => text === "Fix it in Vaults"));
|
|
expect(onManageVaults).toHaveBeenCalledTimes(1);
|
|
// Nothing to continue with while the vault cannot be listed.
|
|
expect(findButton((text) => text.startsWith("Continue"))).toBeUndefined();
|
|
expect(banner?.textContent).not.toContain(rawProviderMessage);
|
|
expect(banner?.textContent).not.toContain("arn:aws");
|
|
expect(banner?.textContent).not.toContain("123456789012");
|
|
|
|
await act(async () => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("debounces search and uses the new query for the next preview", async () => {
|
|
mockSecretsApi.remoteImportPreview
|
|
.mockResolvedValueOnce(makePreview([makeCandidate()]))
|
|
.mockResolvedValueOnce(makePreview([
|
|
makeCandidate({
|
|
externalRef: "arn:aws:secretsmanager:us-east-1:1:secret:stripe-XYZ",
|
|
remoteName: "stripe",
|
|
name: "stripe",
|
|
key: "stripe",
|
|
}),
|
|
]));
|
|
|
|
const { queryClient } = makeWrapper();
|
|
const root = createRoot(container);
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<ImportFromVaultDialog
|
|
open
|
|
onOpenChange={vi.fn()}
|
|
companyId="company-1"
|
|
providerConfigs={[awsVault]}
|
|
existingSecrets={[]}
|
|
/>
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
const search = document.querySelector('[data-testid="vault-search"]') as HTMLInputElement;
|
|
expect(search).not.toBeNull();
|
|
const valueSetter = Object.getOwnPropertyDescriptor(
|
|
window.HTMLInputElement.prototype,
|
|
"value",
|
|
)?.set;
|
|
await act(async () => {
|
|
search.focus();
|
|
valueSetter?.call(search, "stripe");
|
|
search.dispatchEvent(new Event("input", { bubbles: true }));
|
|
});
|
|
await flushDebounce();
|
|
await flush();
|
|
|
|
expect(mockSecretsApi.remoteImportPreview).toHaveBeenCalledTimes(2);
|
|
const lastCall = mockSecretsApi.remoteImportPreview.mock.calls.at(-1);
|
|
expect(lastCall?.[1]).toMatchObject({ query: "stripe" });
|
|
|
|
await act(async () => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("explains why Continue does nothing when no secret is selected", async () => {
|
|
mockSecretsApi.remoteImportPreview.mockResolvedValueOnce(makePreview([makeCandidate()]));
|
|
|
|
const { queryClient } = makeWrapper();
|
|
const root = createRoot(container);
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<ImportFromVaultDialog
|
|
open
|
|
onOpenChange={vi.fn()}
|
|
companyId="company-1"
|
|
providerConfigs={[awsVault]}
|
|
existingSecrets={[]}
|
|
/>
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
const continueBtn = findButton((text) => text === "Continue");
|
|
expect(continueBtn?.disabled).toBe(false);
|
|
await click(continueBtn);
|
|
expect(
|
|
document.querySelector('[data-testid="import-blocked-message"]')?.textContent,
|
|
).toBe("Select at least one secret to import.");
|
|
expect(document.querySelector('[data-testid="vault-list"]')).not.toBeNull();
|
|
|
|
// Picking a secret clears the message.
|
|
await click(document.querySelector('[data-testid="vault-select-all"]'));
|
|
expect(document.querySelector('[data-testid="import-blocked-message"]')).toBeNull();
|
|
|
|
await act(async () => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("offers a vault picker only when more than one vault is usable, and asks before discarding picks", async () => {
|
|
mockSecretsApi.remoteImportPreview.mockResolvedValue(makePreview([makeCandidate()]));
|
|
const secondVault: CompanySecretProviderConfig = {
|
|
...awsVault,
|
|
id: "vault-aws-2",
|
|
displayName: "AWS staging",
|
|
isDefault: false,
|
|
};
|
|
const onOpenChange = vi.fn();
|
|
|
|
const { queryClient } = makeWrapper();
|
|
const root = createRoot(container);
|
|
await act(async () => {
|
|
root.render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<ImportFromVaultDialog
|
|
open
|
|
onOpenChange={onOpenChange}
|
|
companyId="company-1"
|
|
providerConfigs={[awsVault, secondVault]}
|
|
existingSecrets={[]}
|
|
/>
|
|
</QueryClientProvider>,
|
|
);
|
|
});
|
|
await flush();
|
|
await flush();
|
|
|
|
expect(document.querySelector('[aria-label="Vault"]')).not.toBeNull();
|
|
expect(document.body.textContent).toContain("Secret in AWS production");
|
|
|
|
await click(document.querySelector('[data-testid="vault-select-all"]'));
|
|
const confirmSpy = vi.spyOn(window, "confirm").mockReturnValueOnce(false).mockReturnValueOnce(true);
|
|
await click(findButton((text) => text === "Cancel"));
|
|
expect(confirmSpy).toHaveBeenCalledWith("Discard 1 pending import?");
|
|
expect(onOpenChange).not.toHaveBeenCalled();
|
|
await click(findButton((text) => text === "Cancel"));
|
|
expect(onOpenChange).toHaveBeenCalledWith(false);
|
|
confirmSpy.mockRestore();
|
|
|
|
await act(async () => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
});
|