Skip to content

feat(amazonq): UI Tests Baseline Framework Complete Set Up #7727

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

Merged
merged 40 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
98688bf
initial VET commit with baseline setup + dependencies
laura-codess Jul 2, 2025
5959a38
deleting unnecessary dependencies and refactoring some of VET.test.ts
laura-codess Jul 2, 2025
4540f16
added back the buffer dependency because it failed the tests without it
laura-codess Jul 3, 2025
f1afe95
it was not any of the dependencies that was causing it to break, it w…
laura-codess Jul 3, 2025
4fa90ec
added back some more node: protocol imports to see if it passes all t…
laura-codess Jul 3, 2025
e1c33d8
forgot to save a webpack change. hoping it will fix the one failing t…
laura-codess Jul 3, 2025
ea46464
added back basically all the dependencies because 1 test keeps failing
laura-codess Jul 3, 2025
66f198d
Adding a simple test to send a chat prompt and check if theres a resp…
laura-codess Jul 11, 2025
dd62e27
Adding the wait to improve the robustness
laura-codess Jul 11, 2025
866478a
added logic to the after function to close all the chat tabs after th…
laura-codess Jul 11, 2025
35c656f
fixed the merge conflicts
laura-codess Jul 14, 2025
ed3c220
tested the timeouts, implemented a general wait function
laura-codess Jul 14, 2025
824635e
Merge branch 'feature/ui-e2e-tests' of https://github.com/aws/aws-too…
laura-codess Jul 15, 2025
b30f7f4
checked out master version
laura-codess Jul 15, 2025
5da6336
fix: ignore scripts change
laura-codess Jul 15, 2025
c8ccbae
implementing the initial setup for the framework
laura-codess Jul 16, 2025
74011d2
added setup.ts and testContext so that auth can be shared across tests
laura-codess Jul 17, 2025
b66da8c
implemented the backslash abstraction, required implementing function…
laura-codess Jul 17, 2025
3723e0d
Removed VET.test.ts
laura-codess Jul 17, 2025
8c3a109
implementing a pin context test suite with all the abstractions in pi…
laura-codess Jul 17, 2025
a4d6b32
Removed VET.test.ts
laura-codess Jul 17, 2025
d2bc9dd
small . fix
laura-codess Jul 17, 2025
693404d
fixed the PR based on the comments
laura-codess Jul 17, 2025
2990971
removing comments
laura-codess Jul 18, 2025
bebb6f1
Merge branch 'initializing_framework' into implement_pin_context_test
laura-codess Jul 18, 2025
5fc2de5
fixing the comments and adding the signout functionality
laura-codess Jul 18, 2025
1f830e2
implemented the switchModel test
laura-codess Jul 18, 2025
869c5a4
abstracted the functions in backslash.test.ts
laura-codess Jul 18, 2025
dd78bc2
Merge branch 'implement_backslash' into implement_switch_model
laura-codess Jul 18, 2025
d167c80
small . fix
laura-codess Jul 21, 2025
489712a
added clearChat
laura-codess Jul 21, 2025
c0e319d
changes to the after function
laura-codess Jul 21, 2025
645845f
reverting changes
laura-codess Jul 21, 2025
390f69f
Huge PR
laura-codess Jul 22, 2025
60b136f
small fixes to the waitForElements
laura-codess Jul 22, 2025
098c829
change all the backslash words to quick actions
laura-codess Jul 22, 2025
15bd216
undo change
laura-codess Jul 22, 2025
ad480bc
fixed small nit
laura-codess Jul 22, 2025
8efb913
restructured the files
laura-codess Jul 22, 2025
4dce964
adding some spaces to make auth more readable
laura-codess Jul 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 0 additions & 166 deletions packages/amazonq/test/e2e/amazonq/VET.test.ts

This file was deleted.

106 changes: 106 additions & 0 deletions packages/amazonq/test/e2e_new/amazonq/helpers/pinContextHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import { By, WebviewView } from 'vscode-extension-tester'
import { sleep, waitForElement } from '../utils/generalUtils'
import { WebElement } from 'vscode-extension-tester'

/**
* Clicks the "Pin Context" button in the chat interface
* @param webview The WebviewView instance
* @returns Promise<boolean> True if button was found and clicked, false otherwise
*/
export async function clickPinContextButton(webview: WebviewView): Promise<boolean> {
try {
const topBar = await waitForElement(webview, By.css('.mynah-prompt-input-top-bar'))
const buttons = await topBar.findElements(
By.css('.mynah-button.mynah-button-secondary.fill-state-always.status-clear.mynah-ui-clickable-item')
)
// double check the label to make sure it says "Pin Context"
for (const button of buttons) {
const label = await button.findElement(By.css('.mynah-button-label'))
const labelText = await label.getText()
console.log('THE BUTTON TEXT LABEL IS:', labelText)
if (labelText === '@Pin Context') {
console.log('Found Pin Context button, clicking...')
await button.click()
return true
}
}
console.log('Pin Context button not found')
return false
} catch (e) {
console.error('Error clicking Pin Context button:', e)
return false
}
}

/**
* Lists all the possible Pin Context menu items in the console.
* @param webview The WebviewView instance
* @returns Promise<boolean> Returns the items as a WebElement List and the labels in a string array
*/
export async function getPinContextMenuItems(webview: WebviewView): Promise<{ items: WebElement[]; labels: string[] }> {
try {
const menuList = await waitForElement(webview, By.css('.mynah-detailed-list-items-block'))
await sleep(3000)
const menuListItems = await menuList.findElements(By.css('.mynah-detailed-list-item.mynah-ui-clickable-item'))
const labels: string[] = []

for (const item of menuListItems) {
try {
const textWrapper = await item.findElement(By.css('.mynah-detailed-list-item-text'))
const nameElement = await textWrapper.findElement(By.css('.mynah-detailed-list-item-name'))
const labelText = await nameElement.getText()
labels.push(labelText)
console.log('Menu item found:', labelText)
} catch (e) {
labels.push('')
console.log('Could not get text for menu item')
}
}

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

/**
* Clicks a specific item in the Pin Context menu by its label text
* @param webview The WebviewView instance
* @param itemName The text label of the menu item to click
* @returns Promise<boolean> True if the item was found and clicked, false otherwise
*
* NOTE: To find all possible text labels, you can call getPinContextMenuItems
*/
export async function clickPinContextMenuItem(webview: WebviewView, itemName: string): Promise<boolean> {
try {
const menuList = await waitForElement(webview, By.css('.mynah-detailed-list-items-block'))
await sleep(3000)
const menuListItems = await menuList.findElements(By.css('.mynah-detailed-list-item.mynah-ui-clickable-item'))
for (const item of menuListItems) {
try {
const textWrapper = await item.findElement(By.css('.mynah-detailed-list-item-text'))
const nameElement = await textWrapper.findElement(By.css('.mynah-detailed-list-item-name'))
const labelText = await nameElement.getText()

if (labelText === itemName) {
console.log(`Clicking Pin Context menu item: ${itemName}`)
await item.click()
return true
}
} catch (e) {
continue
}
}

console.log(`Pin Context menu item not found: ${itemName}`)
return false
} catch (e) {
console.error(`Error clicking Pin Context menu item ${itemName}:`, e)
return false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

import { By, WebElement, WebviewView } from 'vscode-extension-tester'
import { writeToChat } from '../utils/generalUtils'
import { sleep, waitForElements } from '../utils/generalUtils'

/**
* Gets all quick action command menu items
* @param webview The WebviewView instance
* @returns Promise<{items: WebElement[], texts: string[]}> Array of menu items and their text labels
*/
export async function getQuickActionsCommands(webview: WebviewView): Promise<{ items: WebElement[]; texts: string[] }> {
try {
await writeToChat('/', webview, false)
await sleep(2000)

const menuItems = await waitForElements(
webview,
By.css('.mynah-detailed-list-item.mynah-ui-clickable-item.target-command'),
10000
)

const menuTexts = []
for (let i = 0; i < menuItems.length; i++) {
try {
const text = await menuItems[i].getText()
menuTexts.push(text)
console.log(`Command ${i + 1}: ${text}`)
} catch (e) {
menuTexts.push('')
console.log(`Could not get text for command ${i + 1}`)
}
}

console.log(`Found ${menuItems.length} quick action command items`)
return { items: menuItems, texts: menuTexts }
} catch (e) {
console.error('Error getting quick action commands:', e)
return { items: [], texts: [] }
}
}

/**
* Clicks a specific quick action command by name
* @param webview The WebviewView instance
* @param commandName The name of the command to click
* @returns Promise<boolean> True if command was found and clicked, false otherwise
*/
export async function clickQuickActionsCommand(webview: WebviewView, commandName: string): Promise<boolean> {
try {
const { items, texts } = await getQuickActionsCommands(webview)
if (items.length === 0) {
console.log('No quick action commands found to click')
return false
}
const indexToClick = texts.findIndex((text) => text === commandName)

if (indexToClick === -1) {
console.log(`Command "${commandName}" not found`)
return false
}
console.log(`Clicking on command: ${commandName}`)
await items[indexToClick].click()
await sleep(3000)
console.log('Command clicked successfully')
return true
} catch (e) {
console.error('Error clicking quick action command:', e)
return false
}
}
Loading
Loading