From f9181914c5ed555f7a71d1f304f00b1c87ea0e58 Mon Sep 17 00:00:00 2001 From: tygao Date: Fri, 2 Feb 2024 09:47:04 +0800 Subject: [PATCH] add case for feedback (#1029) Signed-off-by: tygao (cherry picked from commit afc3731d8f6983b3801e1c18bbd128faea3a9c43) --- .../dashboards-assistant/feedback_spec.js | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 cypress/integration/plugins/dashboards-assistant/feedback_spec.js diff --git a/cypress/integration/plugins/dashboards-assistant/feedback_spec.js b/cypress/integration/plugins/dashboards-assistant/feedback_spec.js new file mode 100644 index 000000000..8940646dc --- /dev/null +++ b/cypress/integration/plugins/dashboards-assistant/feedback_spec.js @@ -0,0 +1,60 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ +import { BASE_PATH } from '../../../utils/constants'; + +if (Cypress.env('DASHBOARDS_ASSISTANT_ENABLED')) { + describe('Assistant feedback spec', () => { + before(() => { + // Set welcome screen tracking to false + localStorage.setItem('home:welcome:show', 'false'); + // Set new theme modal to false + localStorage.setItem('home:newThemeModal:show', 'false'); + }); + + beforeEach(() => { + // Visit ISM OSD + cy.visit(`${BASE_PATH}/app/home`); + + // Common text to wait for to confirm page loaded, give up to 60 seconds for initial load + cy.get(`input[placeholder="Ask question"]`, { timeout: 60000 }).should( + 'be.length', + 1 + ); + }); + + // clean up localStorage items + after(() => { + localStorage.removeItem('home:welcome:show'); + localStorage.removeItem('home:newThemeModal:show'); + }); + + describe('conversation feedback', () => { + it('display feedback button and able to interact', () => { + // input question + cy.wait(1000); + cy.get(`input[placeholder="Ask question"]`) + .click() + .type('What are the indices in my cluster?{enter}'); + + // should have a LLM Response + cy.contains('The indices in your cluster'); + + // should have a thumb up and a thumb down feedback button + cy.get(`[aria-label="feedback thumbs up"]`).should('be.length', 1); + cy.get(`[aria-label="feedback thumbs down"]`).should('be.length', 1); + // click thumb up button to feedback + cy.get(`[aria-label="feedback thumbs up"]`).click(); + // only thumb up button displays and thumb down button is hidden + cy.get(`[aria-label="feedback thumbs down"]`).should('be.length', 0); + cy.get(`[aria-label="feedback thumbs up"]`).should('be.length', 1); + // The type of clicked button should be primary. + cy.get(`[aria-label="feedback thumbs up"]`).should( + 'have.class', + 'euiButtonIcon--primary' + ); + }); + }); + }); +}