@@ -11,21 +11,26 @@ import { SfdxPropertyKeys, OrgConfigProperties } from '@salesforce/core';
11
11
import { env } from '@salesforce/kit' ;
12
12
import { AnyJson , ensureString } from '@salesforce/ts-types' ;
13
13
import { expect } from 'chai' ;
14
- import { exec } from 'shelljs' ;
15
14
import { ConfigResponses , Msg } from '../src/config' ;
16
15
17
16
let testSession : TestSession ;
18
17
19
18
describe ( 'Interoperability NUTs' , async ( ) => {
20
19
ensureString ( env . getString ( 'TESTKIT_AUTH_URL' ) , 'TESTKIT_AUTH_URL must be set in the environment' ) ;
21
- env . setString ( 'TESTKIT_EXECUTABLE_PATH' , path . join ( process . cwd ( ) , 'bin' , 'dev' ) ) ;
22
20
23
21
const ORG_ALIAS = 'my-org' ;
24
22
25
23
before ( async ( ) => {
26
24
testSession = await TestSession . create ( {
27
25
project : { name : 'interoperabilityNUTs' } ,
28
- setupCommands : [ `sfdx force:org:create -f config/project-scratch-def.json -a ${ ORG_ALIAS } ` ] ,
26
+ devhubAuthStrategy : 'AUTH_URL' ,
27
+ scratchOrgs : [
28
+ {
29
+ executable : 'sfdx' ,
30
+ config : path . join ( 'config' , 'project-scratch-def.json' ) ,
31
+ alias : ORG_ALIAS ,
32
+ }
33
+ ] ,
29
34
} ) ;
30
35
} ) ;
31
36
@@ -53,7 +58,6 @@ describe('Interoperability NUTs', async () => {
53
58
it ( 'should set target-org in .sf and defaultusername in .sfdx' , async ( ) => {
54
59
const { result } = execCmd < ConfigResponses > ( `config set target-org ${ ORG_ALIAS } --json` , {
55
60
ensureExitCode : 0 ,
56
- cli : 'sf' ,
57
61
} ) . jsonOutput ;
58
62
const expected = [ { name : OrgConfigProperties . TARGET_ORG , value : ORG_ALIAS , success : true } ] ;
59
63
expect ( result ) . to . deep . equal ( expected ) ;
@@ -65,7 +69,6 @@ describe('Interoperability NUTs', async () => {
65
69
it ( 'should set target-dev-hub in .sf and defaultdevhubusername in .sfdx' , async ( ) => {
66
70
const { result } = execCmd < ConfigResponses > ( `config set target-dev-hub ${ ORG_ALIAS } --json` , {
67
71
ensureExitCode : 0 ,
68
- cli : 'sf' ,
69
72
} ) . jsonOutput ;
70
73
const expected = [ { name : OrgConfigProperties . TARGET_DEV_HUB , value : ORG_ALIAS , success : true } ] ;
71
74
expect ( result ) . to . deep . equal ( expected ) ;
@@ -77,7 +80,6 @@ describe('Interoperability NUTs', async () => {
77
80
it ( 'should fail to set defaultusername' , async ( ) => {
78
81
const { result } = execCmd < ConfigResponses > ( `config set defaultusername ${ ORG_ALIAS } --json` , {
79
82
ensureExitCode : 1 ,
80
- cli : 'sf' ,
81
83
} ) . jsonOutput ;
82
84
expect ( result [ 0 ] . success ) . to . be . false ;
83
85
expect ( result [ 0 ] . name ) . to . equal ( SfdxPropertyKeys . DEFAULT_USERNAME ) ;
@@ -86,7 +88,6 @@ describe('Interoperability NUTs', async () => {
86
88
it ( 'should fail to set defaultdevhubusername' , async ( ) => {
87
89
const { result } = execCmd < ConfigResponses > ( `config set defaultdevhubusername ${ ORG_ALIAS } --json` , {
88
90
ensureExitCode : 1 ,
89
- cli : 'sf' ,
90
91
} ) . jsonOutput ;
91
92
expect ( result [ 0 ] . success ) . to . be . false ;
92
93
expect ( result [ 0 ] . name ) . to . equal ( SfdxPropertyKeys . DEFAULT_DEV_HUB_USERNAME ) ;
@@ -95,15 +96,15 @@ describe('Interoperability NUTs', async () => {
95
96
96
97
describe ( 'sf config list' , ( ) => {
97
98
it ( 'should list target-org when defaultusername is set by sfdx' , async ( ) => {
98
- exec ( `sfdx config:set defaultusername=${ ORG_ALIAS } `, { silent : true } ) ;
99
- const { result } = execCmd < ConfigResponses > ( 'config list --json' , { ensureExitCode : 0 , cli : 'sf' } ) . jsonOutput ;
99
+ execCmd ( ` config:set defaultusername=${ ORG_ALIAS } `, { cli : 'sfdx' } ) ;
100
+ const { result } = execCmd < ConfigResponses > ( 'config list --json' , { ensureExitCode : 0 } ) . jsonOutput ;
100
101
const expected = [ { name : OrgConfigProperties . TARGET_ORG , value : ORG_ALIAS , success : true , location : 'Local' } ] ;
101
102
expect ( result ) . to . deep . equal ( expected ) ;
102
103
} ) ;
103
104
104
105
it ( 'should list target-dev-hub when defaultdevhubusername is set by sfdx' , async ( ) => {
105
- exec ( `sfdx config:set defaultdevhubusername=${ ORG_ALIAS } `, { silent : true } ) ;
106
- const { result } = execCmd < ConfigResponses > ( 'config list --json' , { ensureExitCode : 0 , cli : 'sf' } ) . jsonOutput ;
106
+ execCmd ( ` config:set defaultdevhubusername=${ ORG_ALIAS } `, { cli : 'sfdx' } ) ;
107
+ const { result } = execCmd < ConfigResponses > ( 'config list --json' , { ensureExitCode : 0 } ) . jsonOutput ;
107
108
const expected = [
108
109
{ name : OrgConfigProperties . TARGET_DEV_HUB , value : ORG_ALIAS , success : true , location : 'Local' } ,
109
110
] ;
@@ -113,15 +114,15 @@ describe('Interoperability NUTs', async () => {
113
114
114
115
describe ( 'sf config get' , ( ) => {
115
116
it ( 'should get target-org when defaultusername is set by sfdx' , async ( ) => {
116
- exec ( `sfdx config:set defaultusername=${ ORG_ALIAS } `, { silent : true } ) ;
117
- const { result } = execCmd < Msg > ( 'config get target-org --json' , { ensureExitCode : 0 , cli : 'sf' } ) . jsonOutput ;
117
+ execCmd ( ` config:set defaultusername=${ ORG_ALIAS } `, { cli : 'sfdx' } ) ;
118
+ const { result } = execCmd < Msg > ( 'config get target-org --json' , { ensureExitCode : 0 } ) . jsonOutput ;
118
119
const expected = [ { name : OrgConfigProperties . TARGET_ORG , value : ORG_ALIAS , success : true , location : 'Local' } ] ;
119
120
expect ( result ) . to . deep . equal ( expected ) ;
120
121
} ) ;
121
122
122
123
it ( 'should get target-dev-hub when defaultdevhubusername is set by sfdx' , async ( ) => {
123
- exec ( `sfdx config:set defaultdevhubusername=${ ORG_ALIAS } `, { silent : true } ) ;
124
- const { result } = execCmd < Msg > ( 'config get target-dev-hub --json' , { ensureExitCode : 0 , cli : 'sf' } ) . jsonOutput ;
124
+ execCmd ( ` config:set defaultdevhubusername=${ ORG_ALIAS } `, { cli : 'sfdx' } ) ;
125
+ const { result } = execCmd < Msg > ( 'config get target-dev-hub --json' , { ensureExitCode : 0 } ) . jsonOutput ;
125
126
const expected = [
126
127
{
127
128
name : OrgConfigProperties . TARGET_DEV_HUB ,
@@ -136,7 +137,6 @@ describe('Interoperability NUTs', async () => {
136
137
it ( 'should fail to get defaultusername' , async ( ) => {
137
138
const { result } = execCmd < ConfigResponses > ( `config get defaultusername ${ ORG_ALIAS } --json` , {
138
139
ensureExitCode : 1 ,
139
- cli : 'sf' ,
140
140
} ) . jsonOutput ;
141
141
expect ( result [ 0 ] . success ) . to . be . false ;
142
142
expect ( result [ 0 ] . name ) . to . equal ( SfdxPropertyKeys . DEFAULT_USERNAME ) ;
@@ -145,7 +145,6 @@ describe('Interoperability NUTs', async () => {
145
145
it ( 'should fail to get defaultdevhubusername' , async ( ) => {
146
146
const { result } = execCmd < ConfigResponses > ( `config get defaultdevhubusername ${ ORG_ALIAS } --json` , {
147
147
ensureExitCode : 1 ,
148
- cli : 'sf' ,
149
148
} ) . jsonOutput ;
150
149
expect ( result [ 0 ] . success ) . to . be . false ;
151
150
expect ( result [ 0 ] . name ) . to . equal ( SfdxPropertyKeys . DEFAULT_DEV_HUB_USERNAME ) ;
@@ -154,10 +153,9 @@ describe('Interoperability NUTs', async () => {
154
153
155
154
describe ( 'sf config unset' , ( ) => {
156
155
it ( 'should unset target-org in .sf and defaultusername in .sfdx' , async ( ) => {
157
- exec ( `sfdx config:set defaultusername=${ ORG_ALIAS } `, { silent : true } ) ;
156
+ execCmd ( ` config:set defaultusername=${ ORG_ALIAS } `, { cli : 'sfdx' } ) ;
158
157
const { result } = execCmd < ConfigResponses > ( 'config unset target-org --json' , {
159
158
ensureExitCode : 0 ,
160
- cli : 'sf' ,
161
159
} ) . jsonOutput ;
162
160
const expected = [ { name : OrgConfigProperties . TARGET_ORG , success : true } ] ;
163
161
expect ( result ) . to . deep . equal ( expected ) ;
@@ -167,10 +165,9 @@ describe('Interoperability NUTs', async () => {
167
165
} ) ;
168
166
169
167
it ( 'should unset target-dev-hub in .sf and defaultdevhubusername in .sfdx' , async ( ) => {
170
- exec ( `sfdx config:set defaultdevhubusername=${ ORG_ALIAS } `, { silent : true } ) ;
168
+ execCmd ( ` config:set defaultdevhubusername=${ ORG_ALIAS } `, { cli : 'sfdx' } ) ;
171
169
const { result } = execCmd < ConfigResponses > ( 'config unset target-dev-hub --json' , {
172
170
ensureExitCode : 0 ,
173
- cli : 'sf' ,
174
171
} ) . jsonOutput ;
175
172
const expected = [ { name : OrgConfigProperties . TARGET_DEV_HUB , success : true } ] ;
176
173
expect ( result ) . to . deep . equal ( expected ) ;
@@ -182,7 +179,6 @@ describe('Interoperability NUTs', async () => {
182
179
it ( 'should fail to unset defaultusername' , async ( ) => {
183
180
const { result } = execCmd < ConfigResponses > ( `config unset defaultusername ${ ORG_ALIAS } --json` , {
184
181
ensureExitCode : 1 ,
185
- cli : 'sf' ,
186
182
} ) . jsonOutput ;
187
183
expect ( result [ 0 ] . success ) . to . be . false ;
188
184
expect ( result [ 0 ] . name ) . to . equal ( SfdxPropertyKeys . DEFAULT_USERNAME ) ;
@@ -191,7 +187,6 @@ describe('Interoperability NUTs', async () => {
191
187
it ( 'should fail to unset defaultdevhubusername' , async ( ) => {
192
188
const { result } = execCmd < ConfigResponses > ( `config unset defaultdevhubusername ${ ORG_ALIAS } --json` , {
193
189
ensureExitCode : 1 ,
194
- cli : 'sf' ,
195
190
} ) . jsonOutput ;
196
191
expect ( result [ 0 ] . success ) . to . be . false ;
197
192
expect ( result [ 0 ] . name ) . to . equal ( SfdxPropertyKeys . DEFAULT_DEV_HUB_USERNAME ) ;
@@ -200,14 +195,13 @@ describe('Interoperability NUTs', async () => {
200
195
201
196
describe ( 'sfdx config:set' , ( ) => {
202
197
it ( 'should set target-org in .sf and defaultusername in .sfdx' , async ( ) => {
203
- exec ( `sfdx config:set defaultusername=${ ORG_ALIAS } `, { silent : true } ) ;
198
+ execCmd ( ` config:set defaultusername=${ ORG_ALIAS } `, { cli : 'sfdx' } ) ;
204
199
await configShouldHave ( '.sfdx' , SfdxPropertyKeys . DEFAULT_USERNAME , ORG_ALIAS ) ;
205
200
206
201
// We can't check .sf/config.json directly because sfdx doesn't write back to sf
207
202
// Instead we test this by running `config get`
208
203
const getResult = execCmd < ConfigResponses > ( 'config get target-org --json' , {
209
204
ensureExitCode : 0 ,
210
- cli : 'sf' ,
211
205
} ) . jsonOutput . result ;
212
206
const getExpected = [
213
207
{ name : OrgConfigProperties . TARGET_ORG , value : ORG_ALIAS , success : true , location : 'Local' } ,
@@ -216,14 +210,13 @@ describe('Interoperability NUTs', async () => {
216
210
} ) ;
217
211
218
212
it ( 'should set target-dev-hub in .sf and defaultdevhubusername in .sfdx' , async ( ) => {
219
- exec ( `sfdx config:set defaultdevhubusername=${ ORG_ALIAS } `, { silent : true } ) ;
213
+ execCmd ( ` config:set defaultdevhubusername=${ ORG_ALIAS } `, { cli : 'sfdx' } ) ;
220
214
await configShouldHave ( '.sfdx' , SfdxPropertyKeys . DEFAULT_DEV_HUB_USERNAME , ORG_ALIAS ) ;
221
215
222
216
// We can't check .sf/config.json directly because sfdx doesn't write back to sf
223
217
// Instead we test this by running `config get`
224
218
const getResult = execCmd < ConfigResponses > ( 'config get target-dev-hub --json' , {
225
219
ensureExitCode : 0 ,
226
- cli : 'sf' ,
227
220
} ) . jsonOutput . result ;
228
221
const getExpected = [
229
222
{ name : OrgConfigProperties . TARGET_DEV_HUB , value : ORG_ALIAS , success : true , location : 'Local' } ,
@@ -234,18 +227,16 @@ describe('Interoperability NUTs', async () => {
234
227
it ( 'should overwrite existing .sf configs' , async ( ) => {
235
228
execCmd < ConfigResponses > ( 'config set org-api-version=51.0 --json' , {
236
229
ensureExitCode : 0 ,
237
- cli : 'sf' ,
238
230
} ) ;
239
231
await configShouldHave ( '.sf' , OrgConfigProperties . ORG_API_VERSION , '51.0' ) ;
240
232
241
- exec ( 'sfdx config:set apiVersion=52.0', { silent : true } ) ;
233
+ execCmd ( ' config:set apiVersion=52.0', { cli : 'sfdx' } ) ;
242
234
await configShouldHave ( '.sfdx' , SfdxPropertyKeys . API_VERSION , '52.0' ) ;
243
235
244
236
// We can't check .sf/config.json directly because sfdx doesn't write back to sf
245
237
// Instead we test this by running `config get`
246
238
const getResult = execCmd < ConfigResponses > ( 'config get org-api-version --json' , {
247
239
ensureExitCode : 0 ,
248
- cli : 'sf' ,
249
240
} ) . jsonOutput . result ;
250
241
const getExpected = [
251
242
{ name : OrgConfigProperties . ORG_API_VERSION , value : '52.0' , success : true , location : 'Local' } ,
@@ -259,14 +250,13 @@ describe('Interoperability NUTs', async () => {
259
250
await writeJson ( path . join ( testSession . project . dir , '.sf' , 'config.json' ) , config ) ;
260
251
await configShouldHave ( '.sf' , OrgConfigProperties . TARGET_ORG , 'foobar' ) ;
261
252
262
- exec ( `sfdx config:set defaultusername=${ ORG_ALIAS } `, { silent : true } ) ;
253
+ execCmd ( ` config:set defaultusername=${ ORG_ALIAS } `, { cli : 'sfdx' } ) ;
263
254
await configShouldHave ( '.sfdx' , SfdxPropertyKeys . DEFAULT_USERNAME , ORG_ALIAS ) ;
264
255
265
256
// We can't check .sf/config.json directly because sfdx doesn't write back to sf
266
257
// Instead we test this by running `config get`
267
258
const getResult = execCmd < ConfigResponses > ( 'config get target-org --json' , {
268
259
ensureExitCode : 0 ,
269
- cli : 'sf' ,
270
260
} ) . jsonOutput . result ;
271
261
const getExpected = [
272
262
{ name : OrgConfigProperties . TARGET_ORG , value : ORG_ALIAS , success : true , location : 'Local' } ,
@@ -280,14 +270,13 @@ describe('Interoperability NUTs', async () => {
280
270
await writeJson ( path . join ( testSession . project . dir , '.sf' , 'config.json' ) , config ) ;
281
271
await configShouldHave ( '.sf' , OrgConfigProperties . TARGET_DEV_HUB , 'foobar' ) ;
282
272
283
- exec ( `sfdx config:set defaultdevhubusername=${ ORG_ALIAS } `, { silent : true } ) ;
273
+ execCmd ( ` config:set defaultdevhubusername=${ ORG_ALIAS } `, { cli : 'sfdx' } ) ;
284
274
await configShouldHave ( '.sfdx' , SfdxPropertyKeys . DEFAULT_DEV_HUB_USERNAME , ORG_ALIAS ) ;
285
275
286
276
// We can't check .sf/config.json directly because sfdx doesn't write back to sf
287
277
// Instead we test this by running `config get`
288
278
const getResult = execCmd < ConfigResponses > ( 'config get target-dev-hub --json' , {
289
279
ensureExitCode : 0 ,
290
- cli : 'sf' ,
291
280
} ) . jsonOutput . result ;
292
281
const getExpected = [
293
282
{ name : OrgConfigProperties . TARGET_DEV_HUB , value : ORG_ALIAS , success : true , location : 'Local' } ,
@@ -300,19 +289,17 @@ describe('Interoperability NUTs', async () => {
300
289
it ( 'should unset target-org in .sf and defaultusername in .sfdx' , async ( ) => {
301
290
const setResult = execCmd < ConfigResponses > ( `config set target-org ${ ORG_ALIAS } --json` , {
302
291
ensureExitCode : 0 ,
303
- cli : 'sf' ,
304
292
} ) . jsonOutput . result ;
305
293
const setExpected = [ { name : OrgConfigProperties . TARGET_ORG , value : ORG_ALIAS , success : true } ] ;
306
294
expect ( setResult ) . to . deep . equal ( setExpected ) ;
307
295
308
- exec ( 'sfdx config:unset defaultusername', { silent : true } ) ;
296
+ execCmd ( ' config:unset defaultusername', { cli : 'sfdx' } ) ;
309
297
await configShouldNotHave ( '.sfdx' , SfdxPropertyKeys . DEFAULT_USERNAME ) ;
310
298
311
299
// We can't check .sf/config.json directly because sfdx doesn't write back to sf
312
300
// Instead we test this by running `config get`
313
301
const getResult = execCmd < ConfigResponses > ( 'config get target-org --json' , {
314
302
ensureExitCode : 0 ,
315
- cli : 'sf' ,
316
303
} ) . jsonOutput . result ;
317
304
const getExpected = [ { name : OrgConfigProperties . TARGET_ORG , success : true } ] ;
318
305
expect ( getResult ) . to . deep . equal ( getExpected ) ;
@@ -321,19 +308,17 @@ describe('Interoperability NUTs', async () => {
321
308
it ( 'should unset target-dev-hub in .sf and defaultdevhubusername in .sfdx' , async ( ) => {
322
309
const setResult = execCmd < ConfigResponses > ( `config set target-dev-hub ${ ORG_ALIAS } --json` , {
323
310
ensureExitCode : 0 ,
324
- cli : 'sf' ,
325
311
} ) . jsonOutput . result ;
326
312
const setExpected = [ { name : OrgConfigProperties . TARGET_DEV_HUB , value : ORG_ALIAS , success : true } ] ;
327
313
expect ( setResult ) . to . deep . equal ( setExpected ) ;
328
314
329
- exec ( 'sfdx config:unset defaultdevhubusername', { silent : true } ) ;
315
+ execCmd ( ' config:unset defaultdevhubusername', { cli : 'sfdx' } ) ;
330
316
await configShouldNotHave ( '.sfdx' , SfdxPropertyKeys . DEFAULT_DEV_HUB_USERNAME ) ;
331
317
332
318
// We can't check .sf/config.json directly because sfdx doesn't write back to sf
333
319
// Instead we test this by running `config get`
334
320
const getResult = execCmd < ConfigResponses > ( 'config get target-dev-hub --json' , {
335
321
ensureExitCode : 0 ,
336
- cli : 'sf' ,
337
322
} ) . jsonOutput . result ;
338
323
const getExpected = [ { name : OrgConfigProperties . TARGET_DEV_HUB , success : true } ] ;
339
324
expect ( getResult ) . to . deep . equal ( getExpected ) ;
0 commit comments