Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update access request page: remove regional offices section, remove non-supported roles from dropdown #610

Merged
merged 3 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions app/src/pages/access/AccessRequestPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,27 @@ describe('AccessRequestPage', () => {
});
});

it('shows and hides the regional offices section when the regional offices radio button is selected (respectively)', async () => {
mockBiohubApi().codes.getAllCodeSets.mockResolvedValue({
system_roles: [{ id: 1, name: 'Role 1' }],
regional_offices: [{ id: 1, name: 'Office 1' }]
});
// TODO Release 1 Patch (BHBC-1442): Remove regional offices
// it('shows and hides the regional offices section when the regional offices radio button is selected (respectively)', async () => {
// mockBiohubApi().codes.getAllCodeSets.mockResolvedValue({
// system_roles: [{ id: 1, name: 'Role 1' }],
// regional_offices: [{ id: 1, name: 'Office 1' }]
// });

const { queryByText, getByText, getByTestId } = renderContainer();
// const { queryByText, getByText, getByTestId } = renderContainer();

expect(queryByText('Which Regional Offices do you work for?')).toBeNull();
// expect(queryByText('Which Regional Offices do you work for?')).toBeNull();

fireEvent.click(getByTestId('yes-regional-office'));
// fireEvent.click(getByTestId('yes-regional-office'));

await waitFor(() => {
expect(getByText('Which Regional Offices do you work for?')).toBeInTheDocument();
});
// await waitFor(() => {
// expect(getByText('Which Regional Offices do you work for?')).toBeInTheDocument();
// });

fireEvent.click(getByTestId('no-regional-office'));
// fireEvent.click(getByTestId('no-regional-office'));

expect(queryByText('Which Regional Offices do you work for?')).toBeNull();
});
// expect(queryByText('Which Regional Offices do you work for?')).toBeNull();
// });

it('processes a successful request submission', async () => {
mockBiohubApi().codes.getAllCodeSets.mockResolvedValue({
Expand All @@ -168,7 +169,7 @@ describe('AccessRequestPage', () => {
});

fireEvent.click(systemRoleListbox.getByText(/Role 1/i));
fireEvent.click(getByTestId('no-regional-office'));
// fireEvent.click(getByTestId('no-regional-office')); // TODO Release 1 Patch (BHBC-1442): Remove regional offices
fireEvent.click(getByText('Submit Request'));

await waitFor(() => {
Expand Down Expand Up @@ -235,7 +236,7 @@ describe('AccessRequestPage', () => {
});

fireEvent.click(systemRoleListbox.getByText(/Role 1/i));
fireEvent.click(getByTestId('no-regional-office'));
// fireEvent.click(getByTestId('no-regional-office')); // TODO Release 1 Patch (BHBC-1442): Remove regional offices
fireEvent.click(getByText('Submit Request'));

await waitFor(() => {
Expand Down Expand Up @@ -270,7 +271,7 @@ describe('AccessRequestPage', () => {
});

fireEvent.click(systemRoleListbox.getByText(/Role 1/i));
fireEvent.click(getByTestId('no-regional-office'));
// fireEvent.click(getByTestId('no-regional-office')); // TODO Release 1 Patch (BHBC-1442): Remove regional offices
fireEvent.click(getByText('Submit Request'));

await waitFor(() => {
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/access/AccessRequestPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const AccessRequestPage: React.FC = () => {
{({ handleSubmit }) => (
<>
<Box>
<h1>Request Access to BioHub</h1>
<h1>Request Access to SIMS</h1>
<Typography variant="subtitle1" className={classes.spacingBottom}>
You will need to provide some additional details before accessing this application. Complete the form
below to request access.
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/access/BCeIDRequestForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const BCeIDRequestForm = () => {
/>
</Grid>
<Grid item xs={12}>
<h3>Why are you requesting access to Biohub?</h3>
<h3>Why are you requesting access to SIMS?</h3>
<CustomTextField name="request_reason" label="Request Reason" other={{ multiline: true, rows: 4 }} />
</Grid>
</Grid>
Expand Down
94 changes: 49 additions & 45 deletions app/src/pages/access/IDIRRequestForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export const IDIRRequestFormInitialValues: IIDIRRequestForm = {

export const IDIRRequestFormYupSchema = yup.object().shape({
role: yup.string().required('Required'),
work_from_regional_office: yup.string().required('Required'),
regional_offices: yup
.array()
.when('work_from_regional_office', { is: 'true', then: yup.array().min(1, 'Required').required('Required') }),
// work_from_regional_office: yup.string().required('Required'), // TODO Release 1 Patch (BHBC-1442): Remove field validation
// regional_offices: yup
// .array()
// .when('work_from_regional_office', { is: 'true', then: yup.array().min(1, 'Required').required('Required') }), // TODO Release 1 Patch (BHBC-1442): Remove field validation
comments: yup.string().max(300, 'Maximum 300 characters')
});

Expand Down Expand Up @@ -82,52 +82,56 @@ const IDIRRequestForm: React.FC<IIDIRRequestFormProps> = (props) => {
error={touched.role && Boolean(errors.role)}
displayEmpty
inputProps={{ 'aria-label': 'Role' }}>
{codes?.system_roles.map((item) => (
<MenuItem key={item.id} value={item.id}>
{item.name}
</MenuItem>
))}
{codes?.system_roles
.filter((item) => item.id <= 2) // TODO Release 1 Patch (BHBC-1442): remove other roles from dropdown
.map((item) => (
<MenuItem key={item.id} value={item.id}>
{item.name}
</MenuItem>
))}
</Select>
<FormHelperText>{errors.role}</FormHelperText>
</FormControl>
</Grid>

<Grid item xs={12}>
<FormControl
required={true}
component="fieldset"
onChange={(event: any) => {
if (event.target.value === 'false') {
setFieldValue('regional_offices', []);
}
}}
error={touched.work_from_regional_office && Boolean(errors.work_from_regional_office)}>
<FormLabel component="legend" className={classes.legend}>
Do you work for a Regional Office?
</FormLabel>
<Box mt={2}>
<RadioGroup
name="work_from_regional_office"
aria-label="work_from_regional_office"
value={values.work_from_regional_office}
onChange={handleChange}>
<FormControlLabel
value="true"
data-testid="yes-regional-office"
control={<Radio required={true} color="primary" />}
label="Yes"
/>
<FormControlLabel
value="false"
data-testid="no-regional-office"
control={<Radio required={true} color="primary" />}
label="No"
/>
<FormHelperText>{errors.work_from_regional_office}</FormHelperText>
</RadioGroup>
</Box>
</FormControl>
</Grid>
{false && ( // TODO Release 1 Patch (BHBC-1442): Remove regional offices section
<Grid item xs={12}>
<FormControl
required={true}
component="fieldset"
onChange={(event: any) => {
if (event.target.value === 'false') {
setFieldValue('regional_offices', []);
}
}}
error={touched.work_from_regional_office && Boolean(errors.work_from_regional_office)}>
<FormLabel component="legend" className={classes.legend}>
Do you work for a Regional Office?
</FormLabel>
<Box mt={2}>
<RadioGroup
name="work_from_regional_office"
aria-label="work_from_regional_office"
value={values.work_from_regional_office}
onChange={handleChange}>
<FormControlLabel
value="true"
data-testid="yes-regional-office"
control={<Radio required={true} color="primary" />}
label="Yes"
/>
<FormControlLabel
value="false"
data-testid="no-regional-office"
control={<Radio required={true} color="primary" />}
label="No"
/>
<FormHelperText>{errors.work_from_regional_office}</FormHelperText>
</RadioGroup>
</Box>
</FormControl>
</Grid>
)}

{values.work_from_regional_office === 'true' && (
<Grid item xs={12}>
Expand Down
146 changes: 4 additions & 142 deletions app/src/pages/access/__snapshots__/AccessRequestPage.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`AccessRequestPage renders correctly 1`] = `
class="MuiBox-root MuiBox-root-10"
>
<h1>
Request Access to BioHub
Request Access to SIMS
</h1>
<h6
class="MuiTypography-root makeStyles-spacingBottom-7 MuiTypography-subtitle1"
Expand Down Expand Up @@ -110,144 +110,6 @@ exports[`AccessRequestPage renders correctly 1`] = `
/>
</div>
</div>
<div
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12"
>
<fieldset
class="MuiFormControl-root"
>
<legend
class="MuiFormLabel-root makeStyles-legend-12 Mui-required"
>
Do you work for a Regional Office?
<span
aria-hidden="true"
class="MuiFormLabel-asterisk"
>
 *
</span>
</legend>
<div
class="MuiBox-root MuiBox-root-18"
>
<div
aria-label="work_from_regional_office"
class="MuiFormGroup-root"
role="radiogroup"
>
<label
class="MuiFormControlLabel-root"
data-testid="yes-regional-office"
>
<span
aria-disabled="false"
class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-19 MuiRadio-root MuiRadio-colorPrimary MuiIconButton-colorPrimary"
>
<span
class="MuiIconButton-label"
>
<input
class="PrivateSwitchBase-input-22"
name="work_from_regional_office"
required=""
type="radio"
value="true"
/>
<div
class="PrivateRadioButtonIcon-root-23"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
/>
</svg>
<svg
aria-hidden="true"
class="MuiSvgIcon-root PrivateRadioButtonIcon-layer-24"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M8.465 8.465C9.37 7.56 10.62 7 12 7C14.76 7 17 9.24 17 12C17 13.38 16.44 14.63 15.535 15.535C14.63 16.44 13.38 17 12 17C9.24 17 7 14.76 7 12C7 10.62 7.56 9.37 8.465 8.465Z"
/>
</svg>
</div>
</span>
<span
class="MuiTouchRipple-root"
/>
</span>
<span
class="MuiTypography-root MuiFormControlLabel-label MuiTypography-body1"
>
Yes
</span>
</label>
<label
class="MuiFormControlLabel-root"
data-testid="no-regional-office"
>
<span
aria-disabled="false"
class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-19 MuiRadio-root MuiRadio-colorPrimary MuiIconButton-colorPrimary"
>
<span
class="MuiIconButton-label"
>
<input
class="PrivateSwitchBase-input-22"
name="work_from_regional_office"
required=""
type="radio"
value="false"
/>
<div
class="PrivateRadioButtonIcon-root-23"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
/>
</svg>
<svg
aria-hidden="true"
class="MuiSvgIcon-root PrivateRadioButtonIcon-layer-24"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M8.465 8.465C9.37 7.56 10.62 7 12 7C14.76 7 17 9.24 17 12C17 13.38 16.44 14.63 15.535 15.535C14.63 16.44 13.38 17 12 17C9.24 17 7 14.76 7 12C7 10.62 7.56 9.37 8.465 8.465Z"
/>
</svg>
</div>
</span>
<span
class="MuiTouchRipple-root"
/>
</span>
<span
class="MuiTypography-root MuiFormControlLabel-label MuiTypography-body1"
>
No
</span>
</label>
<p
class="MuiFormHelperText-root Mui-required"
/>
</div>
</div>
</fieldset>
</div>
<div
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12"
>
Expand Down Expand Up @@ -293,17 +155,17 @@ exports[`AccessRequestPage renders correctly 1`] = `
</div>
</div>
<div
class="MuiBox-root MuiBox-root-26"
class="MuiBox-root MuiBox-root-18"
>
<hr
class="MuiDivider-root"
/>
</div>
<div
class="MuiBox-root MuiBox-root-27"
class="MuiBox-root MuiBox-root-19"
>
<div
class="MuiBox-root MuiBox-root-28 buttonWrapper"
class="MuiBox-root MuiBox-root-20 buttonWrapper"
>
<button
class="MuiButtonBase-root MuiButton-root MuiButton-contained makeStyles-actionButton-1 MuiButton-containedPrimary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports[`BCeIDRequestForm matches the snapshot 1`] = `
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12"
>
<h3>
Why are you requesting access to Biohub?
Why are you requesting access to SIMS?
</h3>
<div
class="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth"
Expand Down