From 94d19377f9a37404c6d2c82c66dce8071dfe62a4 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Fri, 20 Nov 2026 08:26:29 +0100 Subject: [PATCH 1/6] test(web): cover reopening the pairing link dialog during creation Co-authored-by: GPT 6.2 Sol --- ...ng-completion-keeps-reopened-dialog.e2e.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts diff --git a/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts b/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts new file mode 100644 index 000000000000..864d84887089 --- /dev/null +++ b/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts @@ -0,0 +1,56 @@ +import { expect } from "e2e"; + +import { test, WEB } from "./t3.ts"; + +test( + "Finishing a pairing link leaves a reopened Create link dialog open", + WEB, + async ({ t3, app, browser, screen }) => { + await t3.project("demo"); + const pairingToken = "**/api/auth/pairing-token"; + const requested = Promise.withResolvers(); + const release = Promise.withResolvers(); + await browser.route(pairingToken, async (route) => { + if (route.request.method !== "POST") return route.fallback(); + requested.resolve(); + // Simulate a delayed request without replacing the server's response. + await release.promise; + await route.continue(); + }); + + await t3.open("/settings/access"); + const authorizedClients = browser.locator("#authorized-clients"); + const open = authorizedClients.getByRole("button", "Create link", { exact: true }); + const dialog = screen.getByRole("dialog", "Create pairing link", { exact: true }); + const label = "Waiting tablet"; + try { + await open.tap(); + await dialog.getByPlaceholder("e.g. Living room iPad").fill(label); + await dialog.getByRole("button", "Create link", { exact: true }).tap(); + await requested.promise; + await dialog.getByRole("button", "Creating…", { exact: true }).waitFor(); + await browser.keyboard.press("Escape"); + + const openPopup = browser + .locator('[data-slot="dialog-popup"][data-open]') + .getByRole("heading", "Create pairing link", { exact: true }); + const dismissed = !(await openPopup.isVisible()); + if (dismissed) { + await dialog.waitFor({ state: "hidden" }); + await open.tap(); + await dialog.waitFor(); + } + + release.resolve(); + await authorizedClients.getByText(label, { exact: true }).waitFor(); + await app.screenshot("after-first-link-finishes"); + expect( + !dismissed || (await openPopup.isVisible()), + "The reopened Create link dialog remains open", + ).toBe(true); + } finally { + release.resolve(); + await browser.unroute(pairingToken); + } + }, +); From d869c1d563f7461915da8d02e9907d61bdf656aa Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Fri, 20 Nov 2026 08:27:17 +0100 Subject: [PATCH 2/6] fix(web): keep reopened pairing link dialogs open on completion Co-authored-by: GPT 6.2 Sol --- .../settings/AuthorizedClientsSettings.tsx | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/apps/web/src/components/settings/AuthorizedClientsSettings.tsx b/apps/web/src/components/settings/AuthorizedClientsSettings.tsx index f308532748c9..d44bffdc0413 100644 --- a/apps/web/src/components/settings/AuthorizedClientsSettings.tsx +++ b/apps/web/src/components/settings/AuthorizedClientsSettings.tsx @@ -3,7 +3,7 @@ import { m as resolveMessage } from "~/i18n/messages"; import { managedCapabilityDenial } from "@t3tools/client-runtime/contract-labels"; import { AUTH_SCOPE_OPTIONS as PAIRING_SCOPE_OPTIONS } from "@t3tools/shared/authScopeOptions"; import { PlugIcon, PlusIcon, QrCodeIcon } from "lucide-react"; -import { type ReactNode, memo, useId, useState } from "react"; +import { type ReactNode, memo, useId, useRef, useState } from "react"; import { T, useGT, useMessages } from "gt-react"; import { AuthAccessWriteScope, @@ -614,6 +614,7 @@ export const AuthorizedClientsHeaderAction = memo(function AuthorizedClientsHead reportFailure: false, }); const [dialogOpen, setDialogOpen] = useState(false); + const pairingDialogSessionRef = useRef(0); const [pairingLabel, setPairingLabel] = useState(""); const [pairingScopes, setPairingScopes] = useState>([ ...AuthStandardClientScopes, @@ -623,6 +624,17 @@ export const AuthorizedClientsHeaderAction = memo(function AuthorizedClientsHead const relayAdminSelected = selectedScopes.includes(AuthRelayConfigureScope); const [isCreatingPairingLink, setIsCreatingPairingLink] = useState(false); + const handlePairingDialogOpenChange = (open: boolean) => { + setDialogOpen(open); + if (!open) { + pairingDialogSessionRef.current += 1; + setPairingLabel(""); + setPairingScopes( + AuthStandardClientScopes.filter((scope) => delegatableScopes.includes(scope)), + ); + } + }; + const handleCreatePairingLink = async () => { if ( selectedScopes.length === 0 || @@ -630,6 +642,7 @@ export const AuthorizedClientsHeaderAction = memo(function AuthorizedClientsHead !selectedScopes.every((scope) => readEnvironmentScope(environmentId, scope)) ) return; + const dialogSession = pairingDialogSessionRef.current; setIsCreatingPairingLink(true); const trimmedLabel = pairingLabel.trim(); const result = await createPairingCredential({ @@ -638,11 +651,9 @@ export const AuthorizedClientsHeaderAction = memo(function AuthorizedClientsHead }); if (result._tag === "Success") { onPairingLinkCreated(result.value); - setPairingLabel(""); - setPairingScopes( - AuthStandardClientScopes.filter((scope) => delegatableScopes.includes(scope)), - ); - setDialogOpen(false); + if (dialogSession === pairingDialogSessionRef.current) { + handlePairingDialogOpenChange(false); + } } else if (!isAtomCommandInterrupted(result)) { const error = squashAtomCommandFailure(result); const message = @@ -688,15 +699,7 @@ export const AuthorizedClientsHeaderAction = memo(function AuthorizedClientsHead ) : null} { - setDialogOpen(open); - if (!open) { - setPairingLabel(""); - setPairingScopes( - AuthStandardClientScopes.filter((scope) => delegatableScopes.includes(scope)), - ); - } - }} + onOpenChange={handlePairingDialogOpenChange} > {pairingDenial === undefined ? ( Date: Fri, 20 Nov 2026 08:37:18 +0100 Subject: [PATCH 3/6] test(web): require reopening before the pairing request completes Co-authored-by: GPT 6.2 Sol --- ...iring-completion-keeps-reopened-dialog.e2e.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts b/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts index 864d84887089..5b4d77212b07 100644 --- a/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts +++ b/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts @@ -34,20 +34,16 @@ test( const openPopup = browser .locator('[data-slot="dialog-popup"][data-open]') .getByRole("heading", "Create pairing link", { exact: true }); - const dismissed = !(await openPopup.isVisible()); - if (dismissed) { - await dialog.waitFor({ state: "hidden" }); - await open.tap(); - await dialog.waitFor(); - } + await dialog.waitFor({ state: "hidden" }); + await open.tap(); + await openPopup.waitFor(); release.resolve(); await authorizedClients.getByText(label, { exact: true }).waitFor(); await app.screenshot("after-first-link-finishes"); - expect( - !dismissed || (await openPopup.isVisible()), - "The reopened Create link dialog remains open", - ).toBe(true); + expect(await openPopup.isVisible(), "The reopened Create link dialog remains open").toBe( + true, + ); } finally { release.resolve(); await browser.unroute(pairingToken); From 2913c862de3dcad778d1769e76ce5938fc0f8533 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Fri, 20 Nov 2026 08:39:51 +0100 Subject: [PATCH 4/6] test(web): wait for the original pairing dialog to close Co-authored-by: GPT 6.2 Sol --- ...ring-completion-keeps-reopened-dialog.e2e.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts b/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts index 5b4d77212b07..922d55f48ad6 100644 --- a/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts +++ b/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts @@ -34,16 +34,21 @@ test( const openPopup = browser .locator('[data-slot="dialog-popup"][data-open]') .getByRole("heading", "Create pairing link", { exact: true }); - await dialog.waitFor({ state: "hidden" }); - await open.tap(); - await openPopup.waitFor(); + await openPopup.waitFor({ state: "hidden" }); + const dismissed = !(await openPopup.isVisible()); + if (dismissed) { + await dialog.waitFor({ state: "hidden" }); + await open.tap(); + await dialog.waitFor(); + } release.resolve(); await authorizedClients.getByText(label, { exact: true }).waitFor(); await app.screenshot("after-first-link-finishes"); - expect(await openPopup.isVisible(), "The reopened Create link dialog remains open").toBe( - true, - ); + expect( + !dismissed || (await openPopup.isVisible()), + "The reopened Create link dialog remains open", + ).toBe(true); } finally { release.resolve(); await browser.unroute(pairingToken); From 120b22a548b2a6a83c345cd4065cc7195cded7cd Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Fri, 20 Nov 2026 08:41:38 +0100 Subject: [PATCH 5/6] chore: credit the models that worked on this change Co-authored-by: Claude Opus 5.5 From 4f310992757b69250f34d7352e9c6b9e96e51cd3 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 20 Nov 2026 08:03:03 +0000 Subject: [PATCH 6/6] test(web): assert the reopened pairing dialog directly The scenario's fallback for a dismissal that never closed could not run: waiting for the popup to hide already fails the step. Co-Authored-By: Claude Opus 5.5 --- ...ng-completion-keeps-reopened-dialog.e2e.ts | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts b/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts index 922d55f48ad6..6027ab461770 100644 --- a/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts +++ b/scripts/scenarios/pairing-completion-keeps-reopened-dialog.e2e.ts @@ -13,7 +13,6 @@ test( await browser.route(pairingToken, async (route) => { if (route.request.method !== "POST") return route.fallback(); requested.resolve(); - // Simulate a delayed request without replacing the server's response. await release.promise; await route.continue(); }); @@ -22,33 +21,25 @@ test( const authorizedClients = browser.locator("#authorized-clients"); const open = authorizedClients.getByRole("button", "Create link", { exact: true }); const dialog = screen.getByRole("dialog", "Create pairing link", { exact: true }); + // A closing popup keeps its role until its exit animation ends; only an open one has data-open. + const openDialog = browser + .locator('[data-slot="dialog-popup"][data-open]') + .getByRole("heading", "Create pairing link", { exact: true }); const label = "Waiting tablet"; try { await open.tap(); await dialog.getByPlaceholder("e.g. Living room iPad").fill(label); await dialog.getByRole("button", "Create link", { exact: true }).tap(); await requested.promise; - await dialog.getByRole("button", "Creating…", { exact: true }).waitFor(); await browser.keyboard.press("Escape"); - - const openPopup = browser - .locator('[data-slot="dialog-popup"][data-open]') - .getByRole("heading", "Create pairing link", { exact: true }); - await openPopup.waitFor({ state: "hidden" }); - const dismissed = !(await openPopup.isVisible()); - if (dismissed) { - await dialog.waitFor({ state: "hidden" }); - await open.tap(); - await dialog.waitFor(); - } + await dialog.waitFor({ state: "hidden" }); + await open.tap(); + await openDialog.waitFor(); release.resolve(); await authorizedClients.getByText(label, { exact: true }).waitFor(); await app.screenshot("after-first-link-finishes"); - expect( - !dismissed || (await openPopup.isVisible()), - "The reopened Create link dialog remains open", - ).toBe(true); + await expect(openDialog).toBeVisible(); } finally { release.resolve(); await browser.unroute(pairingToken);