@@ -110,6 +110,7 @@ describe('org:display', () => {
110110111111 SignupUsername :
'[email protected] ' , 112112 devHubOrgId : testHub . orgId ,
113+ LoginUrl : testHub . instanceUrl ,
113114 } ,
114115 {
115116 CreatedDate : '2024-06-16T05:52:42.000+0000' ,
@@ -124,6 +125,7 @@ describe('org:display', () => {
124125 Username : testOrg . username ,
125126 SignupUsername : testOrg . username ,
126127 devHubOrgId : testHub . orgId ,
128+ LoginUrl : testHub . instanceUrl ,
127129 } ,
128130 ] ) ;
129131 const result = await OrgDisplayCommand . run ( [ '--targetusername' , testOrg . username ] ) ;
@@ -132,6 +134,40 @@ describe('org:display', () => {
132134 expect ( result . orgName ) . to . equal ( 'Dreamhouse' ) ;
133135 } ) ;
134136
137+ it ( 'gets the correct org when username is not the scratch org username and instanceUrl matches' , async ( ) => {
138+ const testHub = new MockTestOrgData ( ) ;
139+ const scratchOrgAdminUser = '[email protected] ' ; 140+ testOrg . devHubUsername = testHub . username ;
141+ testOrg . isScratchOrg = true ;
142+
143+ await $$ . stubAuths ( testOrg , testHub ) ;
144+
145+ $$ . SANDBOX . stub ( OrgListUtil , 'retrieveScratchOrgInfoFromDevHub' ) . resolves ( [
146+ {
147+ CreatedDate : '2024-06-15T05:52:42.000+0000' ,
148+ Edition : 'Developer' ,
149+ Status : 'Active' ,
150+ ExpirationDate : '2024-06-16' ,
151+ Namespace : 'null' ,
152+ OrgName : 'ACME' ,
153+ CreatedBy : {
154+ 155+ } ,
156+ Username : scratchOrgAdminUser ,
157+ SignupUsername : scratchOrgAdminUser , // This won't match but the LoginUrl/instanceUrl will
158+ devHubOrgId : testHub . orgId ,
159+ LoginUrl : testOrg . instanceUrl ,
160+ } ,
161+ ] ) ;
162+ const result = await OrgDisplayCommand . run ( [ '--targetusername' , testOrg . username ] ) ;
163+ expect ( commonAssert ( result ) ) ;
164+ // check specifically `orgName` because it's one of the fields that comes from the payload instead of the auth file
165+ expect ( result . orgName ) . to . equal ( 'ACME' ) ;
166+ expect ( result . username ) . to . equal ( testOrg . username ) ;
167+ expect ( result . signupUsername ) . to . equal ( scratchOrgAdminUser ) ;
168+ expect ( result . instanceUrl ) . to . equal ( testOrg . instanceUrl ) ;
169+ } ) ;
170+
135171 it ( 'gets an org from local auth files by alias' , async ( ) => {
136172 await $$ . stubAuths ( testOrg ) ;
137173 $$ . stubAliases ( { nonscratchalias : testOrg . username } ) ;
@@ -201,6 +237,7 @@ describe('org:display', () => {
201237 OrgName : 'MyOrg' ,
202238 CreatedDate : '2020-12-24T15:18:55.000+0000' ,
203239 SignupUsername : testOrg . username ,
240+ LoginUrl : testOrg . instanceUrl ,
204241 } ,
205242 ] ) ,
206243 } ) ;
@@ -210,9 +247,9 @@ describe('org:display', () => {
210247 expect ( result . status ) . to . equal ( 'Active' ) ;
211248 } ) ;
212249
213- // it('gets non-scratch org connectedStatus');
214- // it('handles properly when username is an accessToken?');
215- // it('displays good error when org is not connectable due to DNS');
216- // it('displays scratch-org-only properties for scratch orgs');
217- // it('displays no scratch-org-only properties for non-scratch orgs');
250+ it ( 'gets non-scratch org connectedStatus' ) ;
251+ it ( 'handles properly when username is an accessToken?' ) ;
252+ it ( 'displays good error when org is not connectable due to DNS' ) ;
253+ it ( 'displays scratch-org-only properties for scratch orgs' ) ;
254+ it ( 'displays no scratch-org-only properties for non-scratch orgs' ) ;
218255} ) ;
0 commit comments