Skip to content

Commit 08ea6f6

Browse files
author
Katelyn Grimes
committed
Refactor and fix some tests
1 parent d5895fa commit 08ea6f6

14 files changed

Lines changed: 533 additions & 400 deletions

File tree

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

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,60 +9,31 @@ import {
99
beforeTestResizeObserver,
1010
} from '__tests__/util/windowResizeObserver';
1111
import { blockImpersonatingNonDevelopers } from 'pages/api/utils/pagePropsHelpers';
12-
import { StaffAccountQuery } from 'src/components/Shared/StaffAccount/StaffAccount.generated';
1312
import { GetUserQuery } from 'src/components/User/GetUser.generated';
14-
import {
15-
PeopleGroupSupportTypeEnum,
16-
UserPersonTypeEnum,
17-
UserTypeEnum,
18-
} from 'src/graphql/types.generated';
13+
import { UsStaffGroupEnum, UserTypeEnum } from 'src/graphql/types.generated';
1914
import theme from 'src/theme';
2015
import AdditionalSalaryRequestPage, { getServerSideProps } from './index.page';
2116

22-
const mocks = {
23-
StaffAccount: {
24-
staffAccount: {
25-
id: '12345',
26-
name: 'Test Account',
27-
},
28-
},
29-
AdditionalSalaryRequest: {
30-
latestAdditionalSalaryRequest: null,
31-
},
32-
Hcm: {
33-
hcm: [
34-
{
35-
salaryRequestEligible: true,
36-
asrEit: {
37-
asrEligibility: true,
38-
},
39-
staffInfo: {
40-
preferredName: 'Test User',
41-
peopleGroupSupportType: PeopleGroupSupportTypeEnum.SupportedRmo,
42-
userPersonType: UserPersonTypeEnum.EmployeeStaff,
43-
},
44-
},
45-
],
46-
},
47-
};
4817
interface TestComponentProps {
4918
userType?: UserTypeEnum;
19+
usStaffGroup?: UsStaffGroupEnum.SeniorStaff;
20+
staffAccountId?: string;
5021
}
5122

5223
const TestComponent: React.FC<TestComponentProps> = ({
5324
userType = UserTypeEnum.UsStaff,
25+
usStaffGroup = UsStaffGroupEnum.SeniorStaff,
26+
staffAccountId = '12345',
5427
}) => (
5528
<ThemeProvider theme={theme}>
5629
<SnackbarProvider>
5730
<TestRouter router={{ query: { accountListId: 'account-list-1' } }}>
5831
<GqlMockedProvider<{
59-
StaffAccount: StaffAccountQuery;
6032
GetUser: GetUserQuery;
6133
}>
6234
mocks={{
63-
...mocks,
6435
GetUser: {
65-
user: { userType },
36+
user: { userType, usStaffGroup, staffAccountId },
6637
},
6738
}}
6839
>
@@ -109,8 +80,10 @@ describe('AdditionalSalaryRequest page', () => {
10980

11081
it('renders no staff account page when no staff account', async () => {
11182
const mockNoStaffAccount = {
112-
StaffAccount: {
113-
staffAccount: null,
83+
GetUser: {
84+
user: {
85+
staffAccountId: null,
86+
},
11487
},
11588
};
11689

@@ -119,7 +92,7 @@ describe('AdditionalSalaryRequest page', () => {
11992
<SnackbarProvider>
12093
<TestRouter router={{ query: { accountListId: 'account-list-1' } }}>
12194
<GqlMockedProvider<{
122-
StaffAccount: StaffAccountQuery;
95+
GetUser: GetUserQuery;
12396
}>
12497
mocks={mockNoStaffAccount}
12598
>

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

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,28 @@ import TestRouter from '__tests__/util/TestRouter';
33
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
44
import { render } from '__tests__/util/testingLibraryReactMock';
55
import { blockImpersonatingNonDevelopers } from 'pages/api/utils/pagePropsHelpers';
6-
import { HcmQuery } from 'src/components/HrTools/Shared/HcmData/Hcm.generated';
76
import { GetUserQuery } from 'src/components/User/GetUser.generated';
8-
import {
9-
PeopleGroupSupportTypeEnum,
10-
UserTypeEnum,
11-
} from 'src/graphql/types.generated';
7+
import { UsStaffGroupEnum, UserTypeEnum } from 'src/graphql/types.generated';
128
import {
139
GoalCalculatorPage,
1410
getServerSideProps,
1511
} from './[goalCalculationId].page';
1612

1713
interface ComponentsProps {
1814
userType?: UserTypeEnum;
19-
peopleGroupSupportType?: PeopleGroupSupportTypeEnum;
20-
salaryRequestEligible?: boolean;
15+
usStaffGroup?: UsStaffGroupEnum;
2116
}
2217

2318
const Components: React.FC<ComponentsProps> = ({
2419
userType = UserTypeEnum.NonCru,
25-
peopleGroupSupportType = PeopleGroupSupportTypeEnum.SupportedRmo,
26-
salaryRequestEligible = true,
20+
usStaffGroup = UsStaffGroupEnum.SeniorStaff,
2721
}) => (
2822
<TestRouter>
2923
<GqlMockedProvider<{
3024
GetUser: GetUserQuery;
31-
Hcm: HcmQuery;
3225
}>
3326
mocks={{
34-
GetUser: { user: { userType } },
35-
Hcm: {
36-
hcm: [
37-
{
38-
salaryRequestEligible,
39-
staffInfo: { peopleGroupSupportType },
40-
},
41-
],
42-
},
27+
GetUser: { user: { userType, usStaffGroup } },
4328
}}
4429
>
4530
<GoalCalculatorPage />
@@ -60,12 +45,11 @@ describe('[goalCalculationId] page', () => {
6045
).toBeInTheDocument();
6146
});
6247

63-
it('should show limited access for a US Staff user whose peopleGroupSupportType is Designation (PDS)', async () => {
48+
it('should show limited access for a US Staff user whose usStaffGroup is PaidWithDesignation (PDS)', async () => {
6449
const { findByText } = render(
6550
<Components
6651
userType={UserTypeEnum.UsStaff}
67-
peopleGroupSupportType={PeopleGroupSupportTypeEnum.Designation}
68-
salaryRequestEligible={false}
52+
usStaffGroup={UsStaffGroupEnum.PaidWithDesignation}
6953
/>,
7054
);
7155

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

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,25 @@ 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';
65
import { GetUserQuery } from 'src/components/User/GetUser.generated';
7-
import {
8-
PeopleGroupSupportTypeEnum,
9-
UserTypeEnum,
10-
} from 'src/graphql/types.generated';
6+
import { UsStaffGroupEnum, UserTypeEnum } from 'src/graphql/types.generated';
117
import { GoalCalculatorPage, getServerSideProps } from './index.page';
128

139
interface ComponentsProps {
1410
userType?: UserTypeEnum;
15-
peopleGroupSupportType?: PeopleGroupSupportTypeEnum;
16-
salaryRequestEligible?: boolean;
11+
usStaffGroup?: UsStaffGroupEnum;
1712
}
1813

1914
const Components: React.FC<ComponentsProps> = ({
2015
userType = UserTypeEnum.NonCru,
21-
peopleGroupSupportType = PeopleGroupSupportTypeEnum.SupportedRmo,
22-
salaryRequestEligible = true,
16+
usStaffGroup = UsStaffGroupEnum.SeniorStaff,
2317
}) => (
2418
<TestRouter>
2519
<GqlMockedProvider<{
2620
GetUser: GetUserQuery;
27-
Hcm: HcmQuery;
2821
}>
2922
mocks={{
30-
GetUser: { user: { userType } },
31-
Hcm: {
32-
hcm: [
33-
{
34-
salaryRequestEligible,
35-
staffInfo: { peopleGroupSupportType },
36-
},
37-
],
38-
},
23+
GetUser: { user: { userType, usStaffGroup } },
3924
}}
4025
>
4126
<GoalCalculatorPage />
@@ -56,12 +41,11 @@ describe('GoalCalculator page', () => {
5641
).toBeInTheDocument();
5742
});
5843

59-
it('should show limited access for a US Staff user whose peopleGroupSupportType is Designation (PDS)', async () => {
44+
it('should show limited access for a US Staff user whose usStaffGroup is PaidWithDesignation (PDS)', async () => {
6045
const { findByText } = render(
6146
<Components
6247
userType={UserTypeEnum.UsStaff}
63-
peopleGroupSupportType={PeopleGroupSupportTypeEnum.Designation}
64-
salaryRequestEligible={false}
48+
usStaffGroup={UsStaffGroupEnum.PaidWithDesignation}
6549
/>,
6650
);
6751

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

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,60 +9,32 @@ import {
99
beforeTestResizeObserver,
1010
} from '__tests__/util/windowResizeObserver';
1111
import { blockImpersonatingNonDevelopers } from 'pages/api/utils/pagePropsHelpers';
12-
import { StaffAccountQuery } from 'src/components/Shared/StaffAccount/StaffAccount.generated';
1312
import { GetUserQuery } from 'src/components/User/GetUser.generated';
14-
import {
15-
AssignmentStatusEnum,
16-
PeopleGroupSupportTypeEnum,
17-
UserPersonTypeEnum,
18-
UserTypeEnum,
19-
} from 'src/graphql/types.generated';
13+
import { UsStaffGroupEnum, UserTypeEnum } from 'src/graphql/types.generated';
2014
import theme from 'src/theme';
2115
import MinisterHousingAllowancePage, { getServerSideProps } from './index.page';
2216

2317
const mutationSpy = jest.fn();
24-
25-
const mocks = {
26-
StaffAccount: {
27-
staffAccount: {
28-
id: '12345',
29-
name: 'Test Account',
30-
},
31-
},
32-
Hcm: {
33-
hcm: [
34-
{
35-
mhaEit: {
36-
mhaEligibility: true,
37-
},
38-
staffInfo: {
39-
preferredName: 'Test User',
40-
peopleGroupSupportType: PeopleGroupSupportTypeEnum.SupportedRmo,
41-
userPersonType: UserPersonTypeEnum.EmployeeStaff,
42-
assignmentStatus: AssignmentStatusEnum.ActivePayrollEligible,
43-
},
44-
},
45-
],
46-
},
47-
};
4818
interface ComponentProps {
4919
userType?: UserTypeEnum;
20+
usStaffGroup?: UsStaffGroupEnum;
21+
staffAccountId?: string;
5022
}
5123

5224
const Components: React.FC<ComponentProps> = ({
5325
userType = UserTypeEnum.UsStaff,
26+
usStaffGroup = UsStaffGroupEnum.SeniorStaff,
27+
staffAccountId = '12345',
5428
}) => (
5529
<ThemeProvider theme={theme}>
5630
<SnackbarProvider>
5731
<TestRouter>
5832
<GqlMockedProvider<{
59-
StaffAccount: StaffAccountQuery;
6033
GetUser: GetUserQuery;
6134
}>
6235
mocks={{
63-
...mocks,
6436
GetUser: {
65-
user: { userType },
37+
user: { userType, usStaffGroup, staffAccountId },
6638
},
6739
}}
6840
onCall={mutationSpy}
@@ -109,15 +81,17 @@ describe('MHA Calculation Page', () => {
10981

11082
it('renders no staff account page when no staff account', async () => {
11183
const mockNoStaffAccount = {
112-
StaffAccount: {
113-
staffAccount: null,
84+
GetUser: {
85+
user: {
86+
staffAccountId: null,
87+
},
11488
},
11589
};
11690

11791
const { findByText } = render(
11892
<TestRouter>
11993
<GqlMockedProvider<{
120-
StaffAccount: StaffAccountQuery;
94+
GetUser: GetUserQuery;
12195
}>
12296
mocks={mockNoStaffAccount}
12397
onCall={mutationSpy}

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

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,31 @@ import {
99
beforeTestResizeObserver,
1010
} from '__tests__/util/windowResizeObserver';
1111
import { blockImpersonatingNonDevelopers } from 'pages/api/utils/pagePropsHelpers';
12-
import { StaffAccountQuery } from 'src/components/Shared/StaffAccount/StaffAccount.generated';
12+
import { GetUserQuery } from 'src/components/User/GetUser.generated';
1313
import { UserTypeEnum } from 'src/graphql/types.generated';
1414
import theme from 'src/theme';
1515
import PartnerRemindersReportPage, { getServerSideProps } from './index.page';
1616

1717
const mutationSpy = jest.fn();
1818

19-
const mocks = {
20-
StaffAccount: {
21-
staffAccount: {
22-
id: '12345',
23-
name: 'Test Account',
24-
},
25-
},
26-
};
2719
interface ComponentProps {
2820
userType?: UserTypeEnum;
21+
staffAccountId?: string;
2922
}
3023

3124
const Components: React.FC<ComponentProps> = ({
3225
userType = UserTypeEnum.UsStaff,
26+
staffAccountId = '12345',
3327
}) => (
3428
<ThemeProvider theme={theme}>
3529
<SnackbarProvider>
3630
<TestRouter>
3731
<GqlMockedProvider<{
38-
StaffAccount: StaffAccountQuery;
32+
GetUser: GetUserQuery;
3933
}>
4034
mocks={{
41-
...mocks,
4235
GetUser: {
43-
user: { userType },
36+
user: { userType, staffAccountId },
4437
},
4538
}}
4639
onCall={mutationSpy}
@@ -84,15 +77,17 @@ describe('Partner Reminders Report Page', () => {
8477

8578
it('renders no staff account page when no staff account', async () => {
8679
const mockNoStaffAccount = {
87-
StaffAccount: {
88-
staffAccount: null,
80+
GetUser: {
81+
user: {
82+
staffAccountId: null,
83+
},
8984
},
9085
};
9186

9287
const { findByText } = render(
9388
<TestRouter>
9489
<GqlMockedProvider<{
95-
StaffAccount: StaffAccountQuery;
90+
GetUser: GetUserQuery;
9691
}>
9792
mocks={mockNoStaffAccount}
9893
onCall={mutationSpy}

0 commit comments

Comments
 (0)