Skip to content

fix: Onboarding - Onboarding tasks in #admins room are grayed out in offline mode. #60973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -9844,7 +9844,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 @@ -9880,7 +9880,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 @@ -9938,7 +9938,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 @@ -10126,7 +10126,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
61 changes: 61 additions & 0 deletions tests/unit/onboardingApiTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* eslint-disable @typescript-eslint/naming-convention */
import Onyx from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
import * as Report from '@src/libs/actions/Report';
import ONYXKEYS from '@src/ONYXKEYS';
import type {ReportActions} from '@src/types/onyx/ReportAction';
import * as TestHelper from '../utils/TestHelper';
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates';

const ESH_EMAIL = '[email protected]';
const ESH_ACCOUNT_ID = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Krishna2323 Either you've used your own details here instead of another contributor's, or you can use a placeholder like TEST_USER_ACCOUNT_ID.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating a new test file named onboardingApiTest, what do you think about adding the test directly under tests/actions/ReportTest.ts, since we're only testing completeOnboarding as part of the Report actions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, agreed. I have added the completeOnboarding test inside tests/actions/ReportTest.ts and removed the file onboardingApiTest.


describe('actions/Report', () => {
beforeAll(() => {
Onyx.init({
keys: ONYXKEYS,
});
});

beforeEach(() => {
global.fetch = TestHelper.getGlobalFetchMock();
return Onyx.clear().then(waitForBatchedUpdates);
});

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

const adminsChatReportID = '7957055873634067';
const onboardingPolicyID = 'A70D00C752416807';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

Report.completeOnboarding({
engagementChoice: 'newDotManageTeam',
onboardingMessage: CONST.ONBOARDING_MESSAGES.newDotManageTeam,
adminsChatReportID,
onboardingPolicyID,
companySize: '1-10',
userReportedIntegration: null,
});

await waitForBatchedUpdates();

const reportActions: OnyxEntry<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();
});
});
});
});
Loading