Skip to content

Commit

Permalink
fix: fixing codecoverage response for non verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
mradulsf committed Jul 10, 2024
1 parent ea7024e commit 7ed19de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions schemas/package-version-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"Branch",
"BuildDurationInSeconds",
"BuildNumber",
"CodeCoverage",
"CreatedBy",
"CreatedDate",
"Description",
Expand Down
13 changes: 9 additions & 4 deletions src/commands/package/version/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type PackageVersionListDetails = Omit<
IsReleased: string | boolean;
HasPassedCodeCoverageCheck: string | boolean;
BuildDurationInSeconds: string | number;
CodeCoverage: string | undefined;
CodeCoverage: string;
NamespacePrefix: string;
Package2Name: string;
Version: string;
Expand Down Expand Up @@ -148,12 +148,17 @@ export class PackageVersionListCommand extends SfCommand<PackageVersionListComma
record.AncestorId = 'N/A';
}

const codeCoverage =
record.CodeCoverage?.apexCodeCoveragePercentage != null
function getCodeCoverage(): string {
if (flags.verbose) {
return 'use --verbose for code coverage';
}

return record.CodeCoverage?.apexCodeCoveragePercentage != null
? `${record.CodeCoverage.apexCodeCoveragePercentage.toString()}%`
: Boolean(record.Package2.IsOrgDependent) || record.ValidationSkipped
? 'N/A'
: '';
}

const hasPassedCodeCoverageCheck =
record.Package2.IsOrgDependent === true || record.ValidationSkipped
Expand Down Expand Up @@ -192,7 +197,7 @@ export class PackageVersionListCommand extends SfCommand<PackageVersionListComma
CreatedDate: new Date(record.CreatedDate).toISOString().replace('T', ' ').substring(0, 16),
LastModifiedDate: new Date(record.LastModifiedDate).toISOString().replace('T', ' ').substring(0, 16),
InstallUrl: INSTALL_URL_BASE.toString() + record.SubscriberPackageVersionId,
CodeCoverage: flags.verbose ? codeCoverage : undefined,
CodeCoverage: getCodeCoverage(),
HasPassedCodeCoverageCheck: hasPassedCodeCoverageCheck as string | boolean,
ValidationSkipped: record.ValidationSkipped,
ValidatedAsync: record.ValidatedAsync,
Expand Down
3 changes: 2 additions & 1 deletion test/commands/package/packageVersion.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ describe('package:version:*', () => {
'CreatedDate',
'LastModifiedDate',
'InstallUrl',
'CodeCoverage',
'ValidationSkipped',
'ValidatedAsync',
'AncestorId',
Expand Down Expand Up @@ -388,7 +389,7 @@ describe('package:version:*', () => {
expect(output).to.have.length.greaterThan(0);
expect(output[0]).to.have.keys(keys);
(output as PackageVersionListDetails[])
.filter((f: { CodeCoverage: string | undefined }) => f.CodeCoverage)
.filter((f: { CodeCoverage: string | boolean }) => f.CodeCoverage)
.map((v: { SubscriberPackageVersionId: string }) => packageVersionIds.push(v.SubscriberPackageVersionId));
});

Expand Down

0 comments on commit 7ed19de

Please sign in to comment.