@@ -22,22 +22,11 @@ describe('Amazon Q Feature Dev', function () {
2222 const fileLevelAcceptPrompt = `${ prompt } and add a license, and a contributing file`
2323 const tooManyRequestsWaitTime = 100000
2424
25- function waitForButtons ( buttons : FollowUpTypes [ ] ) {
26- return tab . waitForEvent ( ( ) => {
27- return buttons . every ( ( value ) => tab . hasButton ( value ) )
28- } )
29- }
30-
3125 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+ } )
4130 }
4231
4332 async function iterate ( prompt : string ) {
@@ -201,12 +190,12 @@ describe('Amazon Q Feature Dev', function () {
201190 it ( 'Clicks accept code and click new task' , async ( ) => {
202191 await retryIfRequired ( async ( ) => {
203192 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 ] ) ,
206195 ] )
207196 } )
208197 tab . clickButton ( FollowUpTypes . InsertCode )
209- await waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
198+ await tab . waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
210199 tab . clickButton ( FollowUpTypes . NewTask )
211200 await waitForText ( 'What new task would you like to work on?' )
212201 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 () {
215204 it ( 'Iterates on codegen' , async ( ) => {
216205 await retryIfRequired ( async ( ) => {
217206 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 ] ) ,
220209 ] )
221210 } )
222211 tab . clickButton ( FollowUpTypes . ProvideFeedbackAndRegenerateCode )
223212 await tab . waitForChatFinishesLoading ( )
224213 await iterate ( codegenApproachPrompt )
225214 tab . clickButton ( FollowUpTypes . InsertCode )
226- await waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
215+ await tab . waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
227216 } )
228217 } )
229218
@@ -240,8 +229,8 @@ describe('Amazon Q Feature Dev', function () {
240229 )
241230 await retryIfRequired ( async ( ) => {
242231 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 ] ) ,
245234 ] )
246235 } )
247236 } )
@@ -271,7 +260,7 @@ describe('Amazon Q Feature Dev', function () {
271260
272261 it ( 'disables all action buttons when new task is clicked' , async ( ) => {
273262 tab . clickButton ( FollowUpTypes . InsertCode )
274- await waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
263+ await tab . waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
275264 tab . clickButton ( FollowUpTypes . NewTask )
276265 await waitForText ( 'What new task would you like to work on?' )
277266
@@ -283,7 +272,7 @@ describe('Amazon Q Feature Dev', function () {
283272
284273 it ( 'disables all action buttons when close session is clicked' , async ( ) => {
285274 tab . clickButton ( FollowUpTypes . InsertCode )
286- await waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
275+ await tab . waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
287276 tab . clickButton ( FollowUpTypes . CloseSession )
288277 await waitForText (
289278 "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 () {
335324 for ( const filePath of filePaths ) {
336325 await clickActionButton ( filePath , 'accept-change' )
337326 }
338- await waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
327+ await tab . waitForButtons ( [ FollowUpTypes . NewTask , FollowUpTypes . CloseSession ] )
339328
340329 assert . ok ( tab . hasButton ( FollowUpTypes . InsertCode ) === false )
341330 assert . ok ( tab . hasButton ( FollowUpTypes . ProvideFeedbackAndRegenerateCode ) === false )
0 commit comments