Skip to content

Commit 8fd0c48

Browse files
committed
tests: stagger tests when you are being rate limited
1 parent 0f46ad1 commit 8fd0c48

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/core/src/testE2E/amazonq/featureDev.test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Messenger } from './framework/messenger'
1313
import { FollowUpTypes } from '../../amazonqFeatureDev/types'
1414
import { examples, newTaskChanges, sessionClosed } from '../../amazonqFeatureDev/userFacingText'
1515
import { ChatItem } from '@aws/mynah-ui'
16+
import { sleep } from '../../shared/utilities/timeoutUtils'
1617

1718
describe('Amazon Q Feature Dev', function () {
1819
let framework: qTestingFramework
@@ -22,6 +23,7 @@ describe('Amazon Q Feature Dev', function () {
2223
const prompt = 'Implement fibonacci in typescript'
2324
const iterateApproachPrompt = prompt + ' and add tests'
2425
const codegenApproachPrompt = prompt + ' and add even more tests'
26+
const tooManyRequestsWaitTime = 100000
2527

2628
before(async function () {
2729
await using(registerAuthHook('amazonq-test-account'), async () => {
@@ -120,16 +122,25 @@ describe('Amazon Q Feature Dev', function () {
120122
await waitUntilReady()
121123

122124
const findAnotherTopic = 'find another topic to discuss'
125+
const tooManyRequests = 'Too many requests'
126+
const failureState = (message: string) => {
127+
return (
128+
tab.getChatItems().pop()?.body?.includes(message) ||
129+
tab.getChatItems().slice(-2).shift()?.body?.includes(message)
130+
)
131+
}
123132
while (
124133
tab.hasButton(FollowUpTypes.Retry) ||
125-
(request &&
126-
(tab.getChatItems().pop()?.body?.includes(findAnotherTopic) ||
127-
tab.getChatItems().slice(-2).shift()?.body?.includes(findAnotherTopic)))
134+
(request && (failureState(findAnotherTopic) || failureState(tooManyRequests)))
128135
) {
129136
if (tab.hasButton(FollowUpTypes.Retry)) {
130137
console.log('Retrying request')
131138
tab.clickButton(FollowUpTypes.Retry)
132139
await waitUntilReady()
140+
} else if (failureState(tooManyRequests)) {
141+
// 3 versions of the e2e tests are running at the same time in the ci so we occassionally need to wait before continuing
142+
request && request()
143+
await sleep(tooManyRequestsWaitTime)
133144
} else {
134145
// We've hit guardrails, re-make the request and wait again
135146
request && request()

0 commit comments

Comments
 (0)