Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9874,7 +9874,7 @@ function prepareOnboardingOnyxData(
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`,
value: {
[taskReportAction.reportAction.reportActionID]: {pendingAction: null},
[taskReportAction.reportAction.reportActionID]: {pendingAction: null, isOptimisticAction: null},
},
},
{
Expand Down Expand Up @@ -9910,7 +9910,7 @@ function prepareOnboardingOnyxData(
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${currentTask.reportID}`,
value: {
[completedTaskReportAction.reportActionID]: {pendingAction: null},
[completedTaskReportAction.reportActionID]: {pendingAction: null, isOptimisticAction: null},
},
});
}
Expand Down Expand Up @@ -9968,7 +9968,7 @@ function prepareOnboardingOnyxData(
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`,
value: {
[textCommentAction.reportActionID]: {pendingAction: null},
[textCommentAction.reportActionID]: {pendingAction: null, isOptimisticAction: null},
},
});
}
Expand Down Expand Up @@ -10156,7 +10156,7 @@ function prepareOnboardingOnyxData(
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`,
value: {
[welcomeSignOffCommentAction.reportActionID]: {pendingAction: null},
[welcomeSignOffCommentAction.reportActionID]: {pendingAction: null, isOptimisticAction: null},
},
});

Expand Down
42 changes: 42 additions & 0 deletions tests/actions/ReportTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('actions/Report', () => {
beforeEach(() => {
HttpUtils.xhr = originalXHR;
const promise = Onyx.clear().then(jest.useRealTimers);

if (getIsUsingFakeTimers()) {
// flushing pending timers
// Onyx.clear() promise is resolved in batch which happens after the current microtasks cycle
Expand Down Expand Up @@ -1606,4 +1607,45 @@ describe('actions/Report', () => {
expect(derivedConciergeChatReportID).toBe(conciergeChatReport2.reportID);
});
});

describe('completeOnboarding', () => {
const TEST_USER_LOGIN = 'test@gmail.com';
const TEST_USER_ACCOUNT_ID = 1;
global.fetch = TestHelper.getGlobalFetchMock();

it('should set "isOptimisticAction" to false/null for all actions in admins report after completing onboarding setup', async () => {
await Onyx.set(ONYXKEYS.SESSION, {email: TEST_USER_LOGIN, accountID: TEST_USER_ACCOUNT_ID});
await waitForBatchedUpdates();

const adminsChatReportID = '7957055873634067';
const onboardingPolicyID = 'A70D00C752416807';
const engagementChoice = CONST.INTRO_CHOICES.MANAGE_TEAM;

Report.completeOnboarding({
engagementChoice,
onboardingMessage: CONST.ONBOARDING_MESSAGES[engagementChoice],
adminsChatReportID,
onboardingPolicyID,
companySize: CONST.ONBOARDING_COMPANY_SIZE.MICRO,
userReportedIntegration: null,
});

await waitForBatchedUpdates();

const reportActions: OnyxEntry<OnyxTypes.ReportActions> = await new Promise((resolve) => {
const connection = Onyx.connect({
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${adminsChatReportID}`,
callback: (id) => {
Onyx.disconnect(connection);
resolve(id);
},
});
});
expect(reportActions).not.toBeNull();
expect(reportActions).not.toBeUndefined();
Object.values(reportActions ?? {}).forEach((action) => {
expect(action.isOptimisticAction).toBeFalsy();
});
});
});
});