@@ -53,6 +53,13 @@ class AppTest {
53
53
await this . page . locator ( '#button-save-settings' ) . click ( )
54
54
}
55
55
56
+ async sendMessage ( message ) {
57
+ await this . page . fill ( '#message-input' , message )
58
+ await this . page . click ( '#send-button' )
59
+ await expect ( this . page . locator ( '#abort-button' ) ) . toBeVisible ( )
60
+ await this . page . waitForSelector ( '#send-button' , { timeout : 60000 } )
61
+ }
62
+
56
63
async newChat ( title ) {
57
64
await this . page . click ( '#new-chat-button' )
58
65
const newTitle = / U n t i t l e d /
@@ -145,7 +152,6 @@ test.describe('Application tests', () => {
145
152
await app . selectChat ( 'Happy Hamster' )
146
153
await app . selectChat ( 'Super Hamster' )
147
154
await app . selectChat ( 'Smart Hamster' )
148
- await app . screenshot ( 'screenshots/main.png' )
149
155
} )
150
156
151
157
test ( 'Edit chat title' , async ( ) => {
@@ -155,16 +161,16 @@ test.describe('Application tests', () => {
155
161
156
162
test ( 'Show settings' , async ( ) => {
157
163
await app . showSettings ( )
164
+ await app . screenshot ( 'screenshots/settings.png' )
158
165
} )
159
166
160
167
test ( 'Update settings' , async ( ) => {
161
168
await app . updateSettings ( url , model )
162
- await app . screenshot ( 'screenshots/settings.png' )
163
169
} )
164
170
165
171
test ( 'Search chats' , async ( ) => {
166
172
// Create chats for each country
167
- for ( const name of [ 'Finland' , 'Sweden' , 'Norway' , 'Denmark' ] ) {
173
+ for ( const name of [ 'Finland' , 'Sweden' , 'Canada' , ' Norway', 'Denmark' ] ) {
168
174
await app . newChat ( name )
169
175
}
170
176
@@ -183,7 +189,7 @@ test.describe('Application tests', () => {
183
189
184
190
// Search for 'Sweden', and verify its visibility
185
191
await app . page . fill ( '#search-input' , '' )
186
- await app . page . type ( '#search-input' , 'Sweden ' )
192
+ await app . page . type ( '#search-input' , 'w ' )
187
193
await app . page . waitForTimeout ( 500 ) // Small delay to allow UI to update
188
194
await app . screenshot ( 'screenshots/search.png' )
189
195
// Check if 'Sweden' is visible
@@ -210,10 +216,7 @@ test.describe('Application tests', () => {
210
216
test ( 'Send message' , async ( ) => {
211
217
await app . updateSettings ( url , model )
212
218
await app . editChatTitle ( 'What is 10+10?' )
213
- await app . page . fill ( '#message-input' , 'What is 10+10?' )
214
- await app . page . click ( '#send-button' )
215
- await expect ( app . page . locator ( '#abort-button' ) ) . toBeVisible ( )
216
- await app . page . waitForSelector ( '#send-button' , { timeout : 60000 } )
219
+ await app . sendMessage ( 'What is 10+10?' )
217
220
await app . screenshot ( 'screenshots/chat.png' )
218
221
} )
219
222
@@ -226,4 +229,29 @@ test.describe('Application tests', () => {
226
229
await expect ( app . page . locator ( '#abort-button' ) ) . not . toBeVisible ( )
227
230
await expect ( app . page . locator ( '#send-button' ) ) . toBeVisible ( )
228
231
} )
232
+
233
+ /*
234
+ TODO:
235
+ test('Download chat', async () => {
236
+ await app.updateSettings(url, model)
237
+ await app.sendMessage('What is 10+10?')
238
+
239
+ // Set up a listener for the download event
240
+ const [ download ] = await Promise.all([
241
+ // It's important to set up the listener before triggering the download
242
+ app.page.waitForEvent('download'),
243
+ // Trigger the download here
244
+ app.page.click('.download-button')
245
+ ])
246
+
247
+ // Wait for the download to complete
248
+ const path = await download.path()
249
+
250
+ // Verify the download (e.g., check file name, size, etc.)
251
+ console.log(`Downloaded file: ${path}`)
252
+
253
+ // Optional: Check the download's filename
254
+ console.log(`Downloaded filename: ${download.suggestedFilename()}`)
255
+ })
256
+ */
229
257
} )
0 commit comments