mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
fix: Hide assistant button when showing Click to connect (#10932)
This commit is contained in:
parent
f96977e6e4
commit
d74cff2030
|
@ -1,7 +1,10 @@
|
||||||
|
import { type ICredentialType } from 'n8n-workflow';
|
||||||
|
|
||||||
import { clickCreateNewCredential, openCredentialSelect } from '../composables/ndv';
|
import { clickCreateNewCredential, openCredentialSelect } from '../composables/ndv';
|
||||||
import { GMAIL_NODE_NAME, SCHEDULE_TRIGGER_NODE_NAME } from '../constants';
|
import { GMAIL_NODE_NAME, SCHEDULE_TRIGGER_NODE_NAME } from '../constants';
|
||||||
import { CredentialsModal, CredentialsPage, NDV, WorkflowPage } from '../pages';
|
import { CredentialsModal, CredentialsPage, NDV, WorkflowPage } from '../pages';
|
||||||
import { AIAssistant } from '../pages/features/ai-assistant';
|
import { AIAssistant } from '../pages/features/ai-assistant';
|
||||||
|
import { getVisibleSelect } from '../utils';
|
||||||
|
|
||||||
const wf = new WorkflowPage();
|
const wf = new WorkflowPage();
|
||||||
const ndv = new NDV();
|
const ndv = new NDV();
|
||||||
|
@ -327,8 +330,8 @@ describe('AI Assistant Credential Help', () => {
|
||||||
wf.actions.openNode('Gmail');
|
wf.actions.openNode('Gmail');
|
||||||
openCredentialSelect();
|
openCredentialSelect();
|
||||||
clickCreateNewCredential();
|
clickCreateNewCredential();
|
||||||
aiAssistant.getters.credentialEditAssistantButton().should('be.visible');
|
aiAssistant.getters.credentialEditAssistantButton().find('button').should('be.visible');
|
||||||
aiAssistant.getters.credentialEditAssistantButton().click();
|
aiAssistant.getters.credentialEditAssistantButton().find('button').click();
|
||||||
cy.wait('@chatRequest');
|
cy.wait('@chatRequest');
|
||||||
aiAssistant.getters.chatMessagesUser().should('have.length', 1);
|
aiAssistant.getters.chatMessagesUser().should('have.length', 1);
|
||||||
aiAssistant.getters
|
aiAssistant.getters
|
||||||
|
@ -340,7 +343,7 @@ describe('AI Assistant Credential Help', () => {
|
||||||
.chatMessagesAssistant()
|
.chatMessagesAssistant()
|
||||||
.eq(0)
|
.eq(0)
|
||||||
.should('contain.text', 'Hey, this is an assistant message');
|
.should('contain.text', 'Hey, this is an assistant message');
|
||||||
aiAssistant.getters.credentialEditAssistantButton().should('be.disabled');
|
aiAssistant.getters.credentialEditAssistantButton().find('button').should('be.disabled');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should start credential help from credential list', () => {
|
it('should start credential help from credential list', () => {
|
||||||
|
@ -358,8 +361,8 @@ describe('AI Assistant Credential Help', () => {
|
||||||
|
|
||||||
credentialsModal.getters.newCredentialTypeButton().click();
|
credentialsModal.getters.newCredentialTypeButton().click();
|
||||||
|
|
||||||
aiAssistant.getters.credentialEditAssistantButton().should('be.visible');
|
aiAssistant.getters.credentialEditAssistantButton().find('button').should('be.visible');
|
||||||
aiAssistant.getters.credentialEditAssistantButton().click();
|
aiAssistant.getters.credentialEditAssistantButton().find('button').click();
|
||||||
cy.wait('@chatRequest');
|
cy.wait('@chatRequest');
|
||||||
aiAssistant.getters.chatMessagesUser().should('have.length', 1);
|
aiAssistant.getters.chatMessagesUser().should('have.length', 1);
|
||||||
aiAssistant.getters
|
aiAssistant.getters
|
||||||
|
@ -371,7 +374,68 @@ describe('AI Assistant Credential Help', () => {
|
||||||
.chatMessagesAssistant()
|
.chatMessagesAssistant()
|
||||||
.eq(0)
|
.eq(0)
|
||||||
.should('contain.text', 'Hey, this is an assistant message');
|
.should('contain.text', 'Hey, this is an assistant message');
|
||||||
aiAssistant.getters.credentialEditAssistantButton().should('be.disabled');
|
aiAssistant.getters.credentialEditAssistantButton().find('button').should('be.disabled');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not show assistant button when click to connect', () => {
|
||||||
|
cy.intercept('/types/credentials.json', { middleware: true }, (req) => {
|
||||||
|
req.headers['cache-control'] = 'no-cache, no-store';
|
||||||
|
|
||||||
|
req.on('response', (res) => {
|
||||||
|
const credentials: ICredentialType[] = res.body || [];
|
||||||
|
|
||||||
|
const index = credentials.findIndex((c) => c.name === 'slackOAuth2Api');
|
||||||
|
|
||||||
|
credentials[index] = {
|
||||||
|
...credentials[index],
|
||||||
|
__overwrittenProperties: ['clientId', 'clientSecret'],
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
wf.actions.visit(true);
|
||||||
|
wf.actions.addNodeToCanvas('Manual');
|
||||||
|
wf.actions.addNodeToCanvas('Slack', true, true, 'Get a channel');
|
||||||
|
wf.getters.nodeCredentialsSelect().should('exist');
|
||||||
|
wf.getters.nodeCredentialsSelect().click();
|
||||||
|
getVisibleSelect().find('li').last().click();
|
||||||
|
credentialsModal.getters.credentialAuthTypeRadioButtons().first().click();
|
||||||
|
ndv.getters.copyInput().should('not.exist');
|
||||||
|
credentialsModal.getters.oauthConnectButton().should('have.length', 1);
|
||||||
|
credentialsModal.getters.credentialInputs().should('have.length', 0);
|
||||||
|
aiAssistant.getters.credentialEditAssistantButton().should('not.exist');
|
||||||
|
|
||||||
|
credentialsModal.getters.credentialAuthTypeRadioButtons().eq(1).click();
|
||||||
|
credentialsModal.getters.credentialInputs().should('have.length', 1);
|
||||||
|
aiAssistant.getters.credentialEditAssistantButton().should('exist');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not show assistant button when click to connect with some fields', () => {
|
||||||
|
cy.intercept('/types/credentials.json', { middleware: true }, (req) => {
|
||||||
|
req.headers['cache-control'] = 'no-cache, no-store';
|
||||||
|
|
||||||
|
req.on('response', (res) => {
|
||||||
|
const credentials: ICredentialType[] = res.body || [];
|
||||||
|
|
||||||
|
const index = credentials.findIndex((c) => c.name === 'microsoftOutlookOAuth2Api');
|
||||||
|
|
||||||
|
credentials[index] = {
|
||||||
|
...credentials[index],
|
||||||
|
__overwrittenProperties: ['authUrl', 'accessTokenUrl', 'clientId', 'clientSecret'],
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
wf.actions.visit(true);
|
||||||
|
wf.actions.addNodeToCanvas('Manual');
|
||||||
|
wf.actions.addNodeToCanvas('Microsoft Outlook', true, true, 'Get a calendar');
|
||||||
|
wf.getters.nodeCredentialsSelect().should('exist');
|
||||||
|
wf.getters.nodeCredentialsSelect().click();
|
||||||
|
getVisibleSelect().find('li').last().click();
|
||||||
|
ndv.getters.copyInput().should('not.exist');
|
||||||
|
credentialsModal.getters.oauthConnectButton().should('have.length', 1);
|
||||||
|
credentialsModal.getters.credentialInputs().should('have.length', 1);
|
||||||
|
aiAssistant.getters.credentialEditAssistantButton().should('not.exist');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,7 @@ export class AIAssistant extends BasePage {
|
||||||
codeReplacedMessage: () => cy.getByTestId('code-replaced-message'),
|
codeReplacedMessage: () => cy.getByTestId('code-replaced-message'),
|
||||||
nodeErrorViewAssistantButton: () =>
|
nodeErrorViewAssistantButton: () =>
|
||||||
cy.getByTestId('node-error-view-ask-assistant-button').find('button').first(),
|
cy.getByTestId('node-error-view-ask-assistant-button').find('button').first(),
|
||||||
credentialEditAssistantButton: () =>
|
credentialEditAssistantButton: () => cy.getByTestId('credential-edit-ask-assistant-button'),
|
||||||
cy.getByTestId('credentail-edit-ask-assistant-button').find('button').first(),
|
|
||||||
codeSnippet: () => cy.getByTestId('assistant-code-snippet-content'),
|
codeSnippet: () => cy.getByTestId('assistant-code-snippet-content'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,7 @@ const isAskAssistantAvailable = computed(
|
||||||
documentationUrl.value.includes(DOCS_DOMAIN) &&
|
documentationUrl.value.includes(DOCS_DOMAIN) &&
|
||||||
props.credentialProperties.length &&
|
props.credentialProperties.length &&
|
||||||
props.credentialPermissions.update &&
|
props.credentialPermissions.update &&
|
||||||
|
!(props.isOAuthType && props.requiredPropertiesFilled) &&
|
||||||
assistantStore.isAssistantEnabled,
|
assistantStore.isAssistantEnabled,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -322,7 +323,7 @@ watch(showOAuthSuccessBanner, (newValue, oldValue) => {
|
||||||
<div
|
<div
|
||||||
v-if="isAskAssistantAvailable"
|
v-if="isAskAssistantAvailable"
|
||||||
:class="$style.askAssistantButton"
|
:class="$style.askAssistantButton"
|
||||||
data-test-id="credentail-edit-ask-assistant-button"
|
data-test-id="credential-edit-ask-assistant-button"
|
||||||
>
|
>
|
||||||
<InlineAskAssistantButton :asked="assistantAlreadyAsked" @click="onAskAssistantClick" />
|
<InlineAskAssistantButton :asked="assistantAlreadyAsked" @click="onAskAssistantClick" />
|
||||||
<span>for setup instructions</span>
|
<span>for setup instructions</span>
|
||||||
|
|
Loading…
Reference in a new issue