Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e parallelism #3449

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion vscode/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export default defineConfig({
testDir: 'test/e2e',
timeout: isWin ? 30000 : 20000,
expect: {
timeout: isWin ? 5000 : 3000,
timeout: isWin ? 5000 : 6000,
},
})
7 changes: 6 additions & 1 deletion vscode/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ export const getFullConfig = async (): Promise<ConfigurationWithAccessToken> =>
const config = getConfiguration()
const isTesting = process.env.CODY_TESTING === 'true'
const serverEndpoint =
localStorage?.getEndpoint() || (isTesting ? 'http://localhost:49300/' : DOTCOM_URL.href)
localStorage?.getEndpoint() ||
(isTesting
? `http://localhost:4930${
process.env.VITEST_POOL_ID ?? process.env.TEST_PARALLEL_INDEX ?? 0
}/`
: DOTCOM_URL.href)
const accessToken = (await getAccessToken()) || null
return { ...config, accessToken, serverEndpoint }
}
Expand Down
4 changes: 0 additions & 4 deletions vscode/test/e2e/chat-atFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ test.extend<ExpectedEvents>({
'CodyVSCodeExtension:at-mention:file:executed',
],
})('@-mention file in chat', async ({ page, sidebar }) => {
// This test requires that the window be focused in the OS window manager because it deals with
// focus.
await page.bringToFront()

await sidebarSignin(page, sidebar)

await page.getByRole('button', { name: 'New Chat', exact: true }).click()
Expand Down
4 changes: 0 additions & 4 deletions vscode/test/e2e/chat-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ test.extend<ExpectedEvents>({
})

test('chat input focus', async ({ page, sidebar }) => {
// This test requires that the window be focused in the OS window manager because it deals with
// focus.
await page.bringToFront()

await sidebarSignin(page, sidebar)
// Open the buzz.ts file from the tree view,
// and then submit a chat question from the command menu.
Expand Down
14 changes: 10 additions & 4 deletions vscode/test/e2e/context-settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ test.extend<ExpectedEvents>({
'CodyVSCodeExtension:Auth:connected',
'CodyVSCodeExtension:useEnhancedContextToggler:clicked',
],
})('enhanced context selector is keyboard accessible', async ({ page, sidebar }) => {
// This test requires that the window be focused in the OS window manager because it deals with
// focus.
await page.bringToFront()
})('enhanced context selector is keyboard accessible', async ({ page, sidebar }, testInfo) => {
// This test requires that the window be focused in the OS's window manager. This
// does not work when other tests are running in parallel. TODO(sqs): make this testable in parallel.
const isParallelTest = process.env.TEST_PARALLEL_INDEX !== undefined
if (isParallelTest) {
testInfo.skip()
return
}

await page.bringToFront()
await sidebarSignin(page, sidebar)
const chatFrame = await newChat(page)
const contextSettingsButton = chatFrame.getByTitle('Configure Enhanced Context')
await contextSettingsButton.focus()

await page.keyboard.press('Space')

// Opening the enhanced context settings should focus the checkbox for toggling it.
const enhancedContextCheckbox = chatFrame.locator('#enhanced-context-checkbox')
await expect(enhancedContextCheckbox).toBeFocused()
Expand Down
27 changes: 18 additions & 9 deletions vscode/test/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,15 @@ export const test = base

// Critical test to prevent event logging regressions.
// Do not remove without consulting data analytics team.
try {
await assertEvents(loggedEvents, expectedEvents)
} catch (error) {
console.error('Expected events do not match actual events!')
console.log('Expected:', expectedEvents)
console.log('Logged:', loggedEvents)
throw error
if (testInfo.expectedStatus !== 'skipped') {
try {
await assertEvents(loggedEvents, expectedEvents)
} catch (error) {
console.error('Expected events do not match actual events!')
console.log('Expected:', expectedEvents)
console.log('Logged:', loggedEvents)
throw error // TODO(sqs)
}
}
resetLoggedEvents()

Expand Down Expand Up @@ -258,7 +260,9 @@ async function buildWorkSpaceSettings(
extraSettings: WorkspaceSettings
): Promise<void> {
const settings = {
'cody.serverEndpoint': 'http://localhost:49300',
'cody.serverEndpoint': `http://localhost:4930${
process.env.VITEST_POOL_ID ?? process.env.TEST_PARALLEL_INDEX ?? 0
}`,
'cody.commandCodeLenses': true,
'cody.editorTitleCommandIcon': true,
...extraSettings,
Expand Down Expand Up @@ -298,7 +302,12 @@ export async function executeCommandInPalette(page: Page, commandName: string):
* Verifies that loggedEvents contain all of expectedEvents (in any order).
*/
export async function assertEvents(loggedEvents: string[], expectedEvents: string[]): Promise<void> {
await expect.poll(() => loggedEvents).toEqual(expect.arrayContaining(expectedEvents))
await expect
.poll(() => {
console.log('XX', loggedEvents)
return loggedEvents
})
.toEqual(expect.arrayContaining(expectedEvents))
}

// Creates a temporary directory, calls `f`, and then deletes the temporary
Expand Down
1 change: 0 additions & 1 deletion vscode/test/fixtures/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"cody.codebase": "http://localhost:49300",
"cody.debug.enable": true,
"cody.debug.verbose": true,
}
5 changes: 2 additions & 3 deletions vscode/test/fixtures/mock-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ interface MockRequest {
}
}

const SERVER_PORT = 49300

export const SERVER_URL = 'http://localhost:49300'
const SERVER_PORT = Number(`4930${process.env.VITEST_POOL_ID ?? process.env.TEST_PARALLEL_INDEX ?? 0}`)
export const SERVER_URL = `http://localhost:${SERVER_PORT}`
export const VALID_TOKEN = 'sgp_1234567890123456789012345678901234567890'

const responses = {
Expand Down
1 change: 0 additions & 1 deletion vscode/test/fixtures/multi-root.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"settings": {
// Settings that should also apply to the single-root workspace tests should also be
// included in fixtures\workspace\.vscode\settings.json!
"cody.serverEndpoint": "http://localhost:49300",
"cody.commandCodeLenses": true,
"cody.editorTitleCommandIcon": true,
"cody.experimental.symfContext": false,
Expand Down