diff --git a/src/formatters/deployResultFormatter.ts b/src/formatters/deployResultFormatter.ts index 7d9b04c1..07f59c1b 100644 --- a/src/formatters/deployResultFormatter.ts +++ b/src/formatters/deployResultFormatter.ts @@ -9,7 +9,14 @@ import * as path from 'path'; import * as fs from 'fs'; import { ux } from '@oclif/core'; import { dim, underline, bold } from 'chalk'; -import { DeployResult, Failures, FileResponse, RequestStatus, Successes } from '@salesforce/source-deploy-retrieve'; +import { + DeployResult, + Failures, + FileResponse, + FileResponseFailure, + RequestStatus, + Successes, +} from '@salesforce/source-deploy-retrieve'; import { Org, SfError } from '@salesforce/core'; import { ensureArray } from '@salesforce/kit'; import { @@ -234,6 +241,17 @@ export class DeployResultFormatter implements Formatter { if (this.result.response.status === RequestStatus.Succeeded) return; const failures = this.relativeFiles.filter(isSdrFailure); + // .push returns a number, so push here + failures.push( + ...ensureArray(this.result.response.details.componentFailures).map( + (fail) => + ({ + problemType: fail.problemType, + fullName: fail.fullName, + error: fail.problem, + } as FileResponseFailure) + ) + ); if (!failures.length) return; const columns = { diff --git a/test/utils/output.test.ts b/test/utils/output.test.ts index f64df7c5..28c62f54 100644 --- a/test/utils/output.test.ts +++ b/test/utils/output.test.ts @@ -8,6 +8,7 @@ import * as path from 'path'; import { assert, expect, config } from 'chai'; import * as sinon from 'sinon'; import { DeployResult } from '@salesforce/source-deploy-retrieve'; +import { ux } from '@oclif/core'; import { getCoverageFormattersOptions } from '../../src/utils/coverage'; import { DeployResultFormatter } from '../../src/formatters/deployResultFormatter'; import { getDeployResult } from './deployResponses'; @@ -21,6 +22,29 @@ describe('deployResultFormatter', () => { sandbox.restore(); }); + describe('displayFailures', () => { + const deployResultFailure = getDeployResult('failed'); + const tableStub = sandbox.stub(ux, 'table'); + + it('prints file responses, and messages from server', () => { + const formatter = new DeployResultFormatter(deployResultFailure, { verbose: true }); + formatter.display(); + expect(tableStub.callCount).to.equal(1); + expect(tableStub.firstCall.args[0]).to.deep.equal([ + { + error: 'This component has some problems', + fullName: 'ProductController', + problemType: 'Error', + }, + { + error: 'This component has some problems', + fullName: 'ProductController', + problemType: 'Error', + }, + ]); + }); + }); + describe('coverage functions', () => { describe('getCoverageFormattersOptions', () => { it('clover, json', () => {