@@ -68,6 +68,7 @@ describe('actions/Report', () => {
68
68
beforeEach ( ( ) => {
69
69
HttpUtils . xhr = originalXHR ;
70
70
const promise = Onyx . clear ( ) . then ( jest . useRealTimers ) ;
71
+
71
72
if ( getIsUsingFakeTimers ( ) ) {
72
73
// flushing pending timers
73
74
// Onyx.clear() promise is resolved in batch which happens after the current microtasks cycle
@@ -1606,4 +1607,45 @@ describe('actions/Report', () => {
1606
1607
expect ( derivedConciergeChatReportID ) . toBe ( conciergeChatReport2 . reportID ) ;
1607
1608
} ) ;
1608
1609
} ) ;
1610
+
1611
+ describe ( 'completeOnboarding' , ( ) => {
1612
+ const TEST_USER_LOGIN = '[email protected] ' ;
1613
+ const TEST_USER_ACCOUNT_ID = 1 ;
1614
+ global . fetch = TestHelper . getGlobalFetchMock ( ) ;
1615
+
1616
+ it ( 'should set "isOptimisticAction" to false/null for all actions in admins report after completing onboarding setup' , async ( ) => {
1617
+ await Onyx . set ( ONYXKEYS . SESSION , { email : TEST_USER_LOGIN , accountID : TEST_USER_ACCOUNT_ID } ) ;
1618
+ await waitForBatchedUpdates ( ) ;
1619
+
1620
+ const adminsChatReportID = '7957055873634067' ;
1621
+ const onboardingPolicyID = 'A70D00C752416807' ;
1622
+ const engagementChoice = CONST . INTRO_CHOICES . MANAGE_TEAM ;
1623
+
1624
+ Report . completeOnboarding ( {
1625
+ engagementChoice,
1626
+ onboardingMessage : CONST . ONBOARDING_MESSAGES [ engagementChoice ] ,
1627
+ adminsChatReportID,
1628
+ onboardingPolicyID,
1629
+ companySize : CONST . ONBOARDING_COMPANY_SIZE . MICRO ,
1630
+ userReportedIntegration : null ,
1631
+ } ) ;
1632
+
1633
+ await waitForBatchedUpdates ( ) ;
1634
+
1635
+ const reportActions : OnyxEntry < OnyxTypes . ReportActions > = await new Promise ( ( resolve ) => {
1636
+ const connection = Onyx . connect ( {
1637
+ key : `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ adminsChatReportID } ` ,
1638
+ callback : ( id ) => {
1639
+ Onyx . disconnect ( connection ) ;
1640
+ resolve ( id ) ;
1641
+ } ,
1642
+ } ) ;
1643
+ } ) ;
1644
+ expect ( reportActions ) . not . toBeNull ( ) ;
1645
+ expect ( reportActions ) . not . toBeUndefined ( ) ;
1646
+ Object . values ( reportActions ?? { } ) . forEach ( ( action ) => {
1647
+ expect ( action . isOptimisticAction ) . toBeFalsy ( ) ;
1648
+ } ) ;
1649
+ } ) ;
1650
+ } ) ;
1609
1651
} ) ;
0 commit comments