Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions e2e/scenarios/connection-remove-confirm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ scenario(
const client = yield* makeClient(api, identity);

const slug = IntegrationSlug.make(`rm-confirm-${randomBytes(4).toString("hex")}`);
const name = ConnectionName.make("main");
const name = ConnectionName.make("longconnectionnamethatmustwrapwithoutoverflow");

yield* Effect.ensuring(
Effect.gen(function* () {
Expand Down Expand Up @@ -73,9 +73,10 @@ scenario(
const connections = page.locator("section").filter({
has: page.getByRole("heading", { level: 3, name: "Connections" }),
});
const row = connections.getByText("main", { exact: true });
const row = connections.getByText(String(name), { exact: true });
const menuTrigger = connections.locator('button[aria-haspopup="menu"]');
const confirm = page.getByRole("alertdialog");
const removeAction = confirm.getByRole("button", { name: "Remove connection" });

await step("Open the integration's connections", async () => {
await visit(page, `/integrations/${slug}`);
Expand All @@ -85,7 +86,24 @@ scenario(
await step("Remove asks for confirmation instead of firing", async () => {
await menuTrigger.click();
await page.getByRole("menuitem", { name: "Remove" }).click();
await confirm.getByText("Remove main?").waitFor();
const title = confirm.getByText(`Remove ${String(name)}?`);
await title.waitFor();
await removeAction.getByText("Remove", { exact: true }).waitFor();

const layout = await confirm.evaluate((dialog) => {
const title = dialog.querySelector<HTMLElement>('[data-slot="alert-dialog-title"]');
if (title === null) return null;
const titleText = document.createRange();
titleText.selectNodeContents(title);
return {
dialogFits: dialog.scrollWidth <= dialog.clientWidth + 1,
titleWraps: titleText.getClientRects().length > 1,
};
});
expect(layout, "the confirmation title wraps without widening the dialog").toEqual({
dialogFits: true,
titleWraps: true,
});
});

await step("Cancel keeps the connection", async () => {
Expand All @@ -97,7 +115,7 @@ scenario(
await step("Confirming actually removes it", async () => {
await menuTrigger.click();
await page.getByRole("menuitem", { name: "Remove" }).click();
await confirm.getByRole("button", { name: "Remove connection" }).click();
await removeAction.click();
await confirm.waitFor({ state: "detached" });
await row.waitFor({ state: "detached" });
});
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/components/accounts-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -571,13 +571,14 @@ function OwnerAccounts(props: {
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
variant="destructive"
aria-label="Remove connection"
onClick={() => {
if (props.canManageConnections && removingConnection !== null) {
void handleRemove(removingConnection);
}
}}
>
Remove connection
Remove
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/alert-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function AlertDialogTitle({
<AlertDialogPrimitive.Title
data-slot="alert-dialog-title"
className={cn(
"text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",
"wrap-anywhere text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",
className,
)}
{...props}
Expand Down
Loading