@@ -6,6 +6,7 @@ export class AgenticChatPage {
6
6
readonly agentGreeting : Locator ;
7
7
readonly chatInput : Locator ;
8
8
readonly sendButton : Locator ;
9
+ readonly chatBackground : Locator ;
9
10
readonly agentMessage : Locator ;
10
11
readonly userMessage : Locator ;
11
12
@@ -25,6 +26,10 @@ export class AgenticChatPage {
25
26
. locator ( '[data-test-id="copilot-chat-ready"]' )
26
27
. or ( page . getByRole ( "button" , { name : / s e n d / i } ) )
27
28
. 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' ) ) ;
28
33
this . agentMessage = page
29
34
. locator ( ".copilotKitAssistantMessage" ) ;
30
35
this . userMessage = page
@@ -49,6 +54,59 @@ export class AgenticChatPage {
49
54
}
50
55
}
51
56
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
+
52
110
async assertUserMessageVisible ( text : string | RegExp ) {
53
111
await expect ( this . userMessage . getByText ( text ) ) . toBeVisible ( ) ;
54
112
}
@@ -60,20 +118,25 @@ export class AgenticChatPage {
60
118
await expect ( agentMessage . last ( ) ) . toBeVisible ( { timeout : 10000 } ) ;
61
119
}
62
120
121
+ async assertAgentReplyContains ( expectedText : string ) {
122
+ const agentMessage = this . page . locator ( ".copilotKitAssistantMessage" ) . last ( ) ;
123
+ await expect ( agentMessage ) . toContainText ( expectedText , { timeout : 10000 } ) ;
124
+ }
125
+
63
126
async assertWeatherResponseStructure ( ) {
64
127
const agentMessage = this . page . locator ( ".copilotKitAssistantMessage" ) . last ( ) ;
65
-
128
+
66
129
// Check for main weather response structure
67
130
await expect ( agentMessage ) . toContainText ( "The current weather in Islamabad is as follows:" , { timeout : 10000 } ) ;
68
-
131
+
69
132
// Check for temperature information
70
- await expect ( agentMessage ) . toContainText ( "Temperature:" , { timeout : 5000 } ) ;
133
+ await expect ( agentMessage ) . toContainText ( "Temperature:" , { timeout : 5000 } ) ;
71
134
// Check for humidity
72
135
await expect ( agentMessage ) . toContainText ( "Humidity:" , { timeout : 5000 } ) ;
73
-
136
+
74
137
// Check for wind speed
75
138
await expect ( agentMessage ) . toContainText ( "Wind Speed:" , { timeout : 5000 } ) ;
76
139
// Check for conditions
77
140
await expect ( agentMessage ) . toContainText ( "Conditions:" , { timeout : 5000 } ) ;
78
141
}
79
- }
142
+ }
0 commit comments