DEV: migrate tests to async/await

This commit is contained in:
Maja Komel
2018-07-29 22:51:32 +02:00
parent 176d8ca78d
commit 04baddf731
31 changed files with 1320 additions and 1729 deletions

View File

@@ -24,8 +24,8 @@ QUnit.test("flagged posts - agree", async assert => {
await visit("/admin/flags/active");
await agreeFlag.expandAwait();
await agreeFlag.selectRowByValueAwait("confirm-agree-keep");
await agreeFlag.expand();
await agreeFlag.selectRowByValue("confirm-agree-keep");
assert.equal(
find(".admin-flags .flagged-post").length,
@@ -39,8 +39,8 @@ QUnit.test("flagged posts - agree + hide", async assert => {
await visit("/admin/flags/active");
await agreeFlag.expandAwait();
await agreeFlag.selectRowByValueAwait("confirm-agree-hide");
await agreeFlag.expand();
await agreeFlag.selectRowByValue("confirm-agree-hide");
assert.equal(
find(".admin-flags .flagged-post").length,
@@ -54,8 +54,8 @@ QUnit.test("flagged posts - agree + deleteSpammer", async assert => {
await visit("/admin/flags/active");
await agreeFlag.expandAwait();
await agreeFlag.selectRowByValueAwait("delete-spammer");
await agreeFlag.expand();
await agreeFlag.selectRowByValue("delete-spammer");
await click(".confirm-delete");
@@ -85,8 +85,8 @@ QUnit.test("flagged posts - delete + defer", async assert => {
await visit("/admin/flags/active");
await deleteFlag.expandAwait();
await deleteFlag.selectRowByValueAwait("delete-defer");
await deleteFlag.expand();
await deleteFlag.selectRowByValue("delete-defer");
assert.equal(find(".admin-flags .flagged-post").length, 0);
});
@@ -96,8 +96,8 @@ QUnit.test("flagged posts - delete + agree", async assert => {
await visit("/admin/flags/active");
await deleteFlag.expandAwait();
await deleteFlag.selectRowByValueAwait("delete-agree");
await deleteFlag.expand();
await deleteFlag.selectRowByValue("delete-agree");
assert.equal(find(".admin-flags .flagged-post").length, 0);
});
@@ -107,8 +107,8 @@ QUnit.test("flagged posts - delete + deleteSpammer", async assert => {
await visit("/admin/flags/active");
await deleteFlag.expandAwait();
await deleteFlag.selectRowByValueAwait("delete-spammer");
await deleteFlag.expand();
await deleteFlag.selectRowByValue("delete-spammer");
await click(".confirm-delete");

View File

@@ -50,8 +50,8 @@ QUnit.test("suspend, then unsuspend a user", async assert => {
"disabled by default"
);
await suspendUntilCombobox.expandAwait();
await suspendUntilCombobox.selectRowByValueAwait("tomorrow");
await suspendUntilCombobox.expand();
await suspendUntilCombobox.selectRowByValue("tomorrow");
await fillIn(".suspend-reason", "for breaking the rules");
await fillIn(".suspend-message", "this is an email reason why");

View File

@@ -13,7 +13,7 @@ QUnit.test("does not display uncategorized if not allowed", async assert => {
await visit("/");
await click("#create-topic");
await categoryChooser.expandAwait();
await categoryChooser.expand();
assert.ok(categoryChooser.rowByIndex(0).name() !== "uncategorized");
});

View File

@@ -33,7 +33,7 @@ QUnit.test("removing a permission", async assert => {
await click(".edit-category");
await click("li.edit-category-security a");
await click(".edit-category-tab-security .edit-permission");
await availableGroups.expandAwait();
await availableGroups.expand();
assert.notOk(
availableGroups.rowByValue("everyone").exists(),
@@ -43,7 +43,7 @@ QUnit.test("removing a permission", async assert => {
await click(
".edit-category-tab-security .permission-list li:first-of-type .remove-permission"
);
await availableGroups.expandAwait();
await availableGroups.expand();
assert.ok(
availableGroups.rowByValue("everyone").exists(),
@@ -60,10 +60,10 @@ QUnit.test("adding a permission", async assert => {
await click(".edit-category");
await click("li.edit-category-security a");
await click(".edit-category-tab-security .edit-permission");
await availableGroups.expandAwait();
await availableGroups.selectRowByValueAwait("staff");
await permissionSelector.expandAwait();
await permissionSelector.selectRowByValueAwait("2");
await availableGroups.expand();
await availableGroups.selectRowByValue("staff");
await permissionSelector.expand();
await permissionSelector.selectRowByValue("2");
await click(".edit-category-tab-security .add-permission");
const $addedPermissionItem = find(
@@ -95,8 +95,8 @@ QUnit.test("adding a previously removed permission", async assert => {
"it removes the permission from the list"
);
await availableGroups.expandAwait();
await availableGroups.selectRowByValueAwait("everyone");
await availableGroups.expand();
await availableGroups.selectRowByValue("everyone");
await click(".edit-category-tab-security .add-permission");
assert.equal(

View File

@@ -78,8 +78,8 @@ QUnit.test("Subcategory list settings", async assert => {
);
await click(".edit-category-general");
await categoryChooser.expandAwait();
await categoryChooser.selectRowByValueAwait(3);
await categoryChooser.expand();
await categoryChooser.selectRowByValue(3);
await click(".edit-category-settings a");

View File

@@ -16,7 +16,7 @@ QUnit.test("replying to post", async assert => {
await visit("/t/internationalization-localization/280");
await click("article#post_3 button.reply");
await composerActions.expandAwait();
await composerActions.expand();
assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic");
assert.equal(
@@ -34,8 +34,8 @@ QUnit.test("replying to post - reply_as_private_message", async assert => {
await visit("/t/internationalization-localization/280");
await click("article#post_3 button.reply");
await composerActions.expandAwait();
await composerActions.selectRowByValueAwait("reply_as_private_message");
await composerActions.expand();
await composerActions.selectRowByValue("reply_as_private_message");
assert.equal(find(".users-input .item:eq(0)").text(), "codinghorror");
assert.ok(
@@ -55,8 +55,8 @@ QUnit.test("replying to post - reply_to_topic", async assert => {
"test replying to topic when initially replied to post"
);
await composerActions.expandAwait();
await composerActions.selectRowByValueAwait("reply_to_topic");
await composerActions.expand();
await composerActions.selectRowByValue("reply_to_topic");
assert.equal(
find(".action-title .topic-link")
@@ -84,8 +84,8 @@ QUnit.test("replying to post - toggle_whisper", async assert => {
"test replying as whisper to topic when initially not a whisper"
);
await composerActions.expandAwait();
await composerActions.selectRowByValueAwait("toggle_whisper");
await composerActions.expand();
await composerActions.selectRowByValue("toggle_whisper");
assert.ok(
find(".composer-fields .whisper")
@@ -103,15 +103,15 @@ QUnit.test("replying to post - reply_as_new_topic", async assert => {
await visit("/t/internationalization-localization/280");
await click("#topic-title .d-icon-pencil");
await categoryChooser.expandAwait();
await categoryChooser.selectRowByValueAwait(4);
await categoryChooser.expand();
await categoryChooser.selectRowByValue(4);
await click("#topic-title .submit-edit");
await click("article#post_3 button.reply");
await fillIn(".d-editor-input", quote);
await composerActions.expandAwait();
await composerActions.selectRowByValueAwait("reply_as_new_topic");
await composerActions.expand();
await composerActions.selectRowByValue("reply_as_new_topic");
assert.equal(categoryChooserReplyArea.header().name(), "faq");
assert.equal(
@@ -133,8 +133,8 @@ QUnit.test("shared draft", async assert => {
await visit("/");
await click("#create-topic");
await composerActions.expandAwait();
await composerActions.selectRowByValueAwait("shared_draft");
await composerActions.expand();
await composerActions.selectRowByValue("shared_draft");
assert.equal(
find("#reply-control .btn-primary.create .d-button-label").text(),
@@ -159,8 +159,8 @@ QUnit.test("interactions", async assert => {
await visit("/t/internationalization-localization/280");
await click("article#post_3 button.reply");
await fillIn(".d-editor-input", quote);
await composerActions.expandAwait();
await composerActions.selectRowByValueAwait("reply_to_topic");
await composerActions.expand();
await composerActions.selectRowByValue("reply_to_topic");
assert.equal(
find(".action-title")
@@ -170,7 +170,7 @@ QUnit.test("interactions", async assert => {
);
assert.equal(find(".d-editor-input").val(), quote);
await composerActions.expandAwait();
await composerActions.expand();
assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic");
assert.equal(composerActions.rowByIndex(1).value(), "reply_to_post");
@@ -181,8 +181,8 @@ QUnit.test("interactions", async assert => {
assert.equal(composerActions.rowByIndex(3).value(), "toggle_whisper");
assert.equal(composerActions.rows().length, 4);
await composerActions.selectRowByValueAwait("reply_to_post");
await composerActions.expandAwait();
await composerActions.selectRowByValue("reply_to_post");
await composerActions.expand();
assert.ok(exists(find(".action-title img.avatar")));
assert.equal(
@@ -201,8 +201,8 @@ QUnit.test("interactions", async assert => {
assert.equal(composerActions.rowByIndex(3).value(), "toggle_whisper");
assert.equal(composerActions.rows().length, 4);
await composerActions.selectRowByValueAwait("reply_as_new_topic");
await composerActions.expandAwait();
await composerActions.selectRowByValue("reply_as_new_topic");
await composerActions.expand();
assert.equal(
find(".action-title")
@@ -224,8 +224,8 @@ QUnit.test("interactions", async assert => {
assert.equal(composerActions.rowByIndex(3).value(), "shared_draft");
assert.equal(composerActions.rows().length, 4);
await composerActions.selectRowByValueAwait("reply_as_private_message");
await composerActions.expandAwait();
await composerActions.selectRowByValue("reply_as_private_message");
await composerActions.expand();
assert.equal(
find(".action-title")

View File

@@ -295,8 +295,8 @@ QUnit.test(
await visit("/t/this-is-a-test-topic/9");
await click(".topic-post:eq(0) button.reply");
await selectKit(".toolbar-popup-menu-options").expandAwait();
await selectKit(".toolbar-popup-menu-options").selectRowByValueAwait(
await selectKit(".toolbar-popup-menu-options").expand();
await selectKit(".toolbar-popup-menu-options").selectRowByValue(
"toggleWhisper"
);
@@ -318,8 +318,8 @@ QUnit.test(
"it should reset the state of the composer's model"
);
await selectKit(".toolbar-popup-menu-options").expandAwait();
await selectKit(".toolbar-popup-menu-options").selectRowByValueAwait(
await selectKit(".toolbar-popup-menu-options").expand();
await selectKit(".toolbar-popup-menu-options").selectRowByValue(
"toggleInvisible"
);
@@ -409,8 +409,8 @@ QUnit.test("Disable body until category is selected", async assert => {
const categoryChooser = selectKit(".category-chooser");
await categoryChooser.expandAwait();
await categoryChooser.selectRowByValueAwait(2);
await categoryChooser.expand();
await categoryChooser.selectRowByValue(2);
assert.ok(
find(".d-editor-textarea-wrapper.disabled").length === 0,
@@ -418,8 +418,8 @@ QUnit.test("Disable body until category is selected", async assert => {
);
await fillIn(".d-editor-input", "Now I can type stuff");
await categoryChooser.expandAwait();
await categoryChooser.selectRowByValueAwait("__none__");
await categoryChooser.expand();
await categoryChooser.selectRowByValue("__none__");
assert.ok(
find(".d-editor-textarea-wrapper.disabled").length === 0,

View File

@@ -58,9 +58,12 @@ QUnit.test("update some fields", async assert => {
await savePreferences();
click(".preferences-nav .nav-notifications a");
selectKit(".control-group.notifications .combo-box.duration")
.expand()
.selectRowByValue(1440);
await selectKit(
".control-group.notifications .combo-box.duration"
).expand();
await selectKit(
".control-group.notifications .combo-box.duration"
).selectRowByValue(1440);
await savePreferences();
click(".preferences-nav .nav-categories a");

View File

@@ -156,9 +156,9 @@ QUnit.test("update category through advanced search ui", async assert => {
await fillIn(".search-query", "none");
await categoryChooser.expandAwait();
await categoryChooser.expand();
await categoryChooser.fillInFilter("faq");
await categoryChooser.selectRowByValueAwait(4);
await categoryChooser.selectRowByValue(4);
assert.ok(
exists('.search-advanced-options .badge-category:contains("faq")'),
@@ -317,8 +317,8 @@ QUnit.test("update in filter through advanced search ui", async assert => {
await visit("/search");
await fillIn(".search-query", "none");
await inSelector.expandAwait();
await inSelector.selectRowByValueAwait("bookmarks");
await inSelector.expand();
await inSelector.selectRowByValue("bookmarks");
assert.ok(
inSelector.rowByName("I bookmarked").exists(),
@@ -339,8 +339,8 @@ QUnit.test("update status through advanced search ui", async assert => {
await visit("/search");
await fillIn(".search-query", "none");
await statusSelector.expandAwait();
await statusSelector.selectRowByValueAwait("closed");
await statusSelector.expand();
await statusSelector.selectRowByValue("closed");
assert.ok(
statusSelector.rowByName("are closed").exists(),
@@ -362,8 +362,8 @@ QUnit.test("update post time through advanced search ui", async assert => {
await fillIn(".search-query", "none");
await fillIn("#search-post-date .date-picker", "2016-10-05");
await postTimeSelector.expandAwait();
await postTimeSelector.selectRowByValueAwait("after");
await postTimeSelector.expand();
await postTimeSelector.selectRowByValue("after");
assert.ok(
postTimeSelector.rowByName("after").exists(),

View File

@@ -89,7 +89,7 @@ QUnit.test("Right filters are shown to anonymous users", async assert => {
await visit("/search?expanded=true");
await inSelector.expandAwait();
await inSelector.expand();
assert.ok(inSelector.rowByValue("first").exists());
assert.ok(inSelector.rowByValue("pinned").exists());
@@ -115,7 +115,7 @@ QUnit.test("Right filters are shown to logged-in users", async assert => {
Discourse.reset();
await visit("/search?expanded=true");
await inSelector.expandAwait();
await inSelector.expand();
assert.ok(inSelector.rowByValue("first").exists());
assert.ok(inSelector.rowByValue("pinned").exists());

View File

@@ -51,8 +51,8 @@ QUnit.test("autoclose - specific time", async assert => {
await click(".toggle-admin-menu");
await click(".topic-admin-status-update button");
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("next_week");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("next_week");
assert.equal(futureDateInputSelector.header().title(), "Next week");
assert.equal(futureDateInputSelector.header().value(), "next_week");
@@ -71,8 +71,8 @@ QUnit.test("autoclose", async assert => {
await click(".toggle-admin-menu");
await click(".topic-admin-status-update button");
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("next_week");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("next_week");
assert.equal(futureDateInputSelector.header().title(), "Next week");
assert.equal(futureDateInputSelector.header().value(), "next_week");
@@ -83,8 +83,8 @@ QUnit.test("autoclose", async assert => {
.trim();
assert.ok(regex1.test(html1));
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("pick_date_and_time");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("pick_date_and_time");
await fillIn(".future-date-input .date-picker", "2099-11-24");
@@ -97,8 +97,8 @@ QUnit.test("autoclose", async assert => {
.trim();
assert.ok(regex2.test(html2));
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("set_based_on_last_post");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("set_based_on_last_post");
await fillIn(".future-date-input input[type=number]", "2");
@@ -126,14 +126,14 @@ QUnit.test("close temporarily", async assert => {
await click(".toggle-admin-menu");
await click(".topic-admin-status-update button");
await timerType.expandAwait();
await timerType.selectRowByValueAwait("open");
await timerType.expand();
await timerType.selectRowByValue("open");
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
assert.equal(futureDateInputSelector.header().value(), null);
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("next_week");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("next_week");
assert.equal(futureDateInputSelector.header().title(), "Next week");
assert.equal(futureDateInputSelector.header().value(), "next_week");
@@ -144,8 +144,8 @@ QUnit.test("close temporarily", async assert => {
.trim();
assert.ok(regex1.test(html1));
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("pick_date_and_time");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("pick_date_and_time");
await fillIn(".future-date-input .date-picker", "2099-11-24");
@@ -168,8 +168,8 @@ QUnit.test("schedule", async assert => {
await click(".toggle-admin-menu");
await click(".topic-admin-status-update button");
await timerType.expandAwait();
await timerType.selectRowByValueAwait("publish_to_category");
await timerType.expand();
await timerType.selectRowByValue("publish_to_category");
assert.equal(categoryChooser.header().title(), "uncategorized");
assert.equal(categoryChooser.header().value(), null);
@@ -177,11 +177,11 @@ QUnit.test("schedule", async assert => {
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
assert.equal(futureDateInputSelector.header().value(), null);
await categoryChooser.expandAwait();
await categoryChooser.selectRowByValueAwait("7");
await categoryChooser.expand();
await categoryChooser.selectRowByValue("7");
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("next_week");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("next_week");
assert.equal(futureDateInputSelector.header().title(), "Next week");
assert.equal(futureDateInputSelector.header().value(), "next_week");
@@ -202,7 +202,7 @@ QUnit.test("TL4 can't auto-delete", async assert => {
const timerType = selectKit(".select-kit.timer-type");
await timerType.expandAwait();
await timerType.expand();
assert.ok(!timerType.rowByValue("delete").exists());
});
@@ -215,14 +215,14 @@ QUnit.test("auto delete", async assert => {
await click(".toggle-admin-menu");
await click(".topic-admin-status-update button");
await timerType.expandAwait();
await timerType.selectRowByValueAwait("delete");
await timerType.expand();
await timerType.selectRowByValue("delete");
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
assert.equal(futureDateInputSelector.header().value(), null);
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("two_weeks");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("two_weeks");
assert.equal(futureDateInputSelector.header().title(), "Two Weeks");
assert.equal(futureDateInputSelector.header().value(), "two_weeks");
@@ -242,7 +242,8 @@ QUnit.test(
await visit("/t/internationalization-localization");
await click(".toggle-admin-menu");
await click(".topic-admin-status-update button");
await futureDateInputSelector.expand().selectRowByValue("next_week");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("next_week");
await click(".modal-footer button.btn-primary");
const regex = /will automatically close in/g;

View File

@@ -20,8 +20,8 @@ QUnit.test("Updating topic notification level", async assert => {
"it should display the notification options button in the topic's footer"
);
await notificationOptions.expandAwait();
await notificationOptions.selectRowByValueAwait("3");
await notificationOptions.expand();
await notificationOptions.selectRowByValue("3");
assert.equal(
notificationOptions.selectedRow().name(),

View File

@@ -54,8 +54,8 @@ QUnit.test("Updating the topic title and category", async assert => {
await click("#topic-title .d-icon-pencil");
await fillIn("#edit-title", "this is the new title");
await categoryChooser.expandAwait();
await categoryChooser.selectRowByValueAwait(4);
await categoryChooser.expand();
await categoryChooser.selectRowByValue(4);
await click("#topic-title .submit-edit");
assert.equal(