From 324ac8074e7921ff508bc6fa78e28096f4646ba4 Mon Sep 17 00:00:00 2001 From: phoenixide Date: Mon, 16 Oct 2023 22:16:26 +0530 Subject: [PATCH] fix: remove aggresive awaitsFor test timeouts as slow github actions test runners needs more time --- src/extensions/default/CodeFolding/unittests.js | 4 ++-- .../default/JavaScriptRefactoring/unittests.js | 2 +- src/extensions/default/QuickView/unittests.js | 2 +- src/extensions/default/UrlCodeHints/unittests.js | 6 +++--- test/spec/Async-test.js | 2 +- test/spec/EditorCommandHandlers-integ-test.js | 3 +-- test/spec/EventManager-test.js | 4 ++-- test/spec/FeatureGate-test.js | 2 +- test/spec/FindReplace-integ-test.js | 4 ++-- test/spec/LanguageManager-test.js | 8 ++++---- test/spec/ProjectManager-integ-test.js | 2 +- test/spec/WorkerComm-test.js | 8 ++++---- test/spec/WorkingSetView-integ-test.js | 12 ++++++------ 13 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/extensions/default/CodeFolding/unittests.js b/src/extensions/default/CodeFolding/unittests.js index 2522ff00c..18ae99a0f 100644 --- a/src/extensions/default/CodeFolding/unittests.js +++ b/src/extensions/default/CodeFolding/unittests.js @@ -430,7 +430,7 @@ define(function (require, exports, module) { await awaitsFor(function () { return expandTimeoutElapsed; - }, "waiting a moment for gutter markerts to be re-rendered", 500); + }, "waiting a moment for gutter markerts to be re-rendered"); var marks = getGutterFoldMarks().filter(filterFolded); expect(marks.length).toEqual(0); @@ -448,7 +448,7 @@ define(function (require, exports, module) { await awaitsFor(function () { return expandTimeoutElapsed; - }, "waiting a moment for gutter markerts to be re-rendered", 500); + }, "waiting a moment for gutter markerts to be re-rendered"); var marks = getGutterFoldMarks().filter(filterFolded); expect(marks.length).toEqual(0); diff --git a/src/extensions/default/JavaScriptRefactoring/unittests.js b/src/extensions/default/JavaScriptRefactoring/unittests.js index aaac9d947..35244a520 100644 --- a/src/extensions/default/JavaScriptRefactoring/unittests.js +++ b/src/extensions/default/JavaScriptRefactoring/unittests.js @@ -92,7 +92,7 @@ define(function (require, exports, module) { } await awaitsFor(function() { return (testDoc.getText().length !== prevDocLength || (numberOfLines && testDoc.getText().split("\n").length !== numberOfLines)); - }, "_waitForRefactoring", 500); + }, "_waitForRefactoring"); callback(); } diff --git a/src/extensions/default/QuickView/unittests.js b/src/extensions/default/QuickView/unittests.js index b76edf1e4..bf3995b8e 100644 --- a/src/extensions/default/QuickView/unittests.js +++ b/src/extensions/default/QuickView/unittests.js @@ -347,7 +347,7 @@ define(function (require, exports, module) { await awaitsFor(()=>{ let currentFile = MainViewManager.getCurrentlyViewedFile(); return currentFile.fullPath.endsWith(expectedPathEnding); - }, "waits for image to open", 2000); + }, "waits for image to open"); }); it("Should show image preview for urls with http/https",async function () { diff --git a/src/extensions/default/UrlCodeHints/unittests.js b/src/extensions/default/UrlCodeHints/unittests.js index f253669e4..8e0f8355c 100644 --- a/src/extensions/default/UrlCodeHints/unittests.js +++ b/src/extensions/default/UrlCodeHints/unittests.js @@ -68,7 +68,7 @@ define(function (require, exports, module) { await awaitsFor(function () { return (testDocument); - }, "Unable to open test document", 2000); + }, "Unable to open test document"); // create Editor instance (containing a CodeMirror instance) testEditor = createMockEditor(testDocument); @@ -106,7 +106,7 @@ define(function (require, exports, module) { await awaitsFor(function () { return (!hintsObj || hintsObj.hints); - }, "Unable to resolve hints", 2000); + }, "Unable to resolve hints"); } // Ask provider for hints at current cursor position; expect it NOT to return any @@ -296,7 +296,7 @@ define(function (require, exports, module) { await awaitsFor(function () { return (testDocument); - }, "Unable to open test document", 2000); + }, "Unable to open test document"); MainViewManager._edit(MainViewManager.ACTIVE_PANE, testDocument); testEditor = EditorManager.getCurrentFullEditor(); diff --git a/test/spec/Async-test.js b/test/spec/Async-test.js index f36e86215..36276a8d6 100644 --- a/test/spec/Async-test.js +++ b/test/spec/Async-test.js @@ -111,7 +111,7 @@ define(function (require, exports, module) { await awaitsFor(function () { return done; - }, "The chain should complete", 100); + }, "The chain should complete"); expect(success).toBe(shouldSucceed); responseComparator(response); } diff --git a/test/spec/EditorCommandHandlers-integ-test.js b/test/spec/EditorCommandHandlers-integ-test.js index 6fd11ae04..b38b869b8 100644 --- a/test/spec/EditorCommandHandlers-integ-test.js +++ b/test/spec/EditorCommandHandlers-integ-test.js @@ -84,8 +84,7 @@ define(function (require, exports, module) { let $dlg = testWindow.$(".modal.instance"); return !!$dlg.length; }, - "brackets.test.closing", - 1000 + "brackets.test.closing" ); } catch (e) { // do nothing. diff --git a/test/spec/EventManager-test.js b/test/spec/EventManager-test.js index 9beaee1e4..456e37541 100644 --- a/test/spec/EventManager-test.js +++ b/test/spec/EventManager-test.js @@ -45,7 +45,7 @@ define(function (require, exports, module) { await awaitsFor(function () { return arg1 === 1 && arg2 === "param1"; - }, 100, "awaiting event trigger"); + }, "awaiting event trigger"); }); it("should receive event from embedded iframe", async function () { @@ -71,7 +71,7 @@ define(function (require, exports, module) { document.body.appendChild(iframe); await awaitsFor(function () { return !!recvdMessageEvent; - }, 100, "awaiting message event reception"); + }, "awaiting message event reception"); expect(recvdMessageEvent.data.handlerName).toBe(HANDLER_NAME); expect(recvdMessageEvent.data.eventName).toBe(EVENT_NAME); expect(recvdMessageEvent.data.message).toEql({hello: TEST_MESSAGE}); diff --git a/test/spec/FeatureGate-test.js b/test/spec/FeatureGate-test.js index 2c916cdf4..1a50d5227 100644 --- a/test/spec/FeatureGate-test.js +++ b/test/spec/FeatureGate-test.js @@ -40,7 +40,7 @@ define(function (require, exports, module) { expect(FeatureGate.getAllRegisteredFeatures().includes(FEATURE2)).toEqual(true); await awaitsFor(function () { return notified === FEATURE2 && featureDefaultValue === true; - }, 100, "Feature gate registration notification"); + }, "Feature gate registration notification"); }); it("user should be able to override feature in localstorage", function () { diff --git a/test/spec/FindReplace-integ-test.js b/test/spec/FindReplace-integ-test.js index 0d96c5d6c..5054765f5 100644 --- a/test/spec/FindReplace-integ-test.js +++ b/test/spec/FindReplace-integ-test.js @@ -166,7 +166,7 @@ define(function (require, exports, module) { async function waitsForSearchBarClose() { await awaitsFor(function () { return getSearchBar().length === 0; - }, 1000, "search bar closing"); + }, "search bar closing"); } async function waitsForSearchBarReopen() { // If Find is invoked again while a previous Find bar is already up, we want to @@ -174,7 +174,7 @@ define(function (require, exports, module) { // which modal bar to look at. await awaitsFor(function () { return getSearchBar().length === 1; - }, 1000, "search bar reopening"); + }, "search bar reopening"); } function enterSearchText(str) { diff --git a/test/spec/LanguageManager-test.js b/test/spec/LanguageManager-test.js index 56867e20e..d2e4657c0 100644 --- a/test/spec/LanguageManager-test.js +++ b/test/spec/LanguageManager-test.js @@ -319,7 +319,7 @@ define(function (require, exports, module) { await awaitsFor(function () { return Boolean(language); - }, "The language should be resolved", 50); + }, "The language should be resolved", 2000); expect(LanguageManager.getLanguageForPath("file.p")).toBe(language); validateLanguage(def, language); @@ -340,7 +340,7 @@ define(function (require, exports, module) { await awaitsFor(function () { return Boolean(lang); - }, "The language should be resolved", 150); + }, "The language should be resolved", 2000); expect(xmlBefore).toBe(xmlAfter); expect(LanguageManager.getLanguageForPath("file.wix")).toBe(lang); @@ -361,7 +361,7 @@ define(function (require, exports, module) { await awaitsFor(function () { return error !== -1; - }, "The promise should be rejected with an error", 150); + }, "The promise should be rejected with an error", 2000); expect(error).toBe("Language \"pascal\" is already defined"); }); @@ -445,7 +445,7 @@ define(function (require, exports, module) { await awaitsFor(function () { return Boolean(language); - }, "The language should be resolved", 150); + }, "The language should be resolved", 2000); expect(LanguageManager.getLanguageForPath("file.erlang")).toBe(language); validateLanguage(def, language); diff --git a/test/spec/ProjectManager-integ-test.js b/test/spec/ProjectManager-integ-test.js index 83a44a0eb..9b9105423 100644 --- a/test/spec/ProjectManager-integ-test.js +++ b/test/spec/ProjectManager-integ-test.js @@ -78,7 +78,7 @@ define(function (require, exports, module) { await awaitsFor(function () { $dlg = testWindow.$(".modal.instance"); return $dlg.length > 0; - }, 300, "dialog to appear"); + }, "dialog to appear"); } describe("createNewItem", function () { diff --git a/test/spec/WorkerComm-test.js b/test/spec/WorkerComm-test.js index 8da84bd9a..ef3f3ea91 100644 --- a/test/spec/WorkerComm-test.js +++ b/test/spec/WorkerComm-test.js @@ -44,7 +44,7 @@ define(function (require, exports, module) { }); await awaitsFor(function () { return initDone; - }, "waiting for worker to load WorkerComm", 500); + }, "waiting for worker to load WorkerComm"); }); afterAll(function () { @@ -108,7 +108,7 @@ define(function (require, exports, module) { exports.triggerPeer("echoNotify1", "yo1"); await awaitsFor(function () { return echoVal === "yo1"; - }, "waiting for worker to notify main", 500); + }, "waiting for worker to notify main"); }); it("Should trigger notification in worker and main thread even if some handlers errored", async function () { @@ -120,14 +120,14 @@ define(function (require, exports, module) { exports.triggerPeer("echoNotify2", "yo2"); await awaitsFor(function () { return echoVal === "yo2"; - }, "waiting for worker to notify main", 500); + }, "waiting for worker to notify main"); // check if the notification works again after error in worker echoVal = ""; exports.triggerPeer("echoNotify2", "yo2"); await awaitsFor(function () { return echoVal === "yo2"; - }, "waiting for worker to notify main", 500); + }, "waiting for worker to notify main"); }); }); diff --git a/test/spec/WorkingSetView-integ-test.js b/test/spec/WorkingSetView-integ-test.js index cc11b328d..ea10de756 100644 --- a/test/spec/WorkingSetView-integ-test.js +++ b/test/spec/WorkingSetView-integ-test.js @@ -48,7 +48,7 @@ define(function (require, exports, module) { .done(function () { didOpen = true; }) .fail(function () { gotError = true; }); await awaitsFor(function () { return didOpen && !gotError; }, - "FILE_OPEN on file timeout", 1000); + "FILE_OPEN on file timeout"); // change editor content to make doc dirty which adds it to the working set doc = DocumentManager.getCurrentDocument(); @@ -102,7 +102,7 @@ define(function (require, exports, module) { await openAndMakeDirty(testPath + "/file_two.js"); // Wait for both files to be added to the working set - await awaitsFor(function () { return workingSetListItemCount === 2; }, "workingSetListItemCount to equal 2", 1000); + await awaitsFor(function () { return workingSetListItemCount === 2; }, "workingSetListItemCount to equal 2"); }); afterEach(async function () { @@ -125,7 +125,7 @@ define(function (require, exports, module) { CommandManager.execute(Commands.FILE_CLOSE) .done(function () { didClose = true; }) .fail(function () { gotError = true; }); - await awaitsFor(function () { return didClose && !gotError; }, "FILE_OPEN on file timeout", 1000); + await awaitsFor(function () { return didClose && !gotError; }, "FILE_OPEN on file timeout"); // check there are no list items var listItems = testWindow.$(".open-files-container > ul").children(); @@ -169,7 +169,7 @@ define(function (require, exports, module) { closeIcon.trigger("mousedown"); - await awaitsFor(function () { return didClose; }, "click on working set close icon timeout", 1000); + await awaitsFor(function () { return didClose; }, "click on working set close icon timeout"); var $listItems = $(".open-files-container > ul").children(); expect($listItems.length).toBe(1); @@ -211,7 +211,7 @@ define(function (require, exports, module) { await openAndMakeDirty(testPath + "/directory/file_one.js"); // Wait for file to be added to the working set - await awaitsFor(function () { return workingSetListItemCount === workingSetListItemCountBeforeTest + 1; }, 1000); + await awaitsFor(function () { return workingSetListItemCount === workingSetListItemCountBeforeTest + 1; }); // Two files with the same name file_one.js should be now opened var $list = testWindow.$(".open-files-container > ul"); @@ -234,7 +234,7 @@ define(function (require, exports, module) { await openAndMakeDirty(testPath + "/directory/directory/file_one.js"); // Wait for them to load - await awaitsFor(function () { return workingSetListItemCount === workingSetListItemCountBeforeTest + 2; }, "Open file count to be increased by 2", 1000); + await awaitsFor(function () { return workingSetListItemCount === workingSetListItemCountBeforeTest + 2; }, "Open file count to be increased by 2"); // Collect all directory names displayed var $list = testWindow.$(".open-files-container > ul");