Skip to content

feat(amazonq): Added basic chat tests & fixed nomenclature of clearChat util #7812

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 7 commits into
base: feature/ui-e2e-tests
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 20 additions & 8 deletions packages/amazonq/test/e2e_new/amazonq/tests/chat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
import '../utils/setup'
import { WebviewView } from 'vscode-extension-tester'
import { WebviewView, By } from 'vscode-extension-tester'
import { testContext } from '../utils/testContext'
import { clearChat, waitForChatResponse, writeToChat } from '../utils/generalUtils'
import { waitForChatResponse, writeToChat, waitForElement } from '../utils/generalUtils'
import { closeAllTabs } from '../utils/cleanupUtils'

describe('Amazon Q Chat Basic Functionality', function () {
Expand All @@ -17,20 +17,32 @@ describe('Amazon Q Chat Basic Functionality', function () {
webviewView = testContext.webviewView
})

after(async function () {
afterEach(async function () {
await closeAllTabs(webviewView)
})

afterEach(async () => {
await clearChat(webviewView)
})

it('Chat Prompt Test', async () => {
it('Allows User to Chat with AmazonQ', async () => {
await writeToChat('Hello, Amazon Q!', webviewView)
const responseReceived = await waitForChatResponse(webviewView)
if (!responseReceived) {
throw new Error('Chat response not received within timeout')
}
console.log('Chat response detected successfully')
})
it('Allows User to Add Multiple Chat Tabs', async () => {
console.log('Starting Multiple Chat Test')
for (let i = 0; i < 3; i++) {
const addChat = await webviewView.findWebElement(By.css('.mynah-ui-icon.mynah-ui-icon-plus'))
await addChat.click()
}
})
it('Allows User to View Chat History', async () => {
console.log('Starting View History Test')
const viewHistory = await webviewView.findWebElement(By.css('.mynah-ui-icon.mynah-ui-icon-history'))
await viewHistory.click()
await waitForElement(webviewView, By.css('.mynah-detailed-list-item-groups-wrapper'))
console.log('History wrapper found successfully')
const closeHistory = await waitForElement(webviewView, By.css('.mynah-ui-icon.mynah-ui-icon-cancel'))
await closeHistory.click()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { WebviewView } from 'vscode-extension-tester'
import { closeAllTabs, dismissOverlayIfPresent } from '../utils/cleanupUtils'
import { testContext } from '../utils/testContext'
import { clickPinContextButton, getPinContextMenuItems, clickPinContextMenuItem } from '../helpers/pinContextHelper'
import { clearChat } from '../utils/generalUtils'
import { clearChatInput } from '../utils/generalUtils'

describe('Amazon Q Pin Context Functionality', function () {
// this timeout is the general timeout for the entire test suite
Expand All @@ -24,7 +24,7 @@ describe('Amazon Q Pin Context Functionality', function () {

afterEach(async () => {
await dismissOverlayIfPresent(webviewView)
await clearChat(webviewView)
await clearChatInput(webviewView)
})

it('Pin Context Test', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { WebviewView } from 'vscode-extension-tester'
import { closeAllTabs, dismissOverlayIfPresent } from '../utils/cleanupUtils'
import { testContext } from '../utils/testContext'
import { clickQuickActionsCommand } from '../helpers/quickActionsHelper'
import { clearChat } from '../utils/generalUtils'
import { clearChatInput } from '../utils/generalUtils'

describe('Amazon Q Chat Quick Actions Functionality', function () {
// this timeout is the general timeout for the entire test suite
Expand All @@ -25,7 +25,7 @@ describe('Amazon Q Chat Quick Actions Functionality', function () {
afterEach(async () => {
// before closing the tabs, make sure that any overlays have been dismissed
await dismissOverlayIfPresent(webviewView)
await clearChat(webviewView)
await clearChatInput(webviewView)
})

it('Quick Actions Test', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export async function waitForChatResponse(webview: WebviewView, timeout = 15000)
* @param webview The WebviewView instance
* @returns Promise<boolean> True if successful, false if an error occurred
*/
export async function clearChat(webview: WebviewView): Promise<boolean> {
export async function clearChatInput(webview: WebviewView): Promise<boolean> {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, I like how this disambiguates between it clearing the entire chat window and the chat contents itself.

try {
const chatInput = await waitForElement(webview, By.css('.mynah-chat-prompt-input'))
await chatInput.sendKeys(
Expand Down
Loading