Skip to content

Commit

Permalink
Merge pull request #1480 from Availity/feature/feedback-form
Browse files Browse the repository at this point in the history
feat: ON-10523 feedback text area optional in feedback form component
  • Loading branch information
dhruv-availity authored Oct 23, 2024
2 parents ae40619 + eed0e83 commit 11fd4d7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/feedback/src/FeedbackForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const FeedbackForm = ({
onClose,
faceOptions,
aboutOptions = [],
feedbackText = true,
aboutLabel = 'This is about',
onFeedbackSent,
prompt,
Expand Down Expand Up @@ -129,7 +130,10 @@ const FeedbackForm = ({
smileField: undefined,
}}
validationSchema={yup.object().shape({
feedback: yup.string().max(200, 'Feedback cannot exceed 200 characters.').required('This field is required.'),
feedback: yup
.string()
.max(200, 'Feedback cannot exceed 200 characters.')
.isRequired(feedbackText, 'This field is required.'),
additionalFeedback: yup.string().max(200, 'Additional Feedback cannot exceed 200 characters.'),
smileField: yup
.object()
Expand Down Expand Up @@ -276,6 +280,8 @@ FeedbackForm.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
})
),
/** If false, then feedback text area is made optional */
feedbackText: PropTypes.bool,
/** Label text for the dropdown created via the aboutOptions prop. Default: "This is about".
*Previously aboutPlaceholder. All placeholders replaced with labels starting v6.0.0. */
aboutLabel: PropTypes.node,
Expand Down
22 changes: 22 additions & 0 deletions packages/feedback/tests/FeedbackForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ describe('FeedbackForm', () => {
);
});

test('should submit without feedback text value when feedbackText set to false', async () => {
const onFeedbackSent = jest.fn();

const { getByText } = render(<FeedbackForm onFeedbackSent={onFeedbackSent} name="Payer Space" feedbackText={false}/>);

// Simulate the Click
fireEvent.click(getByText('Smiley face'));

fireEvent.click(getByText('Send Feedback'));

await waitFor(
() => {
expect(onFeedbackSent).toHaveBeenCalledWith(
expect.objectContaining({
active: 'smile',
})
);
},
{ timeout: 2500 }
);
});

test('should submit and disable button when clicked', async () => {
// mock log messages api to return a promise that resolves after 3 seconds
avLogMessagesApiV2.info = jest.fn(
Expand Down

0 comments on commit 11fd4d7

Please sign in to comment.