Skip to content

Commit

Permalink
Try using fireEvent for comboboxes. On linux machines, user event tri…
Browse files Browse the repository at this point in the history
…ggers some errors.
  • Loading branch information
dompuiu committed Feb 10, 2023
1 parent 46f00de commit f38d865
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/view/__tests_helpers__/jsDomHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export const changeInputValue = async (input, value) => {
}
};

export const changeComboboxValue = async (input, value) => {
fireEvent.change(input, { target: { value } });
};

export const click = async (newTab) => {
await userEvent.click(newTab);
};
Expand Down
14 changes: 7 additions & 7 deletions src/view/actions/__tests__/currencyField.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import renderView from '../../__tests_helpers__/renderView';
import Event from '../sendAddToCartEvent';
import createExtensionBridge from '../../__tests_helpers__/createExtensionBridge';

import { changeInputValue } from '../../__tests_helpers__/jsDomHelpers';
import { changeComboboxValue } from '../../__tests_helpers__/jsDomHelpers';

let extensionBridge;

Expand Down Expand Up @@ -71,7 +71,7 @@ describe('Currency field', () => {

const input = getField();

await changeInputValue(input, '%ab%');
await changeComboboxValue(input, '%ab%');

expect(extensionBridge.getSettings()).toEqual({
currency: '%ab%'
Expand All @@ -89,7 +89,7 @@ describe('Currency field', () => {

const input = getField();

await changeInputValue(input, 'EUR');
await changeComboboxValue(input, 'EUR');

expect(extensionBridge.getSettings()).toEqual({
currency: 'EUR'
Expand All @@ -107,7 +107,7 @@ describe('Currency field', () => {

const input = getField();

await changeInputValue(input, '');
await changeComboboxValue(input, '');

expect(extensionBridge.getSettings()).toEqual({});
});
Expand All @@ -120,7 +120,7 @@ describe('Currency field', () => {
const input = getField();
expect(input).not.toHaveAttribute('aria-invalid');

await changeInputValue(input, 'USD');
await changeComboboxValue(input, 'USD');
await extensionBridge.validate();

expect(input).not.toHaveAttribute('aria-invalid', 'true');
Expand All @@ -134,7 +134,7 @@ describe('Currency field', () => {
const input = getField();
expect(input).not.toHaveAttribute('aria-invalid');

await changeInputValue(input, '%a%');
await changeComboboxValue(input, '%a%');
await extensionBridge.validate();

expect(input).not.toHaveAttribute('aria-invalid', 'true');
Expand All @@ -148,7 +148,7 @@ describe('Currency field', () => {
const input = getField();
expect(input).not.toHaveAttribute('aria-invalid');

await changeInputValue(input, 'a');
await changeComboboxValue(input, 'a');
await extensionBridge.validate();

expect(input).toHaveAttribute('aria-invalid', 'true');
Expand Down

0 comments on commit f38d865

Please sign in to comment.