-
Notifications
You must be signed in to change notification settings - Fork 731
feat(amazonq): add shortcut test for UI E2E Tests #7863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
6dddd03
97a6ad7
c8bc42c
4761d6e
87a1c2e
8549a9b
3cca3f3
5be15af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| import '../utils/setup' | ||
| import { Workbench, EditorView, TextEditor, InputBox, WebviewView, Key } from 'vscode-extension-tester' | ||
| import { testContext } from '../utils/testContext' | ||
| import { | ||
| clearChat, | ||
| pressShortcut, | ||
| createNewTextFile, | ||
| writeToTextEditor, | ||
| waitForChatResponse, | ||
| } from '../utils/generalUtils' | ||
| import { closeAllTabs } from '../utils/cleanupUtils' | ||
|
|
||
| describe('Amazon Q Shortcut Functionality Tests', function () { | ||
| // this timeout is the general timeout for the entire test suite | ||
| this.timeout(150000) | ||
| let workbench: Workbench | ||
| let editorView: EditorView | ||
| let textEditor: TextEditor | ||
| let webviewView: WebviewView | ||
|
|
||
| beforeEach(async function () { | ||
| webviewView = testContext.webviewView | ||
| await webviewView.switchBack() | ||
| workbench = testContext.workbench | ||
| editorView = new EditorView() | ||
| testContext.editorView = editorView | ||
| textEditor = await createNewTextFile(workbench, editorView) | ||
| }) | ||
|
|
||
| afterEach(async function () { | ||
| await closeAllTabs(webviewView) | ||
| await clearChat(webviewView) | ||
| }) | ||
| it('Allows User to Verify Command Palette Works as Expected', async () => { | ||
| const driver = webviewView.getDriver() | ||
| await pressShortcut(driver, Key.COMMAND, Key.SHIFT, 'p') | ||
|
||
| const input = new InputBox() | ||
| await input.sendKeys('Preferences: Open Keyboard Shortcuts') | ||
| await input.sendKeys(Key.ENTER) | ||
| await editorView.closeAllEditors() | ||
| await webviewView.switchToFrame() | ||
| }) | ||
| it('Allows User to Generate Tests Using Keybind', async () => { | ||
| await writeToTextEditor(textEditor, 'def fibonacci(n):') | ||
| await textEditor.selectText('def fibonacci(n):') | ||
|
|
||
| const driver = webviewView.getDriver() | ||
| await pressShortcut(driver, Key.COMMAND, Key.ALT, 't') | ||
| await textEditor.clearText() | ||
| await editorView.closeAllEditors() | ||
| await webviewView.switchToFrame() | ||
| await waitForChatResponse(webviewView) | ||
| }) | ||
| it('Allows User to Select and Explain Code Using Keybind', async () => { | ||
| await writeToTextEditor(textEditor, 'def fibonacci(n):') | ||
| await textEditor.selectText('def fibonacci(n):') | ||
|
|
||
| const driver = webviewView.getDriver() | ||
| await pressShortcut(driver, Key.COMMAND, Key.ALT, 'e') | ||
| await textEditor.clearText() | ||
| await editorView.closeAllEditors() | ||
| await webviewView.switchToFrame() | ||
| await waitForChatResponse(webviewView) | ||
| }) | ||
| it('Allows User to Optimize Code Using Keybind', async () => { | ||
| await writeToTextEditor(textEditor, 'def fibonacci(n):') | ||
| await textEditor.selectText('def fibonacci(n):') | ||
|
|
||
| const driver = webviewView.getDriver() | ||
| await pressShortcut(driver, Key.COMMAND, Key.ALT, 'a') | ||
| await textEditor.clearText() | ||
| await editorView.closeAllEditors() | ||
| await webviewView.switchToFrame() | ||
| await waitForChatResponse(webviewView) | ||
| }) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,7 @@ export async function pressKey(driver: WebDriver, key: keyof typeof Key): Promis | |
| * Ctrl + C | await pressShortcut(driver, Key.CONTROL, 'c') | ||
| * Ctrl + Shift + T | await pressShortcut(driver, Key.CONTROL, Key.SHIFT, 't') | ||
| */ | ||
| export async function pressShortcut(driver: WebDriver, ...keys: (keyof typeof Key)[]): Promise<void> { | ||
| export async function pressShortcut(driver: WebDriver, ...keys: (string | keyof typeof Key)[]): Promise<void> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way to describe the 'a' key as the specified type rather than the string? Or is this change necessary?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, so to my understanding, the problem isn't actually the 'a' string but also the IKey variables which are declared as strings. For example:
|
||
| const actions = driver.actions() | ||
| for (const key of keys) { | ||
| actions.keyDown(key) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we centralize this to one place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: once all PRs are in, go into all files and create a constant.ts file to manage repeated code. @surajrdy-aws