-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functional test for dashboard assistant trace page (opensearch-pr…
…oject#1012) * Add functional test for trace page Signed-off-by: Hailong Cui <[email protected]> * update to ask question direclty instead of click Signed-off-by: Hailong Cui <[email protected]> * replace focus with click Signed-off-by: Hailong Cui <[email protected]> * add wait before input Signed-off-by: Hailong Cui <[email protected]> * address review comments Signed-off-by: Hailong Cui <[email protected]> --------- Signed-off-by: Hailong Cui <[email protected]> (cherry picked from commit 32cba83)
- Loading branch information
1 parent
58923a4
commit a50d2c4
Showing
3 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
cypress/fixtures/plugins/dashboards-assistant/agent-framework-thought-response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"completion": " ```json\n{\n \"thought\": \"Thought: Let me use tool to figure out\",\n \"action\": \"CatIndexTool\",\n \"action_input\": \"\"}\n```\n", | ||
"stop_reason": "stop_sequence", | ||
"stop": "\n\nHuman:" | ||
} |
104 changes: 104 additions & 0 deletions
104
cypress/integration/plugins/dashboards-assistant/chatbot_interaction_trace_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { BASE_PATH } from '../../../utils/constants'; | ||
|
||
if (Cypress.env('DASHBOARDS_ASSISTANT_ENABLED')) { | ||
describe('Interaction trace 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'); | ||
|
||
cy.visit(`${BASE_PATH}/app/home`); | ||
// cy.waitForLoader(); | ||
|
||
// Common text to wait for to confirm page loaded, give up to 120 seconds for initial load | ||
cy.get(`input[placeholder="Ask question"]`, { timeout: 120000 }).as( | ||
'chatInput' | ||
); | ||
cy.get('@chatInput').should('be.length', 1); | ||
|
||
cy.wait(1000); | ||
|
||
cy.get('@chatInput') | ||
.click() | ||
.type('What are the indices in my cluster?{enter}'); | ||
|
||
// should have a LLM Response | ||
cy.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.' | ||
); | ||
}); | ||
|
||
// clean up localStorage items | ||
after(() => { | ||
localStorage.removeItem('home:welcome:show'); | ||
localStorage.removeItem('home:newThemeModal:show'); | ||
}); | ||
|
||
describe('Trace page', () => { | ||
it('open trace page and verify page content', () => { | ||
// click How was this generated? to view trace | ||
cy.contains('How was this generated?').click(); | ||
|
||
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('@tracePage') | ||
.find(`button[aria-label="close"]`) | ||
.should('have.length', 0); | ||
|
||
// title | ||
cy.get('@tracePage').contains('h1', 'How was this generated'); | ||
|
||
// question | ||
cy.get('@tracePage').contains('What are the indices in my cluster?'); | ||
|
||
// result | ||
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`).as('tracePage'); | ||
cy.get('@tracePage').find('.euiAccordion').should('have.length', 1); | ||
|
||
cy.get('@tracePage') | ||
.find('.euiAccordion') | ||
// tool name | ||
.contains('Step 1 - CatIndexTool') | ||
.click({ force: true }); | ||
|
||
// tool output | ||
cy.contains('Output: health status index'); | ||
}); | ||
|
||
it('trace page display correctly in fullscreen mode', () => { | ||
cy.get(`.llm-chat-flyout-header`) | ||
.find(`button[aria-label="fullScreen"]`) | ||
.click({ force: true }); | ||
|
||
// show close button | ||
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('@tracePage') | ||
.find(`button[aria-label="back"]`) | ||
.should('have.length', 0); | ||
|
||
// both chat and trace are both displayed | ||
cy.contains('How was this generated?').click(); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters