Skip to content

Commit

Permalink
✅ Replace interaction test with jest test
Browse files Browse the repository at this point in the history
The focus/blur and race conditions in CI lead to flaky tests.
  • Loading branch information
sergei-maertens committed Aug 16, 2024
1 parent be03945 commit 119bcff
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 62 deletions.
41 changes: 41 additions & 0 deletions src/registry/select/select-validation.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,44 @@ test('Option values and labels are required fields', async () => {
expect(await screen.findByText('The option label is a required field.')).toBeVisible();
expect(await screen.findByText('The option value is a required field.')).toBeVisible();
});

test('There is always at least one option', async () => {
const onSubmit = jest.fn();
const component = {
id: 'wqimsadk',
type: 'select',
key: 'select',
label: 'A select field',
dataSrc: 'values',
openForms: {
dataSrc: 'manual',
translations: {},
},
data: {
values: [],
},
defaultValue: '',
} satisfies SelectComponentSchema;

const builderInfo = {
title: 'Select',
icon: 'th-list',
group: 'basic',
weight: 70,
schema: {},
};
contextRender(
<ComponentEditForm
isNew
component={component}
builderInfo={builderInfo}
onCancel={jest.fn()}
onRemove={jest.fn()}
onSubmit={onSubmit}
/>
);

// wait for first value to be added
const firstValueLabel = await screen.findByTestId('input-data.values[0].label');
expect(firstValueLabel).toBeVisible();
});
62 changes: 0 additions & 62 deletions src/registry/select/select-validation.stories.ts

This file was deleted.

0 comments on commit 119bcff

Please sign in to comment.