|
| 1 | +/*! |
| 2 | + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | +import '../utils/setup' |
| 6 | +import { Workbench, EditorView, TextEditor, InputBox, WebviewView, Key } from 'vscode-extension-tester' |
| 7 | +import { testContext } from '../utils/testContext' |
| 8 | +import { |
| 9 | + clearChatInput, |
| 10 | + pressShortcut, |
| 11 | + createNewTextFile, |
| 12 | + writeToTextEditor, |
| 13 | + waitForChatResponse, |
| 14 | +} from '../utils/generalUtils' |
| 15 | +import { closeAllTabs } from '../utils/cleanupUtils' |
| 16 | + |
| 17 | +describe('Amazon Q Shortcut Functionality Tests', function () { |
| 18 | + // this timeout is the general timeout for the entire test suite |
| 19 | + this.timeout(150000) |
| 20 | + let workbench: Workbench |
| 21 | + let editorView: EditorView |
| 22 | + let textEditor: TextEditor |
| 23 | + let webviewView: WebviewView |
| 24 | + |
| 25 | + beforeEach(async function () { |
| 26 | + webviewView = testContext.webviewView |
| 27 | + await webviewView.switchBack() |
| 28 | + workbench = testContext.workbench |
| 29 | + editorView = new EditorView() |
| 30 | + testContext.editorView = editorView |
| 31 | + textEditor = await createNewTextFile(workbench, editorView) |
| 32 | + }) |
| 33 | + |
| 34 | + afterEach(async function () { |
| 35 | + await closeAllTabs(webviewView) |
| 36 | + await clearChatInput(webviewView) |
| 37 | + }) |
| 38 | + it('Allows User to Verify Command Palette Works as Expected', async () => { |
| 39 | + const driver = webviewView.getDriver() |
| 40 | + await pressShortcut(driver, Key.CONTROL, Key.SHIFT, 'p') |
| 41 | + const input = new InputBox() |
| 42 | + await input.sendKeys('Preferences: Open Keyboard Shortcuts') |
| 43 | + await input.sendKeys(Key.ENTER) |
| 44 | + await editorView.closeAllEditors() |
| 45 | + await webviewView.switchToFrame() |
| 46 | + }) |
| 47 | + it('Allows User to Generate Tests Using Keybind', async () => { |
| 48 | + await writeToTextEditor(textEditor, 'def fibonacci(n):') |
| 49 | + await textEditor.selectText('def fibonacci(n):') |
| 50 | + |
| 51 | + const driver = webviewView.getDriver() |
| 52 | + await pressShortcut(driver, Key.CONTROL, Key.ALT, 't') |
| 53 | + await textEditor.clearText() |
| 54 | + await editorView.closeAllEditors() |
| 55 | + await webviewView.switchToFrame() |
| 56 | + await waitForChatResponse(webviewView) |
| 57 | + }) |
| 58 | + it('Allows User to Select and Explain Code Using Keybind', async () => { |
| 59 | + await writeToTextEditor(textEditor, 'def fibonacci(n):') |
| 60 | + await textEditor.selectText('def fibonacci(n):') |
| 61 | + |
| 62 | + const driver = webviewView.getDriver() |
| 63 | + await pressShortcut(driver, Key.CONTROL, Key.ALT, 'e') |
| 64 | + await textEditor.clearText() |
| 65 | + await editorView.closeAllEditors() |
| 66 | + await webviewView.switchToFrame() |
| 67 | + await waitForChatResponse(webviewView) |
| 68 | + }) |
| 69 | + it('Allows User to Optimize Code Using Keybind', async () => { |
| 70 | + await writeToTextEditor(textEditor, 'def fibonacci(n):') |
| 71 | + await textEditor.selectText('def fibonacci(n):') |
| 72 | + |
| 73 | + const driver = webviewView.getDriver() |
| 74 | + await pressShortcut(driver, Key.CONTROL, Key.ALT, 'a') |
| 75 | + await textEditor.clearText() |
| 76 | + await editorView.closeAllEditors() |
| 77 | + await webviewView.switchToFrame() |
| 78 | + await waitForChatResponse(webviewView) |
| 79 | + }) |
| 80 | +}) |
0 commit comments