55import '../utils/setup'
66import { Workbench , EditorView , InputBox , TextEditor , WebviewView , Key } from 'vscode-extension-tester'
77import { testContext } from '../utils/testContext'
8- import { createNewTextFile , writeToTextEditor , waitForInlineGeneration } from '../utils/generalUtils'
8+ import { createNewTextFile , writeToTextEditor , waitForInlineGeneration , pressShortcut } from '../utils/generalUtils'
99import assert from 'assert'
1010
1111describe ( 'Amazon Q Inline Completion / Chat Functionality' , function ( ) {
@@ -16,25 +16,20 @@ describe('Amazon Q Inline Completion / Chat Functionality', function () {
1616 let textEditor : TextEditor
1717 let webviewView : WebviewView
1818
19- before ( async function ( ) {
19+ beforeEach ( async function ( ) {
2020 webviewView = testContext . webviewView
2121 await webviewView . switchBack ( )
2222 workbench = testContext . workbench
2323 editorView = new EditorView ( )
2424 testContext . editorView = editorView
2525 textEditor = await createNewTextFile ( workbench , editorView )
2626 } )
27- after ( async function ( ) {
27+ afterEach ( async function ( ) {
2828 // Switch back to Webview Iframe when dealing with external webviews from Amazon Q.
2929 await editorView . closeAllEditors ( )
3030 await webviewView . switchToFrame ( )
3131 } )
32- it ( 'Inline Test Shortcut' , async ( ) => {
33- await writeToTextEditor ( textEditor , 'def factorial(n):' )
34- const text = await textEditor . getText ( )
35- assert . equal ( text , 'def factorial(n): ' )
36- await textEditor . clearText ( )
37-
32+ it ( 'Inline Test Generate' , async ( ) => {
3833 const textBefore = await textEditor . getText ( )
3934 await workbench . executeCommand ( 'Amazon Q: Inline Chat' )
4035 const input = new InputBox ( )
@@ -47,4 +42,17 @@ describe('Amazon Q Inline Completion / Chat Functionality', function () {
4742 assert ( textAfter . length > textBefore . length , 'Amazon Q generated code' )
4843 await textEditor . clearText ( )
4944 } )
45+ it ( 'Inline Keybind Shortcut' , async ( ) => {
46+ await writeToTextEditor ( textEditor , 'def fibonacci(n):' )
47+ await textEditor . selectText ( 'def fibonacci(n):' )
48+
49+ const driver = webviewView . getDriver ( )
50+ await pressShortcut ( driver , Key . COMMAND , 'i' )
51+ const input = new InputBox ( )
52+ await input . sendKeys ( 'Generate the fibonacci sequence through recursion' )
53+ await input . sendKeys ( Key . ENTER )
54+ await waitForInlineGeneration ( textEditor )
55+ //Clean Up Text
56+ await textEditor . clearText ( )
57+ } )
5058} )
0 commit comments