-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54105 from bernhardoj/fix/53931-member-added-offl…
…ine-doesnt-show-on-approval-flow Fix new member added while offline doesn't show in approval flow list
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,4 +228,40 @@ describe('actions/PolicyMember', () => { | |
}); | ||
}); | ||
}); | ||
|
||
describe('addMembersToWorkspace', () => { | ||
it('Add a new member to a workspace', async () => { | ||
const policyID = '1'; | ||
const defaultApprover = '[email protected]'; | ||
const newUserEmail = '[email protected]'; | ||
|
||
await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, { | ||
...createRandomPolicy(Number(policyID)), | ||
approver: defaultApprover, | ||
}); | ||
|
||
mockFetch?.pause?.(); | ||
Member.addMembersToWorkspace({[newUserEmail]: 1234}, 'Welcome', policyID, []); | ||
|
||
await waitForBatchedUpdates(); | ||
|
||
await new Promise<void>((resolve) => { | ||
const connection = Onyx.connect({ | ||
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, | ||
waitForCollectionCallback: false, | ||
callback: (policy) => { | ||
Onyx.disconnect(connection); | ||
const newEmployee = policy?.employeeList?.[newUserEmail]; | ||
expect(newEmployee).not.toBeUndefined(); | ||
expect(newEmployee?.email).toBe(newUserEmail); | ||
expect(newEmployee?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); | ||
expect(newEmployee?.role).toBe(CONST.POLICY.ROLE.USER); | ||
expect(newEmployee?.submitsTo).toBe(defaultApprover); | ||
resolve(); | ||
}, | ||
}); | ||
}); | ||
await mockFetch?.resume?.(); | ||
}); | ||
}); | ||
}); |