@@ -9,7 +9,7 @@ import fs from 'node:fs';
99import path from 'node:path' ;
1010import { assert , expect } from 'chai' ;
1111import sinon from 'sinon' ;
12- import { TestSession } from '@salesforce/cli-plugins-testkit' ;
12+ import { TestSession , genUniqueString } from '@salesforce/cli-plugins-testkit' ;
1313import { Org , SandboxProcessObject , SandboxRequestCache , SfError , Messages , AuthInfo } from '@salesforce/core' ;
1414import { stubSfCommandUx , stubSpinner , stubUx } from '@salesforce/sf-plugins-core' ;
1515import RefreshSandbox from '../../src/commands/org/refresh/sandbox.js' ;
@@ -30,7 +30,7 @@ import {
3030Messages . importMessagesDirectoryFromMetaUrl ( import . meta. url ) ;
3131const messages = Messages . loadMessages ( '@salesforce/plugin-org' , 'sandboxbase' ) ;
3232
33- describe . skip ( 'Sandbox Refresh' , ( ) => {
33+ describe ( 'Sandbox Refresh' , ( ) => {
3434 let session : TestSession ;
3535 let hubOrgUsername : string ;
3636 let cacheFilePath : string ;
@@ -43,9 +43,11 @@ describe.skip('Sandbox Refresh', () => {
4343 const sandboxProcessSoql = getSandboxProcessSoql ( ) ;
4444
4545 before ( async ( ) => {
46+ const uid = genUniqueString ( 'sbxRefresh_%s' ) ;
4647 session = await TestSession . create ( {
4748 project : { name : 'sandboxRefresh' } ,
48- devhubAuthStrategy : 'AUTO' ,
49+ devhubAuthStrategy : 'AUTH_URL' ,
50+ sessionDir : path . join ( process . cwd ( ) , `test_session_${ uid } ` ) ,
4951 } ) ;
5052 assert ( session . hubOrg . username ) ;
5153 hubOrgUsername = session . hubOrg . username ;
@@ -67,13 +69,13 @@ describe.skip('Sandbox Refresh', () => {
6769 await session ?. clean ( ) ;
6870 } ) ;
6971
70- afterEach ( async ( ) => {
71- sinonSandbox . restore ( ) ;
72+ afterEach ( ( ) => {
7273 try {
73- await deleteSandboxCacheFile ( cacheFilePath ) ;
74+ deleteSandboxCacheFile ( cacheFilePath ) ;
7475 } catch ( err ) {
7576 // ignore since there isn't always a cache file written
7677 }
78+ sinonSandbox . restore ( ) ;
7779 } ) ;
7880
7981 //
@@ -110,7 +112,7 @@ describe.skip('Sandbox Refresh', () => {
110112 expect ( toolingQueryStub . calledOnce ) . to . be . true ;
111113
112114 // check the sandbox cache entry
113- const cache = await readSandboxCacheFile ( cacheFilePath ) ;
115+ const cache = readSandboxCacheFile ( cacheFilePath ) ;
114116 expect ( cache ) . to . have . property ( sbxName ) ;
115117 expect ( cache [ sbxName ] ) . to . have . property ( 'action' , 'Refresh' ) ;
116118 expect ( cache [ sbxName ] ) . to . have . property ( 'prodOrgUsername' , hubOrgUsername ) ;
@@ -154,7 +156,7 @@ describe.skip('Sandbox Refresh', () => {
154156 expect ( toolingQueryStub . calledOnce ) . to . be . true ;
155157
156158 // check the sandbox cache entry
157- const cache = await readSandboxCacheFile ( cacheFilePath ) ;
159+ const cache = readSandboxCacheFile ( cacheFilePath ) ;
158160 expect ( cache ) . to . have . property ( sbxName ) ;
159161 expect ( cache [ sbxName ] ) . to . have . property ( 'action' , 'Refresh' ) ;
160162 expect ( cache [ sbxName ] ) . to . have . property ( 'prodOrgUsername' , hubOrgUsername ) ;
@@ -190,6 +192,7 @@ describe.skip('Sandbox Refresh', () => {
190192
191193 try {
192194 await RefreshSandbox . run ( [ '--name' , sbxName , '-o' , hubOrgUsername , '--async' , '--json' ] ) ;
195+ assert ( false , 'Expected SandboxNotFoundError' ) ;
193196 } catch ( e ) {
194197 assert ( e instanceof SfError , 'Expect error to be an instance of SfError' ) ;
195198 expect ( e . name ) . to . equal ( 'SandboxNotFoundError' ) ;
@@ -238,7 +241,7 @@ describe.skip('Sandbox Refresh', () => {
238241 expect ( toolingQueryStub . calledOnce ) . to . be . true ;
239242
240243 // check the sandbox cache entry
241- const cache = await readSandboxCacheFile ( cacheFilePath ) ;
244+ const cache = readSandboxCacheFile ( cacheFilePath ) ;
242245 expect ( cache ) . to . have . property ( sbxName ) ;
243246 expect ( cache [ sbxName ] ) . to . have . property ( 'action' , 'Refresh' ) ;
244247 expect ( cache [ sbxName ] ) . to . have . property ( 'prodOrgUsername' , hubOrgUsername ) ;
@@ -283,7 +286,7 @@ describe.skip('Sandbox Refresh', () => {
283286 expect ( querySandboxProcessByIdStub . callCount ) . to . be . greaterThan ( 2 ) ;
284287
285288 // check the sandbox cache entry
286- const cache = await readSandboxCacheFile ( cacheFilePath ) ;
289+ const cache = readSandboxCacheFile ( cacheFilePath ) ;
287290 expect ( cache ) . to . have . property ( sbxName ) ;
288291 expect ( cache [ sbxName ] ) . to . have . property ( 'action' , 'Refresh' ) ;
289292 expect ( cache [ sbxName ] ) . to . have . property ( 'prodOrgUsername' , hubOrgUsername ) ;
@@ -299,7 +302,7 @@ describe.skip('Sandbox Refresh', () => {
299302 expect ( sfCommandUxStubs . info . firstCall . args [ 0 ] ) . to . equal ( sbxStatusMsg ) ;
300303 } ) ;
301304
302- it . skip ( 'should poll and report a success and write an auth file' , async ( ) => {
305+ it ( 'should poll and report a success and write an auth file' , async ( ) => {
303306 const sbxInfo = getSandboxInfo ( ) ;
304307 const sbxName = sbxInfo . SandboxName ;
305308 const sbxProcess = getSandboxProcess ( ) ;
@@ -334,7 +337,7 @@ describe.skip('Sandbox Refresh', () => {
334337
335338 // Stub AuthInfo functions so an auth file is written without making http calls
336339 // @ts -expect-error stubbing private function
337- const authInfoCreateStub = sinonSandbox . stub ( AuthInfo . prototype , 'exchangeToken' ) . resolves ( {
340+ const authInfoExchangeTokenStub = sinonSandbox . stub ( AuthInfo . prototype , 'exchangeToken' ) . resolves ( {
338341 username : sbxAuthResponse . authUserName ,
339342 parentUsername : hubOrgUsername ,
340343 instanceUrl : sbxAuthResponse . instanceUrl ,
@@ -366,10 +369,10 @@ describe.skip('Sandbox Refresh', () => {
366369 expect ( toolingQueryStub . calledOnce , 'toolingQueryStub called' ) . to . be . true ;
367370 expect ( querySandboxProcessByIdStub . called , 'querySandboxProcessByIdStub called' ) . to . be . true ;
368371 expect ( sandboxSignupCompleteStub . called , 'sandboxSignupCompleteStub called' ) . to . be . true ;
369- expect ( authInfoCreateStub . called , 'authInfoCreateStub called' ) . to . be . true ;
372+ expect ( authInfoExchangeTokenStub . called , 'authInfoExchangeTokenStub called' ) . to . be . true ;
370373
371374 // Check auth files exist
372- const authFileContents = await readAuthFile ( session . homeDir , sbxAuthResponse . authUserName ) ;
375+ const authFileContents = readAuthFile ( session . homeDir , sbxAuthResponse . authUserName ) ;
373376 expect ( authFileContents ) . to . be . ok ;
374377 expect ( authFileContents ) . to . have . property ( 'username' , sbxAuthResponse . authUserName ) ;
375378 expect ( authFileContents ) . to . have . property ( 'parentUsername' , hubOrgUsername ) ;
@@ -379,7 +382,7 @@ describe.skip('Sandbox Refresh', () => {
379382
380383 // check sandbox auth file doesn't exist
381384 try {
382- await readSandboxCacheFile ( cacheFilePath ) ;
385+ readSandboxCacheFile ( cacheFilePath ) ;
383386 assert ( false , 'should not have found a sandbox cache file' ) ;
384387 } catch ( err ) {
385388 // ignore
0 commit comments