diff --git a/packages/frontend/editor-ui/src/features/credentials/components/CredentialEdit/CredentialEdit.test.ts b/packages/frontend/editor-ui/src/features/credentials/components/CredentialEdit/CredentialEdit.test.ts index 05f67034d41..1c3a3011f6b 100644 --- a/packages/frontend/editor-ui/src/features/credentials/components/CredentialEdit/CredentialEdit.test.ts +++ b/packages/frontend/editor-ui/src/features/credentials/components/CredentialEdit/CredentialEdit.test.ts @@ -1013,5 +1013,38 @@ describe('CredentialEdit', () => { expect(confirmMock).not.toHaveBeenCalled(); }); }); + + describe('switching a static credential to private', () => { + test('resets the connected state so no Disconnect button is shown', async () => { + confirmMock.mockResolvedValue('confirm'); + const pinia = createPiniaForBannerTest(); + // A static credential whose per-user connection flag leaked over from a + // prior in-session connect. Switching it to private must not carry that + // connected state over, since no end-user connection exists yet. + const credentialsStore = setupOAuthCredential({ + isResolvable: false, + connectedByMe: true, + oauthTokenData: false, + }); + + const { queryByTestId, getByTestId } = renderComponent({ + props: { + activeId: 'cred-banner', + modalName: CREDENTIAL_EDIT_MODAL_KEY, + mode: 'edit', + }, + pinia, + }); + + await retry(() => expect(credentialsStore.getCredentialData).toHaveBeenCalled()); + await retry(() => expect(getByTestId('dynamic-credentials-toggle')).toBeVisible()); + + await userEvent.click(getByTestId('dynamic-credentials-toggle')); + + await retry(() => expect(queryByTestId('oauth-not-connected-banner')).toBeVisible()); + expect(queryByTestId('oauth-connect-success-banner')).not.toBeVisible(); + expect(queryByTestId('oauth-disconnect-button')).not.toBeInTheDocument(); + }); + }); }); }); diff --git a/packages/frontend/editor-ui/src/features/credentials/components/CredentialEdit/CredentialEdit.vue b/packages/frontend/editor-ui/src/features/credentials/components/CredentialEdit/CredentialEdit.vue index c1d0a028515..ffa58969871 100644 --- a/packages/frontend/editor-ui/src/features/credentials/components/CredentialEdit/CredentialEdit.vue +++ b/packages/frontend/editor-ui/src/features/credentials/components/CredentialEdit/CredentialEdit.vue @@ -804,6 +804,11 @@ async function onResolvableChange(value: boolean) { } isResolvable.value = value; + // Switching sharing mode invalidates any carried-over connection state: a + // freshly-private credential has no per-user connection for the current + // user yet, so reset it to avoid rendering a stale "connected" state with a + // Disconnect button that has nothing to disconnect. + connectedByMe.value = false; hasUnsavedChanges.value = true; }