@@ -11,72 +11,73 @@ import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
1111import { DescribeMetadataResult } from 'jsforce/lib/api/metadata/schema' ;
1212import { ListMetadataCommandResult } from '../../src/commands/org/list/metadata' ;
1313
14- let session : TestSession ;
15-
16- before ( async ( ) => {
17- session = await TestSession . create ( {
18- project : {
19- gitClone : 'https://github.com/trailheadapps/dreamhouse-lwc.git' ,
20- } ,
21- devhubAuthStrategy : 'AUTO' ,
22- scratchOrgs : [
23- {
24- executable : 'sfdx' ,
25- config : path . join ( 'config' , 'project-scratch-def.json' ) ,
26- setDefault : true ,
27- duration : 1 ,
14+ describe ( 'org list metadata*' , ( ) => {
15+ let session : TestSession ;
16+ before ( async ( ) => {
17+ session = await TestSession . create ( {
18+ project : {
19+ gitClone : 'https://github.com/trailheadapps/dreamhouse-lwc.git' ,
2820 } ,
29- ] ,
30- } ) ;
31-
32- execCmd ( 'force:source:deploy -p force-app' , { cli : 'sfdx' } ) ;
33- } ) ;
21+ devhubAuthStrategy : 'AUTO' ,
22+ scratchOrgs : [
23+ {
24+ executable : 'sfdx' ,
25+ config : path . join ( 'config' , 'project-scratch-def.json' ) ,
26+ setDefault : true ,
27+ duration : 1 ,
28+ } ,
29+ ] ,
30+ } ) ;
3431
35- after ( async ( ) => {
36- await session ?. zip ( undefined , 'artifacts' ) ;
37- await session ?. clean ( ) ;
38- } ) ;
32+ execCmd ( 'force:source:deploy -p force-app' , { cli : 'sfdx' } ) ;
33+ } ) ;
3934
40- describe ( 'list metadata' , ( ) => {
41- it ( 'should successfully execute list metadata for type CustomObject' , ( ) => {
42- const result = execCmd < ListMetadataCommandResult > (
43- 'org:list:metadata -f output --json --metadatatype CustomObject'
44- ) . jsonOutput ;
45- expect ( result ?. status ) . to . equal ( 0 ) ;
46- expect ( result ?. result ) . to . be . an ( 'array' ) . with . length . greaterThan ( 3 ) ;
47- expect ( result ?. result [ 0 ] ) . to . have . property ( 'type' , 'CustomObject' ) ;
48- expect ( fs . existsSync ( path . join ( session . project . dir , 'output' ) ) ) . to . equal ( true ) ;
35+ after ( async ( ) => {
36+ await session ?. zip ( undefined , 'artifacts' ) ;
37+ await session ?. clean ( ) ;
4938 } ) ;
5039
51- it ( 'should successfully execute list metadata for type ListView' , ( ) => {
52- // ListView is sensitive to how the connection.metadata.list() call is made.
53- // e.g., if you pass { type: 'ListView', folder: undefined } it will not return
54- // any ListViews but if you pass { type: 'ListView' } it returns all ListViews.
55- const result = execCmd < ListMetadataCommandResult > ( 'org:list:metadata --json --metadatatype ListView' ) . jsonOutput ;
56- expect ( result ?. status ) . to . equal ( 0 ) ;
57- expect ( result ?. result ) . to . be . an ( 'array' ) . with . length . greaterThan ( 10 ) ;
58- expect ( result ?. result [ 0 ] ) . to . have . property ( 'type' , 'ListView' ) ;
40+ describe ( 'list metadata' , ( ) => {
41+ it ( 'should successfully execute list metadata for type CustomObject' , ( ) => {
42+ const result = execCmd < ListMetadataCommandResult > (
43+ 'org:list:metadata -f output --json --metadatatype CustomObject'
44+ ) . jsonOutput ;
45+ expect ( result ?. status ) . to . equal ( 0 ) ;
46+ expect ( result ?. result ) . to . be . an ( 'array' ) . with . length . greaterThan ( 3 ) ;
47+ expect ( result ?. result [ 0 ] ) . to . have . property ( 'type' , 'CustomObject' ) ;
48+ expect ( fs . existsSync ( path . join ( session . project . dir , 'output' ) ) ) . to . equal ( true ) ;
49+ } ) ;
50+
51+ it ( 'should successfully execute list metadata for type ListView' , ( ) => {
52+ // ListView is sensitive to how the connection.metadata.list() call is made.
53+ // e.g., if you pass { type: 'ListView', folder: undefined } it will not return
54+ // any ListViews but if you pass { type: 'ListView' } it returns all ListViews.
55+ const result = execCmd < ListMetadataCommandResult > ( 'org:list:metadata --json --metadatatype ListView' ) . jsonOutput ;
56+ expect ( result ?. status ) . to . equal ( 0 ) ;
57+ expect ( result ?. result ) . to . be . an ( 'array' ) . with . length . greaterThan ( 10 ) ;
58+ expect ( result ?. result [ 0 ] ) . to . have . property ( 'type' , 'ListView' ) ;
59+ } ) ;
5960 } ) ;
60- } ) ;
6161
62- describe ( 'list metadata-types' , ( ) => {
63- it ( 'should successfully execute describemetadata' , ( ) => {
64- const result = execCmd < DescribeMetadataResult > ( 'org:list:metadata-types --json --resultfile md-describe.json' , {
65- ensureExitCode : 0 ,
66- } ) . jsonOutput ;
67- const json = result ?. result ;
68- expect ( json ) . to . have . property ( 'metadataObjects' ) ;
69- const mdObjects = json ?. metadataObjects ;
70- expect ( mdObjects ) . to . be . an ( 'array' ) . with . length . greaterThan ( 100 ) ;
71- const customLabelsDef = mdObjects ?. find ( ( md ) => md . xmlName === 'CustomLabels' ) ;
72- expect ( customLabelsDef ) . to . deep . equal ( {
73- childXmlNames : [ 'CustomLabel' ] ,
74- directoryName : 'labels' ,
75- inFolder : false ,
76- metaFile : false ,
77- suffix : 'labels' ,
78- xmlName : 'CustomLabels' ,
62+ describe ( 'list metadata-types' , ( ) => {
63+ it ( 'should successfully execute describemetadata' , ( ) => {
64+ const result = execCmd < DescribeMetadataResult > ( 'org:list:metadata-types --json --resultfile md-describe.json' , {
65+ ensureExitCode : 0 ,
66+ } ) . jsonOutput ;
67+ const json = result ?. result ;
68+ expect ( json ) . to . have . property ( 'metadataObjects' ) ;
69+ const mdObjects = json ?. metadataObjects ;
70+ expect ( mdObjects ) . to . be . an ( 'array' ) . with . length . greaterThan ( 100 ) ;
71+ const customLabelsDef = mdObjects ?. find ( ( md ) => md . xmlName === 'CustomLabels' ) ;
72+ expect ( customLabelsDef ) . to . deep . equal ( {
73+ childXmlNames : [ 'CustomLabel' ] ,
74+ directoryName : 'labels' ,
75+ inFolder : false ,
76+ metaFile : false ,
77+ suffix : 'labels' ,
78+ xmlName : 'CustomLabels' ,
79+ } ) ;
80+ expect ( fs . existsSync ( path . join ( session . project . dir , 'md-describe.json' ) ) ) . to . be . true ;
7981 } ) ;
80- expect ( fs . existsSync ( path . join ( session . project . dir , 'md-describe.json' ) ) ) . to . be . true ;
8182 } ) ;
8283} ) ;
0 commit comments