Skip to content

Commit 32dde8a

Browse files
authored
Merge pull request #60973 from Krishna2323/krishna2323/issue/60833
fix: Onboarding - Onboarding tasks in #admins room are grayed out in offline mode.
2 parents 43bb4f8 + 6e349d3 commit 32dde8a

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

src/libs/ReportUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9872,7 +9872,7 @@ function prepareOnboardingOnyxData(
98729872
onyxMethod: Onyx.METHOD.MERGE,
98739873
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`,
98749874
value: {
9875-
[taskReportAction.reportAction.reportActionID]: {pendingAction: null},
9875+
[taskReportAction.reportAction.reportActionID]: {pendingAction: null, isOptimisticAction: null},
98769876
},
98779877
},
98789878
{
@@ -9908,7 +9908,7 @@ function prepareOnboardingOnyxData(
99089908
onyxMethod: Onyx.METHOD.MERGE,
99099909
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${currentTask.reportID}`,
99109910
value: {
9911-
[completedTaskReportAction.reportActionID]: {pendingAction: null},
9911+
[completedTaskReportAction.reportActionID]: {pendingAction: null, isOptimisticAction: null},
99129912
},
99139913
});
99149914
}
@@ -9966,7 +9966,7 @@ function prepareOnboardingOnyxData(
99669966
onyxMethod: Onyx.METHOD.MERGE,
99679967
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`,
99689968
value: {
9969-
[textCommentAction.reportActionID]: {pendingAction: null},
9969+
[textCommentAction.reportActionID]: {pendingAction: null, isOptimisticAction: null},
99709970
},
99719971
});
99729972
}
@@ -10154,7 +10154,7 @@ function prepareOnboardingOnyxData(
1015410154
onyxMethod: Onyx.METHOD.MERGE,
1015510155
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`,
1015610156
value: {
10157-
[welcomeSignOffCommentAction.reportActionID]: {pendingAction: null},
10157+
[welcomeSignOffCommentAction.reportActionID]: {pendingAction: null, isOptimisticAction: null},
1015810158
},
1015910159
});
1016010160

tests/actions/ReportTest.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ describe('actions/Report', () => {
6868
beforeEach(() => {
6969
HttpUtils.xhr = originalXHR;
7070
const promise = Onyx.clear().then(jest.useRealTimers);
71+
7172
if (getIsUsingFakeTimers()) {
7273
// flushing pending timers
7374
// Onyx.clear() promise is resolved in batch which happens after the current microtasks cycle
@@ -1606,4 +1607,45 @@ describe('actions/Report', () => {
16061607
expect(derivedConciergeChatReportID).toBe(conciergeChatReport2.reportID);
16071608
});
16081609
});
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+
});
16091651
});

0 commit comments

Comments
 (0)