mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-05 02:59:27 +02:00
fix(editor): Reset connection state when switching credential to private (#31713)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
88fae045ef
commit
b2942b4b54
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user