55import '../utils/setup'
66import { Workbench , EditorView , InputBox , TextEditor , WebviewView , Key } from 'vscode-extension-tester'
77import { testContext } from '../utils/testContext'
8- import { pressKey , createNewTextFile , writeToTextEditor } from '../utils/generalUtils'
8+ import { createNewTextFile , writeToTextEditor , sleep } from '../utils/generalUtils'
99import assert from 'assert'
1010
1111describe ( 'Amazon Q Inline Completion / Chat Functionality' , function ( ) {
@@ -20,25 +20,32 @@ describe('Amazon Q Inline Completion / Chat Functionality', function () {
2020 webviewView = testContext . webviewView
2121 await webviewView . switchBack ( )
2222 workbench = testContext . workbench
23-
2423 editorView = new EditorView ( )
2524 testContext . editorView = editorView
26-
2725 textEditor = await createNewTextFile ( workbench , editorView )
2826 } )
29-
30- it ( 'Inline Test' , async ( ) => {
31- await writeToTextEditor ( textEditor , 'Select Me' )
27+ after ( async function ( ) {
28+ // Switch back to Webview Iframe when dealing with external webviews from Amazon Q.
29+ await editorView . closeAllEditors ( )
30+ await webviewView . switchToFrame ( )
31+ testContext . webviewView = webviewView
32+ } )
33+ it ( 'Inline Test Shortcut' , async ( ) => {
34+ await writeToTextEditor ( textEditor , 'def factorial(n):' )
3235 const text = await textEditor . getText ( )
33- assert . equal ( text , 'Select Me ' )
36+ assert . equal ( text , 'def factorial(n): ' )
3437 await textEditor . clearText ( )
3538
39+ const textBefore = await textEditor . getText ( )
3640 await workbench . executeCommand ( 'Amazon Q: Inline Chat' )
3741 const input = new InputBox ( )
38- await input . sendKeys ( 'Write a simple sentece ' )
42+ await input . sendKeys ( 'Generate the fibonacci sequence through iteration ' )
3943 await input . sendKeys ( Key . ENTER )
40- const driver = textEditor . getDriver ( )
41- await pressKey ( driver , 'ENTER' )
42- await pressKey ( driver , 'TAB' )
44+ await sleep ( 8000 )
45+
46+ const textAfter = await textEditor . getText ( )
47+ assert ( textAfter . length > textBefore . length , 'Amazon Q should have generated code' )
48+ assert ( textAfter . includes ( 'fibonacci' ) , 'Generated code should contain fibonacci logic' )
49+ await textEditor . clearText ( )
4350 } )
4451} )
0 commit comments