@@ -22,22 +22,11 @@ describe('Amazon Q Feature Dev', function () {
22
22
const fileLevelAcceptPrompt = `${ prompt } and add a license, and a contributing file`
23
23
const tooManyRequestsWaitTime = 100000
24
24
25
- function waitForButtons ( buttons : FollowUpTypes [ ] ) {
26
- return tab . waitForEvent ( ( ) => {
27
- return buttons . every ( ( value ) => tab . hasButton ( value ) )
28
- } )
29
- }
30
-
31
25
async function waitForText ( text : string ) {
32
- await tab . waitForEvent (
33
- ( ) => {
34
- return tab . getChatItems ( ) . some ( ( chatItem ) => chatItem . body === text )
35
- } ,
36
- {
37
- waitIntervalInMs : 250 ,
38
- waitTimeoutInMs : 2000 ,
39
- }
40
- )
26
+ await tab . waitForText ( text , {
27
+ waitIntervalInMs : 250 ,
28
+ waitTimeoutInMs : 2000 ,
29
+ } )
41
30
}
42
31
43
32
async function iterate ( prompt : string ) {
@@ -201,12 +190,12 @@ describe('Amazon Q Feature Dev', function () {
201
190
it ( 'Clicks accept code and click new task' , async ( ) => {
202
191
await retryIfRequired ( async ( ) => {
203
192
await Promise . any ( [
204
- waitForButtons ( [ FollowUpTypes . InsertCode , FollowUpTypes . ProvideFeedbackAndRegenerateCode ] ) ,
205
- waitForButtons ( [ FollowUpTypes . Retry ] ) ,
193
+ tab . waitForButtons ( [ FollowUpTypes . InsertCode , FollowUpTypes . ProvideFeedbackAndRegenerateCode ] ) ,
194
+ tab . waitForButtons ( [ FollowUpTypes . Retry ] ) ,
206
195
] )
207
196
} )
208
197
tab . clickButton ( FollowUpTypes . InsertCode )
209
- await waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
198
+ await tab . waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
210
199
tab . clickButton ( FollowUpTypes . NewTask )
211
200
await waitForText ( 'What new task would you like to work on?' )
212
201
assert . deepStrictEqual ( tab . getChatItems ( ) . pop ( ) ?. body , 'What new task would you like to work on?' )
@@ -215,15 +204,15 @@ describe('Amazon Q Feature Dev', function () {
215
204
it ( 'Iterates on codegen' , async ( ) => {
216
205
await retryIfRequired ( async ( ) => {
217
206
await Promise . any ( [
218
- waitForButtons ( [ FollowUpTypes . InsertCode , FollowUpTypes . ProvideFeedbackAndRegenerateCode ] ) ,
219
- waitForButtons ( [ FollowUpTypes . Retry ] ) ,
207
+ tab . waitForButtons ( [ FollowUpTypes . InsertCode , FollowUpTypes . ProvideFeedbackAndRegenerateCode ] ) ,
208
+ tab . waitForButtons ( [ FollowUpTypes . Retry ] ) ,
220
209
] )
221
210
} )
222
211
tab . clickButton ( FollowUpTypes . ProvideFeedbackAndRegenerateCode )
223
212
await tab . waitForChatFinishesLoading ( )
224
213
await iterate ( codegenApproachPrompt )
225
214
tab . clickButton ( FollowUpTypes . InsertCode )
226
- await waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
215
+ await tab . waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
227
216
} )
228
217
} )
229
218
@@ -240,8 +229,8 @@ describe('Amazon Q Feature Dev', function () {
240
229
)
241
230
await retryIfRequired ( async ( ) => {
242
231
await Promise . any ( [
243
- waitForButtons ( [ FollowUpTypes . InsertCode , FollowUpTypes . ProvideFeedbackAndRegenerateCode ] ) ,
244
- waitForButtons ( [ FollowUpTypes . Retry ] ) ,
232
+ tab . waitForButtons ( [ FollowUpTypes . InsertCode , FollowUpTypes . ProvideFeedbackAndRegenerateCode ] ) ,
233
+ tab . waitForButtons ( [ FollowUpTypes . Retry ] ) ,
245
234
] )
246
235
} )
247
236
} )
@@ -271,7 +260,7 @@ describe('Amazon Q Feature Dev', function () {
271
260
272
261
it ( 'disables all action buttons when new task is clicked' , async ( ) => {
273
262
tab . clickButton ( FollowUpTypes . InsertCode )
274
- await waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
263
+ await tab . waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
275
264
tab . clickButton ( FollowUpTypes . NewTask )
276
265
await waitForText ( 'What new task would you like to work on?' )
277
266
@@ -283,7 +272,7 @@ describe('Amazon Q Feature Dev', function () {
283
272
284
273
it ( 'disables all action buttons when close session is clicked' , async ( ) => {
285
274
tab . clickButton ( FollowUpTypes . InsertCode )
286
- await waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
275
+ await tab . waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
287
276
tab . clickButton ( FollowUpTypes . CloseSession )
288
277
await waitForText (
289
278
"Okay, I've ended this chat session. You can open a new tab to chat or start another workflow."
@@ -335,7 +324,7 @@ describe('Amazon Q Feature Dev', function () {
335
324
for ( const filePath of filePaths ) {
336
325
await clickActionButton ( filePath , 'accept-change' )
337
326
}
338
- await waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
327
+ await tab . waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
339
328
340
329
assert . ok ( tab . hasButton ( FollowUpTypes . InsertCode ) === false )
341
330
assert . ok ( tab . hasButton ( FollowUpTypes . ProvideFeedbackAndRegenerateCode ) === false )
0 commit comments