Skip to content

Commit

Permalink
Adding a new funding source test case (#237)
Browse files Browse the repository at this point in the history
add funding source test case
  • Loading branch information
sdevalapurkar authored Apr 16, 2021
1 parent bea4a3e commit 3df47f7
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 40 deletions.
1 change: 1 addition & 0 deletions app/src/components/fields/DollarAmountField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const DollarAmountField: React.FC<IDollarAmountFieldProps> = (props) => {
InputProps={{
inputComponent: NumberFormatCustom as any
}}
inputProps={{ 'data-testid': name }}
/>
);
};
Expand Down
6 changes: 2 additions & 4 deletions app/src/components/fields/StartEndDateFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ const StartEndDateFields: React.FC<IStartEndDateFieldsProps> = (props) => {
<TextField
id="start_date"
name="start_date"
data-testid="start-date"
label="Start Date"
variant="outlined"
required={startRequired}
value={values.start_date}
type="date"
inputProps={{ min: DATE_LIMIT.min, max: DATE_LIMIT.max }}
inputProps={{ min: DATE_LIMIT.min, max: DATE_LIMIT.max, 'data-testid': 'start-date' }}
onChange={handleChange}
error={touched.start_date && Boolean(errors.start_date)}
helperText={errors.start_date}
Expand All @@ -45,13 +44,12 @@ const StartEndDateFields: React.FC<IStartEndDateFieldsProps> = (props) => {
<TextField
id="end_date"
name="end_date"
data-testid="end-date"
label="End Date"
variant="outlined"
required={endRequired}
value={values.end_date}
type="date"
inputProps={{ min: DATE_LIMIT.min, max: DATE_LIMIT.max }}
inputProps={{ min: DATE_LIMIT.min, max: DATE_LIMIT.max, 'data-testid': 'end-date' }}
onChange={handleChange}
error={touched.end_date && Boolean(errors.end_date)}
helperText={errors.end_date}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ exports[`DollarAmountField matches the snapshot with error 1`] = `
aria-describedby="id-helper-text"
aria-invalid="true"
class="MuiInputBase-input MuiOutlinedInput-input"
data-testid="name"
id="id"
inputmode="numeric"
name="name"
Expand Down Expand Up @@ -81,6 +82,7 @@ exports[`DollarAmountField matches the snapshot without error 1`] = `
<input
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input"
data-testid="name"
id="id"
inputmode="numeric"
name="name"
Expand Down
17 changes: 6 additions & 11 deletions app/src/features/projects/components/ProjectFundingItemForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ const ProjectFundingItemForm: React.FC<IProjectFundingItemFormProps> = (props) =
<Select
id="agency_id"
name="agency_id"
data-testid="agency-id"
labelId="agency_id-label"
label="Agency Name"
value={values.agency_id}
Expand All @@ -118,7 +117,7 @@ const ProjectFundingItemForm: React.FC<IProjectFundingItemFormProps> = (props) =
}}
error={touched.agency_id && Boolean(errors.agency_id)}
displayEmpty
inputProps={{ 'aria-label': 'Agency Name' }}>
inputProps={{ 'aria-label': 'Agency Name', 'data-testid': 'agency-id' }}>
{props.funding_sources.map((item) => (
<MenuItem key={item.value} value={item.value}>
{item.label}
Expand All @@ -135,14 +134,16 @@ const ProjectFundingItemForm: React.FC<IProjectFundingItemFormProps> = (props) =
<Select
id="investment_action_category"
name="investment_action_category"
test-dataid="investment_action_category"
labelId="investment_action_category-label"
label={investment_action_category_label}
value={values.investment_action_category}
onChange={handleChange}
error={touched.investment_action_category && Boolean(errors.investment_action_category)}
displayEmpty
inputProps={{ 'aria-label': `${investment_action_category_label}` }}>
inputProps={{
'aria-label': `${investment_action_category_label}`,
'data-testid': 'investment_action_category'
}}>
{props.investment_action_category
// Only show the investment action categories whose fs_id matches the agency_id id
.filter((item) => item.fs_id === values.agency_id)
Expand Down Expand Up @@ -176,13 +177,7 @@ const ProjectFundingItemForm: React.FC<IProjectFundingItemFormProps> = (props) =
<FormLabel component="legend">Funding Details</FormLabel>
<Grid container spacing={3}>
<Grid item xs={12}>
<DollarAmountField
test-dataid="funding-amount"
required={true}
id="funding_amount"
name="funding_amount"
label="Funding Amount"
/>
<DollarAmountField required={true} id="funding_amount" name="funding_amount" label="Funding Amount" />
</Grid>
<StartEndDateFields formikProps={formikProps} startRequired={true} endRequired={true} />
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ exports[`ProjectDetailsForm renders correctly with default empty values 1`] = `
>
<div
class="MuiFormControl-root MuiTextField-root"
data-testid="start-date"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined Mui-required Mui-required"
Expand All @@ -361,6 +360,7 @@ exports[`ProjectDetailsForm renders correctly with default empty values 1`] = `
<input
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input"
data-testid="start-date"
id="start_date"
max="2100-12-31"
min="1900-01-01"
Expand Down Expand Up @@ -389,7 +389,6 @@ exports[`ProjectDetailsForm renders correctly with default empty values 1`] = `
>
<div
class="MuiFormControl-root MuiTextField-root"
data-testid="end-date"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined"
Expand All @@ -405,6 +404,7 @@ exports[`ProjectDetailsForm renders correctly with default empty values 1`] = `
<input
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input"
data-testid="end-date"
id="end_date"
max="2100-12-31"
min="1900-01-01"
Expand Down Expand Up @@ -858,7 +858,6 @@ exports[`ProjectDetailsForm renders correctly with existing details values 1`] =
>
<div
class="MuiFormControl-root MuiTextField-root"
data-testid="start-date"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-filled Mui-required Mui-required"
Expand All @@ -880,6 +879,7 @@ exports[`ProjectDetailsForm renders correctly with existing details values 1`] =
<input
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input"
data-testid="start-date"
id="start_date"
max="2100-12-31"
min="1900-01-01"
Expand Down Expand Up @@ -908,7 +908,6 @@ exports[`ProjectDetailsForm renders correctly with existing details values 1`] =
>
<div
class="MuiFormControl-root MuiTextField-root"
data-testid="end-date"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-filled"
Expand All @@ -924,6 +923,7 @@ exports[`ProjectDetailsForm renders correctly with existing details values 1`] =
<input
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input"
data-testid="end-date"
id="end_date"
max="2100-12-31"
min="1900-01-01"
Expand Down
Loading

0 comments on commit 3df47f7

Please sign in to comment.