-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathmds_chatbot_interaction_trace_spec.js
More file actions
104 lines (84 loc) · 3.29 KB
/
Copy pathmds_chatbot_interaction_trace_spec.js
File metadata and controls
104 lines (84 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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(() => {
cy.setDefaultDataSourceForAssistant();
// Set welcome screen tracking to false
localStorage.setItem('home:welcome:show', 'false');
cy.visit(`${BASE_PATH}/app/home`);
// cy.waitForLoader();
// enable to toggle and show Chatbot
cy.openAssistantChatbot();
cy.startNewAssistantConversation();
// click suggestions to generate response
cy.contains('What are the indices in my cluster?').click();
// 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(() => {
cy.clearDataSourceForAssistant();
localStorage.removeItem('home:welcome:show');
});
describe('Trace page', () => {
it('open trace page and verify page content', () => {
// click view trace button
cy.get(`[aria-label="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', 3);
cy.get('@tracePage')
.find('.euiAccordion')
// tool name
.contains('Step 2 - ListIndexTool')
.click({ force: true });
// tool output
cy.contains('row,health,status,index');
});
it('trace page display correctly in fullscreen mode', () => {
// switch to takeover mode for fullscreen
cy.get('[id="sidecarModeIcon"]').click();
cy.get(
'[data-test-subj="sidecar-mode-icon-menu-item-takeover"]'
).click();
// 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.get(`[aria-label="How was this generated?"]`).click();
// trace page opend
cy.contains('h1', 'How was this generated');
// chat page opened
cy.contains('suggestion1');
});
});
});
}