Skip to content

Commit 2aa3c62

Browse files
Copilotconnor4312
andauthored
testing: add toggle command for showing test coverage in Explorer view (microsoft#261062)
* Initial plan * Add toggle command for coverage in Explorer view - Add CoverageToggleInExplorer command ID to TestCommandId enum - Implement ToggleCoverageInExplorer action with proper menu integration - Add test to verify command registration Co-authored-by: connor4312 <[email protected]> * Enhance toggle command with Test Explorer integration - Add command to Test Explorer view title bar - Add comprehensive test suite for toggle functionality - Improve command discoverability and UX Co-authored-by: connor4312 <[email protected]> * Remove menu and no-op tests as requested Co-authored-by: connor4312 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: connor4312 <[email protected]>
1 parent 95aefe8 commit 2aa3c62

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/vs/workbench/contrib/testing/browser/codeCoverageDecorations.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,32 @@ registerAction2(class FilterCoverageToTestInEditor extends Action2 {
878878
}
879879
});
880880

881+
registerAction2(class ToggleCoverageInExplorer extends Action2 {
882+
constructor() {
883+
super({
884+
id: TestCommandId.CoverageToggleInExplorer,
885+
title: localize2('testing.toggleCoverageInExplorerTitle', "Toggle Coverage in Explorer"),
886+
metadata: {
887+
description: localize2('testing.toggleCoverageInExplorerDesc', 'Toggle the display of test coverage in the File Explorer view.')
888+
},
889+
category: Categories.Test,
890+
toggled: {
891+
condition: ContextKeyExpr.equals('config.testing.showCoverageInExplorer', true),
892+
title: localize('testing.hideCoverageInExplorer', "Hide Coverage in Explorer"),
893+
},
894+
menu: [
895+
{ id: MenuId.CommandPalette, when: TestingContextKeys.isTestCoverageOpen },
896+
]
897+
});
898+
}
899+
900+
run(accessor: ServicesAccessor): void {
901+
const config = accessor.get(IConfigurationService);
902+
const value = getTestingConfiguration(config, TestingConfigKeys.ShowCoverageInExplorer);
903+
config.updateValue(TestingConfigKeys.ShowCoverageInExplorer, !value);
904+
}
905+
});
906+
881907
class ActionWithIcon extends Action {
882908
constructor(id: string, title: string, public readonly icon: ThemeIcon, enabled: boolean | undefined, run: () => void) {
883909
super(id, title, undefined, enabled, run);

src/vs/workbench/contrib/testing/common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export const enum TestCommandId {
6969
CoverageFilterToTestInEditor = 'testing.coverageFilterToTestInEditor',
7070
CoverageLastRun = 'testing.coverageLastRun',
7171
CoverageSelectedAction = 'testing.coverageSelected',
72+
CoverageToggleInExplorer = 'testing.toggleCoverageInExplorer',
7273
CoverageToggleToolbar = 'testing.coverageToggleToolbar',
7374
CoverageViewChangeSorting = 'testing.coverageViewChangeSorting',
7475
DebugAction = 'testing.debug',

src/vs/workbench/contrib/testing/test/browser/codeCoverageDecorations.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,5 @@ suite('Code Coverage Decorations', () => {
100100
// Should have no ranges available for inline display
101101
assert.strictEqual(emptyModel.ranges.length === 0, true, 'Model with no coverage details should have no ranges');
102102
});
103+
103104
});

0 commit comments

Comments
 (0)