Skip to content

feat(amazonq): Add Pin Context Tests and Update to pinContextHelper #7829

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 3 commits into
base: feature/ui-e2e-tests
Choose a base branch
from

Conversation

surajrdy-aws
Copy link

@surajrdy-aws surajrdy-aws commented Aug 6, 2025

Problem

We have yet to implement the initial P0 Pin Context Tests. The pinContextHelper does not mesh well with sub menu items when clicking through different prompts to use.

Solution

I have implemented the File Context and Prompt Context Test. The Pin Context test with the @workspace was previously implemented. I have implemented the helpers: getSubMenuItems and clickSubMenuItem in the pinContextHelper. All tests still run together.

Test Suite:

  • View Context Options
  • Reusable Prompt (New)
  • Add File as context (New)
  • Add Workspace as Context

  • 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 6, 2025 18:39
Copy link

github-actions bot commented Aug 6, 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.

Copy link

@laura-codess laura-codess left a comment

Choose a reason for hiding this comment

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

LGTM

@laura-codess
Copy link

looks like we need to rebase the latest changes based on the github actions

@Hweinstock
Copy link
Contributor

feature --> feat

Invalid pull request title: `feature(amazonq): Add Pin Context Tests and Update to pinContextHelper`

* 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 Pin Context Tests and Update to pinContextHelper feat(amazonq): Add Pin Context Tests and Update to pinContextHelper Aug 12, 2025
@surajrdy-aws surajrdy-aws reopened this Aug 12, 2025
export async function getSubMenuItems(webview: WebviewView): Promise<{ items: WebElement[]; labels: string[] }> {
try {
const menuList = await waitForElement(webview, By.css('.mynah-detailed-list-items-block'))
await sleep(3000)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this additional sleep needed?

console.log('Menu item found:', labelText)
} catch (e) {
labels.push('')
console.log('Could not get text for menu item')
Copy link
Contributor

Choose a reason for hiding this comment

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

should we fail here? If we can't find an item in the menu isn't that indicative of a bug?


return { items: menuListItems, labels }
} catch (e) {
console.error('Error getting Pin Context menu items:', e)
Copy link
Contributor

Choose a reason for hiding this comment

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

same question here.

export async function clickSubMenuItem(webview: WebviewView, itemName: string): Promise<boolean> {
try {
const menuList = await waitForElement(webview, By.css('.mynah-detailed-list-items-block'))
await sleep(3000)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this sleep needed? Shouldn't it be covered by waitForElement?

return true
}
} catch (e) {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

same question as above about errors.

console.log(`Pin Context menu item not found: ${itemName}`)
return false
} catch (e) {
console.error(`Error clicking Pin Context menu item ${itemName}:`, e)
Copy link
Contributor

Choose a reason for hiding this comment

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

If this fails I think we should throw instead of returning a boolean.

await createPrompt.click()
await clickPinContextButton(webviewView)
await clickPinContextMenuItem(webviewView, 'Prompts')
await clickSubMenuItem(webviewView, 'test')
Copy link
Contributor

Choose a reason for hiding this comment

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

my understanding is that this returns a boolean false if it fails, but this won't cause the test to fail.

await clickPinContextMenuItem(webviewView, '@workspace')
})
it('Prompts Context Test', 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 idea before on test labels.

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.

3 participants