From 9db1baa448754832e611b10a03983f5f5310128c Mon Sep 17 00:00:00 2001 From: Lin Wang Date: Fri, 26 Jan 2024 13:45:58 +0800 Subject: [PATCH] Add comments and remove only Signed-off-by: Lin Wang --- .../conversation_history_spec.js | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/cypress/integration/plugins/dashboards-assistant/conversation_history_spec.js b/cypress/integration/plugins/dashboards-assistant/conversation_history_spec.js index 324a69d0b..938b6d0d1 100644 --- a/cypress/integration/plugins/dashboards-assistant/conversation_history_spec.js +++ b/cypress/integration/plugins/dashboards-assistant/conversation_history_spec.js @@ -29,6 +29,20 @@ if (Cypress.env('DASHBOARDS_ASSISTANT_ENABLED')) { 'home:newThemeModal:show', 'false' ); + + // Open assistant flyout + cy.get('body').then(($body) => { + if ($body.find('.llm-chat-flyout').length === 0) { + /** + * Use cypress.get.click got CypressError(element detached from the DOM), like + * https://github.com/opensearch-project/opensearch-dashboards-functional-test/actions/runs/7663718989/job/20887600834 + * use native js call instead. + **/ + $body + .find('img[aria-label="toggle chat flyout icon"]') + .trigger('click'); + } + }); }); after(() => { if (restoreShowHome) { @@ -37,20 +51,19 @@ if (Cypress.env('DASHBOARDS_ASSISTANT_ENABLED')) { if (restoreNewThemeModal) { restoreNewThemeModal(); } - }); - - // beforeEach(() => { - // // Open Chat assistant flyout - // cy.get('img[aria-label="toggle chat flyout icon"]').click(); - // }); - // afterEach(() => { - // // Close Chat assistant flyout - // cy.get('img[aria-label="toggle chat flyout icon"]').click(); - // }); + // Close assistant flyout + cy.get('body').then(($body) => { + if ($body.find('.llm-chat-flyout').length !== 0) { + $body + .find('img[aria-label="toggle chat flyout icon"]') + .trigger('click'); + } + }); + }); describe('panel operations', () => { - it.only('should toggle history list', () => { + it('should toggle history list', () => { // Visit OSD cy.visit(`${BASE_PATH}/app/home`); // Common text to wait for to confirm page loaded, give up to 60 seconds for initial load @@ -74,12 +87,6 @@ if (Cypress.env('DASHBOARDS_ASSISTANT_ENABLED')) { cy.get('.llm-chat-flyout-body') .contains('Conversations') .should('not.be.visible'); - - cy.get('body').then(($body) => { - $body - .find('img[aria-label="toggle chat flyout icon"]') - .trigger('click'); - }); }); it('should back to chat panel', () => { @@ -109,7 +116,7 @@ if (Cypress.env('DASHBOARDS_ASSISTANT_ENABLED')) { cy.get('.llm-chat-flyout button[aria-label="history"]').click(); }); }); - describe.skip('history item operations', () => { + describe('history item operations', () => { const conversations = []; before(() => {