Skip to content

feat(amazonq): Implement Rules Abstraction + Rules Option Test #7841

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

Open
wants to merge 22 commits into
base: feature/ui-e2e-tests
Choose a base branch
from

Conversation

laura-codess
Copy link

Change

I implemented the Rules Option Test and all the abstractions needed to write that test. Since there is only 1 test in the test suite, this will be the complete test suite unless the Rules feature gets expanded or the team decides to write more tests for it.


  • 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.

@laura-codess laura-codess requested a review from a team as a code owner August 7, 2025 20:17
@laura-codess laura-codess marked this pull request as draft August 7, 2025 20:21
@laura-codess laura-codess marked this pull request as ready for review August 8, 2025 18:03
Copy link

github-actions bot commented Aug 8, 2025

  • 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.

tgodara-aws and others added 20 commits August 11, 2025 14:35
## Problem
Job history-related code is scattered throughout various files, making
it difficult to review and understand.

## Solution
Centralize existing history functions in a new file and add helper
functions to declutter transformation flow. Update and simplify unit
tests accordingly.

---

- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
)

## Problem
discard when it's not yet shown.
reject when user's typing and makes the diff invalid.

## Solution


---

- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
…or agentic chat (aws#7857)

## Problem
In order to set appropriate Origin Info on LSP side for SMAI CodeEditor,
[link](https://github.com/aws/language-servers/blob/68adf18d7ec46a7ecf9c66fd9d52b1b8f7bc236e/server/aws-lsp-codewhisperer/src/shared/utils.ts#L377),
clientInfo needs to be distinct
- related [PR to support
SMUS](aws#7817)

## Solution
- To check if the environment is SageMaker and a Unified Studio instance
and set corresponding clientInfo Name which is ```AmazonQ-For-SMUS-CE```

## Testing
- Built artefact locally using ```npm run compile && npm run package```
and tested on a SMAI CE space
- Ran ```npm run test -w packages/toolkit``` which succeeded
- LSP logs show the respective client Info details
```

---

- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

Co-authored-by: Laxman Reddy <[email protected]>
…ws#7839)

## Problem
Inline completion suggestions were being shown even when edit
suggestions were active, creating a confusing user experience where both
types of suggestions could appear simultaneously.

## Solution
1. Added conflict prevention logic in provideInlineCompletionItems() to
check for active edit suggestions using the existing
aws.amazonq.editSuggestionActive context flag
1. Created isEditSuggestionActive() method to encapsulate context
checking
1. Implemented DISCARD telemetry for completion suggestions that can't
be shown due to active edits
1. Added unit tests covering the new functionality, including edge cases
for mixed suggestion types and items without IDs
1. Updated displayImage.ts to properly set/unset the context flag when
edit suggestions are displayed/cleared
1. The solution ensures only one type of suggestion is active at a time
while maintaining telemetry compliance and following existing codebase
patterns.

---
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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
This is the initial commit for UI Tests using the framework
vscode-extension-tester. It instantiates the VSCode instance which opens
Amazon Q and goes through some basic flows to login. This is done using
the [VSCode-Extension-Tester
Framework](https://github.com/redhat-developer/vscode-extension-tester/wiki/).
(Note: It is missing full authentication and stops working once Amazon Q
needs to open the browser).

**To run this test**

1. First compile the test files
`npm run testCompile`
2. Then run the test setup
`node_modules/.bin/extest setup-tests`
2. Then run the script (NOTE: this js file should be generated when you
compile the test files)
`node_modules/.bin/extest run-tests
aws-toolkit-vscode/packages/amazonq/dist/test/e2e/amazonq/VET.test.js`

For information why each dependency / webpack change is needed, please
see
[here](https://quip-amazon.com/lCuBAOGibHzm/UI-Tests-PR-Explanation).

Demo Video:

https://github.com/user-attachments/assets/f1c6e59f-d4e3-4ae0-a164-1da389ec1339

---

- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
## Changes

Adding the simple chat prompt test. 


---

- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
…extension-tester (VET) (aws#7666)

Users running our new E2E UI testing suite have to run a plethora of
commands in order to setup and run our test suite each time their
testing code may change or a new workspace in VSCode is instantiated.
This
[document](https://quip-amazon.com/KfISA389hGty/Setup-Instructions-for-Amazon-Q-VET-UI-Tests)
contains rationale. These commands are exact and can be easy to forget
and small errors in the CLI commands lead to headaches with the setup.
Additionally, we run into a problem when running `npm run package` where
each VSIX installation will have a unique hash and VSCode version
attached to the name, and due to the lack of CLI args for renaming our
VSIX package, we must be able to reference the path to this VSIX
installation on anyones local devices. Notably, many
Vscode-extension-tester (VET) projects use "setup-tests" to attach a
VSCode instance and a Chromedriver instance which is crucial for the
functionality of VET; however, this leads to build issues due to the
inherent nature of VET's "setup-tests" packaging its own VSIX
automatically. In normal circumstances, this would be fine; however, due
to our unique packaging structure of the amazonq directory, we require a
package.ts script to package our directory properly.

My solution encompasses adding additional scripts to the package.json
file in the root directory of the aws-toolkit-vscode repository. These
scripts must be run in a specific order in order for them to work
correctly and must **all by run in the root directory.** Namely these
npm scripts are:

```
"test:ui:prepare": "./node_modules/.bin/extest get-vscode -s ~/.vscode-test-resources -n && extest get-chromedriver -s ~/.vscode-test-resources -n",
```
This script essentially does the bulk of the previous "setup-tests", it
installs a local VSCode instance and clears the previous cache and
installs the chromdriver into the VSCode instance. This is stored in a
vscode-test-resources directory in ones local User directory.
```
"test:ui:install": "cd packages/amazonq && npm run package 2>&1 | grep -o 'VSIX Version: [^ ]*' | cut -d' ' -f3 | xargs -I{} bash -c 'cd ../../ && ./node_modules/.bin/extest install-vsix -f amazon-q-vscode-{}.vsix -e packages/amazonq/test/e2e/amazonq/resources -s ~/.vscode-test-resources'",
```
This script installs our VSIX by going into the amazonq package and
running our npm run package. This eliminates the need for any additional
scripts by allowing for a CLI/RegEx command to be utilized to find the
specific hash of the VSIX in our terminal output and input it within the
install-vsix command for extest.
```
"test:ui:run": "npm run testCompile && ./node_modules/.bin/extest run-tests -s ~/.vscode-test-resources -e packages/amazonq/test/e2e/amazonq/resources packages/amazonq/dist/test/e2e/amazonq/VET.test.js",
```
This script runs our VET.test.js script and does the testCompile npm
script that has already been built into the repo. This is because when
we run "npm run package", our compiled tests within the dist directory
are deleted. We must run testCompile after this command in order to
properly compile our tests.
```
"test:ui": "npm run test:ui:prepare && npm run test:ui:install && npm run test:ui:run",
```
This script combines all of our scripts into a chronological order.
---

- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.

---------

Co-authored-by: laura-codess <[email protected]>
This is a large PR for all the baseline setup of the framework. It
includes the auth, setup, 4 test suites and the abstractions for each,
and the cleanup functions.

---

- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
- Resolve conflicts and push to this PR branch.
- **Do not squash-merge** this PR. Use the "Create a merge commit"
option to do a regular merge.

To perform the merge from the command line, you could do something like
the following (where "origin" is the name of the remote in your local
git repo):
```
git stash
git fetch --all
git checkout origin/feature/ui-e2e-tests
git merge origin/master
git commit
git push origin HEAD:refs/heads/autoMerge/feature/ui-e2e-tests
```

---------

Co-authored-by: Roger Zhang <[email protected]>
Co-authored-by: 🥩 Flora <[email protected]>
Co-authored-by: Reed Hamilton <[email protected]>
Co-authored-by: Laxman Reddy <[email protected]>
Co-authored-by: Roger Zhang <[email protected]>
Co-authored-by: Jacob Chung <[email protected]>
Co-authored-by: aws-asolidu <[email protected]>
Co-authored-by: Newton Der <[email protected]>
Co-authored-by: Newton Der <[email protected]>
Co-authored-by: aws-toolkit-automation <>
Co-authored-by: laura-codess <[email protected]>
Co-authored-by: Tyrone Smith <[email protected]>
Co-authored-by: Aidan Ton <[email protected]>
Co-authored-by: abhraina-aws <[email protected]>
Co-authored-by: atontb <[email protected]>
Co-authored-by: Nitish <[email protected]>
Co-authored-by: Nitish Kumar Singh <[email protected]>
Co-authored-by: Blake Lazarine <[email protected]>
Co-authored-by: mkovelam <[email protected]>
Co-authored-by: BlakeLazarine <[email protected]>
Co-authored-by: Will Lo <[email protected]>
Co-authored-by: Na Yue <[email protected]>
Co-authored-by: Lei Gao <[email protected]>
Co-authored-by: tsmithsz <[email protected]>
Co-authored-by: Reed Hamilton <[email protected]>
Co-authored-by: surajrdy-aws <[email protected]>
Co-authored-by: Boyu <[email protected]>
Co-authored-by: Dung Dong <[email protected]>
Implemented the inline completion test within inline.test.ts. This test
suite does not need any special helper functions but I added a bunch of
new functions in generalUtils.ts

Note: I added the types@selenium-webdriver because we have started to
interact with elements outside of the Amazon Q webview (ie. the text
editor)

---

- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
- Resolve conflicts and push to this PR branch.
- **Do not squash-merge** this PR. Use the "Create a merge commit"
option to do a regular merge.

To perform the merge from the command line, you could do something like
the following (where "origin" is the name of the remote in your local
git repo):
```
git stash
git fetch --all
git checkout origin/feature/ui-e2e-tests
git merge origin/master
git commit
git push origin HEAD:refs/heads/autoMerge/feature/ui-e2e-tests
```

---------

Co-authored-by: Roger Zhang <[email protected]>
Co-authored-by: 🥩 Flora <[email protected]>
Co-authored-by: Reed Hamilton <[email protected]>
Co-authored-by: Laxman Reddy <[email protected]>
Co-authored-by: Roger Zhang <[email protected]>
Co-authored-by: Jacob Chung <[email protected]>
Co-authored-by: aws-asolidu <[email protected]>
Co-authored-by: Newton Der <[email protected]>
Co-authored-by: Newton Der <[email protected]>
Co-authored-by: aws-toolkit-automation <>
Co-authored-by: Tyrone Smith <[email protected]>
Co-authored-by: Aidan Ton <[email protected]>
Co-authored-by: abhraina-aws <[email protected]>
Co-authored-by: atontb <[email protected]>
Co-authored-by: Nitish <[email protected]>
Co-authored-by: Nitish Kumar Singh <[email protected]>
Co-authored-by: Blake Lazarine <[email protected]>
Co-authored-by: mkovelam <[email protected]>
Co-authored-by: BlakeLazarine <[email protected]>
Co-authored-by: Will Lo <[email protected]>
Co-authored-by: Na Yue <[email protected]>
Co-authored-by: Lei Gao <[email protected]>
Co-authored-by: tsmithsz <[email protected]>
Co-authored-by: Reed Hamilton <[email protected]>
Co-authored-by: Boyu <[email protected]>
Co-authored-by: Dung Dong <[email protected]>
Co-authored-by: Bryce Ito <[email protected]>
Co-authored-by: Suraj Reddy <[email protected]>
…fix, and package.json pathing fix (aws#7800)

## Problem
The inline test cannot be run consecutively with other tests in our
suite since it switches its focus to the editorView and textEditorView.
Each time the inline test is run, a new driver was launched with caused
a new VSCode instance to instantiate.

The `package.json` should only target the `.test.js` files. Right now it
targets all .js files in the directory.

The `writeToTextEditor` function is faulty since it is wrongly indexed
due to its element not being accessed before counting and referencing
its indices within code.

## Solution
Implemented an `after` function which correctly switches back to our
webviewView (AmazonQ). Added the true inline test into the suite and
fixed driver problem.

Changed the path referenced in the `package.json` to `.test.js` files. 

Fixed the `writeToTextEditor` function such that it includes a "dummy"
space input into the textEditor and then counts the number of indices of
lines. This then writes the desired text within the correct line without
problems.

---

- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
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.

7 participants