Skip to content

Commit

Permalink
Fix tests (mainly flakyness)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebelga committed May 12, 2020
1 parent 6a60f57 commit d12ac63
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ describe.skip('Mappings editor: shape datatype', () => {
*/
let data: any;

beforeAll(() => {
jest.useFakeTimers();
});

afterAll(() => {
jest.useRealTimers();
});

test('initial view and default parameters values', async () => {
const defaultMappings = {
_meta: {},
Expand All @@ -44,40 +52,27 @@ describe.skip('Mappings editor: shape datatype', () => {
const updatedMappings = { ...defaultMappings };

await act(async () => {
testBed = await setup({ value: defaultMappings, onChange: onChangeHandler });
testBed = setup({ value: defaultMappings, onChange: onChangeHandler });
});

const {
exists,
waitFor,
waitForFn,
component,
actions: { startEditField, updateFieldAndCloseFlyout },
} = testBed;

// Open the flyout to edit the field
await act(async () => {
startEditField('myField');
});

await waitFor('mappingsEditorFieldEdit');
startEditField('myField');

// Save the field and close the flyout
await act(async () => {
await updateFieldAndCloseFlyout();
});

await waitForFn(
async () => exists('mappingsEditorFieldEdit') === false,
'Error waiting for the details flyout to close'
);
await updateFieldAndCloseFlyout();

// It should have the default parameters values added
updatedMappings.properties.myField = {
type: 'shape',
...defaultShapeParameters,
};

({ data } = await getMappingsEditorData());
({ data } = await getMappingsEditorData(component));
expect(data).toEqual(updatedMappings);
});
});
Loading

0 comments on commit d12ac63

Please sign in to comment.