Skip to content

Commit 6a7c936

Browse files
authored
fix: conditionally include folder (#309)
1 parent 4a186e5 commit 6a7c936

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/commands/force/mdapi/listmetadata.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ export class ListMetadata extends SourceCommand {
6868

6969
this.validateResultFile();
7070

71-
const query: ListMetadataQuery = { type, folder };
71+
const query: ListMetadataQuery = { type };
72+
if (folder) {
73+
query.folder = folder;
74+
}
7275
const connection = this.org.getConnection();
7376
const result = (await connection.metadata.list(query, apiversion)) || [];
7477
this.listResult = Array.isArray(result) ? result : [result];

test/nuts/mdapi.nut.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,22 @@ describe('mdapi NUTs', () => {
4949
});
5050

5151
describe('mdapi:listmetadata', () => {
52-
it('should successfully execute listmetadata', () => {
52+
it('should successfully execute listmetadata for type CustomObject', () => {
5353
const result = execCmd('force:mdapi:listmetadata --json --metadatatype CustomObject');
5454
expect(result.jsonOutput.status).to.equal(0);
5555
expect(result.jsonOutput.result).to.be.an('array').with.length.greaterThan(100);
5656
expect(result.jsonOutput.result[0]).to.have.property('type', 'CustomObject');
5757
});
58+
59+
it('should successfully execute listmetadata for type ListView', () => {
60+
// ListView is sensitive to how the connection.metadata.list() call is made.
61+
// e.g., if you pass { type: 'ListView', folder: undefined } it will not return
62+
// any ListViews but if you pass { type: 'ListView' } it returns all ListViews.
63+
const result = execCmd('force:mdapi:listmetadata --json --metadatatype ListView');
64+
expect(result.jsonOutput.status).to.equal(0);
65+
expect(result.jsonOutput.result).to.be.an('array').with.length.greaterThan(10);
66+
expect(result.jsonOutput.result[0]).to.have.property('type', 'ListView');
67+
});
5868
});
5969

6070
describe('mdapi:describemetadata', () => {

0 commit comments

Comments
 (0)