Skip to content

Commit a8b4ebf

Browse files
fix: remove duplicates from file responses (#1137)
1 parent 07d8ca9 commit a8b4ebf

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

src/client/metadataApiDeploy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ export class DeployResult implements MetadataTransferResult {
8686
);
8787
}
8888
}
89-
return this.fileResponses;
89+
// removes duplicates from the file responses by parsing the object into a string, used as the key of the map
90+
return [...new Map(this.fileResponses.map((v) => [JSON.stringify(v), v])).values()];
9091
}
9192

9293
private createResponses(component: SourceComponent, responseMessages: DeployMessage[]): FileResponse[] {

test/client/metadataApiDeploy.test.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,63 @@ describe('MetadataApiDeploy', () => {
819819
expect(responses).to.deep.equal(expected);
820820
});
821821

822+
it('should not report duplicates component', () => {
823+
const component = matchingContentFile.COMPONENT;
824+
const deployedSet = new ComponentSet([component]);
825+
const { fullName, type, content } = component;
826+
const problem = 'something went wrong';
827+
const problemType = 'Error';
828+
const apiStatus: Partial<MetadataApiDeployStatus> = {
829+
details: {
830+
componentFailures: [
831+
{
832+
changed: 'false',
833+
created: 'false',
834+
deleted: 'false',
835+
success: 'false',
836+
lineNumber: '3',
837+
columnNumber: '5',
838+
problem,
839+
problemType,
840+
fullName,
841+
fileName: component.content,
842+
componentType: type.name,
843+
} as DeployMessage,
844+
{
845+
changed: 'false',
846+
created: 'false',
847+
deleted: 'false',
848+
success: 'false',
849+
lineNumber: '3',
850+
columnNumber: '5',
851+
problem,
852+
problemType,
853+
fullName,
854+
fileName: component.content,
855+
componentType: type.name,
856+
} as DeployMessage,
857+
],
858+
},
859+
};
860+
const result = new DeployResult(apiStatus as MetadataApiDeployStatus, deployedSet);
861+
862+
const responses = result.getFileResponses();
863+
const expected: FileResponse[] = [
864+
{
865+
fullName,
866+
type: type.name,
867+
state: ComponentStatus.Failed,
868+
filePath: content,
869+
error: `${problem} (3:5)`,
870+
lineNumber: 3,
871+
columnNumber: 5,
872+
problemType,
873+
},
874+
];
875+
876+
expect(responses).to.deep.equal(expected);
877+
});
878+
822879
it('should report children of deployed component', () => {
823880
const component = DECOMPOSED_COMPONENT;
824881
const deployedSet = new ComponentSet([component]);

0 commit comments

Comments
 (0)