@@ -6,6 +6,7 @@ export class AgenticChatPage {
66 readonly agentGreeting : Locator ;
77 readonly chatInput : Locator ;
88 readonly sendButton : Locator ;
9+ readonly chatBackground : Locator ;
910 readonly agentMessage : Locator ;
1011 readonly userMessage : Locator ;
1112
@@ -25,6 +26,10 @@ export class AgenticChatPage {
2526 . locator ( '[data-test-id="copilot-chat-ready"]' )
2627 . or ( page . getByRole ( "button" , { name : / s e n d / i } ) )
2728 . or ( page . locator ( 'button[type="submit"]' ) ) ;
29+ this . chatBackground = page
30+ . locator ( 'div[style*="background"]' )
31+ . or ( page . locator ( '.flex.justify-center.items-center.h-full.w-full' ) )
32+ . or ( page . locator ( 'body' ) ) ;
2833 this . agentMessage = page
2934 . locator ( ".copilotKitAssistantMessage" ) ;
3035 this . userMessage = page
@@ -49,6 +54,59 @@ export class AgenticChatPage {
4954 }
5055 }
5156
57+ async getBackground (
58+ property : "backgroundColor" | "backgroundImage" = "backgroundColor"
59+ ) : Promise < string > {
60+ // Wait a bit for background to apply
61+ await this . page . waitForTimeout ( 500 ) ;
62+
63+ // Try multiple selectors for the background element
64+ const selectors = [
65+ 'div[style*="background"]' ,
66+ 'div[style*="background-color"]' ,
67+ '.flex.justify-center.items-center.h-full.w-full' ,
68+ 'div.flex.justify-center.items-center.h-full.w-full' ,
69+ '[class*="bg-"]' ,
70+ 'div[class*="background"]'
71+ ] ;
72+
73+ for ( const selector of selectors ) {
74+ try {
75+ const element = this . page . locator ( selector ) . first ( ) ;
76+ if ( await element . isVisible ( { timeout : 1000 } ) ) {
77+ const value = await element . evaluate (
78+ ( el , prop ) => {
79+ // Check inline style first
80+ if ( el . style . background ) return el . style . background ;
81+ if ( el . style . backgroundColor ) return el . style . backgroundColor ;
82+ // Then computed style
83+ return getComputedStyle ( el ) [ prop as any ] ;
84+ } ,
85+ property
86+ ) ;
87+ if ( value && value !== "rgba(0, 0, 0, 0)" && value !== "transparent" ) {
88+ console . log ( `[${ selector } ] ${ property } : ${ value } ` ) ;
89+ return value ;
90+ }
91+ }
92+ } catch ( e ) {
93+ continue ;
94+ }
95+ }
96+
97+ // Fallback to original element
98+ const value = await this . chatBackground . first ( ) . evaluate (
99+ ( el , prop ) => getComputedStyle ( el ) [ prop as any ] ,
100+ property
101+ ) ;
102+ console . log ( `[Fallback] ${ property } : ${ value } ` ) ;
103+ return value ;
104+ }
105+
106+ async getGradientButtonByName ( name : string | RegExp ) {
107+ return this . page . getByRole ( "button" , { name } ) ;
108+ }
109+
52110 async assertUserMessageVisible ( text : string | RegExp ) {
53111 await expect ( this . userMessage . getByText ( text ) ) . toBeVisible ( ) ;
54112 }
@@ -60,20 +118,25 @@ export class AgenticChatPage {
60118 await expect ( agentMessage . last ( ) ) . toBeVisible ( { timeout : 10000 } ) ;
61119 }
62120
121+ async assertAgentReplyContains ( expectedText : string ) {
122+ const agentMessage = this . page . locator ( ".copilotKitAssistantMessage" ) . last ( ) ;
123+ await expect ( agentMessage ) . toContainText ( expectedText , { timeout : 10000 } ) ;
124+ }
125+
63126 async assertWeatherResponseStructure ( ) {
64127 const agentMessage = this . page . locator ( ".copilotKitAssistantMessage" ) . last ( ) ;
65-
128+
66129 // Check for main weather response structure
67130 await expect ( agentMessage ) . toContainText ( "The current weather in Islamabad is as follows:" , { timeout : 10000 } ) ;
68-
131+
69132 // Check for temperature information
70- await expect ( agentMessage ) . toContainText ( "Temperature:" , { timeout : 5000 } ) ;
133+ await expect ( agentMessage ) . toContainText ( "Temperature:" , { timeout : 5000 } ) ;
71134 // Check for humidity
72135 await expect ( agentMessage ) . toContainText ( "Humidity:" , { timeout : 5000 } ) ;
73-
136+
74137 // Check for wind speed
75138 await expect ( agentMessage ) . toContainText ( "Wind Speed:" , { timeout : 5000 } ) ;
76139 // Check for conditions
77140 await expect ( agentMessage ) . toContainText ( "Conditions:" , { timeout : 5000 } ) ;
78141 }
79- }
142+ }
0 commit comments