Skip to content

Commit

Permalink
fix: add ids and classnames for e2e tests (#526)
Browse files Browse the repository at this point in the history
* Add description test id to TextAreaAutoSize

Required for cypress tests

* Add optional class name and id to RenderField

For cypress testing
  • Loading branch information
Lael Birch authored Apr 14, 2021
1 parent a9c731a commit d2499a1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/components/CodeAssignmentModal/BulkAssignFields.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const BulkAssignFields = () => (
component={TextAreaAutoSize}
label="Email Addresses"
description="To add more than one user, enter one email address per line."
descriptionTestId="email-addresses-help-text"
/>
<p className="pb-2">
OR
Expand All @@ -24,6 +25,7 @@ const BulkAssignFields = () => (
component={FileInput}
label="Upload Email Addresses"
description="The file must be a CSV containing a single column of email addresses."
descriptionTestId="csv-email-addresses-help-text"
accept=".csv"
normalize={normalizeFileUpload}
/>
Expand Down
8 changes: 7 additions & 1 deletion src/components/RenderField/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ const RenderField = ({
description,
disabled,
required,
className,
id,
meta: { touched, error },
}) => {
const hasError = !!(touched && error);
return (
<Form.Group>
<Form.Group id={id} className={className}>
<Form.Label>{label}</Form.Label>
<Form.Control
{...input}
Expand All @@ -34,6 +36,8 @@ RenderField.defaultProps = {
description: null,
disabled: false,
required: false,
className: null,
id: null,
};

RenderField.propTypes = {
Expand All @@ -48,6 +52,8 @@ RenderField.propTypes = {
description: PropTypes.string,
disabled: PropTypes.bool,
required: PropTypes.bool,
className: PropTypes.string,
id: PropTypes.string,
};

export default RenderField;
4 changes: 4 additions & 0 deletions src/components/RequestCodesPage/RequestCodesForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class RequestCodesForm extends React.Component {
<form onSubmit={handleSubmit}>
<Field
name="emailAddress"
className="emailAddress"
type="email"
component={RenderField}
label={(
Expand All @@ -81,6 +82,7 @@ class RequestCodesForm extends React.Component {
/>
<Field
name="enterpriseName"
className="enterpriseName"
type="text"
component={RenderField}
label={(
Expand All @@ -95,13 +97,15 @@ class RequestCodesForm extends React.Component {
/>
<Field
name="numberOfCodes"
className="numberOfCodes"
type="number"
component={RenderField}
label="Number of Codes"
validate={[isValidNumber]}
/>
<Field
name="notes"
className="notes"
type="text"
component={RenderField}
label="Notes"
Expand Down
5 changes: 4 additions & 1 deletion src/components/TextAreaAutoSize/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const TextAreaAutoSize = ({
disabled,
required,
meta: { touched, error },
descriptionTestId,
}) => {
const hasError = !!(touched && error);

Expand All @@ -26,7 +27,7 @@ const TextAreaAutoSize = ({
rows={3}
/>
{hasError && <FormControl.Feedback type="invalid">{error}</FormControl.Feedback>}
{description && <Form.Text>{description}</Form.Text>}
{description && <Form.Text id={descriptionTestId}>{description}</Form.Text>}
</Form.Group>
);
};
Expand All @@ -35,6 +36,7 @@ TextAreaAutoSize.defaultProps = {
description: null,
disabled: false,
required: false,
descriptionTestId: 'textarea-helptext',
};

TextAreaAutoSize.propTypes = {
Expand All @@ -47,6 +49,7 @@ TextAreaAutoSize.propTypes = {
description: PropTypes.string,
disabled: PropTypes.bool,
required: PropTypes.bool,
descriptionTestId: PropTypes.string,
};

export default TextAreaAutoSize;

0 comments on commit d2499a1

Please sign in to comment.