@@ -505,6 +505,52 @@ describe('WorkspaceTravelInvoicingSection', () => {
505505 } ) ;
506506 } ) ;
507507
508+ describe ( 'Lock icon (outstanding balance)' , ( ) => {
509+ const cardSettingsKey = getTravelInvoicingCardSettingsKey ( WORKSPACE_ACCOUNT_ID ) ;
510+
511+ it ( 'shows the toggle lock icon when there is an outstanding travel balance' , async ( ) => {
512+ // Given a configured workspace with an unpaid travel balance
513+ await act ( async ( ) => {
514+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ POLICY_ID } ` , mockPolicy ) ;
515+ await Onyx . merge ( cardSettingsKey , {
516+ TRAVEL_US : {
517+ isEnabled : true ,
518+ paymentBankAccountID : 12345 ,
519+ currentBalance : 5000 ,
520+ } ,
521+ } ) ;
522+ await waitForBatchedUpdatesWithAct ( ) ;
523+ } ) ;
524+
525+ renderWorkspaceTravelInvoicingSection ( ) ;
526+ await waitForBatchedUpdatesWithAct ( ) ;
527+
528+ // The lock stays on the toggle since the feature can't be turned off until the balance is paid
529+ expect ( screen . getByTestId ( CONST . SWITCH_LOCK_ICON_TEST_ID , { includeHiddenElements : true } ) ) . toBeTruthy ( ) ;
530+ } ) ;
531+
532+ it ( 'does not show the toggle lock icon when the balance is paid' , async ( ) => {
533+ // Given a configured workspace with no outstanding balance and no pending settlement
534+ await act ( async ( ) => {
535+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ POLICY_ID } ` , mockPolicy ) ;
536+ await Onyx . merge ( cardSettingsKey , {
537+ TRAVEL_US : {
538+ isEnabled : true ,
539+ paymentBankAccountID : 12345 ,
540+ currentBalance : 0 ,
541+ pendingSettlementAmount : 0 ,
542+ } ,
543+ } ) ;
544+ await waitForBatchedUpdatesWithAct ( ) ;
545+ } ) ;
546+
547+ renderWorkspaceTravelInvoicingSection ( ) ;
548+ await waitForBatchedUpdatesWithAct ( ) ;
549+
550+ expect ( screen . queryByTestId ( CONST . SWITCH_LOCK_ICON_TEST_ID , { includeHiddenElements : true } ) ) . toBeNull ( ) ;
551+ } ) ;
552+ } ) ;
553+
508554 describe ( 'Currency Conversion Prompt' , ( ) => {
509555 const cardSettingsKey = getTravelInvoicingCardSettingsKey ( WORKSPACE_ACCOUNT_ID ) ;
510556
0 commit comments