diff --git a/packages/amazonq/test/e2e/amazonq/featureDev.test.ts b/packages/amazonq/test/e2e/amazonq/featureDev.test.ts index d40ff72a0a9..2ce9a32f85e 100644 --- a/packages/amazonq/test/e2e/amazonq/featureDev.test.ts +++ b/packages/amazonq/test/e2e/amazonq/featureDev.test.ts @@ -17,9 +17,13 @@ describe('Amazon Q Feature Dev', function () { let framework: qTestingFramework let tab: Messenger - const prompt = 'Add blank.txt file with empty content' - const codegenApproachPrompt = `${prompt} and add a readme that describes the changes` - const fileLevelAcceptPrompt = `${prompt} and add a license, and a contributing file` + const maxTestDuration = 600000 // /dev can go beyond 10 mins to complete. + + const prompt = 'Add current timestamp into blank.txt' + const iteratePrompt = `Add a new section in readme to explain your change` + const fileLevelAcceptPrompt = `${prompt} and ${iteratePrompt}` + const informationCard = + '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)' const tooManyRequestsWaitTime = 100000 async function waitForText(text: string) { @@ -144,34 +148,36 @@ describe('Amazon Q Feature Dev', function () { }) describe('/dev entry', () => { - it('Clicks examples', async () => { - const q = framework.createTab() - q.addChatMessage({ command: '/dev' }) + before(async () => { + tab = framework.createTab() + tab.addChatMessage({ command: '/dev' }) // This would create a new tab for feature dev. + tab = framework.getSelectedTab() + }) + + it('should display information card', async () => { await retryIfRequired( async () => { - await q.waitForChatFinishesLoading() + await tab.waitForChatFinishesLoading() }, () => { - q.clickButton(FollowUpTypes.DevExamples) - - const lastChatItems = q.getChatItems().pop() - assert.deepStrictEqual(lastChatItems?.body, examples) + const lastChatItems = tab.getChatItems().pop() + assert.deepStrictEqual(lastChatItems?.body, informationCard) } ) }) }) - // Disable failing tests while investigation. The tests are only failing in CI environments. - describe.skip('/dev {msg} entry', async () => { + describe('/dev {msg} entry', async () => { beforeEach(async function () { + this.timeout(maxTestDuration) + tab = framework.createTab() tab.addChatMessage({ command: '/dev', prompt }) + tab = framework.getSelectedTab() await retryIfRequired( async () => { await tab.waitForChatFinishesLoading() }, - () => { - tab.addChatMessage({ prompt }) - } + () => {} ) }) @@ -211,15 +217,18 @@ describe('Amazon Q Feature Dev', function () { }) tab.clickButton(FollowUpTypes.ProvideFeedbackAndRegenerateCode) await tab.waitForChatFinishesLoading() - await iterate(codegenApproachPrompt) + await iterate(iteratePrompt) tab.clickButton(FollowUpTypes.InsertCode) await tab.waitForButtons([FollowUpTypes.NewTask, FollowUpTypes.CloseSession]) }) }) - describe.skip('file-level accepts', async () => { + describe('file-level accepts', async () => { beforeEach(async function () { + this.timeout(maxTestDuration) + tab = framework.createTab() tab.addChatMessage({ command: '/dev', prompt: fileLevelAcceptPrompt }) + tab = framework.getSelectedTab() await retryIfRequired( async () => { await tab.waitForChatFinishesLoading() diff --git a/packages/amazonq/test/e2e/amazonq/framework/framework.ts b/packages/amazonq/test/e2e/amazonq/framework/framework.ts index 6a29015c06f..1dcdd433ea5 100644 --- a/packages/amazonq/test/e2e/amazonq/framework/framework.ts +++ b/packages/amazonq/test/e2e/amazonq/framework/framework.ts @@ -105,6 +105,16 @@ export class qTestingFramework { return Object.entries(tabs).map(([tabId]) => new Messenger(tabId, this.mynahUIProps, this.mynahUI)) } + public getSelectedTab() { + const selectedTabId = this.mynahUI.getSelectedTabId() + const selectedTab = this.getTabs().find((tab) => tab.tabID === selectedTabId) + + if (!selectedTab) { + assert.fail('Selected tab not found') + } + return selectedTab + } + public findTab(title: string) { return Object.values(this.getTabs()).find((tab) => tab.getStore().tabTitle === title) }