From 8bc31625ecd92e123eccb83a337fc7a59f203443 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Thu, 5 Oct 2023 18:03:36 -0500 Subject: [PATCH] test: ut for mdapi line/col numbers --- src/client/metadataApiDeploy.ts | 2 ++ test/client/metadataApiDeploy.test.ts | 48 +++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/client/metadataApiDeploy.ts b/src/client/metadataApiDeploy.ts index 8af572118f..ceb42e8e50 100644 --- a/src/client/metadataApiDeploy.ts +++ b/src/client/metadataApiDeploy.ts @@ -74,6 +74,8 @@ export class DeployResult implements MetadataTransferResult { ? { error: c.problem, problemType: c.problemType, + columnNumber: c.columnNumber ? parseInt(c.columnNumber, 10) : undefined, + lineNumber: c.lineNumber ? parseInt(c.lineNumber, 10) : undefined, } : {}), fullName: c.fullName, diff --git a/test/client/metadataApiDeploy.test.ts b/test/client/metadataApiDeploy.test.ts index 4e6355e66a..fd44ced1f4 100644 --- a/test/client/metadataApiDeploy.test.ts +++ b/test/client/metadataApiDeploy.test.ts @@ -704,6 +704,54 @@ describe('MetadataApiDeploy', () => { expect(responses).to.deep.equal(expected); }); + it('should return line/col numbers for mdapi deploy', () => { + const component = matchingContentFile.COMPONENT; + const { fullName, type } = component; + const problem = 'something went wrong'; + const problemType = 'Error'; + const apiStatus: Partial = { + details: { + componentFailures: [ + { + changed: 'false', + created: 'false', + deleted: 'false', + success: 'false', + lineNumber: '3', + columnNumber: '5', + problem, + problemType, + fullName, + fileName: component.content, + componentType: type.name, + } as DeployMessage, + { + changed: 'false', + created: 'false', + deleted: 'false', + success: 'false', + lineNumber: '12', + columnNumber: '3', + problem, + problemType, + fullName, + fileName: component.content, + componentType: type.name, + } as DeployMessage, + ], + }, + }; + // intentionally don't include the componentSet + const result = new DeployResult(apiStatus as MetadataApiDeployStatus); + const fileResponses = result.getFileResponses(); + assert(fileResponses[0].state === ComponentStatus.Failed); + expect(fileResponses[0].lineNumber).equal(3); + expect(fileResponses[0].columnNumber).equal(5); + assert(fileResponses[1].state === ComponentStatus.Failed); + expect(fileResponses[1].lineNumber).equal(12); + expect(fileResponses[1].columnNumber).equal(3); + }); + it('should aggregate diagnostics for a component', () => { const component = matchingContentFile.COMPONENT; const deployedSet = new ComponentSet([component]);