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 , printElementHTML , sleep , waitForElements } from './generalUtils'
5+ import { Workbench , WebviewView , By } from 'vscode-extension-tester'
6+ import { printElementHTML , sleep } from './generalUtils'
77import { testContext } from './testContext'
8- import { isRunningInGitHubActionsE2E } from './ciUtils'
9- import { authenticateForCI } from './ciOidcClient'
108
119/* Completes the entire Amazon Q login flow
1210
@@ -18,34 +16,78 @@ Currently, the function will
1816
1917TO-DO: Currently this signInToAmazonQ is not fully autonomous as we ran into a blocker when the browser window pops up */
2018export async function signInToAmazonQ ( ) : Promise < void > {
21- if ( isRunningInGitHubActionsE2E ( ) ) {
22- console . log ( 'CI Environment detected: Using automated authentication' )
23- await authenticateForCI ( )
24-
25- // Set up minimal test context for CI
26- const workbench = new Workbench ( )
27- testContext . workbench = workbench
28- // Skip webview setup for CI as authentication is handled by Lambda
29- await workbench . executeCommand ( 'Amazon Q: Open Chat' )
30- console . log ( 'THIS WORKED 1' )
31- const editorView = workbench . getEditorView ( )
32- console . log ( 'THIS WORKED 2' )
33- await editorView . closeAllEditors ( )
34- console . log ( 'THIS WORKED 3' )
35- const webviewView = new WebviewView ( )
36- console . log ( 'THIS WORKED 4' )
37- await webviewView . switchToFrame ( )
38- console . log ( 'THIS WORKED 5' )
39-
40- testContext . webviewView = webviewView
41- console . log ( 'IT WORKED' )
42- const body = webviewView . findElement ( By . css ( '*' ) )
43- const body2 = workbench . findElement ( By . css ( '*' ) )
44- await printElementHTML ( body )
45- await printElementHTML ( body2 )
46- //if were not getting the print that we're expecting josh's registerhook works the moment the browser popup happens so we can probs use that
47- return
48- }
19+ // if (isRunningInGitHubActionsE2E()) {
20+ // console.log('CI Environment detected: Using automated authentication')
21+ // const workbench = new Workbench()
22+ // await workbench.executeCommand('Amazon Q: Open Chat')
23+
24+ // await sleep(5000)
25+ // let webviewView = new WebviewView()
26+ // await webviewView.switchToFrame()
27+
28+ // const selectableItems = await waitForElements(webviewView, By.css('.selectable-item'))
29+ // if (selectableItems.length === 0) {
30+ // throw new Error('No selectable login options found')
31+ // }
32+
33+ // // find the button / input + click the button / input
34+ // const companyItem = await findItemByText(selectableItems, 'Company account')
35+ // await companyItem.click()
36+
37+ // const signInContinue = await webviewView.findWebElement(By.css('#connection-selection-continue-button'))
38+ // await signInContinue.click()
39+
40+ // const startUrlInput = await webviewView.findWebElement(By.id('startUrl'))
41+ // await startUrlInput.clear()
42+ // await startUrlInput.sendKeys('https://amzn.awsapps.com/start')
43+
44+ // const UrlContinue = await webviewView.findWebElement(By.css('button.continue-button.topMargin'))
45+ // await UrlContinue.click()
46+
47+ // await sleep(3000)
48+ // await authenticateForCI()
49+ // console.log('Waiting for manual authentication...')
50+ // await sleep(12000)
51+ // console.log('Manual authentication should be done')
52+
53+ // await webviewView.switchBack()
54+
55+ // const editorView = workbench.getEditorView()
56+ // await editorView.closeAllEditors()
57+ // webviewView = new WebviewView()
58+ // await webviewView.switchToFrame()
59+ // const body = webviewView.findElement(By.css('*'))
60+ // const body2 = workbench.findElement(By.css('*'))
61+ // await printElementHTML(body)
62+ // await printElementHTML(body2)
63+
64+ // testContext.workbench = workbench
65+ // testContext.webviewView = webviewView
66+
67+ // // // Set up minimal test context for CI
68+ // // const workbench = new Workbench()
69+ // // testContext.workbench = workbench
70+ // // // Skip webview setup for CI as authentication is handled by Lambda
71+ // // await workbench.executeCommand('Amazon Q: Open Chat')
72+ // // console.log('THIS WORKED 1')
73+ // // const editorView = workbench.getEditorView()
74+ // // console.log('THIS WORKED 2')
75+ // // await editorView.closeAllEditors()
76+ // // console.log('THIS WORKED 3')
77+ // // const webviewView = new WebviewView()
78+ // // console.log('THIS WORKED 4')
79+ // // await webviewView.switchToFrame()
80+ // // console.log('THIS WORKED 5')
81+
82+ // // testContext.webviewView = webviewView
83+ // // console.log('IT WORKED')
84+ // // const body = webviewView.findElement(By.css('*'))
85+ // // const body2 = workbench.findElement(By.css('*'))
86+ // // await printElementHTML(body)
87+ // // await printElementHTML(body2)
88+ // //if were not getting the print that we're expecting josh's registerhook works the moment the browser popup happens so we can probs use that
89+ // return
90+ // }
4991
5092 // Normal manual authentication flow for local development
5193 const workbench = new Workbench ( )
@@ -55,25 +97,26 @@ export async function signInToAmazonQ(): Promise<void> {
5597 let webviewView = new WebviewView ( )
5698 await webviewView . switchToFrame ( )
5799
58- const selectableItems = await waitForElements ( webviewView , By . css ( '.selectable-item' ) )
59- if ( selectableItems . length === 0 ) {
60- throw new Error ( 'No selectable login options found' )
61- }
100+ // const selectableItems = await waitForElements(webviewView, By.css('.selectable-item'))
101+ // if (selectableItems.length === 0) {
102+ // throw new Error('No selectable login options found')
103+ // }
62104
63- // find the button / input + click the button / input
64- const companyItem = await findItemByText ( selectableItems , 'Company account' )
65- await companyItem . click ( )
105+ // // find the button / input + click the button / input
106+ // const companyItem = await findItemByText(selectableItems, 'Company account')
107+ // await companyItem.click()
66108
67- const signInContinue = await webviewView . findWebElement ( By . css ( '#connection-selection-continue-button' ) )
68- await signInContinue . click ( )
109+ // const signInContinue = await webviewView.findWebElement(By.css('#connection-selection-continue-button'))
110+ // await signInContinue.click()
69111
70- const startUrlInput = await webviewView . findWebElement ( By . id ( 'startUrl' ) )
71- await startUrlInput . clear ( )
72- await startUrlInput . sendKeys ( 'https://amzn.awsapps.com/start' )
73-
74- const UrlContinue = await webviewView . findWebElement ( By . css ( 'button.continue-button.topMargin' ) )
75- await UrlContinue . click ( )
112+ // const startUrlInput = await webviewView.findWebElement(By.id('startUrl'))
113+ // await startUrlInput.clear()
114+ // await startUrlInput.sendKeys('https://amzn.awsapps.com/start')
76115
116+ // const UrlContinue = await webviewView.findWebElement(By.css('button.continue-button.topMargin'))
117+ // await UrlContinue.click()
118+ const body = webviewView . findElement ( By . css ( '*' ) )
119+ await printElementHTML ( body )
77120 console . log ( 'Waiting for manual authentication...' )
78121 await sleep ( 12000 )
79122 console . log ( 'Manual authentication should be done' )
0 commit comments