Skip to content

Commit 89ecdcd

Browse files
sessions: fix editor contribution test cleanup
Dispose the per-test instantiation service in the editor contribution regression tests and assert the maximize call order described by the test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4d0a202 commit 89ecdcd

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/vs/sessions/contrib/editor/test/browser/editor.contribution.test.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import assert from 'assert';
7+
import { DisposableStore } from '../../../../../base/common/lifecycle.js';
78
import { mock } from '../../../../../base/test/common/mock.js';
89
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';
910
import { CommandsRegistry } from '../../../../../platform/commands/common/commands.js';
@@ -18,10 +19,20 @@ import '../../browser/editor.contribution.js';
1819

1920
suite('Sessions - Editor Contribution', () => {
2021
ensureNoDisposablesAreLeakedInTestSuite();
22+
let store: DisposableStore;
23+
24+
setup(() => {
25+
store = new DisposableStore();
26+
});
27+
28+
teardown(() => {
29+
store.dispose();
30+
});
2131

2232
test('maximize editor hides the terminal panel before maximizing', async () => {
23-
const instantiationService = new TestInstantiationService();
33+
const instantiationService = store.add(new TestInstantiationService());
2434
const layoutService = new class extends mock<IAgentWorkbenchLayoutService>() {
35+
readonly calls: string[] = [];
2536
readonly hiddenParts: Parts[] = [];
2637
editorMaximized = false;
2738
panelVisible = true;
@@ -36,11 +47,13 @@ suite('Sessions - Editor Contribution', () => {
3647
}
3748

3849
if (hidden && part === Parts.PANEL_PART) {
50+
this.calls.push('hidePanel');
3951
this.hiddenParts.push(part);
4052
}
4153
}
4254

4355
override setEditorMaximized(maximized: boolean): void {
56+
this.calls.push(maximized ? 'maximizeEditor' : 'restoreEditor');
4457
this.editorMaximized = maximized;
4558
}
4659
};
@@ -56,12 +69,13 @@ suite('Sessions - Editor Contribution', () => {
5669

5770
await handler(instantiationService);
5871

72+
assert.deepStrictEqual(layoutService.calls, ['hidePanel', 'maximizeEditor']);
5973
assert.deepStrictEqual(layoutService.hiddenParts, [Parts.PANEL_PART]);
6074
assert.strictEqual(layoutService.editorMaximized, true);
6175
});
6276

6377
test('maximize editor keeps non-terminal panels visible', async () => {
64-
const instantiationService = new TestInstantiationService();
78+
const instantiationService = store.add(new TestInstantiationService());
6579
const layoutService = new class extends mock<IAgentWorkbenchLayoutService>() {
6680
readonly hiddenParts: Parts[] = [];
6781
editorMaximized = false;
@@ -102,7 +116,7 @@ suite('Sessions - Editor Contribution', () => {
102116
});
103117

104118
test('restore editor reopens the terminal panel when maximize hid it', async () => {
105-
const instantiationService = new TestInstantiationService();
119+
const instantiationService = store.add(new TestInstantiationService());
106120
const layoutService = new class extends mock<IAgentWorkbenchLayoutService>() {
107121
readonly hiddenParts: Parts[] = [];
108122
readonly shownParts: Parts[] = [];
@@ -150,7 +164,7 @@ suite('Sessions - Editor Contribution', () => {
150164
});
151165

152166
test('restore editor does not reopen the panel when maximize left it visible', async () => {
153-
const instantiationService = new TestInstantiationService();
167+
const instantiationService = store.add(new TestInstantiationService());
154168
const layoutService = new class extends mock<IAgentWorkbenchLayoutService>() {
155169
readonly shownParts: Parts[] = [];
156170
readonly maximizedStates: boolean[] = [];

0 commit comments

Comments
 (0)