Skip to content

Commit

Permalink
fix: remove duplicates from file responses
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Oct 11, 2023
1 parent 853c1a5 commit 92ab6a6
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/client/metadataApiDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export class DeployResult implements MetadataTransferResult {
);
}
}
return this.fileResponses;
// removes duplicates from the file responses by parsing the object into a string, used as the key of the map
return [...new Map(this.fileResponses.map((v) => [JSON.stringify(v), v])).values()];
}

private createResponses(component: SourceComponent, responseMessages: DeployMessage[]): FileResponse[] {
Expand Down
57 changes: 57 additions & 0 deletions test/client/metadataApiDeploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,63 @@ describe('MetadataApiDeploy', () => {
expect(responses).to.deep.equal(expected);
});

it('should not report duplicates component', () => {
const component = matchingContentFile.COMPONENT;
const deployedSet = new ComponentSet([component]);
const { fullName, type, content } = component;
const problem = 'something went wrong';
const problemType = 'Error';
const apiStatus: Partial<MetadataApiDeployStatus> = {
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: '3',
columnNumber: '5',
problem,
problemType,
fullName,
fileName: component.content,
componentType: type.name,
} as DeployMessage,
],
},
};
const result = new DeployResult(apiStatus as MetadataApiDeployStatus, deployedSet);

const responses = result.getFileResponses();
const expected: FileResponse[] = [
{
fullName,
type: type.name,
state: ComponentStatus.Failed,
filePath: content,
error: `${problem} (3:5)`,
lineNumber: 3,
columnNumber: 5,
problemType,
},
];

expect(responses).to.deep.equal(expected);
});

it('should report children of deployed component', () => {
const component = DECOMPOSED_COMPONENT;
const deployedSet = new ComponentSet([component]);
Expand Down

0 comments on commit 92ab6a6

Please sign in to comment.