Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
26 changes: 19 additions & 7 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,14 +17,10 @@ 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 () => {
await writeToChat('Hello, Amazon Q!', webviewView)
const responseReceived = await waitForChatResponse(webviewView)
Expand All @@ -33,4 +29,20 @@ describe('Amazon Q Chat Basic Functionality', function () {
}
console.log('Chat response detected successfully')
})
it('Multiple Chat 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.

can we use a more descriptive label here? Usually each it is followed by an action. Ex. "allows user to add multiple tabs"

Copy link
Author

Choose a reason for hiding this comment

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

Ah I see, didn't realize that! Will update all functions accordingly.

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('View History', 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 as above.

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