|
| 1 | +/* |
| 2 | + * Copyright OpenSearch Contributors |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | +import { BASE_PATH } from '../../../utils/constants'; |
| 6 | + |
| 7 | +if (Cypress.env('DASHBOARDS_ASSISTANT_ENABLED')) { |
| 8 | + describe('Assistant feedback spec', () => { |
| 9 | + before(() => { |
| 10 | + // Set welcome screen tracking to false |
| 11 | + localStorage.setItem('home:welcome:show', 'false'); |
| 12 | + // Set new theme modal to false |
| 13 | + localStorage.setItem('home:newThemeModal:show', 'false'); |
| 14 | + }); |
| 15 | + |
| 16 | + beforeEach(() => { |
| 17 | + // Visit ISM OSD |
| 18 | + cy.visit(`${BASE_PATH}/app/home`); |
| 19 | + |
| 20 | + // Common text to wait for to confirm page loaded, give up to 60 seconds for initial load |
| 21 | + cy.get(`input[placeholder="Ask question"]`, { timeout: 60000 }).should( |
| 22 | + 'be.length', |
| 23 | + 1 |
| 24 | + ); |
| 25 | + }); |
| 26 | + |
| 27 | + // clean up localStorage items |
| 28 | + after(() => { |
| 29 | + localStorage.removeItem('home:welcome:show'); |
| 30 | + localStorage.removeItem('home:newThemeModal:show'); |
| 31 | + }); |
| 32 | + |
| 33 | + describe('conversation feedback', () => { |
| 34 | + it('display feedback button and able to interact', () => { |
| 35 | + // input question |
| 36 | + cy.wait(1000); |
| 37 | + cy.get(`input[placeholder="Ask question"]`) |
| 38 | + .click() |
| 39 | + .type('What are the indices in my cluster?{enter}'); |
| 40 | + |
| 41 | + // should have a LLM Response |
| 42 | + cy.contains('The indices in your cluster'); |
| 43 | + |
| 44 | + // should have a thumb up and a thumb down feedback button |
| 45 | + cy.get(`[aria-label="feedback thumbs up"]`).should('be.length', 1); |
| 46 | + cy.get(`[aria-label="feedback thumbs down"]`).should('be.length', 1); |
| 47 | + // click thumb up button to feedback |
| 48 | + cy.get(`[aria-label="feedback thumbs up"]`).click(); |
| 49 | + // only thumb up button displays and thumb down button is hidden |
| 50 | + cy.get(`[aria-label="feedback thumbs down"]`).should('be.length', 0); |
| 51 | + cy.get(`[aria-label="feedback thumbs up"]`).should('be.length', 1); |
| 52 | + // The type of clicked button should be primary. |
| 53 | + cy.get(`[aria-label="feedback thumbs up"]`).should( |
| 54 | + 'have.class', |
| 55 | + 'euiButtonIcon--primary' |
| 56 | + ); |
| 57 | + }); |
| 58 | + }); |
| 59 | + }); |
| 60 | +} |
0 commit comments