Skip to content

Commit 2d028ed

Browse files
authored
feat(amazonq): Added basic chat tests & fixed nomenclature of clearChat util (#7812)
## Problem We have yet to implement the multiple chat test and the view history chat test. The clearChat abstraction can also be confusing to some individuals since the /clear command is different. ## Solution I have made the clearChat abstraction clearer in name so people do not get confused with the /clear command. Additionally, I have implemented the multipleChatTest and the viewHistory chat 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.
1 parent e97c6e9 commit 2d028ed

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

packages/amazonq/test/e2e_new/amazonq/tests/chat.test.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55
import '../utils/setup'
6-
import { WebviewView } from 'vscode-extension-tester'
6+
import { WebviewView, By } from 'vscode-extension-tester'
77
import { testContext } from '../utils/testContext'
8-
import { clearChat, waitForChatResponse, writeToChat } from '../utils/generalUtils'
8+
import { waitForChatResponse, writeToChat, waitForElement } from '../utils/generalUtils'
99
import { closeAllTabs } from '../utils/cleanupUtils'
1010

1111
describe('Amazon Q Chat Basic Functionality', function () {
@@ -17,20 +17,32 @@ describe('Amazon Q Chat Basic Functionality', function () {
1717
webviewView = testContext.webviewView
1818
})
1919

20-
after(async function () {
20+
afterEach(async function () {
2121
await closeAllTabs(webviewView)
2222
})
2323

24-
afterEach(async () => {
25-
await clearChat(webviewView)
26-
})
27-
28-
it('Chat Prompt Test', async () => {
24+
it('Allows User to Chat with AmazonQ', async () => {
2925
await writeToChat('Hello, Amazon Q!', webviewView)
3026
const responseReceived = await waitForChatResponse(webviewView)
3127
if (!responseReceived) {
3228
throw new Error('Chat response not received within timeout')
3329
}
3430
console.log('Chat response detected successfully')
3531
})
32+
it('Allows User to Add Multiple Chat Tabs', async () => {
33+
console.log('Starting Multiple Chat Test')
34+
for (let i = 0; i < 3; i++) {
35+
const addChat = await webviewView.findWebElement(By.css('.mynah-ui-icon.mynah-ui-icon-plus'))
36+
await addChat.click()
37+
}
38+
})
39+
it('Allows User to View Chat History', async () => {
40+
console.log('Starting View History Test')
41+
const viewHistory = await webviewView.findWebElement(By.css('.mynah-ui-icon.mynah-ui-icon-history'))
42+
await viewHistory.click()
43+
await waitForElement(webviewView, By.css('.mynah-detailed-list-item-groups-wrapper'))
44+
console.log('History wrapper found successfully')
45+
const closeHistory = await waitForElement(webviewView, By.css('.mynah-ui-icon.mynah-ui-icon-cancel'))
46+
await closeHistory.click()
47+
})
3648
})

packages/amazonq/test/e2e_new/amazonq/tests/pinContext.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { WebviewView } from 'vscode-extension-tester'
77
import { closeAllTabs, dismissOverlayIfPresent } from '../utils/cleanupUtils'
88
import { testContext } from '../utils/testContext'
99
import { clickPinContextButton, getPinContextMenuItems, clickPinContextMenuItem } from '../helpers/pinContextHelper'
10-
import { clearChat } from '../utils/generalUtils'
10+
import { clearChatInput } from '../utils/generalUtils'
1111

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

2525
afterEach(async () => {
2626
await dismissOverlayIfPresent(webviewView)
27-
await clearChat(webviewView)
27+
await clearChatInput(webviewView)
2828
})
2929

3030
it('Pin Context Test', async () => {

packages/amazonq/test/e2e_new/amazonq/tests/quickActions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { WebviewView } from 'vscode-extension-tester'
77
import { closeAllTabs, dismissOverlayIfPresent } from '../utils/cleanupUtils'
88
import { testContext } from '../utils/testContext'
99
import { clickQuickActionsCommand } from '../helpers/quickActionsHelper'
10-
import { clearChat } from '../utils/generalUtils'
10+
import { clearChatInput } from '../utils/generalUtils'
1111

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

3131
it('Quick Actions Test', async () => {

packages/amazonq/test/e2e_new/amazonq/utils/generalUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export async function waitForChatResponse(webview: WebviewView, timeout = 15000)
117117
* @param webview The WebviewView instance
118118
* @returns Promise<boolean> True if successful, false if an error occurred
119119
*/
120-
export async function clearChat(webview: WebviewView): Promise<boolean> {
120+
export async function clearChatInput(webview: WebviewView): Promise<boolean> {
121121
try {
122122
const chatInput = await waitForElement(webview, By.css('.mynah-chat-prompt-input'))
123123
await chatInput.sendKeys(

0 commit comments

Comments
 (0)