Skip to content

Commit 5fc2de5

Browse files
committed
fixing the comments and adding the signout functionality
1 parent bebb6f1 commit 5fc2de5

File tree

7 files changed

+221
-8
lines changed

7 files changed

+221
-8
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
export default {
7+
selector: 'data-testid',
8+
prompt: {
9+
wrapper: 'prompt-input-wrapper',
10+
attachmentWrapper: 'prompt-input-attachment-wrapper',
11+
attachment: 'prompt-input-attachment',
12+
options: 'prompt-input-options',
13+
attachmentRemove: 'prompt-input-attachment-remove-button',
14+
send: 'prompt-input-send-button',
15+
input: 'prompt-input-textarea',
16+
inputWrapper: 'prompt-input-input-wrapper',
17+
remainingCharsIndicator: 'prompt-input-remaining-chars-indicator',
18+
contextTooltip: 'prompt-input-context-tooltip',
19+
selectedCommand: 'prompt-input-selected-command',
20+
quickPicksWrapper: 'prompt-input-quick-picks-wrapper',
21+
quickPicksGroup: 'prompt-input-quick-picks-group',
22+
quickPicksGroupTitle: 'prompt-input-quick-picks-group-title',
23+
quickPickItem: 'prompt-input-quick-pick-item',
24+
footerInfo: 'prompt-input-footer-info',
25+
footerInfoBody: 'prompt-input-footer-info-body',
26+
stickyCard: 'prompt-input-sticky-card',
27+
progress: 'prompt-input-progress-wrapper',
28+
label: 'prompt-input-label',
29+
topBar: 'prompt-input-top-bar',
30+
topBarButton: 'prompt-input-top-bar-button',
31+
topBarContextPill: 'prompt-input-top-bar-context-pill',
32+
topBarContextTooltip: 'prompt-input-top-bar-context-tooltip',
33+
tobBarOverflowPill: 'prompt-input-top-bar-overflow-pill',
34+
tobBarOverflowOverlay: 'prompt-input-top-bar-overflow-overlay',
35+
tobBarActionOverlay: 'prompt-input-top-bar-action-overlay',
36+
},
37+
chat: {
38+
wrapper: 'chat-wrapper',
39+
chatItemsContainer: 'chat-chat-items-container',
40+
conversationContainer: 'chat-chat-items-conversation-container',
41+
middleBlockWrapper: 'chat-middle-block-wrapper',
42+
stopButton: 'chat-middle-block-stop-button',
43+
header: 'chat-wrapper-header-details',
44+
moreContentIndicator: 'chat-wrapper-more-content-available-indicator',
45+
moreContentIndicatorButton: 'chat-wrapper-more-content-available-indicator-button',
46+
},
47+
chatItem: {
48+
type: {
49+
any: 'chat-item',
50+
answer: 'chat-item-answer',
51+
answerStream: 'chat-item-answer-stream',
52+
prompt: 'chat-item-prompt',
53+
aiPrompt: 'chat-item-ai-prompt',
54+
systemPrompt: 'chat-item-system-prompt',
55+
},
56+
moreContentIndicator: 'chat-item-card-more-content-indicator',
57+
card: 'chat-item-card',
58+
cardBody: 'chat-item-card-body',
59+
buttons: {
60+
wrapper: 'chat-item-buttons-wrapper',
61+
button: 'chat-item-action-button',
62+
},
63+
dismissButton: 'chat-item-dismiss-button',
64+
chatItemFollowup: {
65+
optionsWrapper: 'chat-item-followup-options-wrapper',
66+
optionButton: 'chat-item-followup-option',
67+
title: 'chat-item-followup-title',
68+
wrapper: 'chat-item-followup-wrapper',
69+
},
70+
syntaxHighlighter: {
71+
wrapper: 'chat-item-syntax-highlighter-wrapper',
72+
codeBlock: 'chat-item-syntax-highlighter-code-block',
73+
lineNumbers: 'chat-item-syntax-highlighter-line-numbers',
74+
language: 'chat-item-syntax-highlighter-language',
75+
buttonsWrapper: 'chat-item-syntax-highlighter-buttons-wrapper',
76+
button: 'chat-item-syntax-highlighter-button',
77+
},
78+
chatItemForm: {
79+
wrapper: 'chat-item-form-wrapper',
80+
title: 'chat-item-form-title',
81+
description: 'chat-item-form-description',
82+
itemSelectWrapper: 'chat-item-form-item-select-wrapper',
83+
itemSelect: 'chat-item-form-item-select',
84+
itemRadioWrapper: 'chat-item-form-item-radio-wrapper',
85+
itemRadio: 'chat-item-form-item-radio',
86+
itemInput: 'chat-item-form-item-text-input',
87+
itemList: 'chat-item-form-item-list',
88+
itemStarsWrapper: 'chat-item-form-item-stars-wrapper',
89+
itemStars: 'chat-item-form-item-stars',
90+
itemTextArea: 'chat-item-form-item-textarea',
91+
itemToggleWrapper: 'chat-item-form-item-toggle-wrapper',
92+
itemToggleOption: 'chat-item-form-item-toggle-option',
93+
itemSwitch: 'chat-item-form-item-switch',
94+
},
95+
vote: {
96+
wrapper: 'chat-item-vote-wrapper',
97+
upvote: 'chat-item-upvote',
98+
upvoteLabel: 'chat-item-upvote-label',
99+
downvote: 'chat-item-downvote',
100+
downvoteLabel: 'chat-item-downvote-label',
101+
reportButton: 'chat-item-vote-report',
102+
thanks: 'chat-item-vote-thanks',
103+
},
104+
relatedLinks: {
105+
showMore: 'chat-item-related-links-show-more',
106+
wrapper: 'chat-item-related-links-wrapper',
107+
title: 'chat-item-related-links-title',
108+
linkWrapper: 'chat-item-related-link-wrapper',
109+
link: 'chat-item-related-link',
110+
linkPreviewOverlay: 'chat-item-related-link-preview-overlay',
111+
linkPreviewOverlayCard: 'chat-item-related-link-preview-overlay-card',
112+
},
113+
fileTree: {
114+
wrapper: 'chat-item-file-tree-wrapper',
115+
title: 'chat-item-file-tree-title',
116+
license: 'chat-item-file-tree-license',
117+
folder: 'chat-item-file-tree-folder',
118+
file: 'chat-item-file-tree-file',
119+
fileAction: 'chat-item-file-tree-file-action',
120+
fileTooltipWrapper: 'chat-item-file-tree-file-tooltip-wrapper',
121+
},
122+
tabbedCard: {
123+
tabs: 'chat-item-tabbed-card-tabs',
124+
},
125+
},
126+
feedbackForm: {
127+
optionsSelectWrapper: 'feedback-form-options-select-wrapper',
128+
optionsSelect: 'feedback-form-options-select',
129+
comment: 'feedback-form-comment-text-area',
130+
cancelButton: 'feedback-form-cancel-button',
131+
submitButton: 'feedback-form-submit-button',
132+
},
133+
sheet: {
134+
wrapper: 'sheet-wrapper',
135+
header: 'sheet-header',
136+
title: 'sheet-title',
137+
description: 'sheet-description',
138+
closeButton: 'sheet-close-button',
139+
},
140+
detailedList: {
141+
action: 'detailed-list-action',
142+
actionMenu: 'detailed-list-action-menu',
143+
status: 'detailed-list-status',
144+
},
145+
tabBar: {
146+
wrapper: 'tab-bar-wrapper',
147+
buttonsWrapper: 'tab-bar-buttons-wrapper',
148+
button: 'tab-bar-button',
149+
menuButton: 'tab-bar-menu-button',
150+
menuOption: 'tab-bar-menu-option',
151+
tabsWrapper: 'tab-bar-tabs',
152+
tabOptionWrapper: 'tab-bar-tabs-option-wrapper',
153+
tabOption: 'tab-bar-tabs-option',
154+
tabOptionLabel: 'tab-bar-tabs-option-label',
155+
tabOptionCloseButton: 'tab-bar-tabs-option-close-button',
156+
tabAddButton: 'tab-bar-tab-add-button',
157+
maxTabsReachedOverlay: 'tab-bar-max-tabs-reached-overlay',
158+
tabCloseConfirmationOverlay: 'tab-bar-tab-close-confirmation-overlay',
159+
tabCloseConfirmationBody: 'tab-bar-tab-close-confirmation-body',
160+
tabCloseConfirmationCancelButton: 'tab-bar-tab-close-confirmation-cancel-button',
161+
tabCloseConfirmationAcceptButton: 'tab-bar-tab-close-confirmation-accept-button',
162+
},
163+
noTabs: {
164+
wrapper: 'no-tabs-wrapper',
165+
newTabButton: 'no-tabs-new-tab-button',
166+
},
167+
notification: {
168+
wrapper: 'notification-wrapper',
169+
title: 'notification-title',
170+
content: 'notification-content',
171+
},
172+
}

packages/amazonq/test/e2e_new/amazonq/framework/loginHelper.ts renamed to packages/amazonq/test/e2e_new/amazonq/framework/authHelper.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import { Workbench, By, WebviewView } from 'vscode-extension-tester'
66
import { waitForElement, findItemByText } from './generalHelper'
77
import { testContext } from '../utils/testContext'
8+
89
/* Completes the entire Amazon Q login flow
910
1011
Currently, the function will
@@ -14,8 +15,7 @@ Currently, the function will
1415
4. IMPORTANT: you must click manually open yourself when the popup window asks to open the browser and complete the authentication in the browser**
1516
1617
TO-DO: Currently this loginToAmazonQ is not fully autonomous as we ran into a blocker when the browser window pops up */
17-
18-
export async function loginToAmazonQ(): Promise<void> {
18+
export async function signInToAmazonQ(): Promise<void> {
1919
const workbench = new Workbench()
2020
await workbench.executeCommand('Amazon Q: Open Chat')
2121

@@ -50,3 +50,9 @@ export async function loginToAmazonQ(): Promise<void> {
5050
testContext.workbench = workbench
5151
testContext.webviewView = webviewView
5252
}
53+
54+
/* NOTE: The workbench and webviewView is grabbed directly from testContext because we are under the assumption that if you want to log out
55+
you've already logged in before. */
56+
export async function signOutFromAmazonQ(workbench: Workbench): Promise<void> {
57+
await workbench.executeCommand('Amazon Q: Sign Out')
58+
}

packages/amazonq/test/e2e_new/amazonq/framework/chatHelper.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
import { By, WebviewView } from 'vscode-extension-tester'
66
import { waitForElement } from './generalHelper'
77

8+
/**
9+
* Writes text to the chat input and optionally sends it
10+
* @param prompt The text to write in the chat input
11+
* @param webview The WebviewView instance
12+
* @param send Whether to click the send button (defaults to true)
13+
* @returns Promise<boolean> True if successful
14+
*/
815
export async function writeToChat(prompt: string, webview: WebviewView, send = true): Promise<boolean> {
916
const chatInput = await waitForElement(webview, By.css('.mynah-chat-prompt-input'))
1017
await chatInput.sendKeys(prompt)
@@ -15,6 +22,12 @@ export async function writeToChat(prompt: string, webview: WebviewView, send = t
1522
return true
1623
}
1724

25+
/**
26+
* Waits for a chat response to be generated
27+
* @param webview The WebviewView instance
28+
* @param timeout The timeout in milliseconds
29+
* @returns Promise<boolean> True if a response was detected, false if timeout occurred
30+
*/
1831
export async function waitForChatResponse(webview: WebviewView, timeout = 15000): Promise<boolean> {
1932
const startTime = Date.now()
2033

packages/amazonq/test/e2e_new/amazonq/framework/cleanupHelper.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
*/
55
import { By, WebviewView } from 'vscode-extension-tester'
66

7+
/**
8+
* Closes all open chat tabs
9+
* @param webview The WebviewView instance
10+
* @returns Promise<boolean> True if all tabs were successfully closed
11+
* @throws Error if tabs could not be closed
12+
*/
713
export async function closeAllTabs(webview: WebviewView): Promise<boolean> {
814
try {
915
const closeButtons = await webview.findWebElements(By.css('.mynah-tabs-close-button'))
@@ -30,6 +36,11 @@ export async function closeAllTabs(webview: WebviewView): Promise<boolean> {
3036
}
3137
}
3238

39+
/**
40+
* Attempts to dismiss any open overlays
41+
* @param webview The WebviewView instance
42+
* @returns Promise<boolean> True if overlay was dismissed or none was present, false if dismissal failed
43+
*/
3344
export async function dismissOverlayIfPresent(webview: WebviewView): Promise<boolean> {
3445
try {
3546
const overlays = await webview.findWebElements(By.css('.mynah-overlay.mynah-overlay-open'))

packages/amazonq/test/e2e_new/amazonq/framework/generalHelper.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
import { By, WebviewView, WebElement } from 'vscode-extension-tester'
66
import { until } from 'selenium-webdriver'
77

8-
/* Note: If multiple is set to False, then it will return the first element it finds that matches the Locator*/
8+
/**
9+
* Waits for an element to be located
10+
* @param webview The WebviewView instance
11+
* @param locator The selenium locator
12+
* @param multiple Whether to return multiple elements (Note: If multiple is set to False, then it will return the first element it finds that matches the Locator)
13+
* @param timeout The timeout in milliseconds
14+
* @returns Promise<WebElement | WebElement[]> Returns the element or multiple elements that were found
15+
*/
916
export async function waitForElement(
1017
webview: WebviewView,
1118
locator: By,
@@ -29,6 +36,13 @@ export async function waitForElement(
2936
return multiple ? await webview.findWebElements(locator) : await webview.findWebElement(locator)
3037
}
3138

39+
/**
40+
* Finds an item based on the text
41+
* @param items WebElement array to search
42+
* @param text The text of the item
43+
* @returns Promise<WebElement> The first element that contains the specified text
44+
* TO-DO: Make this function more general by eliminated the By.css('.title')
45+
*/
3246
export async function findItemByText(items: WebElement[], text: string) {
3347
for (const item of items) {
3448
const titleDivs = await item.findElements(By.css('.title'))

packages/amazonq/test/e2e_new/amazonq/framework/pinContextHelper.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,9 @@ export async function getPinContextMenuItems(webview: WebviewView): Promise<{ it
7878
*/
7979
export async function clickPinContextMenuItem(webview: WebviewView, itemName: string): Promise<boolean> {
8080
try {
81-
// Find the menu list independently
8281
const menuList = await waitForElement(webview, By.css('.mynah-detailed-list-items-block'))
8382
await new Promise((resolve) => setTimeout(resolve, 3000))
8483
const menuListItems = await menuList.findElements(By.css('.mynah-detailed-list-item.mynah-ui-clickable-item'))
85-
// Iterate through items to find the one with matching text
8684
for (const item of menuListItems) {
8785
try {
8886
const textWrapper = await item.findElement(By.css('.mynah-detailed-list-item-text'))
@@ -95,7 +93,6 @@ export async function clickPinContextMenuItem(webview: WebviewView, itemName: st
9593
return true
9694
}
9795
} catch (e) {
98-
// Continue to next item if this one has issues
9996
continue
10097
}
10198
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
5-
import { loginToAmazonQ } from '../framework/loginHelper'
5+
import { signInToAmazonQ } from '../framework/loginHelper'
66

77
before(async function () {
88
this.timeout(60000)
99
console.log('\n\n*** MANUAL INTERVENTION REQUIRED ***')
1010
console.log('When prompted, you must manually click to open the browser and complete authentication')
1111
console.log('You have 60 seconds to complete this step\n\n')
12-
await loginToAmazonQ()
12+
await signInToAmazonQ()
1313
})

0 commit comments

Comments
 (0)