@@ -53,6 +53,13 @@ class AppTest {
5353 await this . page . locator ( '#button-save-settings' ) . click ( )
5454 }
5555
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+
5663 async newChat ( title ) {
5764 await this . page . click ( '#new-chat-button' )
5865 const newTitle = / U n t i t l e d /
@@ -145,7 +152,6 @@ test.describe('Application tests', () => {
145152 await app . selectChat ( 'Happy Hamster' )
146153 await app . selectChat ( 'Super Hamster' )
147154 await app . selectChat ( 'Smart Hamster' )
148- await app . screenshot ( 'screenshots/main.png' )
149155 } )
150156
151157 test ( 'Edit chat title' , async ( ) => {
@@ -155,16 +161,16 @@ test.describe('Application tests', () => {
155161
156162 test ( 'Show settings' , async ( ) => {
157163 await app . showSettings ( )
164+ await app . screenshot ( 'screenshots/settings.png' )
158165 } )
159166
160167 test ( 'Update settings' , async ( ) => {
161168 await app . updateSettings ( url , model )
162- await app . screenshot ( 'screenshots/settings.png' )
163169 } )
164170
165171 test ( 'Search chats' , async ( ) => {
166172 // Create chats for each country
167- for ( const name of [ 'Finland' , 'Sweden' , 'Norway' , 'Denmark' ] ) {
173+ for ( const name of [ 'Finland' , 'Sweden' , 'Canada' , ' Norway', 'Denmark' ] ) {
168174 await app . newChat ( name )
169175 }
170176
@@ -183,7 +189,7 @@ test.describe('Application tests', () => {
183189
184190 // Search for 'Sweden', and verify its visibility
185191 await app . page . fill ( '#search-input' , '' )
186- await app . page . type ( '#search-input' , 'Sweden ' )
192+ await app . page . type ( '#search-input' , 'w ' )
187193 await app . page . waitForTimeout ( 500 ) // Small delay to allow UI to update
188194 await app . screenshot ( 'screenshots/search.png' )
189195 // Check if 'Sweden' is visible
@@ -210,10 +216,7 @@ test.describe('Application tests', () => {
210216 test ( 'Send message' , async ( ) => {
211217 await app . updateSettings ( url , model )
212218 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?' )
217220 await app . screenshot ( 'screenshots/chat.png' )
218221 } )
219222
@@ -226,4 +229,29 @@ test.describe('Application tests', () => {
226229 await expect ( app . page . locator ( '#abort-button' ) ) . not . toBeVisible ( )
227230 await expect ( app . page . locator ( '#send-button' ) ) . toBeVisible ( )
228231 } )
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+ */
229257} )
0 commit comments