Skip to content

Commit b4af3b4

Browse files
committed
Removed Javascript file for npm script and made it all through CLI arguements, fixed PR conflicts
1 parent 74c5770 commit b4af3b4

File tree

8 files changed

+76
-634
lines changed

8 files changed

+76
-634
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ telemetryCache
1414
quickStart*.html
1515
.gitcommit
1616
__pycache__
17+
packages/amazonq/.vscodeignore
1718

1819
# Generated if running the `depcruise` command from the documentation example
1920
/dependency-graph.svg

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"test": "npm run test -w packages/ --if-present",
2929
"testWeb": "npm run testWeb -w packages/ --if-present",
3030
"testE2E": "npm run testE2E -w packages/ --if-present",
31-
"setupE2E": "cd packages/amazonq && npm run package > ../../vsix.log 2>&1 && cd ../.. && node_modules/.bin/extest install-vsix --vsix_file amazon-q-vscode-$(node scripts/get-vsix-version.js).vsix",
31+
"setupUI": "cd packages/amazonq && npm run package 2>&1 | grep -o 'VSIX Version: [^ ]*' | cut -d' ' -f3 | xargs -I{} bash -c 'cd ../../ && ./node_modules/.bin/extest install-vsix --vsix_file amazon-q-vscode-{}.vsix'",
3232
"testUI": "npm run testCompile && node_modules/.bin/extest run-tests packages/amazonq/dist/test/e2e/amazonq/VET.test.js -u",
3333
"testInteg": "npm run testInteg -w packages/ --if-present",
3434
"package": "npm run package -w packages/toolkit -w packages/amazonq",

packages/amazonq/package.json

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "amazon-q-vscode",
33
"displayName": "Amazon Q",
44
"description": "The most capable generative AI-powered assistant for building, operating, and transforming software, with advanced capabilities for managing data and AI",
5-
"version": "1.83.0-g8500b1e",
5+
"version": "1.84.0-SNAPSHOT",
66
"extensionKind": [
77
"workspace"
88
],
@@ -13,7 +13,6 @@
1313
"type": "git",
1414
"url": "https://github.com/aws/aws-toolkit-vscode"
1515
},
16-
"homepage": "https://github.com/aws/aws-toolkit-vscode",
1716
"bugs": {
1817
"url": "https://github.com/aws/aws-toolkit-vscode/issues"
1918
},
@@ -70,6 +69,9 @@
7069
"generateIcons": "ts-node ../../scripts/generateIcons.ts",
7170
"generateSettings": "ts-node ../../scripts/generateSettings.ts"
7271
},
72+
"dependencies": {
73+
"aws-core-vscode": "file:../core/"
74+
},
7375
"contributesComments": {
7476
"configuration": {
7577
"properties": "Any settings also defined in packages/core/package.json will override same-named settings in this file."
@@ -552,6 +554,21 @@
552554
]
553555
},
554556
"commands": [
557+
{
558+
"command": "aws.amazonq.stopCmdExecution",
559+
"title": "Stop Amazon Q Command Execution",
560+
"category": "%AWS.amazonq.title%"
561+
},
562+
{
563+
"command": "aws.amazonq.runCmdExecution",
564+
"title": "Run Amazon Q Command Execution",
565+
"category": "%AWS.amazonq.title%"
566+
},
567+
{
568+
"command": "aws.amazonq.rejectCmdExecution",
569+
"title": "Reject Amazon Q Command Execution",
570+
"category": "%AWS.amazonq.title%"
571+
},
555572
{
556573
"command": "_aws.amazonq.notifications.dismiss",
557574
"title": "%AWS.generic.dismiss%",
@@ -841,6 +858,24 @@
841858
}
842859
],
843860
"keybindings": [
861+
{
862+
"command": "aws.amazonq.stopCmdExecution",
863+
"key": "ctrl+shift+backspace",
864+
"mac": "cmd+shift+backspace",
865+
"when": "aws.amazonq.amazonqChatLSP.isRunning"
866+
},
867+
{
868+
"command": "aws.amazonq.runCmdExecution",
869+
"key": "ctrl+shift+enter",
870+
"mac": "cmd+shift+enter",
871+
"when": "aws.amazonq.amazonqChatLSP.isRunning"
872+
},
873+
{
874+
"command": "aws.amazonq.rejectCmdExecution",
875+
"key": "ctrl+shift+r",
876+
"mac": "cmd+shift+r",
877+
"when": "aws.amazonq.amazonqChatLSP.isRunning"
878+
},
844879
{
845880
"command": "_aws.amazonq.focusChat.keybinding",
846881
"win": "win+alt+i",
@@ -915,12 +950,12 @@
915950
},
916951
{
917952
"key": "right",
918-
"command": "editor.action.inlineSuggest.showNext",
953+
"command": "aws.amazonq.showNext",
919954
"when": "inlineSuggestionVisible && !editorReadonly && aws.codewhisperer.connected"
920955
},
921956
{
922957
"key": "left",
923-
"command": "editor.action.inlineSuggest.showPrevious",
958+
"command": "aws.amazonq.showPrev",
924959
"when": "inlineSuggestionVisible && !editorReadonly && aws.codewhisperer.connected"
925960
},
926961
{
Lines changed: 33 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,60 @@
1-
import { Workbench, By, WebviewView, WebElement } from 'vscode-extension-tester'
2-
import { until } from 'selenium-webdriver'
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
35

4-
describe('Amazon Q E2E UI Test', function () {
6+
import { Workbench, By, EditorView, WebviewView, WebElement } from 'vscode-extension-tester'
7+
8+
describe('Amazon Q Login Flow', function () {
59
// need this timeout because Amazon Q takes awhile to load
6-
this.timeout(150000)
10+
this.timeout(30000)
711
let webviewView: WebviewView
8-
let workbench: Workbench
12+
913
// NOTE: I tested all the timeouts and they are necessary for the webview to load properly
1014
before(async function () {
11-
this.timeout(120000)
12-
workbench = new Workbench()
15+
const workbench = new Workbench()
1316
await workbench.executeCommand('Amazon Q: Open Chat')
1417

15-
await new Promise((resolve) => setTimeout(resolve, 5000))
18+
await new Promise((resolve) => setTimeout(resolve, 15000))
1619
webviewView = new WebviewView()
1720
await webviewView.switchToFrame()
21+
})
1822

19-
const driver = webviewView.getDriver()
20-
await driver.wait(until.elementsLocated(By.css('.selectable-item')), 30000)
23+
after(async () => {
24+
await webviewView.switchBack()
25+
try {
26+
await new EditorView().closeAllEditors()
27+
} catch {}
28+
})
29+
30+
it('Should click through the Amazon Q login screen', async () => {
31+
// Select company account option
2132
const selectableItems = await webviewView.findWebElements(By.css('.selectable-item'))
33+
console.log(typeof selectableItems)
2234
if (selectableItems.length === 0) {
2335
throw new Error('No selectable login options found')
2436
}
2537

38+
// Find and click company account
2639
const companyItem = await findItemByText(selectableItems, 'Company account')
2740
await companyItem.click()
41+
await new Promise((resolve) => setTimeout(resolve, 2000))
42+
43+
// Click first continue button
2844
const signInContinue = await webviewView.findWebElement(By.css('#connection-selection-continue-button'))
2945
await signInContinue.click()
46+
await new Promise((resolve) => setTimeout(resolve, 2000))
47+
48+
// Enter start URL
3049
const startUrlInput = await webviewView.findWebElement(By.id('startUrl'))
3150
await startUrlInput.clear()
3251
await startUrlInput.sendKeys('https://amzn.awsapps.com/start')
52+
await new Promise((resolve) => setTimeout(resolve, 1000))
53+
54+
// Click second continue button
3355
const UrlContinue = await webviewView.findWebElement(By.css('button.continue-button.topMargin'))
3456
await UrlContinue.click()
35-
console.log('Waiting for manual authentication...')
36-
await new Promise((resolve) => setTimeout(resolve, 12000))
37-
console.log('Manual authentication should be done')
38-
await webviewView.switchBack()
39-
40-
// AFTER AUTHENTICATION WE MUST RELOAD THE WEBVIEW BECAUSE MULTIPLE WEVIEWS CANNOT BE READ AT THE SAME TIME
41-
const editorView = workbench.getEditorView()
42-
console.log('editorview successfully created')
43-
await editorView.closeAllEditors()
44-
console.log('Closed all editors')
45-
await new Promise((resolve) => setTimeout(resolve, 1500))
46-
webviewView = new WebviewView()
47-
console.log('Reopened webview view')
48-
await webviewView.switchToFrame()
49-
await new Promise((resolve) => setTimeout(resolve, 1200))
50-
})
51-
52-
after(async () => {
53-
// TO-DO: Close all the chat windows after the test is done so that when the test runs again it does not have memory
54-
// from the previous test
55-
await webviewView.switchBack()
56-
})
57-
58-
it('Chat Prompt Test', async () => {
59-
// Debug consoles to look at the html of the current webview
60-
// const chatTitle = await webviewView.getDriver().getTitle()
61-
// const chatHtml = (await webviewView.getDriver().executeScript('return document.body.innerHTML')) as string
62-
// console.log('Chat Title:', chatTitle)
63-
// console.log('Chat HTML:', chatHtml.replace(/></g, '>\n<'))
64-
const driver = webviewView.getDriver()
65-
await driver.wait(until.elementsLocated(By.css('.mynah-chat-prompt-input')), 300000)
66-
// In order to test the chat prompt, we need to find the input field and send keys
67-
const chatInput = await webviewView.findWebElement(By.css('.mynah-chat-prompt-input'))
68-
await chatInput.sendKeys('Hello, Amazon Q!')
69-
await driver.wait(until.elementsLocated(By.css('.mynah-chat-prompt-button')), 300000)
70-
// In order to submit the chat prompt, we need to find the send button and click it
71-
const sendButton = await webviewView.findWebElement(By.css('.mynah-chat-prompt-button'))
72-
await sendButton.click()
73-
74-
// TO-DO: Find out a way to check if the chat response is the expected response
75-
await new Promise((resolve) => setTimeout(resolve, 12000))
76-
// Wait for response using conversation container check
77-
const responseReceived = await waitForChatResponse(webviewView)
78-
if (!responseReceived) {
79-
throw new Error('Chat response not received within timeout')
80-
}
81-
82-
console.log('Chat response detected successfully')
57+
await new Promise((resolve) => setTimeout(resolve, 2000))
8358
})
8459

8560
// Helper to find item by text content
@@ -95,33 +70,4 @@ describe('Amazon Q E2E UI Test', function () {
9570
}
9671
throw new Error(`Item with text "${text}" not found`)
9772
}
98-
99-
/* My Idea: Basically the conversation container's css is .mynah-chat-items-conversation-container
100-
Instead of looking for a specific message like how we look for other elements in the test,
101-
I can check how many elements there are in our specific conversation container. If there is 2 elements,
102-
we can assume that the chat response has been generated. The challenge is, we must grab the latest
103-
conversation container, as there can be multiple conversations in the webview.
104-
*/
105-
async function waitForChatResponse(webview: WebviewView, timeout = 30000): Promise<boolean> {
106-
const startTime = Date.now()
107-
108-
while (Date.now() - startTime < timeout) {
109-
const conversationContainers = await webview.findWebElements(
110-
By.css('.mynah-chat-items-conversation-container')
111-
)
112-
113-
if (conversationContainers.length > 0) {
114-
const latestContainer = conversationContainers[conversationContainers.length - 1]
115-
116-
const chatItems = await latestContainer.findElements(By.css('*'))
117-
118-
if (chatItems.length >= 2) {
119-
return true
120-
}
121-
}
122-
await new Promise((resolve) => setTimeout(resolve, 500))
123-
}
124-
125-
return false
126-
}
12773
})

0 commit comments

Comments
 (0)