|
| 1 | +import { |
| 2 | + adcUser, |
| 3 | + irsPractitionerUser, |
| 4 | + petitionerUser, |
| 5 | + privatePractitionerUser, |
| 6 | +} from '../../../../shared/src/test/mockUsers'; |
| 7 | +import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; |
| 8 | +import { caseDetailHelper as caseDetailHelperComputed } from './caseDetailHelper'; |
| 9 | +import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; |
| 10 | +import { runCompute } from 'cerebral/test'; |
| 11 | +import { withAppContextDecorator } from '../../withAppContext'; |
| 12 | + |
| 13 | +const caseDetailHelper = withAppContextDecorator(caseDetailHelperComputed, { |
| 14 | + ...applicationContext, |
| 15 | + getCurrentUser: () => { |
| 16 | + return globalUser; |
| 17 | + }, |
| 18 | +}); |
| 19 | + |
| 20 | +let globalUser; |
| 21 | + |
| 22 | +const getBaseState = user => { |
| 23 | + globalUser = user; |
| 24 | + return { |
| 25 | + permissions: getUserPermissions(user), |
| 26 | + }; |
| 27 | +}; |
| 28 | + |
| 29 | +describe('showConsolidatedCasesCard', () => { |
| 30 | + it('should be true when the user is a petitioner and the case is in a consolidated group', () => { |
| 31 | + const user = petitionerUser; |
| 32 | + |
| 33 | + const result = runCompute(caseDetailHelper, { |
| 34 | + state: { |
| 35 | + ...getBaseState(user), |
| 36 | + caseDetail: { |
| 37 | + docketEntries: [], |
| 38 | + leadDocketNumber: '101-22F', |
| 39 | + }, |
| 40 | + }, |
| 41 | + }); |
| 42 | + expect(result.showConsolidatedCasesCard).toEqual(true); |
| 43 | + }); |
| 44 | + |
| 45 | + it('should be true when the user is a private practitioner and the case is in a consolidated group', () => { |
| 46 | + const user = privatePractitionerUser; |
| 47 | + |
| 48 | + const result = runCompute(caseDetailHelper, { |
| 49 | + state: { |
| 50 | + ...getBaseState(user), |
| 51 | + caseDetail: { |
| 52 | + docketEntries: [], |
| 53 | + leadDocketNumber: '101-22F', |
| 54 | + }, |
| 55 | + }, |
| 56 | + }); |
| 57 | + expect(result.showConsolidatedCasesCard).toEqual(true); |
| 58 | + }); |
| 59 | + |
| 60 | + it('should be true when the user is an IRS practitioner and the case is in a consolidated group', () => { |
| 61 | + const user = irsPractitionerUser; |
| 62 | + |
| 63 | + const result = runCompute(caseDetailHelper, { |
| 64 | + state: { |
| 65 | + ...getBaseState(user), |
| 66 | + caseDetail: { |
| 67 | + docketEntries: [], |
| 68 | + leadDocketNumber: '101-22F', |
| 69 | + }, |
| 70 | + }, |
| 71 | + }); |
| 72 | + expect(result.showConsolidatedCasesCard).toEqual(true); |
| 73 | + }); |
| 74 | + |
| 75 | + it('should be false when the user is a non practitioner/petitioner user and the case is in a consolidated group', () => { |
| 76 | + const user = adcUser; |
| 77 | + |
| 78 | + const result = runCompute(caseDetailHelper, { |
| 79 | + state: { |
| 80 | + ...getBaseState(user), |
| 81 | + caseDetail: { |
| 82 | + docketEntries: [], |
| 83 | + leadDocketNumber: '101-22F', |
| 84 | + }, |
| 85 | + }, |
| 86 | + }); |
| 87 | + |
| 88 | + expect(result.showConsolidatedCasesCard).toEqual(false); |
| 89 | + }); |
| 90 | + |
| 91 | + it('should be false when the case is not in a consolidated group and the user has VIEW_CONSOLIDATED_CASES_CARD permission', () => { |
| 92 | + const user = petitionerUser; |
| 93 | + |
| 94 | + const result = runCompute(caseDetailHelper, { |
| 95 | + state: { |
| 96 | + ...getBaseState(user), |
| 97 | + caseDetail: { |
| 98 | + docketEntries: [], |
| 99 | + leadDocketNumber: undefined, |
| 100 | + }, |
| 101 | + }, |
| 102 | + }); |
| 103 | + |
| 104 | + expect(result.showConsolidatedCasesCard).toEqual(false); |
| 105 | + }); |
| 106 | +}); |
0 commit comments