5
5
import '../utils/setup'
6
6
import { Workbench , EditorView , InputBox , TextEditor , WebviewView , Key } from 'vscode-extension-tester'
7
7
import { testContext } from '../utils/testContext'
8
- import { pressKey , createNewTextFile , writeToTextEditor } from '../utils/generalUtils'
8
+ import { createNewTextFile , writeToTextEditor , sleep } from '../utils/generalUtils'
9
9
import assert from 'assert'
10
10
11
11
describe ( 'Amazon Q Inline Completion / Chat Functionality' , function ( ) {
@@ -20,25 +20,32 @@ describe('Amazon Q Inline Completion / Chat Functionality', function () {
20
20
webviewView = testContext . webviewView
21
21
await webviewView . switchBack ( )
22
22
workbench = testContext . workbench
23
-
24
23
editorView = new EditorView ( )
25
24
testContext . editorView = editorView
26
-
27
25
textEditor = await createNewTextFile ( workbench , editorView )
28
26
} )
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):' )
32
35
const text = await textEditor . getText ( )
33
- assert . equal ( text , 'Select Me ' )
36
+ assert . equal ( text , 'def factorial(n): ' )
34
37
await textEditor . clearText ( )
35
38
39
+ const textBefore = await textEditor . getText ( )
36
40
await workbench . executeCommand ( 'Amazon Q: Inline Chat' )
37
41
const input = new InputBox ( )
38
- await input . sendKeys ( 'Write a simple sentece ' )
42
+ await input . sendKeys ( 'Generate the fibonacci sequence through iteration ' )
39
43
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 ( )
43
50
} )
44
51
} )
0 commit comments