Skip to content

Commit

Permalink
💚 Try to make tests more reliable
Browse files Browse the repository at this point in the history
Part too-many.
  • Loading branch information
sergei-maertens committed Nov 13, 2023
1 parent 006ae2f commit 70fcd21
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const Default: Story = {
const input = canvas.getByLabelText('Plugin(s)');

// open the dropdown
input.focus();
await userEvent.click(input);
await userEvent.keyboard('[ArrowDown]');

await step('Check available options displayed', async () => {
Expand Down
52 changes: 31 additions & 21 deletions src/registry/file/file-validation.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,33 +103,39 @@ export const MaxFileSize: Story = {
await userEvent.clear(fileSize);
await userEvent.type(fileSize, '-10MB');
await userEvent.keyboard('[Tab]');
expect(
await canvas.findByText(
'Specify a positive, non-zero file size without decimals, e.g. 10MB.'
)
).toBeVisible();
await waitFor(async () => {
expect(
await canvas.findByText(
'Specify a positive, non-zero file size without decimals, e.g. 10MB.'
)
).toBeVisible();
});
});

await step('Decimal file size (period)', async () => {
await userEvent.clear(fileSize);
await userEvent.type(fileSize, '10.5MB');
await userEvent.keyboard('[Tab]');
expect(
await canvas.findByText(
'Specify a positive, non-zero file size without decimals, e.g. 10MB.'
)
).toBeVisible();
await waitFor(async () => {
expect(
await canvas.findByText(
'Specify a positive, non-zero file size without decimals, e.g. 10MB.'
)
).toBeVisible();
});
});

await step('Decimal file size (comma)', async () => {
await userEvent.clear(fileSize);
await userEvent.type(fileSize, '10,5 MB');
await userEvent.keyboard('[Tab]');
expect(
await canvas.findByText(
'Specify a positive, non-zero file size without decimals, e.g. 10MB.'
)
).toBeVisible();
await waitFor(async () => {
expect(
await canvas.findByText(
'Specify a positive, non-zero file size without decimals, e.g. 10MB.'
)
).toBeVisible();
});
});
},
};
Expand All @@ -147,18 +153,22 @@ export const ValidMaxFileSize: Story = {
await userEvent.clear(fileSize);
await userEvent.type(fileSize, '15 mb');
await userEvent.keyboard('[Tab]');
expect(
canvas.queryByText('Specify a positive, non-zero file size without decimals, e.g. 10MB.')
).not.toBeInTheDocument();
await waitFor(async () => {
expect(
canvas.queryByText('Specify a positive, non-zero file size without decimals, e.g. 10MB.')
).not.toBeInTheDocument();
});
});

await step('Accept non-MB values', async () => {
await userEvent.clear(fileSize);
await userEvent.type(fileSize, '200 KB');
await userEvent.keyboard('[Tab]');
expect(
canvas.queryByText('Specify a positive, non-zero file size without decimals, e.g. 10MB.')
).not.toBeInTheDocument();
await waitFor(async () => {
expect(
canvas.queryByText('Specify a positive, non-zero file size without decimals, e.g. 10MB.')
).not.toBeInTheDocument();
});
});
},
};
Expand Down

0 comments on commit 70fcd21

Please sign in to comment.