Skip to content

Commit f251dd1

Browse files
author
Katelyn Grimes
committed
Claude review suggestions round 1
1 parent 2253603 commit f251dd1

2 files changed

Lines changed: 19 additions & 36 deletions

File tree

src/components/Shared/UserTypeAccess/UserTypeAccess.test.tsx

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@ import TestRouter from '__tests__/util/TestRouter';
44
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
55
import { render } from '__tests__/util/testingLibraryReactMock';
66
import { HcmQuery } from 'src/components/HrTools/Shared/HcmData/Hcm.generated';
7-
import { StaffAccountQuery } from 'src/components/Shared/StaffAccount/StaffAccount.generated';
8-
import { GetUserQuery } from 'src/components/User/GetUser.generated';
9-
import {
10-
PeopleGroupSupportTypeEnum,
11-
UsStaffGroupEnum,
12-
UserPersonTypeEnum,
13-
UserTypeEnum,
14-
} from 'src/graphql/types.generated';
7+
import { UsStaffGroupEnum, UserTypeEnum } from 'src/graphql/types.generated';
158
import theme from 'src/theme';
169
import { RequiredUserGroupEnum, UserTypeAccess } from './UserTypeAccess';
1710

@@ -23,11 +16,6 @@ interface TestComponentProps {
2316
usStaffGroup?: UsStaffGroupEnum;
2417
staffAccountId?: string | null;
2518
requireUserGroups?: RequiredUserGroupEnum;
26-
asrEligible?: boolean;
27-
salaryRequestEligible?: boolean;
28-
designationSupportCalculatorEligible?: boolean;
29-
peopleGroupSupportType?: PeopleGroupSupportTypeEnum;
30-
userPersonType?: UserPersonTypeEnum;
3119
}
3220

3321
const TestComponent: React.FC<TestComponentProps> = ({
@@ -36,30 +24,13 @@ const TestComponent: React.FC<TestComponentProps> = ({
3624
usStaffGroup = UsStaffGroupEnum.PartTimeFieldStaff,
3725
staffAccountId = id,
3826
requireUserGroups,
39-
asrEligible = true,
40-
salaryRequestEligible = true,
41-
designationSupportCalculatorEligible = true,
42-
peopleGroupSupportType = PeopleGroupSupportTypeEnum.SupportedRmo,
43-
userPersonType = UserPersonTypeEnum.EmployeeHourly,
4427
}) => (
4528
<ThemeProvider theme={theme}>
4629
<TestRouter>
4730
<GqlMockedProvider<{
48-
StaffAccount: StaffAccountQuery;
49-
GetUser: GetUserQuery;
5031
Hcm: HcmQuery;
5132
}>
5233
mocks={{
53-
Hcm: {
54-
hcm: [
55-
{
56-
asrEit: { asrEligibility: asrEligible },
57-
salaryRequestEligible,
58-
designationSupportCalculatorEligible,
59-
staffInfo: { peopleGroupSupportType, userPersonType },
60-
},
61-
],
62-
},
6334
GetUser: { user: { userType, usStaffGroup, staffAccountId } },
6435
}}
6536
>
@@ -102,7 +73,7 @@ describe('UserTypeAccess', () => {
10273
const { findByRole, getByText } = render(
10374
<TestComponent
10475
requireUserGroups={RequiredUserGroupEnum.Asr}
105-
asrEligible={false}
76+
usStaffGroup={UsStaffGroupEnum.PartTimeFieldStaff}
10677
/>,
10778
);
10879

@@ -122,7 +93,7 @@ describe('UserTypeAccess', () => {
12293
const { findByRole, getByText } = render(
12394
<TestComponent
12495
requireUserGroups={RequiredUserGroupEnum.SalaryCalc}
125-
salaryRequestEligible={false}
96+
usStaffGroup={UsStaffGroupEnum.PartTimeFieldStaff}
12697
/>,
12798
);
12899

@@ -142,7 +113,7 @@ describe('UserTypeAccess', () => {
142113
const { findByRole } = render(
143114
<TestComponent
144115
requireUserGroups={RequiredUserGroupEnum.MpdGoalCalc}
145-
salaryRequestEligible={false}
116+
usStaffGroup={UsStaffGroupEnum.PartTimeFieldStaff}
146117
/>,
147118
);
148119
expect(
@@ -156,7 +127,7 @@ describe('UserTypeAccess', () => {
156127
const { findByRole } = render(
157128
<TestComponent
158129
requireUserGroups={RequiredUserGroupEnum.PdsGoalCalc}
159-
designationSupportCalculatorEligible={false}
130+
usStaffGroup={UsStaffGroupEnum.PartTimeFieldStaff}
160131
/>,
161132
);
162133
expect(
@@ -170,7 +141,6 @@ describe('UserTypeAccess', () => {
170141
const { findByText } = render(
171142
<TestComponent
172143
requireUserGroups={RequiredUserGroupEnum.PdsGoalCalc}
173-
designationSupportCalculatorEligible={true}
174144
usStaffGroup={UsStaffGroupEnum.PaidWithDesignation}
175145
/>,
176146
);

src/hooks/useIneligibleByGroup.test.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { UsStaffGroupEnum, UserTypeEnum } from 'src/graphql/types.generated';
77
import { useIneligibleByGroup } from './useIneligibleByGroup';
88

99
interface MockUser {
10-
usStaffGroup?: UsStaffGroupEnum;
10+
usStaffGroup?: UsStaffGroupEnum | null;
1111
userType?: UserTypeEnum;
1212
staffAccountId?: string | null;
1313
}
@@ -149,5 +149,18 @@ describe('useIneligibleByGroup', () => {
149149
expect(result.current.inMpdGoalCalcIneligibleGroup).toBe(true);
150150
expect(result.current.inPdsGoalCalcIneligibleGroup).toBe(true);
151151
});
152+
153+
it('no us staff group eligibility', async () => {
154+
const { result } = renderUseIneligibleByGroup({
155+
usStaffGroup: null,
156+
});
157+
158+
await waitFor(() => expect(result.current.userLoading).toBe(false));
159+
expect(result.current.inAsrIneligibleGroup).toBe(true);
160+
expect(result.current.inSalaryCalcIneligibleGroup).toBe(true);
161+
expect(result.current.inMhaIneligibleGroup).toBe(true);
162+
expect(result.current.inMpdGoalCalcIneligibleGroup).toBe(true);
163+
expect(result.current.inPdsGoalCalcIneligibleGroup).toBe(true);
164+
});
152165
});
153166
});

0 commit comments

Comments
 (0)