Skip to content

Commit

Permalink
fix: remove aggresive awaitsFor test timeouts as slow github actions …
Browse files Browse the repository at this point in the history
…test runners needs more time
  • Loading branch information
brackets-io committed Oct 16, 2023
1 parent 60b8984 commit 324ac80
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/extensions/default/CodeFolding/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/JavaScriptRefactoring/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/QuickView/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
6 changes: 3 additions & 3 deletions src/extensions/default/UrlCodeHints/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/spec/Async-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions test/spec/EditorCommandHandlers-integ-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions test/spec/EventManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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});
Expand Down
2 changes: 1 addition & 1 deletion test/spec/FeatureGate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
4 changes: 2 additions & 2 deletions test/spec/FindReplace-integ-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ 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
// wait for the old Find bar to disappear before continuing our test, so we know
// which modal bar to look at.
await awaitsFor(function () {
return getSearchBar().length === 1;
}, 1000, "search bar reopening");
}, "search bar reopening");
}

function enterSearchText(str) {
Expand Down
8 changes: 4 additions & 4 deletions test/spec/LanguageManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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");
});
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/spec/ProjectManager-integ-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
8 changes: 4 additions & 4 deletions test/spec/WorkerComm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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 () {
Expand All @@ -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");
});
});

Expand Down
12 changes: 6 additions & 6 deletions test/spec/WorkingSetView-integ-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 () {
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down

0 comments on commit 324ac80

Please sign in to comment.