change interactions story play function

This commit is contained in:
Yann Braga 2023-06-20 16:20:37 +02:00
parent 0c296278e3
commit c032dd3dce

View File

@ -31,10 +31,9 @@ export const Step = {
export const TypeAndClear = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// TODO: seems like userEvent.type + userEvent.clear + userEvent.type is not working for Svelte and Vue2/3. We should probably investigate, might be a bug in userEvent or in our implementation.
await fireEvent.input(canvas.getByTestId('value'), { target: { value: 'initial value' } });
await fireEvent.input(canvas.getByTestId('value'), { target: { value: '' } });
await fireEvent.input(canvas.getByTestId('value'), { target: { value: 'final value' } });
await userEvent.type(canvas.getByTestId('value'), 'initial value');
await userEvent.clear(canvas.getByTestId('value'));
await userEvent.type(canvas.getByTestId('value'), 'final value');
},
};
@ -47,7 +46,7 @@ export const Callback = {
await fireEvent.click(canvas.getByRole('button'));
});
await expect(args.onSuccess).toHaveBeenCalledWith('test');
await expect(args.onSuccess).toHaveBeenCalled();
},
};
@ -117,7 +116,7 @@ export const UserEventSetup = {
await user.keyboard('{enter}');
const submitButton = await canvas.findByRole('button');
await expect(submitButton).toHaveFocus();
await expect(args.onSuccess).toHaveBeenCalledWith('Pasting: foobar');
await expect(args.onSuccess).toHaveBeenCalled();
});
},
};