55import { Workbench , By , WebviewView } from 'vscode-extension-tester'
66import { findItemByText , sleep , waitForElements } from './generalUtils'
77import { testContext } from './testContext'
8+ import { isRunningInGitHubActionsE2E } from './ciUtils'
9+ import { authenticateForCI } from './ciOidcClient'
810
911/* Completes the entire Amazon Q login flow
1012
@@ -16,6 +18,18 @@ Currently, the function will
1618
1719TO-DO: Currently this signInToAmazonQ is not fully autonomous as we ran into a blocker when the browser window pops up */
1820export 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+ return
30+ }
31+
32+ // Normal manual authentication flow for local development
1933 const workbench = new Workbench ( )
2034 await workbench . executeCommand ( 'Amazon Q: Open Chat' )
2135
@@ -45,6 +59,7 @@ export async function signInToAmazonQ(): Promise<void> {
4559 console . log ( 'Waiting for manual authentication...' )
4660 await sleep ( 12000 )
4761 console . log ( 'Manual authentication should be done' )
62+
4863 await webviewView . switchBack ( )
4964
5065 const editorView = workbench . getEditorView ( )
0 commit comments