Commit c2b84de2 authored by Tomas Vik's avatar Tomas Vik

Fix flakey Web IDE editor test

The original use of real timeouts was prone to failure. We replace
a generic setTimeout() with waiting for editor initialization.
parent a6303996
...@@ -546,7 +546,7 @@ describe('RepoEditor', () => { ...@@ -546,7 +546,7 @@ describe('RepoEditor', () => {
store.state.viewer = viewerTypes.diff; store.state.viewer = viewerTypes.diff;
// we delay returning the file to make sure editor doesn't initialize before we fetch file content // we delay returning the file to make sure editor doesn't initialize before we fetch file content
await waitUsingRealTimer(10); await waitUsingRealTimer(30);
return 'rawFileData123\n'; return 'rawFileData123\n';
}); });
...@@ -555,8 +555,7 @@ describe('RepoEditor', () => { ...@@ -555,8 +555,7 @@ describe('RepoEditor', () => {
vm.file = f; vm.file = f;
// use the real timer to accurately simulate the race condition await waitForEditorSetup();
await waitUsingRealTimer(20);
expect(vm.model.getModel().getValue()).toBe('rawFileData123\n'); expect(vm.model.getModel().getValue()).toBe('rawFileData123\n');
}); });
...@@ -575,14 +574,13 @@ describe('RepoEditor', () => { ...@@ -575,14 +574,13 @@ describe('RepoEditor', () => {
}) })
.mockImplementationOnce(async () => { .mockImplementationOnce(async () => {
// we delay returning fileB content to make sure the editor doesn't initialize prematurely // we delay returning fileB content to make sure the editor doesn't initialize prematurely
await waitUsingRealTimer(10); await waitUsingRealTimer(30);
return 'fileB-rawContent\n'; return 'fileB-rawContent\n';
}); });
vm.file = fileA; vm.file = fileA;
// use the real timer to accurately simulate the race condition await waitForEditorSetup();
await waitUsingRealTimer(20);
expect(vm.model.getModel().getValue()).toBe('fileB-rawContent\n'); expect(vm.model.getModel().getValue()).toBe('fileB-rawContent\n');
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment