Skip to content

Commit 824ecf8

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

File tree

2 files changed

+37
-18
lines changed

2 files changed

+37
-18
lines changed

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

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ describe('Amazon Q Feature Dev', function () {
1717
let framework: qTestingFramework
1818
let tab: Messenger
1919

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`
20+
const maxTestDuration = 600000 // /dev can go beyond 10 mins to complete.
21+
22+
const prompt = 'Add current timestamp into blank.txt'
23+
const iteratePrompt = `Add a new section in readme to explain your change`
24+
const fileLevelAcceptPrompt = `${prompt} and ${iteratePrompt}`
25+
const informationCard =
26+
'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)'
2327
const tooManyRequestsWaitTime = 100000
2428

2529
async function waitForText(text: string) {
@@ -144,34 +148,36 @@ describe('Amazon Q Feature Dev', function () {
144148
})
145149

146150
describe('/dev entry', () => {
147-
it('Clicks examples', async () => {
148-
const q = framework.createTab()
149-
q.addChatMessage({ command: '/dev' })
151+
before(async () => {
152+
tab = framework.createTab()
153+
tab.addChatMessage({ command: '/dev' }) // This would create a new tab for feature dev.
154+
tab = framework.getSelectedTab()
155+
})
156+
157+
it('should display information card', async () => {
150158
await retryIfRequired(
151159
async () => {
152-
await q.waitForChatFinishesLoading()
160+
await tab.waitForChatFinishesLoading()
153161
},
154162
() => {
155-
q.clickButton(FollowUpTypes.DevExamples)
156-
157-
const lastChatItems = q.getChatItems().pop()
158-
assert.deepStrictEqual(lastChatItems?.body, examples)
163+
const lastChatItems = tab.getChatItems().pop()
164+
assert.deepStrictEqual(lastChatItems?.body, informationCard)
159165
}
160166
)
161167
})
162168
})
163169

164-
// Disable failing tests while investigation. The tests are only failing in CI environments.
165-
describe.skip('/dev {msg} entry', async () => {
170+
describe('/dev {msg} entry', async () => {
166171
beforeEach(async function () {
172+
this.timeout(maxTestDuration)
173+
tab = framework.createTab()
167174
tab.addChatMessage({ command: '/dev', prompt })
175+
tab = framework.getSelectedTab()
168176
await retryIfRequired(
169177
async () => {
170178
await tab.waitForChatFinishesLoading()
171179
},
172-
() => {
173-
tab.addChatMessage({ prompt })
174-
}
180+
() => {}
175181
)
176182
})
177183

@@ -211,15 +217,18 @@ describe('Amazon Q Feature Dev', function () {
211217
})
212218
tab.clickButton(FollowUpTypes.ProvideFeedbackAndRegenerateCode)
213219
await tab.waitForChatFinishesLoading()
214-
await iterate(codegenApproachPrompt)
220+
await iterate(iteratePrompt)
215221
tab.clickButton(FollowUpTypes.InsertCode)
216222
await tab.waitForButtons([FollowUpTypes.NewTask, FollowUpTypes.CloseSession])
217223
})
218224
})
219225

220-
describe.skip('file-level accepts', async () => {
226+
describe('file-level accepts', async () => {
221227
beforeEach(async function () {
228+
this.timeout(maxTestDuration)
229+
tab = framework.createTab()
222230
tab.addChatMessage({ command: '/dev', prompt: fileLevelAcceptPrompt })
231+
tab = framework.getSelectedTab()
223232
await retryIfRequired(
224233
async () => {
225234
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)