@@ -23,7 +23,7 @@ import { StubbedType, stubInterface, stubMethod } from '@salesforce/ts-sinon';
2323import { assert , expect } from 'chai' ;
2424import { Env } from '@salesforce/kit' ;
2525import { SfCommand , Ux } from '@salesforce/sf-plugins-core' ;
26- import LoginWeb from '../../../../src/commands/org/login/web.js' ;
26+ import LoginWeb , { ExecuteLoginFlowParams } from '../../../../src/commands/org/login/web.js' ;
2727
2828describe ( 'org:login:web' , ( ) => {
2929 const $$ = new TestContext ( ) ;
@@ -195,8 +195,8 @@ describe('org:login:web', () => {
195195
196196 // Verify that executeLoginFlow was called with the scopes parameter
197197 expect ( executeLoginFlowStub . callCount ) . to . equal ( 1 ) ;
198- const callArgs = executeLoginFlowStub . getCall ( 0 ) . args ;
199- expect ( callArgs [ 2 ] ) . to . equal ( 'api web refresh_token' ) ; // scopes should be the 3rd argument
198+ const callArgs = executeLoginFlowStub . getCall ( 0 ) . args [ 0 ] as ExecuteLoginFlowParams ;
199+ expect ( callArgs . scopes ) . to . equal ( 'api web refresh_token' ) ; // scopes should be present in the object
200200 } ) ;
201201
202202 it ( 'should pass undefined scopes to executeLoginFlow when scopes flag is not provided' , async ( ) => {
@@ -223,8 +223,8 @@ describe('org:login:web', () => {
223223
224224 // Verify that executeLoginFlow was called without scopes (undefined)
225225 expect ( executeLoginFlowStub . callCount ) . to . equal ( 1 ) ;
226- const callArgs = executeLoginFlowStub . getCall ( 0 ) . args ;
227- expect ( callArgs [ 2 ] ) . to . be . undefined ; // scopes should be undefined when not provided
226+ const callArgs = executeLoginFlowStub . getCall ( 0 ) . args [ 0 ] as ExecuteLoginFlowParams ;
227+ expect ( callArgs . scopes ) . to . be . undefined ;
228228 } ) ;
229229
230230 it ( 'should pass scopes flag to executeLoginFlow when linking client-app with scopes' , async ( ) => {
@@ -242,8 +242,11 @@ describe('org:login:web', () => {
242242 $$ . SANDBOX . stub ( AuthInfo , 'create' ) . resolves ( authInfoStub ) ;
243243 $$ . SANDBOX . stub ( AuthInfo , 'listAllAuthorizations' ) . resolves ( [ ] ) ;
244244
245- // @ts -ignore
246- const login = new LoginWeb ( [ '--client-app' , 'MyApp' , '--username' , 'test@example.com' , '--scopes' , 'api web' ] , config ) ;
245+ const login = new LoginWeb (
246+ [ '--client-app' , 'MyApp' , '--username' , 'test@example.com' , '--scopes' , 'api web' ] ,
247+ // @ts -ignore
248+ config
249+ ) ;
247250 // @ts -ignore because protected member
248251 login . ux = uxStub ;
249252 // @ts -ignore because protected member
@@ -258,10 +261,10 @@ describe('org:login:web', () => {
258261
259262 // Verify that executeLoginFlow was called with the correct parameters
260263 expect ( executeLoginFlowStub . callCount ) . to . equal ( 1 ) ;
261- const callArgs = executeLoginFlowStub . getCall ( 0 ) . args ;
262- expect ( callArgs [ 2 ] ) . to . equal ( 'MyApp' ) ; // client-app should be the 3rd argument
263- expect ( callArgs [ 3 ] ) . to . equal ( 'test@example.com' ) ; // username should be the 4th argument
264- expect ( callArgs [ 4 ] ) . to . equal ( 'api web' ) ; // scopes should be the 5th argument
264+ const callArgs = executeLoginFlowStub . getCall ( 0 ) . args [ 0 ] as ExecuteLoginFlowParams ;
265+ expect ( callArgs . clientApp ?. name ) . to . equal ( 'MyApp' ) ;
266+ expect ( callArgs . clientApp ?. username ) . to . equal ( 'test@example.com' ) ;
267+ expect ( callArgs . scopes ) . to . equal ( 'api web' ) ;
265268 } ) ;
266269
267270 it ( 'should pass undefined scopes to executeLoginFlow when linking client-app without scopes' , async ( ) => {
@@ -294,9 +297,9 @@ describe('org:login:web', () => {
294297
295298 // Verify that executeLoginFlow was called with the correct parameters
296299 expect ( executeLoginFlowStub . callCount ) . to . equal ( 1 ) ;
297- const callArgs = executeLoginFlowStub . getCall ( 0 ) . args ;
298- expect ( callArgs [ 2 ] ) . to . equal ( 'MyApp' ) ; // client-app should be the 3rd argument
299- expect ( callArgs [ 3 ] ) . to . equal ( 'test@example.com' ) ; // username should be the 4th argument
300- expect ( callArgs [ 4 ] ) . to . be . undefined ; // scopes should be undefined when not provided
300+ const callArgs = executeLoginFlowStub . getCall ( 0 ) . args [ 0 ] as ExecuteLoginFlowParams ;
301+ expect ( callArgs . clientApp ?. name ) . to . equal ( 'MyApp' ) ;
302+ expect ( callArgs . clientApp ?. username ) . to . equal ( 'test@example.com' ) ;
303+ expect ( callArgs . scopes ) . to . be . undefined ;
301304 } ) ;
302305} ) ;
0 commit comments