33 * SPDX-License-Identifier: Apache-2.0
44 */
55import { Workbench , By , WebviewView , WebElement } from 'vscode-extension-tester'
6+ import { until } from 'selenium-webdriver'
67
78describe ( '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 ) {
0 commit comments