-
Notifications
You must be signed in to change notification settings - Fork 747
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
laura-codess
merged 40 commits into
aws:feature/ui-e2e-tests
from
laura-codess:after_function_fix
Jul 23, 2025
Merged
Changes from 38 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 5959a38
deleting unnecessary dependencies and refactoring some of VET.test.ts
laura-codess 4540f16
added back the buffer dependency because it failed the tests without it
laura-codess f1afe95
it was not any of the dependencies that was causing it to break, it w…
laura-codess 4fa90ec
added back some more node: protocol imports to see if it passes all t…
laura-codess e1c33d8
forgot to save a webpack change. hoping it will fix the one failing t…
laura-codess ea46464
added back basically all the dependencies because 1 test keeps failing
laura-codess 66f198d
Adding a simple test to send a chat prompt and check if theres a resp…
laura-codess dd62e27
Adding the wait to improve the robustness
laura-codess 866478a
added logic to the after function to close all the chat tabs after th…
laura-codess 35c656f
fixed the merge conflicts
laura-codess ed3c220
tested the timeouts, implemented a general wait function
laura-codess 824635e
Merge branch 'feature/ui-e2e-tests' of https://github.com/aws/aws-too…
laura-codess b30f7f4
checked out master version
laura-codess 5da6336
fix: ignore scripts change
laura-codess c8ccbae
implementing the initial setup for the framework
laura-codess 74011d2
added setup.ts and testContext so that auth can be shared across tests
laura-codess b66da8c
implemented the backslash abstraction, required implementing function…
laura-codess 3723e0d
Removed VET.test.ts
laura-codess 8c3a109
implementing a pin context test suite with all the abstractions in pi…
laura-codess a4d6b32
Removed VET.test.ts
laura-codess d2bc9dd
small . fix
laura-codess 693404d
fixed the PR based on the comments
laura-codess 2990971
removing comments
laura-codess bebb6f1
Merge branch 'initializing_framework' into implement_pin_context_test
laura-codess 5fc2de5
fixing the comments and adding the signout functionality
laura-codess 1f830e2
implemented the switchModel test
laura-codess 869c5a4
abstracted the functions in backslash.test.ts
laura-codess dd78bc2
Merge branch 'implement_backslash' into implement_switch_model
laura-codess d167c80
small . fix
laura-codess 489712a
added clearChat
laura-codess c0e319d
changes to the after function
laura-codess 645845f
reverting changes
laura-codess 390f69f
Huge PR
laura-codess 60b136f
small fixes to the waitForElements
laura-codess 098c829
change all the backslash words to quick actions
laura-codess 15bd216
undo change
laura-codess ad480bc
fixed small nit
laura-codess 8efb913
restructured the files
laura-codess 4dce964
adding some spaces to make auth more readable
laura-codess File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| import { Workbench, By, WebviewView } from 'vscode-extension-tester' | ||
| import { findItemByText, sleep, waitForElements } from '../utils/generalHelper' | ||
| import { testContext } from '../utils/testContext' | ||
|
|
||
| /* Completes the entire Amazon Q login flow | ||
|
|
||
| Currently, the function will | ||
| 1. Open AmazonQ | ||
| 2. Clicks Company Account | ||
| 3. Inputs the Start URL | ||
| 4. IMPORTANT: you must click manually open yourself when the popup window asks to open the browser and complete the authentication in the browser** | ||
|
|
||
| TO-DO: Currently this signInToAmazonQ is not fully autonomous as we ran into a blocker when the browser window pops up */ | ||
| export async function signInToAmazonQ(): Promise<void> { | ||
| const workbench = new Workbench() | ||
| await workbench.executeCommand('Amazon Q: Open Chat') | ||
|
|
||
| await sleep(5000) | ||
| let webviewView = new WebviewView() | ||
| await webviewView.switchToFrame() | ||
|
|
||
| const selectableItems = await waitForElements(webviewView, By.css('.selectable-item')) | ||
| if (selectableItems.length === 0) { | ||
| throw new Error('No selectable login options found') | ||
| } | ||
|
|
||
| const companyItem = await findItemByText(selectableItems, 'Company account') | ||
| await companyItem.click() | ||
| const signInContinue = await webviewView.findWebElement(By.css('#connection-selection-continue-button')) | ||
laura-codess marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| await signInContinue.click() | ||
| const startUrlInput = await webviewView.findWebElement(By.id('startUrl')) | ||
| await startUrlInput.clear() | ||
| await startUrlInput.sendKeys('https://amzn.awsapps.com/start') | ||
| const UrlContinue = await webviewView.findWebElement(By.css('button.continue-button.topMargin')) | ||
laura-codess marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| await UrlContinue.click() | ||
| console.log('Waiting for manual authentication...') | ||
| await sleep(12000) | ||
| console.log('Manual authentication should be done') | ||
laura-codess marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| await webviewView.switchBack() | ||
|
|
||
| const editorView = workbench.getEditorView() | ||
| await editorView.closeAllEditors() | ||
| webviewView = new WebviewView() | ||
| await webviewView.switchToFrame() | ||
|
|
||
| testContext.workbench = workbench | ||
| testContext.webviewView = webviewView | ||
| } | ||
|
|
||
| /* NOTE: The workbench and webviewView is grabbed directly from testContext because we are under the assumption that if you want to log out | ||
| you've already logged in before. */ | ||
| export async function signOutFromAmazonQ(workbench: Workbench): Promise<void> { | ||
| await workbench.executeCommand('Amazon Q: Sign Out') | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| import '../utils/setup' | ||
| import { WebviewView } from 'vscode-extension-tester' | ||
| import { testContext } from '../utils/testContext' | ||
| import { clearChat, waitForChatResponse, writeToChat } from './chatHelper' | ||
| import { closeAllTabs } from '../utils/cleanupHelper' | ||
|
|
||
| describe('Amazon Q Chat Basic Functionality', function () { | ||
| // this timeout is the general timeout for the entire test suite | ||
| this.timeout(150000) | ||
| let webviewView: WebviewView | ||
|
|
||
| before(async function () { | ||
| webviewView = testContext.webviewView | ||
laura-codess marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }) | ||
|
|
||
| after(async function () { | ||
| await closeAllTabs(webviewView) | ||
| }) | ||
|
|
||
| afterEach(async () => { | ||
| await clearChat(webviewView) | ||
| }) | ||
|
|
||
| it('Chat Prompt Test', async () => { | ||
| await writeToChat('Hello, Amazon Q!', webviewView) | ||
| const responseReceived = await waitForChatResponse(webviewView) | ||
laura-codess marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (!responseReceived) { | ||
| throw new Error('Chat response not received within timeout') | ||
| } | ||
| console.log('Chat response detected successfully') | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /*! | ||
| * 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/generalHelper' | ||
|
|
||
| /** | ||
| * Writes text to the chat input and optionally sends it | ||
| * @param prompt The text to write in the chat input | ||
| * @param webview The WebviewView instance | ||
| * @param send Whether to click the send button (defaults to true) | ||
| * @returns Promise<boolean> True if successful | ||
| */ | ||
| export async function writeToChat(prompt: string, webview: WebviewView, send = true): Promise<boolean> { | ||
laura-codess marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const chatInput = await waitForElement(webview, By.css('.mynah-chat-prompt-input')) | ||
| await chatInput.sendKeys(prompt) | ||
| if (send === true) { | ||
| const sendButton = await waitForElement(webview, By.css('.mynah-chat-prompt-button')) | ||
| await sendButton.click() | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| /** | ||
| * Waits for a chat response to be generated | ||
| * @param webview The WebviewView instance | ||
| * @param timeout The timeout in milliseconds | ||
| * @returns Promise<boolean> True if a response was detected, false if timeout occurred | ||
| */ | ||
| export async function waitForChatResponse(webview: WebviewView, timeout = 15000): Promise<boolean> { | ||
| const startTime = Date.now() | ||
|
|
||
| while (Date.now() - startTime < timeout) { | ||
| const conversationContainers = await webview.findWebElements(By.css('.mynah-chat-items-conversation-container')) | ||
|
|
||
| if (conversationContainers.length > 0) { | ||
| const latestContainer = conversationContainers[conversationContainers.length - 1] | ||
|
|
||
| const chatItems = await latestContainer.findElements(By.css('*')) | ||
|
|
||
| if (chatItems.length >= 2) { | ||
| return true | ||
| } | ||
| } | ||
| await sleep(500) | ||
| } | ||
|
|
||
| return false | ||
| } | ||
|
|
||
| /** | ||
| * Clears the text in the chat input field | ||
| * @param webview The WebviewView instance | ||
| * @returns Promise<boolean> True if successful, false if an error occurred | ||
laura-codess marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| */ | ||
| export async function clearChat(webview: WebviewView): Promise<boolean> { | ||
| try { | ||
| const chatInput = await waitForElement(webview, By.css('.mynah-chat-prompt-input')) | ||
| await chatInput.sendKeys( | ||
| process.platform === 'darwin' | ||
| ? '\uE03D\u0061' // Command+A on macOS | ||
laura-codess marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| : '\uE009\u0061' // Ctrl+A on Windows/Linux | ||
| ) | ||
| await chatInput.sendKeys('\uE003') // Backspace | ||
| return true | ||
| } catch (e) { | ||
| console.error('Error clearing chat input:', e) | ||
| return false | ||
| } | ||
| } | ||
35 changes: 35 additions & 0 deletions
35
packages/amazonq/test/e2e_new/amazonq/pinContext/pinContext.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| import '../utils/setup' | ||
| import { WebviewView } from 'vscode-extension-tester' | ||
| import { closeAllTabs, dismissOverlayIfPresent } from '../utils/cleanupHelper' | ||
| import { testContext } from '../utils/testContext' | ||
| import { clickPinContextButton, getPinContextMenuItems, clickPinContextMenuItem } from './pinContextHelper' | ||
| import { clearChat } from '../chat/chatHelper' | ||
|
|
||
| describe('Amazon Q Pin Context Functionality', function () { | ||
| // this timeout is the general timeout for the entire test suite | ||
| this.timeout(150000) | ||
| let webviewView: WebviewView | ||
|
|
||
| before(async function () { | ||
| webviewView = testContext.webviewView | ||
| }) | ||
|
|
||
| after(async function () { | ||
| await closeAllTabs(webviewView) | ||
| }) | ||
|
|
||
| afterEach(async () => { | ||
| await dismissOverlayIfPresent(webviewView) | ||
| await clearChat(webviewView) | ||
| }) | ||
|
|
||
| it('Pin Context Test', async () => { | ||
| await clickPinContextButton(webviewView) | ||
| await getPinContextMenuItems(webviewView) | ||
| await clickPinContextMenuItem(webviewView, '@workspace') | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.