From 9b5510e90916f291632a4f8f566621be6376337c Mon Sep 17 00:00:00 2001 From: Osvaldo Ortega Date: Thu, 19 Mar 2026 17:27:30 -0600 Subject: [PATCH] Sessions: E2E test fixes --- .github/workflows/sessions-e2e.yml | 17 ++++---- src/vs/sessions/sessions.web.main.ts | 1 + .../02-chat-with-changes.scenario.md | 9 ++--- .../03-session-in-sidebar.scenario.md | 3 +- .../scenarios/06-full-workflow.scenario.md | 37 +++++++++-------- .../02-chat-with-changes.commands.json | 6 --- .../03-session-in-sidebar.commands.json | 6 --- .../generated/06-full-workflow.commands.json | 6 --- src/vs/sessions/test/web.test.ts | 40 +++++++++++++++---- 9 files changed, 64 insertions(+), 61 deletions(-) diff --git a/.github/workflows/sessions-e2e.yml b/.github/workflows/sessions-e2e.yml index 3d2fa4e4e88..b7047a8e30a 100644 --- a/.github/workflows/sessions-e2e.yml +++ b/.github/workflows/sessions-e2e.yml @@ -1,14 +1,13 @@ name: Sessions E2E Tests -# Disabled: Flaky -# on: -# pull_request: -# branches: -# - main -# - 'release/*' -# paths: -# - 'src/vs/sessions/**' -# - 'scripts/code-sessions-web.*' +on: + pull_request: + branches: + - main + - 'release/*' + paths: + - 'src/vs/sessions/**' + - 'scripts/code-sessions-web.*' permissions: contents: read diff --git a/src/vs/sessions/sessions.web.main.ts b/src/vs/sessions/sessions.web.main.ts index f5223d4a29d..be32907bc88 100644 --- a/src/vs/sessions/sessions.web.main.ts +++ b/src/vs/sessions/sessions.web.main.ts @@ -143,6 +143,7 @@ import '../workbench/contrib/issue/browser/issue.contribution.js'; import '../workbench/contrib/splash/browser/splash.contribution.js'; import '../workbench/contrib/remote/browser/remoteStartEntry.contribution.js'; import '../workbench/contrib/processExplorer/browser/processExplorer.web.contribution.js'; +import '../workbench/contrib/browserView/browser/browserView.contribution.js'; //#endregion diff --git a/src/vs/sessions/test/e2e/scenarios/02-chat-with-changes.scenario.md b/src/vs/sessions/test/e2e/scenarios/02-chat-with-changes.scenario.md index 3e25a5c3399..efe11056b87 100644 --- a/src/vs/sessions/test/e2e/scenarios/02-chat-with-changes.scenario.md +++ b/src/vs/sessions/test/e2e/scenarios/02-chat-with-changes.scenario.md @@ -4,8 +4,7 @@ 1. Type "build the project" in the chat input 2. Press Enter to submit 3. Verify there is a response in the chat -4. Toggle the secondary side bar -5. Verify the changes view shows modified files -6. Click on "index.ts" in the changes list -7. Verify a diff editor opens with the modified content -8. Press Escape to close the diff editor +4. Verify the changes view shows modified files +5. Click on "index.ts" in the changes list +6. Verify a diff editor opens with the modified content +7. Press Escape to close the diff editor diff --git a/src/vs/sessions/test/e2e/scenarios/03-session-in-sidebar.scenario.md b/src/vs/sessions/test/e2e/scenarios/03-session-in-sidebar.scenario.md index aededc6ae0b..a69c0ad39a0 100644 --- a/src/vs/sessions/test/e2e/scenarios/03-session-in-sidebar.scenario.md +++ b/src/vs/sessions/test/e2e/scenarios/03-session-in-sidebar.scenario.md @@ -4,6 +4,5 @@ 1. Type "fix the bug" in the chat input 2. Press Enter to submit 3. Verify the session appears in the sessions list -4. Toggle the secondary side bar -5. Verify the changes view shows the modified file +4. Verify the changes view shows the modified file diff --git a/src/vs/sessions/test/e2e/scenarios/06-full-workflow.scenario.md b/src/vs/sessions/test/e2e/scenarios/06-full-workflow.scenario.md index 321446d2af2..89bf1b06048 100644 --- a/src/vs/sessions/test/e2e/scenarios/06-full-workflow.scenario.md +++ b/src/vs/sessions/test/e2e/scenarios/06-full-workflow.scenario.md @@ -4,22 +4,21 @@ 1. Type "build the project" in the chat input 2. Press Enter to submit 3. Verify there is a response in the chat -4. Toggle the secondary side bar -5. Verify the changes view shows "CHANGES" with a badge -6. Verify "package.json" is visible in the changes list -7. Verify "build.ts" is visible in the changes list -8. Verify "index.ts" is visible in the changes list -9. Click on "index.ts" in the changes list -10. Verify a diff editor opens with modified content -11. Press Escape to close the diff editor -12. Verify "Merge" button is visible in changes view header -13. Verify the "Open Terminal" button is visible -14. Click the "Open Terminal" button -15. Verify the terminal panel becomes visible -16. Verify the terminal tab shows "session-1" in its label -17. Click "New Session" to create a new session -18. Type "fix the bug" in the chat input -19. Press Enter to submit -20. Verify the terminal tab label changes to show "session-2" -21. Click back on the first session in the sessions list -22. Verify the terminal tab label changes back to show "session-1" +4. Verify the changes view shows "CHANGES" with a badge +5. Verify "package.json" is visible in the changes list +6. Verify "build.ts" is visible in the changes list +7. Verify "index.ts" is visible in the changes list +8. Click on "index.ts" in the changes list +9. Verify a diff editor opens with modified content +10. Press Escape to close the diff editor +11. Verify "Merge" button is visible in changes view header +12. Verify the "Open Terminal" button is visible +13. Click the "Open Terminal" button +14. Verify the terminal panel becomes visible +15. Verify the terminal tab shows "session-1" in its label +16. Click "New Session" to create a new session +17. Type "fix the bug" in the chat input +18. Press Enter to submit +19. Verify the terminal tab label changes to show "session-2" +20. Click back on the first session in the sessions list +21. Verify the terminal tab label changes back to show "session-1" diff --git a/src/vs/sessions/test/e2e/scenarios/generated/02-chat-with-changes.commands.json b/src/vs/sessions/test/e2e/scenarios/generated/02-chat-with-changes.commands.json index a28fabe6689..766adbd709d 100644 --- a/src/vs/sessions/test/e2e/scenarios/generated/02-chat-with-changes.commands.json +++ b/src/vs/sessions/test/e2e/scenarios/generated/02-chat-with-changes.commands.json @@ -23,12 +23,6 @@ "# ASSERT_VISIBLE: I'll help you build the project. Here are the changes:" ] }, - { - "description": "Toggle the secondary side bar", - "commands": [ - "click button \"Toggle Secondary Side Bar\"" - ] - }, { "description": "Verify the changes view shows modified files", "commands": [ diff --git a/src/vs/sessions/test/e2e/scenarios/generated/03-session-in-sidebar.commands.json b/src/vs/sessions/test/e2e/scenarios/generated/03-session-in-sidebar.commands.json index 0013dbc8921..994ad5868d7 100644 --- a/src/vs/sessions/test/e2e/scenarios/generated/03-session-in-sidebar.commands.json +++ b/src/vs/sessions/test/e2e/scenarios/generated/03-session-in-sidebar.commands.json @@ -23,12 +23,6 @@ "# ASSERT_VISIBLE: fix the bug" ] }, - { - "description": "Toggle the secondary side bar", - "commands": [ - "click button \"Toggle Secondary Side Bar\"" - ] - }, { "description": "Verify the changes view shows the modified file", "commands": [ diff --git a/src/vs/sessions/test/e2e/scenarios/generated/06-full-workflow.commands.json b/src/vs/sessions/test/e2e/scenarios/generated/06-full-workflow.commands.json index 5124b5d6d2d..373e88452be 100644 --- a/src/vs/sessions/test/e2e/scenarios/generated/06-full-workflow.commands.json +++ b/src/vs/sessions/test/e2e/scenarios/generated/06-full-workflow.commands.json @@ -21,12 +21,6 @@ "# ASSERT_VISIBLE: I'll help you build the project. Here are the changes:" ] }, - { - "description": "Toggle the secondary side bar", - "commands": [ - "click button \"Toggle Secondary Side Bar Visibility\"" - ] - }, { "description": "Verify the changes view shows \"CHANGES\" with a badge", "commands": [ diff --git a/src/vs/sessions/test/web.test.ts b/src/vs/sessions/test/web.test.ts index 760fd0000a0..f959d37a076 100644 --- a/src/vs/sessions/test/web.test.ts +++ b/src/vs/sessions/test/web.test.ts @@ -31,6 +31,8 @@ import { IProcessEnvironment } from '../../base/common/platform.js'; import { Registry } from '../../platform/registry/common/platform.js'; import { InMemoryFileSystemProvider } from '../../platform/files/common/inMemoryFilesystemProvider.js'; import { VSBuffer } from '../../base/common/buffer.js'; +import { SyncDescriptor } from '../../platform/instantiation/common/descriptors.js'; +import { getSingletonServiceDescriptors } from '../../platform/instantiation/common/extensions.js'; /** * Mock files pre-seeded in the in-memory file system. These match the @@ -424,6 +426,9 @@ class MockChatAgentContribution extends Disposable implements IWorkbenchContribu return { remoteAuthority: undefined, isVirtualProcess: false, + isResponsive: true, + whenReady: Promise.resolve(), + setReady: () => { }, onDidRequestDetach: Event.None, attachToProcess: async () => { throw new Error('Not supported'); }, attachToRevivedProcess: async () => { throw new Error('Not supported'); }, @@ -481,7 +486,14 @@ class MockChatAgentContribution extends Disposable implements IWorkbenchContribu }, getWslPath: async (original: string, _direction: 'unix-to-win' | 'win-to-unix') => original, getEnvironment: async () => ({}), + getLatency: async () => [], getPerformanceMarks: () => [], + updateTitle: async () => { }, + updateIcon: async () => { }, + setNextCommandId: async () => { }, + restartPtyHost: () => { }, + installAutoReply: async () => { }, + uninstallAllAutoReplies: async () => { }, onPtyHostUnresponsive: Event.None, onPtyHostResponsive: Event.None, onPtyHostRestart: Event.None, @@ -528,14 +540,26 @@ export class TestSessionsBrowserMain extends SessionsBrowserMain { // Register mock-fs:// provider FIRST so all services can resolve workspace files registerMockFileSystemProvider(serviceCollection); - // Override entitlement service so Sessions thinks user is signed in - serviceCollection.set(IChatEntitlementService, new MockChatEntitlementService()); - - // Override default account service to hide the "Sign In" button - serviceCollection.set(IDefaultAccountService, new MockDefaultAccountService()); - - // Override git service so openRepository resolves instantly (no 10s barrier wait) - serviceCollection.set(IGitService, new MockGitService()); + // Override services in the global singleton registry BEFORE the workbench + // reads it in initServices(). getSingletonServiceDescriptors() returns a + // mutable reference to the internal registry array, so replacing entries + // here ensures the workbench picks up our mocks. + const registry = getSingletonServiceDescriptors(); + const overrides: [any, SyncDescriptor][] = [ + [IChatEntitlementService, new SyncDescriptor(MockChatEntitlementService)], + [IDefaultAccountService, new SyncDescriptor(MockDefaultAccountService)], + [IGitService, new SyncDescriptor(MockGitService)], + ]; + for (const [serviceId, mockDescriptor] of overrides) { + const idx = registry.findIndex(([id]) => id === serviceId); + if (idx !== -1) { + registry[idx] = [serviceId, mockDescriptor]; + console.log(`[Sessions Web Test] Replaced singleton: ${serviceId}`); + } else { + registry.push([serviceId, mockDescriptor]); + console.log(`[Sessions Web Test] Added singleton: ${serviceId}`); + } + } console.log('[Sessions Web Test] Creating Sessions workbench with mocks'); return new SessionsWorkbench(domElement, undefined, serviceCollection, logService);