diff --git a/awx/ui_next/src/components/FieldWithPrompt/FieldWithPrompt.jsx b/awx/ui_next/src/components/FieldWithPrompt/FieldWithPrompt.jsx
index 26a6dac3f2..6328c9f26a 100644
--- a/awx/ui_next/src/components/FieldWithPrompt/FieldWithPrompt.jsx
+++ b/awx/ui_next/src/components/FieldWithPrompt/FieldWithPrompt.jsx
@@ -1,5 +1,5 @@
import React from 'react';
-import PropTypes from 'prop-types';
+import { bool, func, node, string } from 'prop-types';
import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro';
import { Tooltip } from '@patternfly/react-core';
@@ -72,13 +72,14 @@ function FieldWithPrompt({
}
FieldWithPrompt.propTypes = {
- fieldId: PropTypes.string.isRequired,
- isRequired: PropTypes.bool,
- label: PropTypes.string.isRequired,
- promptId: PropTypes.string.isRequired,
- promptValidate: PropTypes.func,
- tooltip: PropTypes.node,
- tooltipMaxWidth: PropTypes.string,
+ fieldId: string.isRequired,
+ isRequired: bool,
+ label: string.isRequired,
+ promptId: string.isRequired,
+ promptName: string.isRequired,
+ promptValidate: func,
+ tooltip: node,
+ tooltipMaxWidth: string,
};
FieldWithPrompt.defaultProps = {
diff --git a/awx/ui_next/src/components/FieldWithPrompt/FieldWithPrompt.test.jsx b/awx/ui_next/src/components/FieldWithPrompt/FieldWithPrompt.test.jsx
new file mode 100644
index 0000000000..4358737144
--- /dev/null
+++ b/awx/ui_next/src/components/FieldWithPrompt/FieldWithPrompt.test.jsx
@@ -0,0 +1,66 @@
+import React from 'react';
+import { mountWithContexts } from '@testUtils/enzymeHelpers';
+import { Field, Formik } from 'formik';
+import FieldWithPrompt from './FieldWithPrompt';
+
+describe('FieldWithPrompt', () => {
+ let wrapper;
+
+ afterEach(() => {
+ wrapper.unmount();
+ });
+
+ test('Required asterisk and Tooltip hidden when not required and tooltip not provided', () => {
+ wrapper = mountWithContexts(
+
+ {() => (
+
+
+ {() => }
+
+
+ )}
+
+ );
+ expect(wrapper.find('.pf-c-form__label-required')).toHaveLength(0);
+ expect(wrapper.find('Tooltip')).toHaveLength(0);
+ });
+
+ test('Required asterisk and Tooltip shown when required and tooltip provided', () => {
+ wrapper = mountWithContexts(
+
+ {() => (
+
+
+ {() => }
+
+
+ )}
+
+ );
+ expect(wrapper.find('.pf-c-form__label-required')).toHaveLength(1);
+ expect(wrapper.find('Tooltip')).toHaveLength(1);
+ });
+});