Skip to content

Commit 5a00e95

Browse files
authored
MPDX-9613 Gate MPD and PDS Goal Calculators by peopleGroupSupportType (#1804)
* MPDX-9613 Gate MPD and PDS Goal Calculators by peopleGroupSupportType
1 parent 70292ce commit 5a00e95

19 files changed

Lines changed: 654 additions & 140 deletions

File tree

pages/accountLists/[accountListId]/hrTools/goalCalculator/[goalCalculationId].page.test.tsx

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,45 @@
1+
import React from 'react';
12
import TestRouter from '__tests__/util/TestRouter';
23
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
34
import { render } from '__tests__/util/testingLibraryReactMock';
45
import { blockImpersonatingNonDevelopers } from 'pages/api/utils/pagePropsHelpers';
6+
import { HcmQuery } from 'src/components/HrTools/Shared/HcmData/Hcm.generated';
57
import { GetUserQuery } from 'src/components/User/GetUser.generated';
6-
import { UserTypeEnum } from 'src/graphql/types.generated';
8+
import {
9+
PeopleGroupSupportTypeEnum,
10+
UserTypeEnum,
11+
} from 'src/graphql/types.generated';
712
import {
813
GoalCalculatorPage,
914
getServerSideProps,
1015
} from './[goalCalculationId].page';
1116

12-
const Components = () => (
17+
interface ComponentsProps {
18+
userType?: UserTypeEnum;
19+
peopleGroupSupportType?: PeopleGroupSupportTypeEnum;
20+
salaryRequestEligible?: boolean;
21+
}
22+
23+
const Components: React.FC<ComponentsProps> = ({
24+
userType = UserTypeEnum.NonCru,
25+
peopleGroupSupportType = PeopleGroupSupportTypeEnum.SupportedRmo,
26+
salaryRequestEligible = true,
27+
}) => (
1328
<TestRouter>
1429
<GqlMockedProvider<{
1530
GetUser: GetUserQuery;
31+
Hcm: HcmQuery;
1632
}>
1733
mocks={{
18-
GetUser: { user: { userType: UserTypeEnum.NonCru } },
34+
GetUser: { user: { userType } },
35+
Hcm: {
36+
hcm: [
37+
{
38+
salaryRequestEligible,
39+
staffInfo: { peopleGroupSupportType },
40+
},
41+
],
42+
},
1943
}}
2044
>
2145
<GoalCalculatorPage />
@@ -35,4 +59,18 @@ describe('[goalCalculationId] page', () => {
3559
await findByText('Access to this feature is limited.'),
3660
).toBeInTheDocument();
3761
});
62+
63+
it('should show limited access for a US Staff user whose peopleGroupSupportType is Designation (PDS)', async () => {
64+
const { findByText } = render(
65+
<Components
66+
userType={UserTypeEnum.UsStaff}
67+
peopleGroupSupportType={PeopleGroupSupportTypeEnum.Designation}
68+
salaryRequestEligible={false}
69+
/>,
70+
);
71+
72+
expect(
73+
await findByText('Access to this feature is limited.'),
74+
).toBeInTheDocument();
75+
});
3876
});

pages/accountLists/[accountListId]/hrTools/goalCalculator/[goalCalculationId].page.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ import {
2323
MultiPageMenu,
2424
NavTypeEnum,
2525
} from 'src/components/Shared/MultiPageLayout/MultiPageMenu/MultiPageMenu';
26-
import { UserTypeAccess } from 'src/components/Shared/UserTypeAccess/UserTypeAccess';
26+
import {
27+
RequiredUserGroupEnum,
28+
UserTypeAccess,
29+
} from 'src/components/Shared/UserTypeAccess/UserTypeAccess';
2730
import { ReportPageWrapper } from 'src/components/Shared/styledComponents/ReportPageWrapper';
2831
import { useAccountListId } from 'src/hooks/useAccountListId';
2932
import { getAppName } from 'src/lib/getAppName';
@@ -139,7 +142,7 @@ export const GoalCalculatorPage: React.FC = () => {
139142
<title>{`${appName} | ${t('Reports - Goal Calculation')}`}</title>
140143
</Head>
141144
{accountListId ? (
142-
<UserTypeAccess>
145+
<UserTypeAccess requireUserGroups={RequiredUserGroupEnum.MpdGoalCalc}>
143146
<ReportPageWrapper>
144147
<GoalCalculatorProvider>
145148
<GoalCalculatorContent

pages/accountLists/[accountListId]/hrTools/goalCalculator/index.page.test.tsx

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,40 @@ import TestRouter from '__tests__/util/TestRouter';
22
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
33
import { render } from '__tests__/util/testingLibraryReactMock';
44
import { blockImpersonatingNonDevelopers } from 'pages/api/utils/pagePropsHelpers';
5+
import { HcmQuery } from 'src/components/HrTools/Shared/HcmData/Hcm.generated';
56
import { GetUserQuery } from 'src/components/User/GetUser.generated';
6-
import { UserTypeEnum } from 'src/graphql/types.generated';
7+
import {
8+
PeopleGroupSupportTypeEnum,
9+
UserTypeEnum,
10+
} from 'src/graphql/types.generated';
711
import { GoalCalculatorPage, getServerSideProps } from './index.page';
812

9-
const Components = () => (
13+
interface ComponentsProps {
14+
userType?: UserTypeEnum;
15+
peopleGroupSupportType?: PeopleGroupSupportTypeEnum;
16+
salaryRequestEligible?: boolean;
17+
}
18+
19+
const Components: React.FC<ComponentsProps> = ({
20+
userType = UserTypeEnum.NonCru,
21+
peopleGroupSupportType = PeopleGroupSupportTypeEnum.SupportedRmo,
22+
salaryRequestEligible = true,
23+
}) => (
1024
<TestRouter>
1125
<GqlMockedProvider<{
1226
GetUser: GetUserQuery;
27+
Hcm: HcmQuery;
1328
}>
1429
mocks={{
15-
GetUser: { user: { userType: UserTypeEnum.NonCru } },
30+
GetUser: { user: { userType } },
31+
Hcm: {
32+
hcm: [
33+
{
34+
salaryRequestEligible,
35+
staffInfo: { peopleGroupSupportType },
36+
},
37+
],
38+
},
1639
}}
1740
>
1841
<GoalCalculatorPage />
@@ -32,4 +55,18 @@ describe('GoalCalculator page', () => {
3255
await findByText('Access to this feature is limited.'),
3356
).toBeInTheDocument();
3457
});
58+
59+
it('should show limited access for a US Staff user whose peopleGroupSupportType is Designation (PDS)', async () => {
60+
const { findByText } = render(
61+
<Components
62+
userType={UserTypeEnum.UsStaff}
63+
peopleGroupSupportType={PeopleGroupSupportTypeEnum.Designation}
64+
salaryRequestEligible={false}
65+
/>,
66+
);
67+
68+
expect(
69+
await findByText('Access to this feature is limited.'),
70+
).toBeInTheDocument();
71+
});
3572
});

pages/accountLists/[accountListId]/hrTools/goalCalculator/index.page.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import {
1414
MultiPageMenu,
1515
NavTypeEnum,
1616
} from 'src/components/Shared/MultiPageLayout/MultiPageMenu/MultiPageMenu';
17-
import { UserTypeAccess } from 'src/components/Shared/UserTypeAccess/UserTypeAccess';
17+
import {
18+
RequiredUserGroupEnum,
19+
UserTypeAccess,
20+
} from 'src/components/Shared/UserTypeAccess/UserTypeAccess';
1821
import { ReportPageWrapper } from 'src/components/Shared/styledComponents/ReportPageWrapper';
1922
import { useAccountListId } from 'src/hooks/useAccountListId';
2023
import { getAppName } from 'src/lib/getAppName';
@@ -36,7 +39,7 @@ export const GoalCalculatorPage: React.FC = () => {
3639
<title>{`${appName} | ${t('HR Tools | MPD Goal Calculator')}`}</title>
3740
</Head>
3841
{accountListId ? (
39-
<UserTypeAccess>
42+
<UserTypeAccess requireUserGroups={RequiredUserGroupEnum.MpdGoalCalc}>
4043
<ReportPageWrapper>
4144
<SidePanelsLayout
4245
isScrollBox={false}

pages/accountLists/[accountListId]/hrTools/pdsGoalCalculator/[pdsGoalId].page.test.tsx

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,78 @@
11
import React from 'react';
2-
import { render } from '@testing-library/react';
2+
import TestRouter from '__tests__/util/TestRouter';
3+
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
4+
import { render } from '__tests__/util/testingLibraryReactMock';
35
import { blockImpersonatingNonDevelopers } from 'pages/api/utils/pagePropsHelpers';
46
import { PdsGoalCalculatorTestWrapper } from 'src/components/HrTools/PdsGoalCalculator/PdsGoalCalculatorTestWrapper';
7+
import { HcmQuery } from 'src/components/HrTools/Shared/HcmData/Hcm.generated';
8+
import { GetUserQuery } from 'src/components/User/GetUser.generated';
9+
import { UserTypeEnum } from 'src/graphql/types.generated';
510
import { PdsGoalCalculatorPage, getServerSideProps } from './[pdsGoalId].page';
611

12+
interface AccessComponentsProps {
13+
userType?: UserTypeEnum;
14+
designationSupportCalculatorEligible?: boolean;
15+
}
16+
17+
const AccessComponents: React.FC<AccessComponentsProps> = ({
18+
userType = UserTypeEnum.UsStaff,
19+
designationSupportCalculatorEligible = true,
20+
}) => (
21+
<TestRouter>
22+
<GqlMockedProvider<{
23+
GetUser: GetUserQuery;
24+
Hcm: HcmQuery;
25+
}>
26+
mocks={{
27+
GetUser: { user: { userType } },
28+
Hcm: {
29+
hcm: [{ designationSupportCalculatorEligible }],
30+
},
31+
}}
32+
>
33+
<PdsGoalCalculatorPage />
34+
</GqlMockedProvider>
35+
</TestRouter>
36+
);
37+
738
describe('[pdsGoalId] page', () => {
839
it('uses blockImpersonatingNonDevelopers for server-side props', () => {
940
expect(getServerSideProps).toBe(blockImpersonatingNonDevelopers);
1041
});
1142

12-
it('renders Saving indicator', async () => {
43+
it('should show limited access for a non-Cru user', async () => {
44+
const { findByText } = render(
45+
<AccessComponents userType={UserTypeEnum.NonCru} />,
46+
);
47+
48+
expect(
49+
await findByText('Access to this feature is limited.'),
50+
).toBeInTheDocument();
51+
});
52+
53+
it('should show limited access when designationSupportCalculatorEligible is false', async () => {
54+
const { findByText } = render(
55+
<AccessComponents designationSupportCalculatorEligible={false} />,
56+
);
57+
58+
expect(
59+
await findByText('Access to this feature is limited.'),
60+
).toBeInTheDocument();
61+
});
62+
63+
it('renders Saving indicator for an eligible US Staff user', async () => {
1364
const { findByText } = render(
14-
<PdsGoalCalculatorTestWrapper withProvider={false}>
65+
<PdsGoalCalculatorTestWrapper<{
66+
Hcm: HcmQuery;
67+
}>
68+
withProvider={false}
69+
userMock={{ user: { userType: UserTypeEnum.UsStaff } }}
70+
extraMocks={{
71+
Hcm: {
72+
hcm: [{ designationSupportCalculatorEligible: true }],
73+
},
74+
}}
75+
>
1576
<PdsGoalCalculatorPage />
1677
</PdsGoalCalculatorTestWrapper>,
1778
);

pages/accountLists/[accountListId]/hrTools/pdsGoalCalculator/[pdsGoalId].page.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import {
2222
MultiPageMenu,
2323
NavTypeEnum,
2424
} from 'src/components/Shared/MultiPageLayout/MultiPageMenu/MultiPageMenu';
25+
import {
26+
RequiredUserGroupEnum,
27+
UserTypeAccess,
28+
} from 'src/components/Shared/UserTypeAccess/UserTypeAccess';
2529
import { ReportPageWrapper } from 'src/components/Shared/styledComponents/ReportPageWrapper';
2630
import { useAccountListId } from 'src/hooks/useAccountListId';
2731
import { getAppName } from 'src/lib/getAppName';
@@ -139,16 +143,18 @@ export const PdsGoalCalculatorPage: React.FC = () => {
139143
<title>{`${appName} | ${t('HR Tools - Paid with Designation Support Goal Calculator')}`}</title>
140144
</Head>
141145
{accountListId ? (
142-
<ReportPageWrapper>
143-
<PdsGoalCalculatorProvider>
144-
<PdsGoalCalculatorContent
145-
isNavListOpen={isNavListOpen}
146-
onNavListToggle={handleNavListToggle}
147-
designationAccounts={designationAccounts}
148-
setDesignationAccounts={setDesignationAccounts}
149-
/>
150-
</PdsGoalCalculatorProvider>
151-
</ReportPageWrapper>
146+
<UserTypeAccess requireUserGroups={RequiredUserGroupEnum.PdsGoalCalc}>
147+
<ReportPageWrapper>
148+
<PdsGoalCalculatorProvider>
149+
<PdsGoalCalculatorContent
150+
isNavListOpen={isNavListOpen}
151+
onNavListToggle={handleNavListToggle}
152+
designationAccounts={designationAccounts}
153+
setDesignationAccounts={setDesignationAccounts}
154+
/>
155+
</PdsGoalCalculatorProvider>
156+
</ReportPageWrapper>
157+
</UserTypeAccess>
152158
) : (
153159
<Loading loading />
154160
)}
Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,70 @@
1+
import TestRouter from '__tests__/util/TestRouter';
2+
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
3+
import { render } from '__tests__/util/testingLibraryReactMock';
14
import { blockImpersonatingNonDevelopers } from 'pages/api/utils/pagePropsHelpers';
2-
import { getServerSideProps } from './index.page';
5+
import { HcmQuery } from 'src/components/HrTools/Shared/HcmData/Hcm.generated';
6+
import { GetUserQuery } from 'src/components/User/GetUser.generated';
7+
import {
8+
PeopleGroupSupportTypeEnum,
9+
UserTypeEnum,
10+
} from 'src/graphql/types.generated';
11+
import PdsGoalCalculatorPage, { getServerSideProps } from './index.page';
12+
13+
interface ComponentsProps {
14+
userType?: UserTypeEnum;
15+
peopleGroupSupportType?: PeopleGroupSupportTypeEnum;
16+
}
17+
18+
const Components: React.FC<ComponentsProps> = ({
19+
userType = UserTypeEnum.UsStaff,
20+
peopleGroupSupportType = PeopleGroupSupportTypeEnum.Designation,
21+
}) => (
22+
<TestRouter>
23+
<GqlMockedProvider<{
24+
GetUser: GetUserQuery;
25+
Hcm: HcmQuery;
26+
}>
27+
mocks={{
28+
GetUser: { user: { userType } },
29+
Hcm: {
30+
hcm: [
31+
{
32+
staffInfo: { peopleGroupSupportType },
33+
},
34+
],
35+
},
36+
}}
37+
>
38+
<PdsGoalCalculatorPage />
39+
</GqlMockedProvider>
40+
</TestRouter>
41+
);
342

443
describe('PdsGoalCalculator page', () => {
544
it('uses blockImpersonatingNonDevelopers for server-side props', () => {
645
expect(getServerSideProps).toBe(blockImpersonatingNonDevelopers);
746
});
47+
48+
it('should show limited access for a non-Cru user', async () => {
49+
const { findByText } = render(
50+
<Components userType={UserTypeEnum.NonCru} />,
51+
);
52+
53+
expect(
54+
await findByText('Access to this feature is limited.'),
55+
).toBeInTheDocument();
56+
});
57+
58+
it('should show limited access for a US Staff user whose peopleGroupSupportType is SupportedRmo (Senior)', async () => {
59+
const { findByText } = render(
60+
<Components
61+
userType={UserTypeEnum.UsStaff}
62+
peopleGroupSupportType={PeopleGroupSupportTypeEnum.SupportedRmo}
63+
/>,
64+
);
65+
66+
expect(
67+
await findByText('Access to this feature is limited.'),
68+
).toBeInTheDocument();
69+
});
870
});

0 commit comments

Comments
 (0)