Skip to content

Commit 46a73c6

Browse files
committed
Fix failing tests
1 parent 8ba2aaa commit 46a73c6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Diff for: src/components/field-label/field-label.component.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ const FieldLabelContent: React.FC<FieldLabelContentProps> = ({ field, customLabe
3131
const { t } = useTranslation();
3232
const labelText = customLabel || t(field.label);
3333
return (
34-
<div className={styles.questionLabel}>
34+
<div className={styles.questionLabel} data-testid={`${field.id}-label`}>
3535
<span>{labelText}</span>
3636
{field.isRequired && (
3737
<span title={t('required', 'Required')} className={styles.required}>
3838
*
3939
</span>
4040
)}
41-
{hasTooltip && <Information size={20} aria-hidden="true" className={styles.tooltipIcon} />}
41+
{hasTooltip && (
42+
<Information size={20} aria-hidden="true" className={styles.tooltipIcon} data-testid="information-icon" />
43+
)}
4244
</div>
4345
);
4446
};

Diff for: src/form-engine.test.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,12 @@ describe('Form engine component', () => {
267267

268268
screen.findByRole('textbox', { name: /text question/i });
269269

270-
const textFieldTooltip = screen.getByTestId('id_text');
270+
const textFieldTooltip = screen.getByTestId('id_text-label');
271271
expect(textFieldTooltip).toBeInTheDocument();
272272

273+
const informationIcon = screen.getByTestId('information-icon');
274+
expect(informationIcon).toBeInTheDocument();
275+
273276
await user.hover(textFieldTooltip);
274277
await screen.findByText(/sample tooltip info for text/i);
275278
});

0 commit comments

Comments
 (0)