diff --git a/packages/salesforce/src/salesforceService.ts b/packages/salesforce/src/salesforceService.ts index a738fb17..e76aba49 100644 --- a/packages/salesforce/src/salesforceService.ts +++ b/packages/salesforce/src/salesforceService.ts @@ -553,10 +553,20 @@ export class SalesforceService implements SalesforceConnectionProvider { cache: false, } ); - const results = new Map(records.map(record => [ - record.ApexClassOrTrigger.Name.toLowerCase(), - record.Coverage - ])); + + // Map the results to to class name and remove + // any records that do not have any coverage details + const results = new Map( + records + .filter(record => + record.Coverage.coveredLines?.length && + record.Coverage.uncoveredLines?.length + ) + .map(record => [ + record.ApexClassOrTrigger.Name.toLowerCase(), + record.Coverage as ApexTestCoverage + ]) + ); if (!Array.isArray(apexClassName)) { return results.get(apexClassName.toLowerCase())!; diff --git a/packages/vscode-extension/commands.yaml b/packages/vscode-extension/commands.yaml index 5f718ea8..e634a4f2 100644 --- a/packages/vscode-extension/commands.yaml +++ b/packages/vscode-extension/commands.yaml @@ -350,26 +350,27 @@ vlocode.omniScript.activate: vlocode.openMetaXml: title: 'Salesforce: Open -meta.xml' icon: resources/{type}/meta-xml.svg - when: - - resourceScheme == file && resourcePath =~ /\.cls$/ - - resourceScheme == file && resourcePath =~ /\.trigger$/ menus: - menu: editor/title/run + when: + - resourceScheme == file && resourceExtname =~ /\.cls$/ + - resourceScheme == file && resourceExtname =~ /\.trigger$/ - menu: commandPalette vlocode.openSourceFile: title: 'Salesforce: Open Source' icon: $(code) - when: - - resourceScheme == file && resourcePath =~ /\.cls-meta\.xml$/ - - resourceScheme == file && resourcePath =~ /\.trigger-meta\.xml$/ menus: - menu: editor/title/run + when: + - resourceScheme == file && resourcePath =~ /\.cls-meta\.xml$/ + - resourceScheme == file && resourcePath =~ /\.trigger-meta\.xml$/ - menu: commandPalette vlocode.apex.toggleCoverage: - title: 'APEX: Toggle Test Coverage' + title: 'APEX: Highlight Unit Test Coverage' icon: $(test-view-icon) + group: v_apex when: - - resourceScheme == file && resourcePath =~ /\.cls$/ + - resourceExtname == .cls menus: - menu: commandPalette - menu: editor/context diff --git a/packages/vscode-extension/src/codeLensProviders/testCoverageLensProvider.ts b/packages/vscode-extension/src/codeLensProviders/testCoverageLensProvider.ts index b5f96e1d..37b335e7 100644 --- a/packages/vscode-extension/src/codeLensProviders/testCoverageLensProvider.ts +++ b/packages/vscode-extension/src/codeLensProviders/testCoverageLensProvider.ts @@ -70,12 +70,18 @@ export class TestCoverageLensProvider implements vscode.CodeLensProvider document.lineCount) { - void vscode.window.showWarningMessage(`Coverage data for ${apexClassName} is out of sync with the current file.`); + void vscode.window.showWarningMessage(`Coverage data for ${apexClassName} is out of sync.`); return; }