Skip to content

Commit dd62e27

Browse files
committed
Adding the wait to improve the robustness
1 parent 66f198d commit dd62e27

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

packages/amazonq/test.log

Whitespace-only changes.

packages/amazonq/test/e2e/amazonq/VET.test.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55
import { Workbench, By, WebviewView, WebElement } from 'vscode-extension-tester'
6+
import { until } from 'selenium-webdriver'
67

78
describe('Amazon Q E2E UI Test', function () {
89
// need this timeout because Amazon Q takes awhile to load
@@ -19,12 +20,13 @@ describe('Amazon Q E2E UI Test', function () {
1920
webviewView = new WebviewView()
2021
await webviewView.switchToFrame()
2122

22-
// Login flow, i've gotten rid of the timeouts to make it run super fast
23-
await new Promise((resolve) => setTimeout(resolve, 8000))
23+
const driver = webviewView.getDriver()
24+
await driver.wait(until.elementsLocated(By.css('.selectable-item')), 30000)
2425
const selectableItems = await webviewView.findWebElements(By.css('.selectable-item'))
2526
if (selectableItems.length === 0) {
2627
throw new Error('No selectable login options found')
2728
}
29+
2830
const companyItem = await findItemByText(selectableItems, 'Company account')
2931
await companyItem.click()
3032
const signInContinue = await webviewView.findWebElement(By.css('#connection-selection-continue-button'))
@@ -61,11 +63,12 @@ describe('Amazon Q E2E UI Test', function () {
6163
// const chatHtml = (await webviewView.getDriver().executeScript('return document.body.innerHTML')) as string
6264
// console.log('Chat Title:', chatTitle)
6365
// console.log('Chat HTML:', chatHtml.replace(/></g, '>\n<'))
64-
66+
const driver = webviewView.getDriver()
67+
await driver.wait(until.elementsLocated(By.css('.mynah-chat-prompt-input')), 300000)
6568
// In order to test the chat prompt, we need to find the input field and send keys
6669
const chatInput = await webviewView.findWebElement(By.css('.mynah-chat-prompt-input'))
6770
await chatInput.sendKeys('Hello, Amazon Q!')
68-
71+
await driver.wait(until.elementsLocated(By.css('.mynah-chat-prompt-button')), 300000)
6972
// In order to submit the chat prompt, we need to find the send button and click it
7073
const sendButton = await webviewView.findWebElement(By.css('.mynah-chat-prompt-button'))
7174
await sendButton.click()
@@ -81,18 +84,6 @@ describe('Amazon Q E2E UI Test', function () {
8184
console.log('Chat response detected successfully')
8285
})
8386

84-
// it('fsRead Tool Test', async () => {
85-
// // stop working with the webview
86-
// await webviewView.switchBack()
87-
// const bottomBar = new BottomBarPanel()
88-
// await bottomBar.toggle(true)
89-
// const terminalView = await bottomBar.openTerminalView()
90-
// await terminalView.executeCommand('touch testfile.txt && code testfile.txt')
91-
// await new Promise((resolve) => setTimeout(resolve, 12000))
92-
// })
93-
94-
// Helper to wait for selectable items to load
95-
9687
// Helper to find item by text content
9788
async function findItemByText(items: WebElement[], text: string) {
9889
for (const item of items) {

test.log

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
3+
Writing code settings to /var/folders/2_/2gq5dx0523d60tk4_xn6_pnr0000gq/T/test-resources/settings/User/settings.json
4+
Launching browser...
5+
Browser ready in 1404 ms
6+
Launching tests...
7+
Amazon Q E2E UI Test
8+
Waiting for manual authentication...
9+
Manual authentication should be done
10+
editorview successfully created
11+
Closed all editors
12+
Reopened webview view
13+
Chat response detected successfully
14+
✔ Chat Prompt Test (12165ms)
15+
16+
Shutting down the browser
17+
18+
1 passing (37s)
19+

0 commit comments

Comments
 (0)