Skip to content

Conversation

@surajrdy-aws
Copy link

Problem

We have not implemented the shortcut tests for our UI E2E Test suite with VSCode-Extension-Tester. Additionally, we face a small problem in our pressShortcut abstraction that throws a type error when trying to reference a Key command like Key.COMMAND since it is a IKey String.

Solution

We have implemented the shortcut tests:

  • Optimize Code Shortcut
  • Generate Test Shortcut
  • Keybind Check
  • Explain Code Shortcut

We have also fixed the pressShortcut abstraction with a small edit in the logic of accepted parameters.

NOTE: We have chosen to implement the Inline Shortcut within the Inline Tests even though it could be classified under Shorcuts.


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@surajrdy-aws surajrdy-aws requested a review from a team as a code owner August 11, 2025 19:26
@github-actions
Copy link

  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

@Hweinstock
Copy link
Contributor

Looks like CI is blocked:

Invalid pull request title: `feature(amazonq): add shortcut test for UI E2E Tests`

* Problem: invalid type "feature"
* Expected format: `type(scope): subject...`
    * type: one of (build, ci, config, deps, docs, feat, fix, perf, refactor, revert, style, telemetry, test, types)
    * scope: lowercase, <30 chars
    * subject: must be <100 chars
    * documentation: https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#pull-request-title
* Hint: *close and re-open the PR* to re-trigger CI (after fixing the PR title).

@surajrdy-aws surajrdy-aws changed the title feature(amazonq): add shortcut test for UI E2E Tests feat(amazonq): add shortcut test for UI E2E Tests Aug 12, 2025
@surajrdy-aws surajrdy-aws reopened this Aug 12, 2025

describe('Amazon Q Shortcut Functionality', function () {
// this timeout is the general timeout for the entire test suite
this.timeout(150000)
Copy link
Contributor

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?

Copy link
Author

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

await closeAllTabs(webviewView)
await clearChat(webviewView)
})
it('Keybind Check', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as other PR for the test titles.

it('Keybind Check', async () => {
const driver = webviewView.getDriver()
// Open Command Palette
await pressShortcut(driver, Key.COMMAND, Key.SHIFT, 'p')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does VET not have native support for opening the command palette? Somewhat surprised by that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do, but for these tests, they specifically wanted to test Keybinds on the computer as short cuts. I wonder if just using the native VET support is any different in the testing sense?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting. Does VSC allow for users to overwrite key binds? If so would this test always fail on their machine?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I believe they do allow for users to overwrite key binds. The tests would then fail on the machine. I think generally this test is not extremely robust, but not sure how else to tackle it since some of the test descriptions explicitly asked for keybinds to be used. What are your thoughts on it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I guess this is fine for now. Could be worth adding a comment, but don't see it as a blocker.


const driver = webviewView.getDriver()
await pressShortcut(driver, Key.COMMAND, Key.ALT, 't')
// Clean Up Text
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: idk if these comments are needed.

Copy link
Author

@surajrdy-aws surajrdy-aws Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha!

if (!responseReceived) {
throw new Error('Chat response not received within timeout')
}
console.log('Chat response detected successfully')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't need to log successful tests. This should be done automatically by mocha.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me fix that!

* 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> {
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Author

Choose a reason for hiding this comment

The 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:

COMMAND: string; // Apple command key

@laura-codess laura-codess self-requested a review August 13, 2025 17:47
@surajrdy-aws
Copy link
Author

/retryBuilds

@bywang56 bywang56 merged commit a9a8b27 into aws:feature/ui-e2e-tests Aug 15, 2025
26 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants