Skip to content

Commit 12b7763

Browse files
committed
feature: add inline shortcut test
1 parent 2ecfebc commit 12b7763

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

packages/amazonq/test/e2e_new/amazonq/tests/inline.test.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import '../utils/setup'
66
import { Workbench, EditorView, InputBox, TextEditor, WebviewView, Key } from 'vscode-extension-tester'
77
import { testContext } from '../utils/testContext'
8-
import { createNewTextFile, writeToTextEditor, waitForInlineGeneration } from '../utils/generalUtils'
8+
import { createNewTextFile, writeToTextEditor, waitForInlineGeneration, pressShortcut } from '../utils/generalUtils'
99
import assert from 'assert'
1010

1111
describe('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
})

packages/amazonq/test/e2e_new/amazonq/utils/generalUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export async function pressKey(driver: WebDriver, key: keyof typeof Key): Promis
5757
* Ctrl + C | await pressShortcut(driver, Key.CONTROL, 'c')
5858
* Ctrl + Shift + T | await pressShortcut(driver, Key.CONTROL, Key.SHIFT, 't')
5959
*/
60-
export async function pressShortcut(driver: WebDriver, ...keys: (keyof typeof Key)[]): Promise<void> {
60+
export async function pressShortcut(driver: WebDriver, ...keys: (string | keyof typeof Key)[]): Promise<void> {
6161
const actions = driver.actions()
6262
for (const key of keys) {
6363
actions.keyDown(key)

0 commit comments

Comments
 (0)