@@ -27,6 +27,8 @@ import {
2727} from './fixtures/responses' ;
2828import { openLightspeed , sendMessage } from './utils/testHelper' ;
2929
30+ const botQuery = 'Please respond' ;
31+
3032test . beforeEach ( async ( { page } ) => {
3133 await page . route ( `${ modelBaseUrl } /v1/models` , async route => {
3234 const json = { object : 'list' , data : models } ;
@@ -37,20 +39,19 @@ test.beforeEach(async ({ page }) => {
3739 const json = [ ] ;
3840 await route . fulfill ( { json } ) ;
3941 }
40- if ( route . request ( ) . method ( ) === 'POST' ) {
41- const json = defaultConversation ;
42- await route . fulfill ( { json } ) ;
43- }
4442 } ) ;
4543 await page . route ( `${ modelBaseUrl } /conversations/user*` , async route => {
4644 const json = [ ] ;
4745 await route . fulfill ( { json } ) ;
4846 } ) ;
4947 await page . route ( `${ modelBaseUrl } /v1/query` , async route => {
5048 const payload = route . request ( ) . postDataJSON ( ) ;
51- conversations [ 0 ] . conversation_id = payload . conversation_id ;
52- contents [ 0 ] . kwargs . content = payload . query ;
53- const body = generateQueryResponse ( payload . conversation_id ) ;
49+
50+ const body = generateQueryResponse (
51+ payload . query === botQuery
52+ ? ( conversations [ 1 ] . conversation_id = payload . conversation_id )
53+ : conversations [ 0 ] . conversation_id ,
54+ ) ;
5455 await route . fulfill ( { body } ) ;
5556 } ) ;
5657
@@ -82,27 +83,26 @@ test.describe('Conversation', () => {
8283 test . beforeEach ( async ( { page } ) => {
8384 await page . route ( `${ modelBaseUrl } /conversations` , async route => {
8485 if ( route . request ( ) . method ( ) === 'GET' ) {
85- const json = conversations ;
86+ const json = { conversations } ;
8687 await route . fulfill ( { json } ) ;
8788 } else {
8889 await route . fulfill ( ) ;
8990 }
9091 } ) ;
9192 await page . route ( `${ modelBaseUrl } /conversations/user*` , async route => {
92- const json = contents ;
93+ const json = { chat_history : contents } ;
9394 await route . fulfill ( { json } ) ;
9495 } ) ;
9596 } ) ;
9697
9798 test ( 'Bot responds' , async ( { page } ) => {
98- const inputText = 'Please respond' ;
99- await sendMessage ( inputText , page ) ;
99+ await sendMessage ( botQuery , page ) ;
100100
101101 const userMessage = page . locator ( '.pf-chatbot__message--user' ) ;
102102 const botMessage = page . locator ( '.pf-chatbot__message--bot' ) ;
103103
104104 await expect ( userMessage ) . toBeVisible ( ) ;
105- await expect ( userMessage ) . toContainText ( inputText ) ;
105+ await expect ( userMessage ) . toContainText ( botQuery ) ;
106106 await expect ( botMessage ) . toBeVisible ( ) ;
107107 await expect ( botMessage ) . toContainText ( botResponse ) ;
108108 } ) ;
@@ -123,7 +123,7 @@ test.describe('Conversation', () => {
123123 test ( 'Filter and switch conversations' , async ( { page } ) => {
124124 await page . route ( `${ modelBaseUrl } /conversations` , async route => {
125125 if ( route . request ( ) . method ( ) === 'GET' ) {
126- const json = moreConversations ;
126+ const json = { conversations : moreConversations } ;
127127 await route . fulfill ( { json } ) ;
128128 } else {
129129 await route . fulfill ( ) ;
@@ -133,7 +133,7 @@ test.describe('Conversation', () => {
133133 const sidePanel = page . locator ( '.pf-v6-c-drawer__panel' ) ;
134134
135135 const currentChat = sidePanel . locator ( 'li.pf-chatbot__menu-item--active' ) ;
136- await expect ( currentChat ) . toHaveText ( moreConversations [ 0 ] . summary ) ;
136+ await expect ( currentChat ) . toHaveText ( moreConversations [ 0 ] . topic_summary ) ;
137137
138138 const chats = sidePanel . locator ( 'li.pf-chatbot__menu-item' ) ;
139139 await expect ( chats ) . toHaveCount ( 2 ) ;
@@ -143,14 +143,14 @@ test.describe('Conversation', () => {
143143 ) ;
144144 await searchBox . fill ( 'new' ) ;
145145 await expect ( chats ) . toHaveCount ( 1 ) ;
146- await expect ( chats ) . toHaveText ( moreConversations [ 1 ] . summary ) ;
146+ await expect ( chats ) . toHaveText ( moreConversations [ 1 ] . topic_summary ) ;
147147
148148 await chats . click ( ) ;
149149
150150 const userMessage = page . locator ( '.pf-chatbot__message--user' ) ;
151151 const botMessage = page . locator ( '.pf-chatbot__message--bot' ) ;
152152
153- await expect ( userMessage ) . toContainText ( contents [ 0 ] . kwargs . content ) ;
154- await expect ( botMessage ) . toContainText ( contents [ 1 ] . kwargs . content ) ;
153+ await expect ( userMessage ) . toContainText ( contents [ 0 ] . content ) ;
154+ await expect ( botMessage ) . toContainText ( contents [ 1 ] . content ) ;
155155 } ) ;
156156} ) ;
0 commit comments