Skip to content

Commit 2d4edce

Browse files
committed
test(e2e): stabilize Amazon Q feature development tests
1 parent ed87f5f commit 2d4edce

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

packages/amazonq/test/e2e/amazonq/featureDev.test.ts

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ import sinon from 'sinon'
99
import { registerAuthHook, using } from 'aws-core-vscode/test'
1010
import { loginToIdC } from './utils/setup'
1111
import { Messenger } from './framework/messenger'
12-
import { examples } from 'aws-core-vscode/amazonqFeatureDev'
1312
import { FollowUpTypes } from 'aws-core-vscode/amazonq'
1413
import { sleep } from 'aws-core-vscode/shared'
1514

1615
describe('Amazon Q Feature Dev', function () {
1716
let framework: qTestingFramework
1817
let tab: Messenger
1918

20-
const prompt = 'Add blank.txt file with empty content'
21-
const codegenApproachPrompt = `${prompt} and add a readme that describes the changes`
22-
const fileLevelAcceptPrompt = `${prompt} and add a license, and a contributing file`
19+
const maxTestDuration = 600000 // /dev can go beyond 10 mins to complete.
20+
21+
const prompt = 'Add current timestamp into blank.txt'
22+
const iteratePrompt = `Add a new section in readme to explain your change`
23+
const fileLevelAcceptPrompt = `${prompt} and ${iteratePrompt}`
24+
const informationCard =
25+
'After you provide a task, I will:\n1. Generate code based on your description and the code in your workspace\n2. Provide a list of suggestions for you to review and add to your workspace\n3. If needed, iterate based on your feedback\nTo learn more, visit the [user guide](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/software-dev.html)'
2326
const tooManyRequestsWaitTime = 100000
2427

2528
async function waitForText(text: string) {
@@ -144,34 +147,36 @@ describe('Amazon Q Feature Dev', function () {
144147
})
145148

146149
describe('/dev entry', () => {
147-
it('Clicks examples', async () => {
148-
const q = framework.createTab()
149-
q.addChatMessage({ command: '/dev' })
150+
before(async () => {
151+
tab = framework.createTab()
152+
tab.addChatMessage({ command: '/dev' }) // This would create a new tab for feature dev.
153+
tab = framework.getSelectedTab()
154+
})
155+
156+
it('should display information card', async () => {
150157
await retryIfRequired(
151158
async () => {
152-
await q.waitForChatFinishesLoading()
159+
await tab.waitForChatFinishesLoading()
153160
},
154161
() => {
155-
q.clickButton(FollowUpTypes.DevExamples)
156-
157-
const lastChatItems = q.getChatItems().pop()
158-
assert.deepStrictEqual(lastChatItems?.body, examples)
162+
const lastChatItems = tab.getChatItems().pop()
163+
assert.deepStrictEqual(lastChatItems?.body, informationCard)
159164
}
160165
)
161166
})
162167
})
163168

164-
// Disable failing tests while investigation. The tests are only failing in CI environments.
165-
describe.skip('/dev {msg} entry', async () => {
169+
describe('/dev {msg} entry', async () => {
166170
beforeEach(async function () {
171+
this.timeout(maxTestDuration)
172+
tab = framework.createTab()
167173
tab.addChatMessage({ command: '/dev', prompt })
174+
tab = framework.getSelectedTab()
168175
await retryIfRequired(
169176
async () => {
170177
await tab.waitForChatFinishesLoading()
171178
},
172-
() => {
173-
tab.addChatMessage({ prompt })
174-
}
179+
() => {}
175180
)
176181
})
177182

@@ -211,15 +216,18 @@ describe('Amazon Q Feature Dev', function () {
211216
})
212217
tab.clickButton(FollowUpTypes.ProvideFeedbackAndRegenerateCode)
213218
await tab.waitForChatFinishesLoading()
214-
await iterate(codegenApproachPrompt)
219+
await iterate(iteratePrompt)
215220
tab.clickButton(FollowUpTypes.InsertCode)
216221
await tab.waitForButtons([FollowUpTypes.NewTask, FollowUpTypes.CloseSession])
217222
})
218223
})
219224

220-
describe.skip('file-level accepts', async () => {
225+
describe('file-level accepts', async () => {
221226
beforeEach(async function () {
227+
this.timeout(maxTestDuration)
228+
tab = framework.createTab()
222229
tab.addChatMessage({ command: '/dev', prompt: fileLevelAcceptPrompt })
230+
tab = framework.getSelectedTab()
223231
await retryIfRequired(
224232
async () => {
225233
await tab.waitForChatFinishesLoading()

packages/amazonq/test/e2e/amazonq/framework/framework.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ export class qTestingFramework {
105105
return Object.entries(tabs).map(([tabId]) => new Messenger(tabId, this.mynahUIProps, this.mynahUI))
106106
}
107107

108+
public getSelectedTab() {
109+
const selectedTabId = this.mynahUI.getSelectedTabId()
110+
const selectedTab = this.getTabs().find((tab) => tab.tabID === selectedTabId)
111+
112+
if (!selectedTab) {
113+
assert.fail('Selected tab not found')
114+
}
115+
return selectedTab
116+
}
117+
108118
public findTab(title: string) {
109119
return Object.values(this.getTabs()).find((tab) => tab.getStore().tabTitle === title)
110120
}

0 commit comments

Comments
 (0)