From 12d570d26415f889f1f2e3b3ba5b384134dd9f1f Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Tue, 20 Oct 2026 17:34:30 +0200 Subject: [PATCH] sessions: cover returning the only quick chat to an empty Chats section Adds a regression test for #340740: a quick chat moved into a custom group can be dragged back onto the Chats section header even when it is the only quick chat, so Chats is empty and renders its placeholder. The drop target itself was fixed by #342591, which resolves drops to placements and lets quick chats return to Chats; its test only covered a populated Chats section. Fixes #340740 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../test/browser/sessionsList.test.ts | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/vs/sessions/contrib/sessions/test/browser/sessionsList.test.ts b/src/vs/sessions/contrib/sessions/test/browser/sessionsList.test.ts index 20e353074eff12..3276621377f78b 100644 --- a/src/vs/sessions/contrib/sessions/test/browser/sessionsList.test.ts +++ b/src/vs/sessions/contrib/sessions/test/browser/sessionsList.test.ts @@ -4003,7 +4003,7 @@ suite('Sessions - SessionsList', () => { readonly sortChanges: readonly ISortChangeRecord[]; } - function renderGroupedList(sessions: ISession[], memberships: Map, groupExternalSessions = false, grouping = SessionsGrouping.Workspace): IDropHarness { + function renderGroupedList(sessions: ISession[], memberships: Map, groupExternalSessions = false, grouping = SessionsGrouping.Workspace, supportsQuickChats = false): IDropHarness { const removedFromGroup: string[] = []; const onDidChange = disposables.add(new Emitter()); const harness = createListHarness(disposables, sessions, instantiationService => { @@ -4024,6 +4024,15 @@ suite('Sessions - SessionsList', () => { onDidChange.fire({ groupsChanged: false, membershipChanged: new Set([sessionId]) }); } }); + if (supportsQuickChats) { + void (instantiationService.get(IConfigurationService) as TestConfigurationService).setUserConfiguration(SESSIONS_LIST_SHOW_EMPTY_DEFAULT_GROUPS_SETTING, true); + const quickChatProvider = upcastPartial({ supportsQuickChats: true }); + instantiationService.stub(ISessionsProvidersService, new class extends mock() { + override readonly onDidChangeProviders = Event.None; + override getProviders() { return [quickChatProvider]; } + override getProvider() { return undefined; } + }); + } }); const container = harness.createContainer(); const list = harness.store.add(harness.instantiationService.createInstance(SessionsList, container, { @@ -4166,6 +4175,20 @@ suite('Sessions - SessionsList', () => { reordered: 0, }); }); + + test('returns the only quick chat to the empty Chats section', () => { + const groupedChat = createTestSession('GroupedChat', { isQuickChat: true }).session; + const regular = createTestSession('Regular').session; + const memberships = new Map([[groupedChat.sessionId, group.id]]); + const { container, removedFromGroup } = renderGroupedList([groupedChat, regular], memberships, false, SessionsGrouping.Date, true); + + const chatOntoChats = drag(sessionRow(container, 'GroupedChat'), sectionRow(container, 'Chats'), container); + + assert.deepStrictEqual({ chatOntoChats, removedFromGroup }, { + chatOntoChats: ['Chats'], + removedFromGroup: ['GroupedChat'], + }); + }); }); suite('moving between placements', () => {