1616
1717import { test , expect , Page } from '@playwright/test' ;
1818import {
19- models as fakeModels ,
19+ models ,
2020 conversations ,
2121 contents ,
2222 demoChatContent ,
@@ -118,8 +118,6 @@ import { runAccessibilityTests } from './utils/accessibility';
118118
119119test . describe ( 'Lightspeed tests' , ( ) => {
120120 const botQuery = 'Please respond' ;
121- const devMode = ! process . env . PLAYWRIGHT_URL ;
122- let models = fakeModels ;
123121 let translations : LightspeedMessages ;
124122 let sharedPage : Page ;
125123 let locale : string ;
@@ -130,21 +128,12 @@ test.describe('Lightspeed tests', () => {
130128 locale = await sharedPage . evaluate ( ( ) => globalThis . navigator . language ) ;
131129 translations = getTranslations ( locale ) ;
132130
133- if ( ! devMode ) {
134- const response = await fetch ( `${ process . env . LIGHTSPEED_URL } /models` , {
135- headers : {
136- Authorization : `Bearer ${ process . env . LIGHTSPEED_API_KEY } ` ,
137- } ,
138- } ) ;
139- models = ( await response . json ( ) ) . data ;
140- } else {
141- await mockModels ( sharedPage , models ) ;
142- await mockConversations ( sharedPage ) ;
143- await mockChatHistory ( sharedPage ) ;
144- await mockQuery ( sharedPage , botQuery , conversations ) ;
145- await mockShields ( sharedPage , mockedShields ) ;
146- await mockFeedbackStatus ( sharedPage ) ;
147- }
131+ await mockModels ( sharedPage , models ) ;
132+ await mockConversations ( sharedPage ) ;
133+ await mockChatHistory ( sharedPage ) ;
134+ await mockQuery ( sharedPage , botQuery , conversations ) ;
135+ await mockShields ( sharedPage , mockedShields ) ;
136+ await mockFeedbackStatus ( sharedPage ) ;
148137
149138 await sharedPage . goto ( '/' ) ;
150139 await login ( sharedPage , process . env . RHDH_USER , process . env . RHDH_PASSWORD ) ;
@@ -200,11 +189,6 @@ test.describe('Lightspeed tests', () => {
200189
201190 test ( 'Lightspeed is available' , async ( { browser } , testInfo ) => {
202191 expect ( sharedPage . url ( ) ) . toContain ( '/lightspeed' ) ;
203- if ( devMode ) {
204- expect ( await sharedPage . title ( ) ) . toContain (
205- translations [ 'chatbox.header.title' ] ,
206- ) ;
207- }
208192
209193 const headings = sharedPage . getByRole ( 'heading' ) ;
210194 await expect ( headings . first ( ) ) . toContainText (
@@ -241,7 +225,7 @@ test.describe('Lightspeed tests', () => {
241225 browser,
242226 } , testInfo ) => {
243227 await test . step ( 'Verify initial state of sidebar' , async ( ) => {
244- await assertChatDialogInitialState ( sharedPage , translations , devMode ) ;
228+ await assertChatDialogInitialState ( sharedPage , translations ) ;
245229 } ) ;
246230
247231 await test . step ( 'Close the sidebar and verify elements are hidden' , async ( ) => {
@@ -257,15 +241,22 @@ test.describe('Lightspeed tests', () => {
257241 } ) ;
258242
259243 test ( 'verify default prompts are visible' , async ( ) => {
244+ const greeting = evaluateMessage (
245+ translations [ 'chatbox.welcome.greeting' ] ,
246+ translations [ 'user.guest' ] ,
247+ ) ;
260248 await expect ( sharedPage . getByLabel ( 'Scrollable message log' ) )
261249 . toMatchAriaSnapshot ( `
262- - heading /${ evaluateMessage ( translations [ 'chatbox.welcome.greeting' ] , '' ) } .+ ${ translations [ 'chatbox.welcome.description' ] } / [level=1]
263- - button
264- - text: ''
265- - button
266- - text: ''
267- - button
268- - text: ''
250+ - region "Scrollable message log":
251+ - 'heading "Info alert: ${ translations [ 'aria.important' ] } " [level=4]'
252+ - text: ${ translations [ 'disclaimer.withValidation' ] }
253+ - heading "${ greeting } ${ translations [ 'chatbox.welcome.description' ] } " [level=1]
254+ - button /.+/
255+ - text: /.+/
256+ - button /.+/
257+ - text: /.+/
258+ - button /.+/
259+ - text: /.+/
269260 ` ) ;
270261 const messageLog = sharedPage . locator ( 'div.pf-v6-c-card__title-text' ) ;
271262 const textContents = await messageLog . allTextContents ( ) ;
@@ -333,14 +324,11 @@ test.describe('Lightspeed tests', () => {
333324 } ) ;
334325 } ) ;
335326
336- const describeFn = devMode ? test . describe : test . describe . serial ;
337- describeFn ( 'Conversation' , ( ) => {
338- if ( devMode ) {
339- test . beforeEach ( async ( ) => {
340- await mockConversations ( sharedPage , conversations , true ) ;
341- await mockChatHistory ( sharedPage , contents ) ;
342- } ) ;
343- }
327+ test . describe ( 'Conversation' , ( ) => {
328+ test . beforeEach ( async ( ) => {
329+ await mockConversations ( sharedPage , conversations , true ) ;
330+ await mockChatHistory ( sharedPage , contents ) ;
331+ } ) ;
344332
345333 test ( 'Bot response, feedback submission, and copy to clipboard' , async ( ) => {
346334 await sendMessage ( botQuery , sharedPage , translations ) ;
@@ -352,17 +340,13 @@ test.describe('Lightspeed tests', () => {
352340 await expect ( userMessage ) . toBeVisible ( ) ;
353341 await expect ( userMessage ) . toContainText ( botQuery ) ;
354342
355- const response = devMode
356- ? botResponse
357- : `I'm the Red Hat Developer Hub Lightspeed assistant` ;
358-
359343 await expect ( botMessage ) . toBeVisible ( ) ;
360- await expect ( botMessage ) . toContainText ( response ) ;
344+ await expect ( botMessage ) . toContainText ( botResponse ) ;
361345 await verifyFeedbackButtons ( sharedPage ) ;
362- await submitFeedback ( sharedPage , 'Good response' , devMode , translations ) ;
363- await submitFeedback ( sharedPage , 'Bad response' , devMode , translations ) ;
346+ await submitFeedback ( sharedPage , 'Good response' , translations ) ;
347+ await submitFeedback ( sharedPage , 'Bad response' , translations ) ;
364348 await copyButton . click ( ) ;
365- await assertClipboardContains ( sharedPage , response ) ;
349+ await assertClipboardContains ( sharedPage , botResponse ) ;
366350 } ) ;
367351
368352 test ( 'Conversation is created and shown in side panel' , async ( ) => {
@@ -390,17 +374,9 @@ test.describe('Lightspeed tests', () => {
390374 test ( 'Verify scroll controls in Conversation' , async ( {
391375 browser,
392376 } , testInfo ) => {
393- if ( devMode ) {
394- await mockChatHistory ( sharedPage , demoChatContent ) ;
395- }
377+ await mockChatHistory ( sharedPage , demoChatContent ) ;
396378
397- let message = demoChatContent [ 0 ] . messages [ 0 ] . content ;
398- if ( ! devMode ) {
399- message =
400- ( await sharedPage
401- . locator ( '.pf-v6-c-card__body' , { hasText : 'Tekton' } )
402- . textContent ( ) ) || '' ;
403- }
379+ const message = demoChatContent [ 0 ] . messages [ 0 ] . content ;
404380 await sendMessage ( message , sharedPage , translations , false ) ;
405381
406382 const jumpTopButton = sharedPage . getByRole ( 'button' , {
@@ -422,44 +398,28 @@ test.describe('Lightspeed tests', () => {
422398 await expect ( jumpBottomButton ) . toBeVisible ( ) ;
423399 await jumpBottomButton . click ( ) ;
424400
425- const responseText = devMode ? / O p e n S h i f t d e p l o y m e n t / : / T e k t o n / ;
426401 const responseMessage = sharedPage
427402 . locator ( 'div.pf-chatbot__message-response' )
428403 . last ( ) ;
429- await expect ( responseMessage ) . toHaveText ( responseText ) ;
404+ await expect ( responseMessage ) . toHaveText ( / O p e n S h i f t d e p l o y m e n t / ) ;
430405 } ) ;
431406
432407 test ( 'Filter and switch conversations' , async ( ) => {
433- if ( devMode ) {
434- await mockConversations ( sharedPage , moreConversations ) ;
435- }
408+ await mockConversations ( sharedPage , moreConversations ) ;
436409 await sendMessage ( 'test' , sharedPage , translations ) ;
437410 const sidePanel = sharedPage . locator ( '.pf-v6-c-drawer__panel-main' ) ;
438411
439412 const currentChat = sidePanel . locator ( 'li.pf-chatbot__menu-item--active' ) ;
440- await expect ( currentChat ) . toHaveText (
441- devMode ? moreConversations [ 0 ] . topic_summary : / < [ \w \s ] + t o p i c [ \w \s ] * > / ,
442- ) ;
413+ await expect ( currentChat ) . toHaveText ( moreConversations [ 0 ] . topic_summary ) ;
443414
444415 const chats = sidePanel . locator ( 'li.pf-chatbot__menu-item' ) ;
445- if ( devMode ) {
446- await expect ( chats ) . toHaveCount ( 3 ) ;
447- } else {
448- expect ( await chats . count ( ) ) . toBeGreaterThanOrEqual ( 1 ) ;
449- await sharedPage
450- . getByRole ( 'button' , { name : translations [ 'button.newChat' ] } )
451- . click ( ) ;
452- await sendMessage ( 'tell me about Backstage' , sharedPage , translations ) ;
453- await verifySidePanelConversation ( sharedPage , translations ) ;
454- }
416+ await expect ( chats ) . toHaveCount ( 3 ) ;
455417
456- const searchText = devMode
457- ? moreConversations [ 1 ] . topic_summary
458- : 'Backstage' ;
418+ const searchText = moreConversations [ 1 ] . topic_summary ;
459419 const searchBox = sidePanel . getByPlaceholder (
460420 translations [ 'chatbox.search.placeholder' ] ,
461421 ) ;
462- await searchBox . fill ( devMode ? 'new' : 'Backstage ') ;
422+ await searchBox . fill ( 'new' ) ;
463423 const validChat = sidePanel
464424 . locator ( 'li.pf-chatbot__menu-item' )
465425 . filter ( { hasText : searchText } )
@@ -479,18 +439,11 @@ test.describe('Lightspeed tests', () => {
479439 const userMessage = sharedPage . locator ( '.pf-chatbot__message--user' ) ;
480440 const botMessage = sharedPage . locator ( '.pf-chatbot__message--bot' ) ;
481441
482- await expect ( userMessage ) . toContainText (
483- devMode ? contents [ 0 ] . messages [ 0 ] . content : 'tell me about Backstage' ,
484- ) ;
485- await expect ( botMessage ) . toContainText (
486- devMode ? assistantResponse : 'Backstage' ,
487- ) ;
442+ await expect ( userMessage ) . toContainText ( contents [ 0 ] . messages [ 0 ] . content ) ;
443+ await expect ( botMessage ) . toContainText ( assistantResponse ) ;
488444 } ) ;
489445
490- const chatManagementDescribeFn = devMode
491- ? test . describe
492- : test . describe . skip ;
493- chatManagementDescribeFn ( 'Chat Management' , ( ) => {
446+ test . describe ( 'Chat Management' , ( ) => {
494447 const testChatName = 'Test Rename' ;
495448
496449 test ( 'Verify chat actions menu' , async ( ) => {
0 commit comments