Skip to content

Commit 38cb008

Browse files
committed
test(amazonq): use chat tab title as a proxy for knowing when that tab is ready
1 parent 2853162 commit 38cb008

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

packages/amazonq/test/e2e/amazonq/chat.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { assertContextCommands, assertQuickActions } from './assert'
1212
import { registerAuthHook, using } from 'aws-core-vscode/test'
1313
import { loginToIdC } from './utils/setup'
1414
import { webviewConstants } from 'aws-core-vscode/amazonq'
15+
import { waitUntil } from 'aws-core-vscode/shared'
1516

1617
describe('Amazon Q Chat', function () {
1718
let framework: qTestingFramework
@@ -31,11 +32,26 @@ describe('Amazon Q Chat', function () {
3132
})
3233

3334
// jscpd:ignore-start
34-
beforeEach(() => {
35+
beforeEach(async () => {
3536
// Make sure you're logged in before every test
3637
registerAuthHook('amazonq-test-account')
3738
framework = new qTestingFramework('cwc', true, [])
3839
tab = framework.createTab()
40+
41+
/**
42+
* Since sending messages to the UI is asynchronous, race conditions can occur
43+
* where the event is set but not fully loaded. Instead of checking the store directly,
44+
* we now use the tab title as a proxy to determine when the tab is fully ready
45+
*/
46+
await waitUntil(
47+
async () => {
48+
return tab.getStore().tabTitle === 'Chat'
49+
},
50+
{
51+
interval: 50,
52+
timeout: 2000,
53+
}
54+
)
3955
store = tab.getStore()
4056
})
4157

@@ -48,6 +64,7 @@ describe('Amazon Q Chat', function () {
4864
'prompt input placeholder': store.promptInputPlaceholder,
4965
'quick actions': JSON.stringify(store.quickActionCommands),
5066
'context commands': JSON.stringify(store.contextCommands),
67+
'tab count': framework.getTabs().length,
5168
})
5269
}
5370
framework.removeTab(tab.tabID)

0 commit comments

Comments
 (0)