|
2 | 2 | import * as PolicyUtils from '@libs/PolicyUtils'; |
3 | 3 | import {isQuickActionAllowed} from '@libs/QuickActionUtils'; |
4 | 4 | import CONST from '@src/CONST'; |
5 | | -import type {Policy} from '@src/types/onyx'; |
| 5 | +import type {Policy, Report} from '@src/types/onyx'; |
6 | 6 |
|
7 | 7 | // Mock the PolicyUtils module |
8 | 8 | jest.mock('@libs/PolicyUtils'); |
@@ -82,5 +82,35 @@ describe('QuickActionUtils', () => { |
82 | 82 | expect(result).toBe(false); |
83 | 83 | }); |
84 | 84 | }); |
| 85 | + describe('Manager McTest restrictions', () => { |
| 86 | + const requestScanAction = { |
| 87 | + action: CONST.QUICK_ACTIONS.REQUEST_SCAN, |
| 88 | + isFirstQuickAction: false, |
| 89 | + }; |
| 90 | + |
| 91 | + // Given a report with Manager McTest |
| 92 | + const reportWithManagerMcTest: Report = { |
| 93 | + reportID: '1', |
| 94 | + participants: { |
| 95 | + [CONST.ACCOUNT_ID.MANAGER_MCTEST]: { |
| 96 | + notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, |
| 97 | + }, |
| 98 | + }, |
| 99 | + }; |
| 100 | + |
| 101 | + beforeEach(() => { |
| 102 | + jest.clearAllMocks(); |
| 103 | + }); |
| 104 | + |
| 105 | + it('should return false when report contains Manager McTest', () => { |
| 106 | + mockedPolicyUtils.shouldShowPolicy.mockReturnValue(false); |
| 107 | + |
| 108 | + // When the report contains Manager McTest |
| 109 | + const result = isQuickActionAllowed(requestScanAction, reportWithManagerMcTest, undefined); |
| 110 | + |
| 111 | + // Then it should return false |
| 112 | + expect(result).toBe(false); |
| 113 | + }); |
| 114 | + }); |
85 | 115 | }); |
86 | 116 | }); |
0 commit comments