@@ -21,45 +21,10 @@ import sinon from 'sinon';
2121import { SfCommand } from '@salesforce/sf-plugins-core' ;
2222import { PackageBundlesInstall } from '../../../src/commands/package/bundle/install.js' ;
2323
24- const pkgBundleInstallErrorResult : BundleSObjects . PkgBundleVersionInstallReqResult = {
25- Id : '08c3i000000fylXXXX' ,
26- InstallStatus : BundleSObjects . PkgBundleVersionInstallReqStatus . error ,
27- PackageBundleVersionId : '1Q83i000000fxw1AAA' ,
28- DevelopmentOrganization : '00D3i000000TNHXXXX' ,
29- ValidationError : 'Installation failed due to validation errors' ,
30- CreatedDate : '2022-11-03 09:21' ,
31- CreatedById : '0053i000001ZIyXXXX' ,
32- Error : [
33- 'PropertyController: Invalid type: Schema.Property__c' ,
34- 'SampleDataController: Invalid type: Schema.Property__c' ,
35- ] ,
36- } ;
37-
38- const pkgBundleInstallSuccessResult : BundleSObjects . PkgBundleVersionInstallReqResult = {
39- Id : '08c3i000000fylgAAA' ,
40- InstallStatus : BundleSObjects . PkgBundleVersionInstallReqStatus . success ,
41- PackageBundleVersionId : '1Q83i000000fxw1AAA' ,
42- DevelopmentOrganization : '00D3i000000TNHYCA4' ,
43- ValidationError : '' ,
44- CreatedDate : '2022-11-03 09:46' ,
45- CreatedById : '0053i000001ZIyGAAW' ,
46- Error : [ ] ,
47- } ;
48-
49- const pkgBundleInstallQueuedResult : BundleSObjects . PkgBundleVersionInstallReqResult = {
50- Id : '08c3i000000fylgBBB' ,
51- InstallStatus : BundleSObjects . PkgBundleVersionInstallReqStatus . queued ,
52- PackageBundleVersionId : '1Q83i000000fxw1AAA' ,
53- DevelopmentOrganization : '00D3i000000TNHYCA4' ,
54- ValidationError : '' ,
55- CreatedDate : '2022-11-03 10:00' ,
56- CreatedById : '0053i000001ZIyGAAW' ,
57- Error : [ ] ,
58- } ;
59-
6024describe ( 'package:bundle:install - tests' , ( ) => {
6125 const $$ = new TestContext ( ) ;
6226 const testOrg = new MockTestOrgData ( ) ;
27+ const devHubOrg = new MockTestOrgData ( ) ;
6328 let installStub = $$ . SANDBOX . stub ( PackageBundleInstall , 'installBundle' ) ;
6429 const config = new Config ( { root : import . meta. url } ) ;
6530
@@ -74,7 +39,7 @@ describe('package:bundle:install - tests', () => {
7439 } ;
7540
7641 before ( async ( ) => {
77- await $$ . stubAuths ( testOrg ) ;
42+ await $$ . stubAuths ( testOrg , devHubOrg ) ;
7843 await config . load ( ) ;
7944 } ) ;
8045
@@ -89,122 +54,134 @@ describe('package:bundle:install - tests', () => {
8954
9055 describe ( 'package:bundle:install' , ( ) => {
9156 it ( 'should install a package bundle version successfully' , async ( ) => {
57+ const pkgBundleInstallSuccessResult : BundleSObjects . PkgBundleVersionInstallReqResult = {
58+ Id : '08c3i000000fylgAAA' ,
59+ InstallStatus : BundleSObjects . PkgBundleVersionInstallReqStatus . success ,
60+ PackageBundleVersionId : '1Q83i000000fxw1AAA' ,
61+ DevelopmentOrganization : devHubOrg . orgId ,
62+ ValidationError : '' ,
63+ CreatedDate : '2022-11-03 09:46' ,
64+ CreatedById : '0053i000001ZIyGAAW' ,
65+ Error : [ ] ,
66+ } ;
9267 installStub . resolves ( pkgBundleInstallSuccessResult ) ;
9368
9469 const cmd = new PackageBundlesInstall (
95- [ '-b' , 'TestBundle@1.0' , '--target-org' , 'test@org.org' , '--dev-hub-org' , '00D3i000000TNHYCA4' ] ,
70+ [ '-b' , 'TestBundle@1.0' , '--target-org' , testOrg . username , '--dev-hub-org' , devHubOrg . username ] ,
9671 config
9772 ) ;
9873 stubSpinner ( cmd ) ;
9974 const res = await cmd . run ( ) ;
100- expect ( res ) . to . deep . equal ( {
101- Id : '08c3i000000fylgAAA' ,
102- InstallStatus : 'Success' ,
103- PackageBundleVersionId : '1Q83i000000fxw1AAA' ,
104- DevelopmentOrganization : '00D3i000000TNHYCA4' ,
105- ValidationError : '' ,
106- CreatedDate : '2022-11-03 09:46' ,
107- CreatedById : '0053i000001ZIyGAAW' ,
108- Error : [ ] ,
109- } ) ;
75+ expect ( res ) . to . deep . equal ( pkgBundleInstallSuccessResult ) ;
11076 expect ( warnStub . callCount ) . to . equal ( 0 ) ;
11177 expect ( logStub . callCount ) . to . equal ( 1 ) ;
112- expect ( logStub . args [ 0 ] ) . to . deep . equal ( [
113- 'Successfully installed bundle version 1Q83i000000fxw1AAA to test@org.org' ,
114- ] ) ;
78+ expect ( logStub . args [ 0 ] [ 0 ] ) . to . include ( 'Successfully installed bundle version 1Q83i000000fxw1AAA' ) ;
11579 } ) ;
11680
11781 it ( 'should install a package bundle version with wait option' , async ( ) => {
11882 installStub = $$ . SANDBOX . stub ( PackageBundleInstall , 'installBundle' ) ;
83+ const pkgBundleInstallSuccessResult : BundleSObjects . PkgBundleVersionInstallReqResult = {
84+ Id : '08c3i000000fylgAAA' ,
85+ InstallStatus : BundleSObjects . PkgBundleVersionInstallReqStatus . success ,
86+ PackageBundleVersionId : '1Q83i000000fxw1AAA' ,
87+ DevelopmentOrganization : devHubOrg . orgId ,
88+ ValidationError : '' ,
89+ CreatedDate : '2022-11-03 09:46' ,
90+ CreatedById : '0053i000001ZIyGAAW' ,
91+ Error : [ ] ,
92+ } ;
11993 installStub . resolves ( pkgBundleInstallSuccessResult ) ;
12094
12195 const cmd = new PackageBundlesInstall (
122- [ '-b' , 'TestBundle@1.0' , '--target-org' , 'test@org.org' , '--dev-hub-org' , '00D3i000000TNHYCA4' , '-w' , '10' ] ,
96+ [ '-b' , 'TestBundle@1.0' , '--target-org' , testOrg . username , '--dev-hub-org' , devHubOrg . username , '-w' , '10' ] ,
12397 config
12498 ) ;
12599 stubSpinner ( cmd ) ;
126100 const res = await cmd . run ( ) ;
127- expect ( res ) . to . deep . equal ( {
128- Id : '08c3i000000fylgAAA' ,
129- InstallStatus : 'Success' ,
130- PackageBundleVersionId : '1Q83i000000fxw1AAA' ,
131- DevelopmentOrganization : '00D3i000000TNHYCA4' ,
132- ValidationError : '' ,
133- CreatedDate : '2022-11-03 09:46' ,
134- CreatedById : '0053i000001ZIyGAAW' ,
135- Error : [ ] ,
136- } ) ;
101+ expect ( res ) . to . deep . equal ( pkgBundleInstallSuccessResult ) ;
137102 expect ( warnStub . callCount ) . to . equal ( 0 ) ;
138103 expect ( logStub . callCount ) . to . equal ( 1 ) ;
139- expect ( logStub . args [ 0 ] ) . to . deep . equal ( [
140- 'Successfully installed bundle version 1Q83i000000fxw1AAA to test@org.org' ,
141- ] ) ;
104+ expect ( logStub . args [ 0 ] [ 0 ] ) . to . include ( 'Successfully installed bundle version 1Q83i000000fxw1AAA' ) ;
142105 } ) ;
143106
144107 // This test does very little to test the verbose command except make sure that it is there.
145108 it ( 'should install a package bundle version with verbose option' , async ( ) => {
146109 installStub = $$ . SANDBOX . stub ( PackageBundleInstall , 'installBundle' ) ;
110+ const pkgBundleInstallSuccessResult : BundleSObjects . PkgBundleVersionInstallReqResult = {
111+ Id : '08c3i000000fylgAAA' ,
112+ InstallStatus : BundleSObjects . PkgBundleVersionInstallReqStatus . success ,
113+ PackageBundleVersionId : '1Q83i000000fxw1AAA' ,
114+ DevelopmentOrganization : devHubOrg . orgId ,
115+ ValidationError : '' ,
116+ CreatedDate : '2022-11-03 09:46' ,
117+ CreatedById : '0053i000001ZIyGAAW' ,
118+ Error : [ ] ,
119+ } ;
147120 installStub . resolves ( pkgBundleInstallSuccessResult ) ;
148121
149122 const cmd = new PackageBundlesInstall (
150- [ '-b' , 'TestBundle@1.0' , '--target-org' , 'test@org.org' , '--dev-hub-org' , '00D3i000000TNHYCA4' , '--verbose' ] ,
123+ [ '-b' , 'TestBundle@1.0' , '--target-org' , testOrg . username , '--dev-hub-org' , devHubOrg . username , '--verbose' ] ,
151124 config
152125 ) ;
153126 stubSpinner ( cmd ) ;
154127 const res = await cmd . run ( ) ;
155- expect ( res ) . to . deep . equal ( {
156- Id : '08c3i000000fylgAAA' ,
157- InstallStatus : 'Success' ,
158- PackageBundleVersionId : '1Q83i000000fxw1AAA' ,
159- DevelopmentOrganization : '00D3i000000TNHYCA4' ,
160- ValidationError : '' ,
161- CreatedDate : '2022-11-03 09:46' ,
162- CreatedById : '0053i000001ZIyGAAW' ,
163- Error : [ ] ,
164- } ) ;
128+ expect ( res ) . to . deep . equal ( pkgBundleInstallSuccessResult ) ;
165129 expect ( warnStub . callCount ) . to . equal ( 0 ) ;
166130 expect ( logStub . callCount ) . to . equal ( 1 ) ;
167- expect ( logStub . args [ 0 ] ) . to . deep . equal ( [
168- 'Successfully installed bundle version 1Q83i000000fxw1AAA to test@org.org' ,
169- ] ) ;
131+ expect ( logStub . args [ 0 ] [ 0 ] ) . to . include ( 'Successfully installed bundle version 1Q83i000000fxw1AAA' ) ;
170132 } ) ;
171133
172134 it ( 'should handle queued status' , async ( ) => {
173135 installStub = $$ . SANDBOX . stub ( PackageBundleInstall , 'installBundle' ) ;
136+ const pkgBundleInstallQueuedResult : BundleSObjects . PkgBundleVersionInstallReqResult = {
137+ Id : '08c3i000000fylgBBB' ,
138+ InstallStatus : BundleSObjects . PkgBundleVersionInstallReqStatus . queued ,
139+ PackageBundleVersionId : '1Q83i000000fxw1AAA' ,
140+ DevelopmentOrganization : devHubOrg . orgId ,
141+ ValidationError : '' ,
142+ CreatedDate : '2022-11-03 10:00' ,
143+ CreatedById : '0053i000001ZIyGAAW' ,
144+ Error : [ ] ,
145+ } ;
174146 installStub . resolves ( pkgBundleInstallQueuedResult ) ;
175147
176148 const cmd = new PackageBundlesInstall (
177- [ '-b' , 'TestBundle@1.0' , '--target-org' , 'test@org.org' , '--dev-hub-org' , '00D3i000000TNHYCA4' ] ,
149+ [ '-b' , 'TestBundle@1.0' , '--target-org' , testOrg . username , '--dev-hub-org' , devHubOrg . username ] ,
178150 config
179151 ) ;
180152 stubSpinner ( cmd ) ;
181153 const res = await cmd . run ( ) ;
182- expect ( res ) . to . deep . equal ( {
183- Id : '08c3i000000fylgBBB' ,
184- InstallStatus : 'Queued' ,
185- PackageBundleVersionId : '1Q83i000000fxw1AAA' ,
186- DevelopmentOrganization : '00D3i000000TNHYCA4' ,
187- ValidationError : '' ,
188- CreatedDate : '2022-11-03 10:00' ,
189- CreatedById : '0053i000001ZIyGAAW' ,
190- Error : [ ] ,
191- } ) ;
154+ expect ( res ) . to . deep . equal ( pkgBundleInstallQueuedResult ) ;
192155 expect ( warnStub . callCount ) . to . equal ( 0 ) ;
193156 expect ( logStub . callCount ) . to . equal ( 1 ) ;
194157 // Normalize CRLF to LF to make assertion OS-agnostic
195158 const queuedMsg = String ( logStub . args [ 0 ] [ 0 ] ) . replace ( / \r \n / g, '\n' ) ;
196159 expect ( queuedMsg ) . to . equal (
197- 'Bundle installation is currently Queued. You can continue to query the status using\nsf package bundle install report -i 08c3i000000fylgBBB -o test@org.org'
160+ 'Bundle installation is currently Queued. You can continue to query the status using\nsf package bundle install report -i 08c3i000000fylgBBB -o ' +
161+ testOrg . username
198162 ) ;
199163 } ) ;
200164
201165 it ( 'should handle error status' , async ( ) => {
202166 installStub = $$ . SANDBOX . stub ( PackageBundleInstall , 'installBundle' ) ;
167+ const pkgBundleInstallErrorResult : BundleSObjects . PkgBundleVersionInstallReqResult = {
168+ Id : '08c3i000000fylXXXX' ,
169+ InstallStatus : BundleSObjects . PkgBundleVersionInstallReqStatus . error ,
170+ PackageBundleVersionId : '1Q83i000000fxw1AAA' ,
171+ DevelopmentOrganization : devHubOrg . orgId ,
172+ ValidationError : 'Installation failed due to validation errors' ,
173+ CreatedDate : '2022-11-03 09:21' ,
174+ CreatedById : '0053i000001ZIyXXXX' ,
175+ Error : [
176+ 'PropertyController: Invalid type: Schema.Property__c' ,
177+ 'SampleDataController: Invalid type: Schema.Property__c' ,
178+ ] ,
179+ } ;
203180 installStub . resolves ( pkgBundleInstallErrorResult ) ;
204181
205182 try {
206183 const cmd = new PackageBundlesInstall (
207- [ '-b' , 'TestBundle@1.0' , '--target-org' , 'test@org.org' , '--dev-hub-org' , '00D3i000000TNHYCA4' ] ,
184+ [ '-b' , 'TestBundle@1.0' , '--target-org' , testOrg . username , '--dev-hub-org' , devHubOrg . username ] ,
208185 config
209186 ) ;
210187 stubSpinner ( cmd ) ;
@@ -218,21 +195,35 @@ describe('package:bundle:install - tests', () => {
218195 } ) ;
219196
220197 it ( 'should handle error status with unknown error' , async ( ) => {
221- const errorResult = { ...pkgBundleInstallErrorResult , ValidationError : '' } ;
222198 installStub = $$ . SANDBOX . stub ( PackageBundleInstall , 'installBundle' ) ;
199+ const errorResult : BundleSObjects . PkgBundleVersionInstallReqResult = {
200+ Id : '08c3i000000fylXXXX' ,
201+ InstallStatus : BundleSObjects . PkgBundleVersionInstallReqStatus . error ,
202+ PackageBundleVersionId : '1Q83i000000fxw1AAA' ,
203+ DevelopmentOrganization : devHubOrg . orgId ,
204+ ValidationError : '' ,
205+ CreatedDate : '2022-11-03 09:21' ,
206+ CreatedById : '0053i000001ZIyXXXX' ,
207+ Error : [
208+ 'PropertyController: Invalid type: Schema.Property__c' ,
209+ 'SampleDataController: Invalid type: Schema.Property__c' ,
210+ ] ,
211+ } ;
223212 installStub . resolves ( errorResult ) ;
224213
225214 try {
226215 const cmd = new PackageBundlesInstall (
227- [ '-b' , 'TestBundle@1.0' , '--target-org' , 'test@org.org' , '--dev-hub-org' , '00D3i000000TNHYCA4' ] ,
216+ [ '-b' , 'TestBundle@1.0' , '--target-org' , testOrg . username , '--dev-hub-org' , devHubOrg . username ] ,
228217 config
229218 ) ;
230219 stubSpinner ( cmd ) ;
231220 await cmd . run ( ) ;
232221 assert . fail ( 'the above should throw an error' ) ;
233222 } catch ( e ) {
234223 expect ( ( e as Error ) . message ) . to . equal (
235- "Encountered errors installing the bundle! Bundle installation failed. Run 'sf package bundle install report -i 08c3i000000fylXXXX -o test@org.org' for more details."
224+ "Encountered errors installing the bundle! Bundle installation failed. Run 'sf package bundle install report -i 08c3i000000fylXXXX -o " +
225+ testOrg . username +
226+ "' for more details."
236227 ) ;
237228 }
238229 } ) ;
0 commit comments