Skip to content

Commit

Permalink
E2E Test: improve flaky tests (#3558)
Browse files Browse the repository at this point in the history
  • Loading branch information
abeatrix authored Mar 26, 2024
1 parent d735ff6 commit 6c43d95
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
16 changes: 10 additions & 6 deletions vscode/test/e2e/chat-atFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,13 @@ test.extend<ExpectedEvents>({
// Open the buzz.ts file so that VS Code starts to populate symbols.
await sidebarExplorer(page).click()
await page.getByRole('treeitem', { name: 'buzz.ts' }).locator('a').dblclick()
await page.getByRole('tab', { name: 'buzz.ts' }).hover()
await page.getByRole('tab', { name: 'buzz.ts' }).click()

// Wait for the tsserver to become ready: when loading status disappears
await expect(page.getByRole('button', { name: 'Editor Language Status: Loading' })).toBeVisible()
await page.waitForSelector('button[aria-label="Editor Language Status: Loading"]', {
state: 'hidden',
})

// Go back to the Cody chat tab
await page.getByRole('tab', { name: 'New Chat' }).click()
Expand All @@ -315,11 +321,9 @@ test.extend<ExpectedEvents>({
await expect(chatPanelFrame.getByRole('heading', { name: /^No symbols found/ })).toBeVisible()

// Clicking on a file in the selector should autocomplete the file in chat input with added space
await chatInput.fill('@#fizzb')
await expect(chatPanelFrame.getByRole('option', { name: 'fizzbuzz()' })).toBeVisible({
// Longer timeout because sometimes tsserver takes a while to become ready.
timeout: 15000,
})
await chatInput.clear()
await chatInput.pressSequentially('@#fizzb', { delay: 10 })
await expect(chatPanelFrame.getByRole('option', { name: 'fizzbuzz()' })).toBeVisible()
await chatPanelFrame.getByRole('option', { name: 'fizzbuzz()' }).click()
await expect(chatInput).toHaveText('@buzz.ts:1-15#fizzbuzz() ')

Expand Down
10 changes: 7 additions & 3 deletions vscode/test/e2e/update-notice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ test('existing installs should show the update toast when the last dismissed ver

// Use chat.
let [chatFrame, chatInput] = await createEmptyChatPanel(page)
await chatInput.fill('hey buddy')
await chatInput.press('Enter')

// Forge an older dismissed version into local storage.
expect(
Expand All @@ -47,10 +45,16 @@ test('existing installs should show the update toast when the last dismissed ver
}, versionUpdateStorageKey)
).toBe('0.7')

// Submit a chat message
await chatInput.fill('hey buddy')
await chatInput.press('Enter')
await expect(chatFrame.getByText('hey buddy')).toBeVisible()
await page.getByLabel(/Close /).click()
await expect(chatFrame.getByText('hey buddy')).not.toBeVisible()

// Wait for this chat to be available in the sidebar
const chatHistoryEntry = page.getByRole('treeitem', { name: 'hey buddy' })
await expect(chatHistoryEntry).toBeVisible()
await page.locator('*[aria-label="Tab actions"] *[aria-label~="Close"]').click()

// Reopen the chat; the update notice should be visible.
// Welcome message is removed.
Expand Down

0 comments on commit 6c43d95

Please sign in to comment.