From a92112258117fe2726c5c91ed7c9c77b67c5a57f Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Fri, 26 Jan 2024 19:03:56 +0800 Subject: [PATCH] add wait before input Signed-off-by: Hailong Cui --- .../chatbot_agent_framework_spec.js | 1 + .../chatbot_interaction_trace_spec.js | 38 +++++++++---------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/cypress/integration/plugins/dashboards-assistant/chatbot_agent_framework_spec.js b/cypress/integration/plugins/dashboards-assistant/chatbot_agent_framework_spec.js index a9f8b5699..82e26c306 100644 --- a/cypress/integration/plugins/dashboards-assistant/chatbot_agent_framework_spec.js +++ b/cypress/integration/plugins/dashboards-assistant/chatbot_agent_framework_spec.js @@ -27,6 +27,7 @@ if (Cypress.env('DASHBOARDS_ASSISTANT_ENABLED')) { describe('Interact with Agent framework', () => { it('toggle Chatbot and enable to interact', () => { // input question + cy.wait(1000); cy.get(`input[placeholder="Ask question"]`) .click() .type('What are the indices in my cluster?{enter}'); diff --git a/cypress/integration/plugins/dashboards-assistant/chatbot_interaction_trace_spec.js b/cypress/integration/plugins/dashboards-assistant/chatbot_interaction_trace_spec.js index 163a55bb3..e9b692cf2 100644 --- a/cypress/integration/plugins/dashboards-assistant/chatbot_interaction_trace_spec.js +++ b/cypress/integration/plugins/dashboards-assistant/chatbot_interaction_trace_spec.js @@ -17,12 +17,14 @@ if (Cypress.env('DASHBOARDS_ASSISTANT_ENABLED')) { // cy.waitForLoader(); // Common text to wait for to confirm page loaded, give up to 60 seconds for initial load - cy.get(`input[placeholder="Ask question"]`, { timeout: 120000 }).should( - 'be.length', - 1 + cy.get(`input[placeholder="Ask question"]`, { timeout: 120000 }).as( + 'chatInput' ); + cy.get('@chatInput').should('be.length', 1); - cy.get(`input[placeholder="Ask question"]`) + cy.wait(1000); + + cy.get('@chatInput') .click() .type('What are the indices in my cluster?{enter}'); @@ -37,38 +39,33 @@ if (Cypress.env('DASHBOARDS_ASSISTANT_ENABLED')) { // click How was this generated? to view trace cy.contains('How was this generated?').click(); - cy.get(`.llm-chat-flyout .llm-chat-flyout-body`) + cy.get(`.llm-chat-flyout .llm-chat-flyout-body`).as('tracePage'); + cy.get('@tracePage') .find(`button[aria-label="back"]`) .should('have.length', 1); - cy.get(`.llm-chat-flyout .llm-chat-flyout-body`) + cy.get('@tracePage') .find(`button[aria-label="close"]`) .should('have.length', 0); // title - cy.get(`.llm-chat-flyout .llm-chat-flyout-body`).contains( - 'h1', - 'How was this generated' - ); + cy.get('@tracePage').contains('h1', 'How was this generated'); // question - cy.get(`.llm-chat-flyout .llm-chat-flyout-body`).contains( - 'What are the indices in my cluster?' - ); + cy.get('@tracePage').contains('What are the indices in my cluster?'); // result - cy.get(`.llm-chat-flyout .llm-chat-flyout-body`).contains( + cy.get('@tracePage').contains( 'The indices in your cluster are the names listed in the response obtained from using a tool to get information about the OpenSearch indices.' ); }); it('tools invocation displayed in trace steps', () => { // trace - cy.get(`.llm-chat-flyout .llm-chat-flyout-body`) - .find('.euiAccordion') - .should('have.length', 1); + cy.get(`.llm-chat-flyout .llm-chat-flyout-body`).as('tracePage'); + cy.get('@tracePage').find('.euiAccordion').should('have.length', 1); - cy.get(`.llm-chat-flyout .llm-chat-flyout-body`) + cy.get('@tracePage') .find('.euiAccordion') // tool name .contains('Step 1 - CatIndexTool') @@ -84,11 +81,12 @@ if (Cypress.env('DASHBOARDS_ASSISTANT_ENABLED')) { .click({ force: true }); // show close button - cy.get(`.llm-chat-flyout .llm-chat-flyout-body`) + cy.get(`.llm-chat-flyout .llm-chat-flyout-body`).as('tracePage'); + cy.get('@tracePage') .find(`button[aria-label="close"]`) .should('have.length', 1); - cy.get(`.llm-chat-flyout .llm-chat-flyout-body`) + cy.get('@tracePage') .find(`button[aria-label="back"]`) .should('have.length', 0);