22 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33 * SPDX-License-Identifier: Apache-2.0
44 */
5- import { Workbench , By , WebviewView } from 'vscode-extension-tester'
6- import { findItemByText , sleep , waitForElements } from './generalUtils'
5+ import { Workbench , By , WebviewView , until , ModalDialog } from 'vscode-extension-tester'
6+ import { findItemByText , printElementHTML , sleep , waitForElements } from './generalUtils'
77import { testContext } from './testContext'
88
99/* Completes the entire Amazon Q login flow
@@ -18,7 +18,6 @@ TO-DO: Currently this signInToAmazonQ is not fully autonomous as we ran into a b
1818export async function signInToAmazonQ ( ) : Promise < void > {
1919 const workbench = new Workbench ( )
2020 await workbench . executeCommand ( 'Amazon Q: Open Chat' )
21-
2221 await sleep ( 5000 )
2322 let webviewView = new WebviewView ( )
2423 await webviewView . switchToFrame ( )
@@ -42,6 +41,21 @@ export async function signInToAmazonQ(): Promise<void> {
4241 const UrlContinue = await webviewView . findWebElement ( By . css ( 'button.continue-button.topMargin' ) )
4342 await UrlContinue . click ( )
4443
44+ /**
45+ * this is the moment that a browser should pop up, at this moment can we just call the browser auth function?
46+ */
47+ await webviewView . switchBack ( )
48+ const driver = workbench . getDriver ( )
49+ const modalWnd = By . className ( 'monaco-dialog-box' )
50+ await driver . wait ( until . elementLocated ( modalWnd ) , 10_000 )
51+ const dialog = new ModalDialog ( )
52+ const details = await dialog . getDetails ( )
53+
54+ console . log ( 'this should be the url:' , details )
55+
56+ // await dialog.pushButton('Open')
57+
58+ /** */
4559 console . log ( 'Waiting for manual authentication...' )
4660 await sleep ( 12000 )
4761 console . log ( 'Manual authentication should be done' )
@@ -52,6 +66,8 @@ export async function signInToAmazonQ(): Promise<void> {
5266 webviewView = new WebviewView ( )
5367 await webviewView . switchToFrame ( )
5468
69+ await printElementHTML ( webviewView )
70+
5571 testContext . workbench = workbench
5672 testContext . webviewView = webviewView
5773}
0 commit comments