diff --git a/cypress/e2e/45-ai-assistant.cy.ts b/cypress/e2e/45-ai-assistant.cy.ts index 19dc5380f9..01d07cbd2b 100644 --- a/cypress/e2e/45-ai-assistant.cy.ts +++ b/cypress/e2e/45-ai-assistant.cy.ts @@ -1,10 +1,13 @@ -import { SCHEDULE_TRIGGER_NODE_NAME } from '../constants'; -import { NDV, WorkflowPage } from '../pages'; +import { clickCreateNewCredential, openCredentialSelect } from '../composables/ndv'; +import { GMAIL_NODE_NAME, SCHEDULE_TRIGGER_NODE_NAME } from '../constants'; +import { CredentialsModal, CredentialsPage, NDV, WorkflowPage } from '../pages'; import { AIAssistant } from '../pages/features/ai-assistant'; const wf = new WorkflowPage(); const ndv = new NDV(); const aiAssistant = new AIAssistant(); +const credentialsPage = new CredentialsPage(); +const credentialsModal = new CredentialsModal(); describe('AI Assistant::disabled', () => { beforeEach(() => { @@ -303,3 +306,71 @@ describe('AI Assistant::enabled', () => { aiAssistant.getters.placeholderMessage().should('not.exist'); }); }); + +describe('AI Assistant Credential Help', () => { + beforeEach(() => { + aiAssistant.actions.enableAssistant(); + wf.actions.visit(); + }); + + after(() => { + aiAssistant.actions.disableAssistant(); + }); + + it('should start credential help from node credential', () => { + cy.intercept('POST', '/rest/ai-assistant/chat', { + statusCode: 200, + fixture: 'aiAssistant/simple_message_response.json', + }).as('chatRequest'); + wf.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME); + wf.actions.addNodeToCanvas(GMAIL_NODE_NAME); + wf.actions.openNode('Gmail'); + openCredentialSelect(); + clickCreateNewCredential(); + aiAssistant.getters.credentialEditAssistantButton().should('be.visible'); + aiAssistant.getters.credentialEditAssistantButton().click(); + cy.wait('@chatRequest'); + aiAssistant.getters.chatMessagesUser().should('have.length', 1); + aiAssistant.getters + .chatMessagesUser() + .eq(0) + .should('contain.text', 'How do I set up the credentials for Gmail OAuth2 API?'); + + aiAssistant.getters + .chatMessagesAssistant() + .eq(0) + .should('contain.text', 'Hey, this is an assistant message'); + aiAssistant.getters.credentialEditAssistantButton().should('be.disabled'); + }); + + it('should start credential help from credential list', () => { + cy.intercept('POST', '/rest/ai-assistant/chat', { + statusCode: 200, + fixture: 'aiAssistant/simple_message_response.json', + }).as('chatRequest'); + + cy.visit(credentialsPage.url); + credentialsPage.getters.emptyListCreateCredentialButton().click(); + + credentialsModal.getters.newCredentialModal().should('be.visible'); + credentialsModal.getters.newCredentialTypeSelect().should('be.visible'); + credentialsModal.getters.newCredentialTypeOption('Notion API').click(); + + credentialsModal.getters.newCredentialTypeButton().click(); + + aiAssistant.getters.credentialEditAssistantButton().should('be.visible'); + aiAssistant.getters.credentialEditAssistantButton().click(); + cy.wait('@chatRequest'); + aiAssistant.getters.chatMessagesUser().should('have.length', 1); + aiAssistant.getters + .chatMessagesUser() + .eq(0) + .should('contain.text', 'How do I set up the credentials for Notion API?'); + + aiAssistant.getters + .chatMessagesAssistant() + .eq(0) + .should('contain.text', 'Hey, this is an assistant message'); + aiAssistant.getters.credentialEditAssistantButton().should('be.disabled'); + }); +}); diff --git a/cypress/pages/features/ai-assistant.ts b/cypress/pages/features/ai-assistant.ts index fe4e4d6435..8434074737 100644 --- a/cypress/pages/features/ai-assistant.ts +++ b/cypress/pages/features/ai-assistant.ts @@ -35,6 +35,8 @@ export class AIAssistant extends BasePage { codeReplacedMessage: () => cy.getByTestId('code-replaced-message'), nodeErrorViewAssistantButton: () => cy.getByTestId('node-error-view-ask-assistant-button').find('button').first(), + credentialEditAssistantButton: () => + cy.getByTestId('credentail-edit-ask-assistant-button').find('button').first(), }; actions = { diff --git a/packages/editor-ui/src/App.vue b/packages/editor-ui/src/App.vue index 03a4023119..4c849fb5d9 100644 --- a/packages/editor-ui/src/App.vue +++ b/packages/editor-ui/src/App.vue @@ -30,7 +30,7 @@ useHistoryHelper(route); const loading = ref(true); const defaultLocale = computed(() => rootStore.defaultLocale); const isDemoMode = computed(() => route.name === VIEWS.DEMO); -const showAssistantButton = computed(() => assistantStore.canShowAssistantButtons); +const showAssistantButton = computed(() => assistantStore.canShowAssistantButtonsOnCanvas); const appGrid = ref(null); diff --git a/packages/editor-ui/src/components/AskAssistant/AskAssistantChat.vue b/packages/editor-ui/src/components/AskAssistant/AskAssistantChat.vue index 732c09b903..1a13edb39b 100644 --- a/packages/editor-ui/src/components/AskAssistant/AskAssistantChat.vue +++ b/packages/editor-ui/src/components/AskAssistant/AskAssistantChat.vue @@ -33,7 +33,7 @@ async function onUserMessage(content: string, quickReplyType?: string, isFeedbac } else { await assistantStore.sendMessage({ text: content, quickReplyType }); } - const task = assistantStore.isSupportChatSessionInProgress ? 'support' : 'error'; + const task = assistantStore.chatSessionTask; const solutionCount = assistantStore.chatMessages.filter( (msg) => msg.role === 'assistant' && !['text', 'event'].includes(msg.type), ).length; diff --git a/packages/editor-ui/src/components/AskAssistant/AskAssistantFloatingButton.vue b/packages/editor-ui/src/components/AskAssistant/AskAssistantFloatingButton.vue index 853dd960fb..b147ecca9f 100644 --- a/packages/editor-ui/src/components/AskAssistant/AskAssistantFloatingButton.vue +++ b/packages/editor-ui/src/components/AskAssistant/AskAssistantFloatingButton.vue @@ -1,16 +1,12 @@