diff --git a/lib/shared/src/sourcegraph-api/graphql/client.ts b/lib/shared/src/sourcegraph-api/graphql/client.ts index 6a7b4cada10..5ab9788b6e4 100644 --- a/lib/shared/src/sourcegraph-api/graphql/client.ts +++ b/lib/shared/src/sourcegraph-api/graphql/client.ts @@ -810,7 +810,9 @@ export class SourcegraphGraphQLAPIClient { // make an anonymous request to the Testing API private fetchSourcegraphTestingAPI(body: Record): Promise { - const url = 'http://localhost:49300/.api/testLogging' + const url = `http://localhost:4930${ + process.env.VITEST_POOL_ID ?? process.env.TEST_PARALLEL_INDEX ?? 0 + }/.api/testLogging` const headers = new Headers({ 'Content-Type': 'application/json', }) diff --git a/lib/shared/src/sourcegraph-api/telemetry/MockServerTelemetryExporter.ts b/lib/shared/src/sourcegraph-api/telemetry/MockServerTelemetryExporter.ts index 36b828c749b..b1fa7a96975 100644 --- a/lib/shared/src/sourcegraph-api/telemetry/MockServerTelemetryExporter.ts +++ b/lib/shared/src/sourcegraph-api/telemetry/MockServerTelemetryExporter.ts @@ -3,7 +3,9 @@ import type { TelemetryEventInput, TelemetryExporter } from '@sourcegraph/teleme import { logError } from '../../logger' import { isError } from '../../utils' -const MOCK_URL = 'http://localhost:49300' +const MOCK_URL = `http://localhost:4930${ + process.env.VITEST_POOL_ID ?? process.env.TEST_PARALLEL_INDEX ?? 0 +}/` const ENDPOINT = '/.api/mockEventRecording' /** diff --git a/vscode/playwright.config.ts b/vscode/playwright.config.ts index a36b6f2d680..2154098f887 100644 --- a/vscode/playwright.config.ts +++ b/vscode/playwright.config.ts @@ -8,6 +8,6 @@ export default defineConfig({ testDir: 'test/e2e', timeout: isWin ? 30000 : 20000, expect: { - timeout: isWin ? 5000 : 3000, + timeout: isWin ? 5000 : 6000, }, }) diff --git a/vscode/src/configuration.ts b/vscode/src/configuration.ts index 51e11571ebf..f01dae11791 100644 --- a/vscode/src/configuration.ts +++ b/vscode/src/configuration.ts @@ -191,7 +191,12 @@ export const getFullConfig = async (): Promise => 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 } } diff --git a/vscode/test/e2e/chat-atFile.test.ts b/vscode/test/e2e/chat-atFile.test.ts index ef6c35bd59b..a1185fab450 100644 --- a/vscode/test/e2e/chat-atFile.test.ts +++ b/vscode/test/e2e/chat-atFile.test.ts @@ -16,10 +16,6 @@ test.extend({ '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() diff --git a/vscode/test/e2e/chat-input.test.ts b/vscode/test/e2e/chat-input.test.ts index 3caefe9a0ee..a04c8d73720 100644 --- a/vscode/test/e2e/chat-input.test.ts +++ b/vscode/test/e2e/chat-input.test.ts @@ -45,10 +45,6 @@ test.extend({ }) 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. diff --git a/vscode/test/e2e/context-settings.test.ts b/vscode/test/e2e/context-settings.test.ts index 4612d785a28..198162b24d5 100644 --- a/vscode/test/e2e/context-settings.test.ts +++ b/vscode/test/e2e/context-settings.test.ts @@ -15,17 +15,23 @@ test.extend({ '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() diff --git a/vscode/test/e2e/helpers.ts b/vscode/test/e2e/helpers.ts index f1bbb38b220..54e45008841 100644 --- a/vscode/test/e2e/helpers.ts +++ b/vscode/test/e2e/helpers.ts @@ -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() @@ -258,7 +260,9 @@ async function buildWorkSpaceSettings( extraSettings: WorkspaceSettings ): Promise { 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, @@ -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 { - 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 diff --git a/vscode/test/fixtures/.vscode/settings.json b/vscode/test/fixtures/.vscode/settings.json index ae7a78ff427..0e28aad4e50 100644 --- a/vscode/test/fixtures/.vscode/settings.json +++ b/vscode/test/fixtures/.vscode/settings.json @@ -1,5 +1,4 @@ { - "cody.codebase": "http://localhost:49300", "cody.debug.enable": true, "cody.debug.verbose": true, } diff --git a/vscode/test/fixtures/mock-server.ts b/vscode/test/fixtures/mock-server.ts index 1885512f022..aefaaf82e03 100644 --- a/vscode/test/fixtures/mock-server.ts +++ b/vscode/test/fixtures/mock-server.ts @@ -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 = { diff --git a/vscode/test/fixtures/multi-root.code-workspace b/vscode/test/fixtures/multi-root.code-workspace index 9b10eac4494..641d861ef7d 100644 --- a/vscode/test/fixtures/multi-root.code-workspace +++ b/vscode/test/fixtures/multi-root.code-workspace @@ -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,