Skip to content

Commit 6ce9dca

Browse files
authored
test(amazonq): Set UI ready before executing amazonq e2e tests (aws#6580)
## Problem - after aws@19d0346 the listener adds messages in a buffer until the ui is ready. It looks like some messages get caught in the buffer during tests since the mynah ui activation is slightly different there - The waitUntil was waiting until an event evaluated to true and then afterwords checks to see if that same event is still true. This was causing an issue where if the event originally evaluated to true and then instantly evaluated to false, your tests would fail ## Solution - manually set the ui ready after we've created the mynah ui instance in tests --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 6f6a8c2 commit 6ce9dca

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/amazonq/test/e2e/amazonq/framework/framework.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ export class qTestingFramework {
7979
await ui.messageReceiver(event)
8080
})
8181
)
82+
83+
/**
84+
* We need to manually indicate that the UI is ready since we are using a custom mynah UI event routing
85+
* implementation instead of routing events through the real webview
86+
**/
87+
DefaultAmazonQAppInitContext.instance.getAppsToWebViewMessagePublisher().setUiReady()
8288
}
8389

8490
/**

packages/amazonq/test/e2e/amazonq/framework/messenger.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ export class Messenger {
190190
* Wait until the chat has finished loading. This happens when a backend request
191191
* has finished and responded in the chat
192192
*/
193-
await waitUntil(
194-
() => {
195-
return Promise.resolve(event())
193+
const ok = await waitUntil(
194+
async () => {
195+
return event()
196196
},
197197
{
198198
interval: waitOverrides ? waitOverrides.waitIntervalInMs : this.waitIntervalInMs,
@@ -202,7 +202,7 @@ export class Messenger {
202202
)
203203

204204
// Do another check just in case the waitUntil time'd out
205-
if (!event()) {
205+
if (!ok) {
206206
assert.fail(
207207
`Event has not finished loading in: ${waitOverrides ? waitOverrides.waitTimeoutInMs : this.waitTimeoutInMs} ms`
208208
)

0 commit comments

Comments
 (0)