88import * as path from 'path' ;
99import * as fs from 'fs' ;
1010import { TestSession , execCmd } from '@salesforce/cli-plugins-testkit' ;
11- import { expect , config } from 'chai' ;
11+ import { expect , config , assert } from 'chai' ;
1212import { AuthFields } from '@salesforce/core' ;
1313import { ComponentSetBuilder } from '@salesforce/source-deploy-retrieve' ;
1414import { OrgOpenOutput } from '../../lib/commands/org/open' ;
@@ -30,9 +30,7 @@ describe('test org:open command', () => {
3030 devhubAuthStrategy : 'AUTO' ,
3131 scratchOrgs : [
3232 {
33- executable : 'sfdx' ,
3433 alias : 'default' ,
35- duration : 1 ,
3634 setDefault : true ,
3735 config : path . join ( 'config' , 'project-scratch-def.json' ) ,
3836 } ,
@@ -45,14 +43,12 @@ describe('test org:open command', () => {
4543 } ) ;
4644
4745 it ( 'should produce the default URL for a flexipage resource when it not in org in json' , ( ) => {
48- const result = (
49- execCmd < OrgOpenOutput > ( `force:source:open -f ${ flexiPagePath } --urlonly --json` , {
50- ensureExitCode : 0 ,
51- } ) . jsonOutput as { result : OrgOpenOutput }
52- ) . result ;
53- expect ( result ) . to . be . ok ;
46+ const result = execCmd < OrgOpenOutput > ( `force:source:open -f ${ flexiPagePath } --urlonly --json` , {
47+ ensureExitCode : 0 ,
48+ } ) . jsonOutput ?. result ;
49+ assert ( result ) ;
5450 expect ( result ) . to . include ( { orgId : defaultUserOrgId , username : defaultUsername } ) ;
55- expect ( result ) . to . property ( ' url' ) . to . include ( 'lightning/setup/FlexiPageList/home' ) ;
51+ expect ( result . url ) . to . include ( 'lightning/setup/FlexiPageList/home' ) ;
5652 } ) ;
5753
5854 it ( 'should produce the URL for a flexipage resource in json' , async ( ) => {
@@ -61,14 +57,12 @@ describe('test org:open command', () => {
6157 const deploy = await cs . deploy ( { usernameOrConnection : defaultUsername } ) ;
6258 const deployResult = await deploy . pollStatus ( 1000 , 60000 ) ;
6359 expect ( deployResult . getFileResponses ( ) . length ) . to . not . equal ( 0 ) ;
64- const result = (
65- execCmd < OrgOpenOutput > ( `force:source:open --sourcefile ${ flexiPagePath } --urlonly --json` , {
66- ensureExitCode : 0 ,
67- } ) . jsonOutput as { result : OrgOpenOutput }
68- ) . result ;
69- expect ( result ) . to . be . ok ;
60+ const result = execCmd < OrgOpenOutput > ( `force:source:open --sourcefile ${ flexiPagePath } --urlonly --json` , {
61+ ensureExitCode : 0 ,
62+ } ) . jsonOutput ?. result ;
63+ assert ( result ) ;
7064 expect ( result ) . to . include ( { orgId : defaultUserOrgId , username : defaultUsername } ) ;
71- expect ( result ) . to . property ( ' url' ) . to . include ( '/visualEditor/appBuilder.app?pageId' ) ;
65+ expect ( result . url ) . to . include ( '/visualEditor/appBuilder.app?pageId' ) ;
7266 } ) ;
7367
7468 it ( "should produce the org's frontdoor url when edition of file is not supported" , async ( ) => {
@@ -78,21 +72,19 @@ describe('test org:open command', () => {
7872 path . join ( session . project . dir , layoutFilePath ) ,
7973 '<layout xmlns="http://soap.sforce.com/2006/04/metadata">\n</layout>'
8074 ) ;
81- const result = (
82- execCmd < OrgOpenOutput > ( `force:source:open --source-file ${ layoutFilePath } --urlonly --json` , {
83- ensureExitCode : 0 ,
84- } ) . jsonOutput as { result : OrgOpenOutput }
85- ) . result ;
86- expect ( result ) . to . be . ok ;
75+ const result = execCmd < OrgOpenOutput > ( `force:source:open --source-file ${ layoutFilePath } --urlonly --json` , {
76+ ensureExitCode : 0 ,
77+ } ) . jsonOutput ?. result ;
78+ assert ( result ) ;
8779 expect ( result ) . to . include ( { orgId : defaultUserOrgId , username : defaultUsername } ) ;
88- expect ( result ) . to . property ( ' url' ) . to . include ( 'secur/frontdoor.jsp' ) ;
80+ expect ( result . url ) . to . include ( 'secur/frontdoor.jsp' ) ;
8981 } ) ;
9082
9183 it ( 'org:open command' , ( ) => {
9284 const result = execCmd < OrgOpenOutput > ( 'force:org:open --urlonly --json' , {
9385 ensureExitCode : 0 ,
9486 } ) . jsonOutput ?. result ;
95- expect ( result ) . to . be . ok ;
87+ assert ( result ) ;
9688 expect ( result ) . to . have . keys ( [ 'url' , 'orgId' , 'username' ] ) ;
9789 expect ( result ?. url ) . to . include ( '/secur/frontdoor.jsp' ) ;
9890 } ) ;
0 commit comments