diff --git a/.eslintrc b/.eslintrc index 4d652d710ac..844933e68b1 100644 --- a/.eslintrc +++ b/.eslintrc @@ -48,6 +48,7 @@ "selectKitSelectRowByValue":true, "selectKitSelectRowByName":true, "selectKitSelectRowByIndex":true, + "keyboardHelper":true, "selectKitSelectNoneRow":true, "selectKitFillInFilter":true, "asyncTestDiscourse":true, diff --git a/app/assets/javascripts/wizard/test/acceptance/wizard-test.js.es6 b/app/assets/javascripts/wizard/test/acceptance/wizard-test.js.es6 index 089657bf81d..406ba3551b6 100644 --- a/app/assets/javascripts/wizard/test/acceptance/wizard-test.js.es6 +++ b/app/assets/javascripts/wizard/test/acceptance/wizard-test.js.es6 @@ -11,69 +11,57 @@ QUnit.module("Acceptance: wizard", { } }); -test("Wizard starts", assert => { - visit("/"); - andThen(() => { - assert.ok(exists(".wizard-column-contents")); - assert.equal(currentPath(), "step"); - }); +test("Wizard starts", async assert => { + await visit("/"); + assert.ok(exists(".wizard-column-contents")); + assert.equal(currentPath(), "step"); }); -test("Going back and forth in steps", assert => { - visit("/steps/hello-world"); - andThen(() => { - assert.ok(exists(".wizard-step")); - assert.ok( - exists(".wizard-step-hello-world"), - "it adds a class for the step id" - ); +test("Going back and forth in steps", async assert => { + await visit("/steps/hello-world"); + assert.ok(exists(".wizard-step")); + assert.ok( + exists(".wizard-step-hello-world"), + "it adds a class for the step id" + ); - assert.ok(exists(".wizard-progress")); - assert.ok(exists(".wizard-step-title")); - assert.ok(exists(".wizard-step-description")); - assert.ok( - !exists(".invalid .field-full-name"), - "don't show it as invalid until the user does something" - ); - assert.ok(exists(".wizard-field .field-description")); - assert.ok(!exists(".wizard-btn.back")); - assert.ok(!exists(".wizard-field .field-error-description")); - }); + assert.ok(exists(".wizard-progress")); + assert.ok(exists(".wizard-step-title")); + assert.ok(exists(".wizard-step-description")); + assert.ok( + !exists(".invalid .field-full-name"), + "don't show it as invalid until the user does something" + ); + assert.ok(exists(".wizard-field .field-description")); + assert.ok(!exists(".wizard-btn.back")); + assert.ok(!exists(".wizard-field .field-error-description")); // invalid data - click(".wizard-btn.next"); - andThen(() => { - assert.ok(exists(".invalid .field-full-name")); - }); + await click(".wizard-btn.next"); + assert.ok(exists(".invalid .field-full-name")); // server validation fail - fillIn("input.field-full-name", "Server Fail"); - click(".wizard-btn.next"); - andThen(() => { - assert.ok(exists(".invalid .field-full-name")); - assert.ok(exists(".wizard-field .field-error-description")); - }); + await fillIn("input.field-full-name", "Server Fail"); + await click(".wizard-btn.next"); + assert.ok(exists(".invalid .field-full-name")); + assert.ok(exists(".wizard-field .field-error-description")); // server validation ok - fillIn("input.field-full-name", "Evil Trout"); - click(".wizard-btn.next"); - andThen(() => { - assert.ok(!exists(".wizard-field .field-error-description")); - assert.ok(!exists(".wizard-step-title")); - assert.ok(!exists(".wizard-step-description")); + await fillIn("input.field-full-name", "Evil Trout"); + await click(".wizard-btn.next"); + assert.ok(!exists(".wizard-field .field-error-description")); + assert.ok(!exists(".wizard-step-title")); + assert.ok(!exists(".wizard-step-description")); - assert.ok(exists(".select-kit.field-snack"), "went to the next step"); - assert.ok(exists(".preview-area"), "renders the component field"); + assert.ok(exists(".select-kit.field-snack"), "went to the next step"); + assert.ok(exists(".preview-area"), "renders the component field"); - assert.ok(!exists(".wizard-btn.next")); - assert.ok(exists(".wizard-btn.done"), "last step shows a done button"); - assert.ok(exists(".action-link.back"), "shows the back button"); - }); + assert.ok(!exists(".wizard-btn.next")); + assert.ok(exists(".wizard-btn.done"), "last step shows a done button"); + assert.ok(exists(".action-link.back"), "shows the back button"); - click(".action-link.back"); - andThen(() => { - assert.ok(exists(".wizard-step-title")); - assert.ok(exists(".wizard-btn.next")); - assert.ok(!exists(".wizard-prev")); - }); + await click(".action-link.back"); + assert.ok(exists(".wizard-step-title")); + assert.ok(exists(".wizard-btn.next")); + assert.ok(!exists(".wizard-prev")); }); diff --git a/app/assets/javascripts/wizard/test/components/invite-list-test.js.es6 b/app/assets/javascripts/wizard/test/components/invite-list-test.js.es6 index 53e1aa6b3f9..95436fb69ed 100644 --- a/app/assets/javascripts/wizard/test/components/invite-list-test.js.es6 +++ b/app/assets/javascripts/wizard/test/components/invite-list-test.js.es6 @@ -8,7 +8,7 @@ componentTest("can add users", { this.set("field", {}); }, - test(assert) { + async test(assert) { assert.ok( this.$(".users-list .invite-list-user").length === 0, "no users at first" @@ -26,67 +26,54 @@ componentTest("can add users", { "it has a warning since no users were added" ); - click(".add-user"); - andThen(() => { - assert.ok( - this.$(".users-list .invite-list-user").length === 0, - "doesn't add a blank user" - ); - assert.ok(this.$(".new-user .invalid").length === 1); - }); + await click(".add-user"); + assert.ok( + this.$(".users-list .invite-list-user").length === 0, + "doesn't add a blank user" + ); + assert.ok(this.$(".new-user .invalid").length === 1); - fillIn(".invite-email", "eviltrout@example.com"); - click(".add-user"); + await fillIn(".invite-email", "eviltrout@example.com"); + await click(".add-user"); - andThen(() => { - assert.ok( - this.$(".users-list .invite-list-user").length === 1, - "adds the user" - ); - assert.ok(this.$(".new-user .invalid").length === 0); + assert.ok( + this.$(".users-list .invite-list-user").length === 1, + "adds the user" + ); + assert.ok(this.$(".new-user .invalid").length === 0); - const val = JSON.parse(this.get("field.value")); - assert.equal(val.length, 1); - assert.equal( - val[0].email, - "eviltrout@example.com", - "adds the email to the JSON" - ); - assert.ok(val[0].role.length, "adds the role to the JSON"); - assert.ok( - !this.get("field.warning"), - "no warning once the user is added" - ); - }); + const val = JSON.parse(this.get("field.value")); + assert.equal(val.length, 1); + assert.equal( + val[0].email, + "eviltrout@example.com", + "adds the email to the JSON" + ); + assert.ok(val[0].role.length, "adds the role to the JSON"); + assert.ok(!this.get("field.warning"), "no warning once the user is added"); - fillIn(".invite-email", "eviltrout@example.com"); - click(".add-user"); + await fillIn(".invite-email", "eviltrout@example.com"); + await click(".add-user"); - andThen(() => { - assert.ok( - this.$(".users-list .invite-list-user").length === 1, - "can't add the same user twice" - ); - assert.ok(this.$(".new-user .invalid").length === 1); - }); + assert.ok( + this.$(".users-list .invite-list-user").length === 1, + "can't add the same user twice" + ); + assert.ok(this.$(".new-user .invalid").length === 1); - fillIn(".invite-email", "not-an-email"); - click(".add-user"); + await fillIn(".invite-email", "not-an-email"); + await click(".add-user"); - andThen(() => { - assert.ok( - this.$(".users-list .invite-list-user").length === 1, - "won't add an invalid email" - ); - assert.ok(this.$(".new-user .invalid").length === 1); - }); + assert.ok( + this.$(".users-list .invite-list-user").length === 1, + "won't add an invalid email" + ); + assert.ok(this.$(".new-user .invalid").length === 1); - click(".invite-list .invite-list-user:eq(0) .remove-user"); - andThen(() => { - assert.ok( - this.$(".users-list .invite-list-user").length === 0, - "removed the user" - ); - }); + await click(".invite-list .invite-list-user:eq(0) .remove-user"); + assert.ok( + this.$(".users-list .invite-list-user").length === 0, + "removed the user" + ); } }); diff --git a/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js.es6 b/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js.es6 index bbc19b5959f..08922bd8625 100644 --- a/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js.es6 +++ b/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js.es6 @@ -8,148 +8,126 @@ acceptance("Details Button", { } }); -function findTextarea() { - return find(".d-editor-input")[0]; -} - -test("details button", assert => { +test("details button", async assert => { const popupMenu = selectKit(".toolbar-popup-menu-options"); - visit("/"); - click("#create-topic"); + await visit("/"); + await click("#create-topic"); - popupMenu.expand().selectRowByValue("insertDetails"); + await popupMenu.expand(); + await popupMenu.selectRowByValue("insertDetails"); - andThen(() => { - assert.equal( - find(".d-editor-input").val(), - `\n[details="${I18n.t("composer.details_title")}"]\n${I18n.t( - "composer.details_text" - )}\n[/details]\n`, - "it should contain the right output" - ); - }); + assert.equal( + find(".d-editor-input").val(), + `\n[details="${I18n.t("composer.details_title")}"]\n${I18n.t( + "composer.details_text" + )}\n[/details]\n`, + "it should contain the right output" + ); - fillIn(".d-editor-input", "This is my title"); + await fillIn(".d-editor-input", "This is my title"); - andThen(() => { - const textarea = findTextarea(); - textarea.selectionStart = 0; - textarea.selectionEnd = textarea.value.length; - }); + const textarea = find(".d-editor-input")[0]; + textarea.selectionStart = 0; + textarea.selectionEnd = textarea.value.length; - popupMenu.expand().selectRowByValue("insertDetails"); + await popupMenu.expand(); + await popupMenu.selectRowByValue("insertDetails"); - andThen(() => { - assert.equal( - find(".d-editor-input").val(), - `\n[details="${I18n.t( - "composer.details_title" - )}"]\nThis is my title\n[/details]\n`, - "it should contain the right selected output" - ); + assert.equal( + find(".d-editor-input").val(), + `\n[details="${I18n.t( + "composer.details_title" + )}"]\nThis is my title\n[/details]\n`, + "it should contain the right selected output" + ); - const textarea = findTextarea(); - assert.equal( - textarea.selectionStart, - 21, - "it should start highlighting at the right position" - ); - assert.equal( - textarea.selectionEnd, - 37, - "it should end highlighting at the right position" - ); - }); + assert.equal( + textarea.selectionStart, + 21, + "it should start highlighting at the right position" + ); + assert.equal( + textarea.selectionEnd, + 37, + "it should end highlighting at the right position" + ); - fillIn(".d-editor-input", "Before some text in between After"); + await fillIn(".d-editor-input", "Before some text in between After"); - andThen(() => { - const textarea = findTextarea(); - textarea.selectionStart = 7; - textarea.selectionEnd = 28; - }); + textarea.selectionStart = 7; + textarea.selectionEnd = 28; - popupMenu.expand().selectRowByValue("insertDetails"); + await popupMenu.expand(); + await popupMenu.selectRowByValue("insertDetails"); - andThen(() => { - assert.equal( - find(".d-editor-input").val(), - `Before \n[details="${I18n.t( - "composer.details_title" - )}"]\nsome text in between\n[/details]\n After`, - "it should contain the right output" - ); + assert.equal( + find(".d-editor-input").val(), + `Before \n[details="${I18n.t( + "composer.details_title" + )}"]\nsome text in between\n[/details]\n After`, + "it should contain the right output" + ); - const textarea = findTextarea(); - assert.equal( - textarea.selectionStart, - 28, - "it should start highlighting at the right position" - ); - assert.equal( - textarea.selectionEnd, - 48, - "it should end highlighting at the right position" - ); - }); + assert.equal( + textarea.selectionStart, + 28, + "it should start highlighting at the right position" + ); + assert.equal( + textarea.selectionEnd, + 48, + "it should end highlighting at the right position" + ); - fillIn(".d-editor-input", "Before \nsome text in between\n After"); + await fillIn(".d-editor-input", "Before \nsome text in between\n After"); - andThen(() => { - const textarea = findTextarea(); - textarea.selectionStart = 8; - textarea.selectionEnd = 29; - }); + textarea.selectionStart = 8; + textarea.selectionEnd = 29; - popupMenu.expand().selectRowByValue("insertDetails"); + await popupMenu.expand(); + await popupMenu.selectRowByValue("insertDetails"); - andThen(() => { - assert.equal( - find(".d-editor-input").val(), - `Before \n\n[details="${I18n.t( - "composer.details_title" - )}"]\nsome text in between\n[/details]\n\n After`, - "it should contain the right output" - ); + assert.equal( + find(".d-editor-input").val(), + `Before \n\n[details="${I18n.t( + "composer.details_title" + )}"]\nsome text in between\n[/details]\n\n After`, + "it should contain the right output" + ); - const textarea = findTextarea(); - assert.equal( - textarea.selectionStart, - 29, - "it should start highlighting at the right position" - ); - assert.equal( - textarea.selectionEnd, - 49, - "it should end highlighting at the right position" - ); - }); + assert.equal( + textarea.selectionStart, + 29, + "it should start highlighting at the right position" + ); + assert.equal( + textarea.selectionEnd, + 49, + "it should end highlighting at the right position" + ); }); -test("details button surrounds all selected text in a single details block", assert => { +test("details button surrounds all selected text in a single details block", async assert => { const multilineInput = "first line\n\nsecond line\n\nthird line"; const popupMenu = selectKit(".toolbar-popup-menu-options"); - visit("/"); - click("#create-topic"); - fillIn(".d-editor-input", multilineInput); + await visit("/"); + await click("#create-topic"); + await fillIn(".d-editor-input", multilineInput); - andThen(() => { - const textarea = findTextarea(); - textarea.selectionStart = 0; - textarea.selectionEnd = textarea.value.length; - }); + const textarea = find(".d-editor-input")[0]; + textarea.selectionStart = 0; + textarea.selectionEnd = textarea.value.length; - popupMenu.expand().selectRowByValue("insertDetails"); + await popupMenu.expand(); + await popupMenu.selectRowByValue("insertDetails"); - andThen(() => { - assert.equal( - find(".d-editor-input").val(), - `\n[details="${I18n.t( - "composer.details_title" - )}"]\n${multilineInput}\n[/details]\n`, - "it should contain the right output" - ); - }); + assert.equal( + find(".d-editor-input").val(), + `\n[details="${I18n.t( + "composer.details_title" + )}"]\n${multilineInput}\n[/details]\n`, + "it should contain the right output" + ); }); diff --git a/plugins/poll/test/javascripts/acceptance/polls-test.js.es6 b/plugins/poll/test/javascripts/acceptance/polls-test.js.es6 index f32937ea97a..ebfe91455e3 100644 --- a/plugins/poll/test/javascripts/acceptance/polls-test.js.es6 +++ b/plugins/poll/test/javascripts/acceptance/polls-test.js.es6 @@ -9,7 +9,7 @@ acceptance("Rendering polls", { } }); -test("Single Poll", assert => { +test("Single Poll", async assert => { // prettier-ignore server.get("/t/13.json", () => { // eslint-disable-line no-undef return [ @@ -313,26 +313,24 @@ test("Single Poll", assert => { ]; }); - visit("/t/this-is-a-test-topic-for-polls/13"); + await visit("/t/this-is-a-test-topic-for-polls/13"); - andThen(() => { - const polls = find(".poll"); + const polls = find(".poll"); - assert.equal(polls.length, 2, "it should render the polls correctly"); - assert.equal( - find(".info-number", polls[0]).text(), - "2", - "it should display the right number of votes" - ); - assert.equal( - find(".info-number", polls[1]).text(), - "3", - "it should display the right number of votes" - ); - }); + assert.equal(polls.length, 2, "it should render the polls correctly"); + assert.equal( + find(".info-number", polls[0]).text(), + "2", + "it should display the right number of votes" + ); + assert.equal( + find(".info-number", polls[1]).text(), + "3", + "it should display the right number of votes" + ); }); -test("Public poll", assert => { +test("Public poll", async assert => { // prettier-ignore server.get("/t/12.json", () => { // eslint-disable-line no-undef return [ @@ -1328,35 +1326,29 @@ test("Public poll", assert => { return [200, { "Content-Type": "application/json" }, body]; }); - visit("/t/this-is-a-topic-created-for-testing/12"); + await visit("/t/this-is-a-topic-created-for-testing/12"); - andThen(() => { - const polls = find(".poll"); - assert.equal(polls.length, 1, "it should render the poll correctly"); - }); + const polls = find(".poll"); + assert.equal(polls.length, 1, "it should render the poll correctly"); - click("button.toggle-results"); + await click("button.toggle-results"); - andThen(() => { - assert.equal( - find(".poll-voters:first li").length, - 25, - "it should display the right number of voters" - ); - }); + assert.equal( + find(".poll-voters:first li").length, + 25, + "it should display the right number of voters" + ); - click(".poll-voters-toggle-expand:first a"); + await click(".poll-voters-toggle-expand:first a"); - andThen(() => { - assert.equal( - find(".poll-voters:first li").length, - 50, - "it should display the right number of voters" - ); - }); + assert.equal( + find(".poll-voters:first li").length, + 50, + "it should display the right number of voters" + ); }); -test("Public number poll", assert => { +test("Public number poll", async assert => { // prettier-ignore server.get("/t/13.json", () => { // eslint-disable-line no-undef return [ @@ -2016,30 +2008,24 @@ test("Public number poll", assert => { return [200, { "Content-Type": "application/json" }, body]; }); - visit("/t/this-is-a-topic-for-testing-number-poll/13"); + await visit("/t/this-is-a-topic-for-testing-number-poll/13"); - andThen(() => { - const polls = find(".poll"); - assert.equal(polls.length, 1, "it should render the poll correctly"); - }); + const polls = find(".poll"); + assert.equal(polls.length, 1, "it should render the poll correctly"); - click("button.toggle-results"); + await click("button.toggle-results"); - andThen(() => { - assert.equal( - find(".poll-voters:first li").length, - 25, - "it should display the right number of voters" - ); - }); + assert.equal( + find(".poll-voters:first li").length, + 25, + "it should display the right number of voters" + ); - click(".poll-voters-toggle-expand:first a"); + await click(".poll-voters-toggle-expand:first a"); - andThen(() => { - assert.equal( - find(".poll-voters:first li").length, - 35, - "it should display the right number of voters" - ); - }); + assert.equal( + find(".poll-voters:first li").length, + 35, + "it should display the right number of voters" + ); }); diff --git a/test/javascripts/acceptance/admin-flags-test.js.es6 b/test/javascripts/acceptance/admin-flags-test.js.es6 index b50280d4243..0ce460f4a77 100644 --- a/test/javascripts/acceptance/admin-flags-test.js.es6 +++ b/test/javascripts/acceptance/admin-flags-test.js.es6 @@ -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"); diff --git a/test/javascripts/acceptance/admin-suspend-user-test.js.es6 b/test/javascripts/acceptance/admin-suspend-user-test.js.es6 index 40da286a81c..a982bc74a8b 100644 --- a/test/javascripts/acceptance/admin-suspend-user-test.js.es6 +++ b/test/javascripts/acceptance/admin-suspend-user-test.js.es6 @@ -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"); diff --git a/test/javascripts/acceptance/category-chooser-test.js.es6 b/test/javascripts/acceptance/category-chooser-test.js.es6 index d9aabcb9e01..0a1423a25dc 100644 --- a/test/javascripts/acceptance/category-chooser-test.js.es6 +++ b/test/javascripts/acceptance/category-chooser-test.js.es6 @@ -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"); }); diff --git a/test/javascripts/acceptance/category-edit-security-test.js.es6 b/test/javascripts/acceptance/category-edit-security-test.js.es6 index 158de71336f..6a4ca5856c6 100644 --- a/test/javascripts/acceptance/category-edit-security-test.js.es6 +++ b/test/javascripts/acceptance/category-edit-security-test.js.es6 @@ -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( diff --git a/test/javascripts/acceptance/category-edit-test.js.es6 b/test/javascripts/acceptance/category-edit-test.js.es6 index 8f27724bb1e..afd0df3618d 100644 --- a/test/javascripts/acceptance/category-edit-test.js.es6 +++ b/test/javascripts/acceptance/category-edit-test.js.es6 @@ -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"); diff --git a/test/javascripts/acceptance/composer-actions-test.js.es6 b/test/javascripts/acceptance/composer-actions-test.js.es6 index 11517d60d31..d6b2bfd1272 100644 --- a/test/javascripts/acceptance/composer-actions-test.js.es6 +++ b/test/javascripts/acceptance/composer-actions-test.js.es6 @@ -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") diff --git a/test/javascripts/acceptance/composer-test.js.es6 b/test/javascripts/acceptance/composer-test.js.es6 index 274d4e1642e..ef25782bc61 100644 --- a/test/javascripts/acceptance/composer-test.js.es6 +++ b/test/javascripts/acceptance/composer-test.js.es6 @@ -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, diff --git a/test/javascripts/acceptance/preferences-test.js.es6 b/test/javascripts/acceptance/preferences-test.js.es6 index 00df87be367..51a7eb0418f 100644 --- a/test/javascripts/acceptance/preferences-test.js.es6 +++ b/test/javascripts/acceptance/preferences-test.js.es6 @@ -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"); diff --git a/test/javascripts/acceptance/search-full-test.js.es6 b/test/javascripts/acceptance/search-full-test.js.es6 index a09f2c6cc24..fc6736146c3 100644 --- a/test/javascripts/acceptance/search-full-test.js.es6 +++ b/test/javascripts/acceptance/search-full-test.js.es6 @@ -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(), diff --git a/test/javascripts/acceptance/search-test.js.es6 b/test/javascripts/acceptance/search-test.js.es6 index cdc882d2ffa..1cb01a1a888 100644 --- a/test/javascripts/acceptance/search-test.js.es6 +++ b/test/javascripts/acceptance/search-test.js.es6 @@ -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()); diff --git a/test/javascripts/acceptance/topic-edit-timer-test.js.es6 b/test/javascripts/acceptance/topic-edit-timer-test.js.es6 index 3d969ba8c90..682d8bf1494 100644 --- a/test/javascripts/acceptance/topic-edit-timer-test.js.es6 +++ b/test/javascripts/acceptance/topic-edit-timer-test.js.es6 @@ -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; diff --git a/test/javascripts/acceptance/topic-notifications-button-test.js.es6 b/test/javascripts/acceptance/topic-notifications-button-test.js.es6 index 87d8f239fba..90a41acd71f 100644 --- a/test/javascripts/acceptance/topic-notifications-button-test.js.es6 +++ b/test/javascripts/acceptance/topic-notifications-button-test.js.es6 @@ -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(), diff --git a/test/javascripts/acceptance/topic-test.js.es6 b/test/javascripts/acceptance/topic-test.js.es6 index 9f9473e60a2..f8e8f9ab581 100644 --- a/test/javascripts/acceptance/topic-test.js.es6 +++ b/test/javascripts/acceptance/topic-test.js.es6 @@ -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( diff --git a/test/javascripts/components/categories-admin-dropdown-test.js.es6 b/test/javascripts/components/categories-admin-dropdown-test.js.es6 index c25224d81a2..7e10646b4cd 100644 --- a/test/javascripts/components/categories-admin-dropdown-test.js.es6 +++ b/test/javascripts/components/categories-admin-dropdown-test.js.es6 @@ -10,7 +10,7 @@ componentTest("default", { assert.equal(subject.el().find(".d-icon-bars").length, 1); assert.equal(subject.el().find(".d-icon-caret-down").length, 1); - await subject.expandAwait(); + await subject.expand(); assert.equal(subject.rowByValue("create").name(), "New Category"); } diff --git a/test/javascripts/components/category-chooser-test.js.es6 b/test/javascripts/components/category-chooser-test.js.es6 index 434336b4763..271b00aa695 100644 --- a/test/javascripts/components/category-chooser-test.js.es6 +++ b/test/javascripts/components/category-chooser-test.js.es6 @@ -30,7 +30,7 @@ componentTest("with excludeCategoryId", { template: "{{category-chooser excludeCategoryId=2}}", async test(assert) { - await this.get("subject").expandAwait(); + await this.get("subject").expand(); assert.notOk( this.get("subject") @@ -44,7 +44,7 @@ componentTest("with scopedCategoryId", { template: "{{category-chooser scopedCategoryId=2}}", async test(assert) { - await this.get("subject").expandAwait(); + await this.get("subject").expand(); assert.equal( this.get("subject") diff --git a/test/javascripts/components/category-selector-test.js.es6 b/test/javascripts/components/category-selector-test.js.es6 index d4f158d1b01..88f4346db19 100644 --- a/test/javascripts/components/category-selector-test.js.es6 +++ b/test/javascripts/components/category-selector-test.js.es6 @@ -16,20 +16,18 @@ componentTest("default", { }, test(assert) { - andThen(() => { - assert.equal( - this.get("subject") - .header() - .value(), - 2 - ); - assert.notOk( - this.get("subject") - .rowByValue(2) - .exists(), - "selected categories are not in the list" - ); - }); + assert.equal( + this.get("subject") + .header() + .value(), + 2 + ); + assert.notOk( + this.get("subject") + .rowByValue(2) + .exists(), + "selected categories are not in the list" + ); } }); @@ -41,23 +39,21 @@ componentTest("with blacklist", { this.set("blacklist", [Category.findById(8)]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.ok( - this.get("subject") - .rowByValue(6) - .exists(), - "not blacklisted categories are in the list" - ); - assert.notOk( - this.get("subject") - .rowByValue(8) - .exists(), - "blacklisted categories are not in the list" - ); - }); + assert.ok( + this.get("subject") + .rowByValue(6) + .exists(), + "not blacklisted categories are in the list" + ); + assert.notOk( + this.get("subject") + .rowByValue(8) + .exists(), + "blacklisted categories are not in the list" + ); } }); @@ -68,39 +64,31 @@ componentTest("interactions", { this.set("categories", [Category.findById(2), Category.findById(6)]); }, - test(assert) { - this.get("subject") - .expand() - .selectRowByValue(8); + async test(assert) { + await this.get("subject").expand(); + await this.get("subject").selectRowByValue(8); - andThen(() => { - assert.equal( - this.get("subject") - .header() - .value(), - "2,6,8", - "it adds the selected category" - ); - assert.equal(this.get("categories").length, 3); - }); + assert.equal( + this.get("subject") + .header() + .value(), + "2,6,8", + "it adds the selected category" + ); + assert.equal(this.get("categories").length, 3); - this.get("subject").expand(); - this.get("subject") - .keyboard() - .backspace(); - this.get("subject") - .keyboard() - .backspace(); + await this.get("subject").expand(); - andThen(() => { - assert.equal( - this.get("subject") - .header() - .value(), - "2,6", - "it removes the last selected category" - ); - assert.equal(this.get("categories").length, 2); - }); + await this.get("subject").keyboard("backspace"); + await this.get("subject").keyboard("backspace"); + + assert.equal( + this.get("subject") + .header() + .value(), + "2,6", + "it removes the last selected category" + ); + assert.equal(this.get("categories").length, 2); } }); diff --git a/test/javascripts/components/combo-box-test.js.es6 b/test/javascripts/components/combo-box-test.js.es6 index c127157b907..af7ad93f300 100644 --- a/test/javascripts/components/combo-box-test.js.es6 +++ b/test/javascripts/components/combo-box-test.js.es6 @@ -13,7 +13,7 @@ componentTest("default", { }, async test(assert) { - await this.get("subject").expandAwait(); + await this.get("subject").expand(); assert.equal( this.get("subject") @@ -46,7 +46,7 @@ componentTest("with valueAttribute", { }, async test(assert) { - await this.get("subject").expandAwait(); + await this.get("subject").expand(); assert.equal( this.get("subject") @@ -70,7 +70,7 @@ componentTest("with nameProperty", { }, async test(assert) { - await this.get("subject").expandAwait(); + await this.get("subject").expand(); assert.equal( this.get("subject") @@ -94,7 +94,7 @@ componentTest("with an array as content", { }, async test(assert) { - await this.get("subject").expandAwait(); + await this.get("subject").expand(); assert.equal( this.get("subject") @@ -120,7 +120,7 @@ componentTest("with value and none as a string", { }, async test(assert) { - await this.get("subject").expandAwait(); + await this.get("subject").expand(); assert.equal( this.get("subject") @@ -148,7 +148,7 @@ componentTest("with value and none as a string", { ); assert.equal(this.get("value"), "trout"); - await this.get("subject").selectNoneRowAwait(); + await this.get("subject").selectNoneRow(); assert.equal(this.get("value"), null); } @@ -191,7 +191,7 @@ componentTest("with value and none as an object", { ); assert.equal(this.get("value"), "evil"); - await this.get("subject").selectNoneRowAwait(); + await this.get("subject").selectNoneRow(); assert.equal(this.get("value"), null); } @@ -207,7 +207,7 @@ componentTest("with no value and none as an object", { }, async test(assert) { - await this.get("subject").expandAwait(); + await this.get("subject").expand(); assert.equal( this.get("subject") @@ -228,7 +228,7 @@ componentTest("with no value and none string", { }, async test(assert) { - await this.get("subject").expandAwait(); + await this.get("subject").expand(); assert.equal( this.get("subject") @@ -247,7 +247,7 @@ componentTest("with no value and no none", { }, async test(assert) { - await this.get("subject").expandAwait(); + await this.get("subject").expand(); assert.equal( this.get("subject") @@ -289,7 +289,7 @@ componentTest("with noneLabel", { }, async test(assert) { - await this.get("subject").expandAwait(); + await this.get("subject").expand(); assert.equal( this.get("subject") diff --git a/test/javascripts/components/d-editor-test.js.es6 b/test/javascripts/components/d-editor-test.js.es6 index 58e4f88b305..19dedaf2bcb 100644 --- a/test/javascripts/components/d-editor-test.js.es6 +++ b/test/javascripts/components/d-editor-test.js.es6 @@ -6,35 +6,31 @@ moduleForComponent("d-editor", { integration: true }); componentTest("preview updates with markdown", { template: "{{d-editor value=value}}", - test(assert) { + async test(assert) { assert.ok(this.$(".d-editor-button-bar").length); - fillIn(".d-editor-input", "hello **world**"); + await fillIn(".d-editor-input", "hello **world**"); - andThen(() => { - assert.equal(this.get("value"), "hello **world**"); - assert.equal( - this.$(".d-editor-preview") - .html() - .trim(), - "
hello world
" - ); - }); + assert.equal(this.get("value"), "hello **world**"); + assert.equal( + this.$(".d-editor-preview") + .html() + .trim(), + "hello world
" + ); } }); componentTest("preview sanitizes HTML", { template: "{{d-editor value=value}}", - test(assert) { - fillIn(".d-editor-input", `">`); - andThen(() => { - assert.equal( - this.$(".d-editor-preview") - .html() - .trim(), - '">
' - ); - }); + async test(assert) { + await fillIn(".d-editor-input", `">`); + assert.equal( + this.$(".d-editor-preview") + .html() + .trim(), + '">
' + ); } }); @@ -45,7 +41,7 @@ componentTest("updating the value refreshes the preview", { this.set("value", "evil trout"); }, - test(assert) { + async test(assert) { assert.equal( this.$(".d-editor-preview") .html() @@ -53,14 +49,12 @@ componentTest("updating the value refreshes the preview", { "evil trout
" ); - andThen(() => this.set("value", "zogstrip")); - andThen(() => - assert.equal( - this.$(".d-editor-preview") - .html() - .trim(), - "zogstrip
" - ) + await this.set("value", "zogstrip"); + assert.equal( + this.$(".d-editor-preview") + .html() + .trim(), + "zogstrip
" ); } }); @@ -97,216 +91,167 @@ function composerTestCase(title, testFunc) { }); } -testCase(`selecting the space before a word`, function(assert, textarea) { +testCase(`selecting the space before a word`, async function(assert, textarea) { textarea.selectionStart = 5; textarea.selectionEnd = 7; - click(`button.bold`); - andThen(() => { - assert.equal(this.get("value"), `hello **w**orld.`); - assert.equal(textarea.selectionStart, 8); - assert.equal(textarea.selectionEnd, 9); - }); + await click(`button.bold`); + + assert.equal(this.get("value"), `hello **w**orld.`); + assert.equal(textarea.selectionStart, 8); + assert.equal(textarea.selectionEnd, 9); }); -testCase(`selecting the space after a word`, function(assert, textarea) { +testCase(`selecting the space after a word`, async function(assert, textarea) { textarea.selectionStart = 0; textarea.selectionEnd = 6; - click(`button.bold`); - andThen(() => { - assert.equal(this.get("value"), `**hello** world.`); - assert.equal(textarea.selectionStart, 2); - assert.equal(textarea.selectionEnd, 7); - }); + await click(`button.bold`); + + assert.equal(this.get("value"), `**hello** world.`); + assert.equal(textarea.selectionStart, 2); + assert.equal(textarea.selectionEnd, 7); }); -testCase(`bold button with no selection`, function(assert, textarea) { - click(`button.bold`); - andThen(() => { - const example = I18n.t(`composer.bold_text`); - assert.equal(this.get("value"), `hello world.**${example}**`); - assert.equal(textarea.selectionStart, 14); - assert.equal(textarea.selectionEnd, 14 + example.length); - }); +testCase(`bold button with no selection`, async function(assert, textarea) { + await click(`button.bold`); + + const example = I18n.t(`composer.bold_text`); + assert.equal(this.get("value"), `hello world.**${example}**`); + assert.equal(textarea.selectionStart, 14); + assert.equal(textarea.selectionEnd, 14 + example.length); }); -testCase(`bold button with a selection`, function(assert, textarea) { +testCase(`bold button with a selection`, async function(assert, textarea) { textarea.selectionStart = 6; textarea.selectionEnd = 11; - click(`button.bold`); - andThen(() => { - assert.equal(this.get("value"), `hello **world**.`); - assert.equal(textarea.selectionStart, 8); - assert.equal(textarea.selectionEnd, 13); - }); + await click(`button.bold`); + assert.equal(this.get("value"), `hello **world**.`); + assert.equal(textarea.selectionStart, 8); + assert.equal(textarea.selectionEnd, 13); - click(`button.bold`); - andThen(() => { - assert.equal(this.get("value"), "hello world."); - assert.equal(textarea.selectionStart, 6); - assert.equal(textarea.selectionEnd, 11); - }); + await click(`button.bold`); + assert.equal(this.get("value"), "hello world."); + assert.equal(textarea.selectionStart, 6); + assert.equal(textarea.selectionEnd, 11); }); -testCase(`bold with a multiline selection`, function(assert, textarea) { +testCase(`bold with a multiline selection`, async function(assert, textarea) { this.set("value", "hello\n\nworld\n\ntest."); - andThen(() => { - textarea.selectionStart = 0; - textarea.selectionEnd = 12; - }); + textarea.selectionStart = 0; + textarea.selectionEnd = 12; - click(`button.bold`); - andThen(() => { - assert.equal(this.get("value"), `**hello**\n\n**world**\n\ntest.`); - assert.equal(textarea.selectionStart, 0); - assert.equal(textarea.selectionEnd, 20); - }); + await click(`button.bold`); + assert.equal(this.get("value"), `**hello**\n\n**world**\n\ntest.`); + assert.equal(textarea.selectionStart, 0); + assert.equal(textarea.selectionEnd, 20); - click(`button.bold`); - andThen(() => { - assert.equal(this.get("value"), `hello\n\nworld\n\ntest.`); - assert.equal(textarea.selectionStart, 0); - assert.equal(textarea.selectionEnd, 12); - }); + await click(`button.bold`); + assert.equal(this.get("value"), `hello\n\nworld\n\ntest.`); + assert.equal(textarea.selectionStart, 0); + assert.equal(textarea.selectionEnd, 12); }); -testCase(`italic button with no selection`, function(assert, textarea) { - click(`button.italic`); - andThen(() => { - const example = I18n.t(`composer.italic_text`); - assert.equal(this.get("value"), `hello world._${example}_`); +testCase(`italic button with no selection`, async function(assert, textarea) { + await click(`button.italic`); + const example = I18n.t(`composer.italic_text`); + assert.equal(this.get("value"), `hello world._${example}_`); - assert.equal(textarea.selectionStart, 13); - assert.equal(textarea.selectionEnd, 13 + example.length); - }); + assert.equal(textarea.selectionStart, 13); + assert.equal(textarea.selectionEnd, 13 + example.length); }); -testCase(`italic button with a selection`, function(assert, textarea) { +testCase(`italic button with a selection`, async function(assert, textarea) { textarea.selectionStart = 6; textarea.selectionEnd = 11; - click(`button.italic`); - andThen(() => { - assert.equal(this.get("value"), `hello _world_.`); - assert.equal(textarea.selectionStart, 7); - assert.equal(textarea.selectionEnd, 12); - }); + await click(`button.italic`); + assert.equal(this.get("value"), `hello _world_.`); + assert.equal(textarea.selectionStart, 7); + assert.equal(textarea.selectionEnd, 12); - click(`button.italic`); - andThen(() => { - assert.equal(this.get("value"), "hello world."); - assert.equal(textarea.selectionStart, 6); - assert.equal(textarea.selectionEnd, 11); - }); + await click(`button.italic`); + assert.equal(this.get("value"), "hello world."); + assert.equal(textarea.selectionStart, 6); + assert.equal(textarea.selectionEnd, 11); }); -testCase(`italic with a multiline selection`, function(assert, textarea) { +testCase(`italic with a multiline selection`, async function(assert, textarea) { this.set("value", "hello\n\nworld\n\ntest."); - andThen(() => { - textarea.selectionStart = 0; - textarea.selectionEnd = 12; - }); + textarea.selectionStart = 0; + textarea.selectionEnd = 12; - click(`button.italic`); - andThen(() => { - assert.equal(this.get("value"), `_hello_\n\n_world_\n\ntest.`); - assert.equal(textarea.selectionStart, 0); - assert.equal(textarea.selectionEnd, 16); - }); + await click(`button.italic`); + assert.equal(this.get("value"), `_hello_\n\n_world_\n\ntest.`); + assert.equal(textarea.selectionStart, 0); + assert.equal(textarea.selectionEnd, 16); - click(`button.italic`); - andThen(() => { - assert.equal(this.get("value"), `hello\n\nworld\n\ntest.`); - assert.equal(textarea.selectionStart, 0); - assert.equal(textarea.selectionEnd, 12); - }); + await click(`button.italic`); + assert.equal(this.get("value"), `hello\n\nworld\n\ntest.`); + assert.equal(textarea.selectionStart, 0); + assert.equal(textarea.selectionEnd, 12); }); -testCase("link modal (cancel)", function(assert) { +testCase("link modal (cancel)", async function(assert) { assert.equal(this.$(".insert-link.hidden").length, 1); - click("button.link"); - andThen(() => { - assert.equal(this.$(".insert-link.hidden").length, 0); - }); - - click(".insert-link button.btn-danger"); - andThen(() => { - assert.equal(this.$(".insert-link.hidden").length, 1); - assert.equal(this.get("value"), "hello world."); - }); -}); - -testCase("link modal (cancel clears inputs)", async function(assert) { await click("button.link"); - await fillIn(".insert-link input.link-url", "https://meta.discourse.org/"); - await fillIn(".insert-link input.link-text", "Discourse Meta"); + assert.equal(this.$(".insert-link.hidden").length, 0); + await click(".insert-link button.btn-danger"); - - await click("button.link"); - assert.equal(this.$(".insert-link input.link-url")[0].value, ""); - assert.equal(this.$(".insert-link input.link-text")[0].value, ""); + assert.equal(this.$(".insert-link.hidden").length, 1); + assert.equal(this.get("value"), "hello world."); }); -testCase("link modal (simple link)", function(assert, textarea) { - click("button.link"); +testCase("link modal (simple link)", async function(assert, textarea) { + await click("button.link"); const url = "http://eviltrout.com"; - fillIn(".insert-link input.link-url", url); - click(".insert-link button.btn-primary"); - andThen(() => { - assert.equal(this.$(".insert-link.hidden").length, 1); - assert.equal(this.get("value"), `hello world.[${url}](${url})`); - assert.equal(textarea.selectionStart, 13); - assert.equal(textarea.selectionEnd, 13 + url.length); - }); + await fillIn(".insert-link input.link-url", url); + await click(".insert-link button.btn-primary"); + assert.equal(this.$(".insert-link.hidden").length, 1); + assert.equal(this.get("value"), `hello world.[${url}](${url})`); + assert.equal(textarea.selectionStart, 13); + assert.equal(textarea.selectionEnd, 13 + url.length); }); -testCase("link modal auto http addition", function(assert) { - click("button.link"); - fillIn(".insert-link input.link-url", "sam.com"); - click(".insert-link button.btn-primary"); - andThen(() => { - assert.equal(this.get("value"), `hello world.[sam.com](http://sam.com)`); - }); +testCase("link modal auto http addition", async function(assert) { + await click("button.link"); + await fillIn(".insert-link input.link-url", "sam.com"); + await click(".insert-link button.btn-primary"); + assert.equal(this.get("value"), `hello world.[sam.com](http://sam.com)`); }); -testCase("link modal (simple link) with selected text", function( +testCase("link modal (simple link) with selected text", async function( assert, textarea ) { textarea.selectionStart = 0; textarea.selectionEnd = 12; - click("button.link"); - andThen(() => { - assert.equal(this.$("input.link-text")[0].value, "hello world."); - }); - fillIn(".insert-link input.link-url", "http://eviltrout.com"); - click(".insert-link button.btn-primary"); - andThen(() => { - assert.equal(this.$(".insert-link.hidden").length, 1); - assert.equal(this.get("value"), "[hello world.](http://eviltrout.com)"); - }); + await click("button.link"); + assert.equal(this.$("input.link-text")[0].value, "hello world."); + + await fillIn(".insert-link input.link-url", "http://eviltrout.com"); + await click(".insert-link button.btn-primary"); + assert.equal(this.$(".insert-link.hidden").length, 1); + assert.equal(this.get("value"), "[hello world.](http://eviltrout.com)"); }); -testCase("link modal (link with description)", function(assert) { - click("button.link"); - fillIn(".insert-link input.link-url", "http://eviltrout.com"); - fillIn(".insert-link input.link-text", "evil trout"); - click(".insert-link button.btn-primary"); - andThen(() => { - assert.equal(this.$(".insert-link.hidden").length, 1); - assert.equal( - this.get("value"), - "hello world.[evil trout](http://eviltrout.com)" - ); - }); +testCase("link modal (link with description)", async function(assert) { + await click("button.link"); + await fillIn(".insert-link input.link-url", "http://eviltrout.com"); + await fillIn(".insert-link input.link-text", "evil trout"); + await click(".insert-link button.btn-primary"); + assert.equal(this.$(".insert-link.hidden").length, 1); + assert.equal( + this.get("value"), + "hello world.[evil trout](http://eviltrout.com)" + ); }); componentTest("advanced code", { @@ -325,24 +270,22 @@ function xyz(x, y, z) { ); }, - test(assert) { + async test(assert) { const textarea = this.$("textarea.d-editor-input")[0]; textarea.selectionStart = 0; textarea.selectionEnd = textarea.value.length; - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - ` + await click("button.code"); + assert.equal( + this.get("value"), + ` function xyz(x, y, z) { if (y === z) { return true; } } ` - ); - }); + ); } }); @@ -352,111 +295,85 @@ componentTest("code button", { this.siteSettings.code_formatting_style = "4-spaces-indent"; }, - test(assert) { + async test(assert) { const textarea = jumpEnd(this.$("textarea.d-editor-input")[0]); - click("button.code"); - andThen(() => { - assert.equal(this.get("value"), ` ${I18n.t("composer.code_text")}`); + await click("button.code"); + assert.equal(this.get("value"), ` ${I18n.t("composer.code_text")}`); - this.set("value", "first line\n\nsecond line\n\nthird line"); + this.set("value", "first line\n\nsecond line\n\nthird line"); - textarea.selectionStart = 11; - textarea.selectionEnd = 11; - }); + textarea.selectionStart = 11; + textarea.selectionEnd = 11; - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - `first line + await click("button.code"); + assert.equal( + this.get("value"), + `first line ${I18n.t("composer.code_text")} second line third line` - ); + ); - this.set("value", "first line\n\nsecond line\n\nthird line"); - }); + this.set("value", "first line\n\nsecond line\n\nthird line"); - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - `first line + await click("button.code"); + assert.equal( + this.get("value"), + `first line second line third line\`${I18n.t("composer.code_title")}\`` - ); - this.set("value", "first line\n\nsecond line\n\nthird line"); - }); + ); + this.set("value", "first line\n\nsecond line\n\nthird line"); - andThen(() => { - textarea.selectionStart = 5; - textarea.selectionEnd = 5; - }); + textarea.selectionStart = 5; + textarea.selectionEnd = 5; - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - `first\`${I18n.t("composer.code_title")}\` line + await click("button.code"); + assert.equal( + this.get("value"), + `first\`${I18n.t("composer.code_title")}\` line second line third line` - ); - this.set("value", "first line\n\nsecond line\n\nthird line"); - }); + ); + this.set("value", "first line\n\nsecond line\n\nthird line"); - andThen(() => { - textarea.selectionStart = 6; - textarea.selectionEnd = 10; - }); + textarea.selectionStart = 6; + textarea.selectionEnd = 10; - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - "first `line`\n\nsecond line\n\nthird line" - ); - assert.equal(textarea.selectionStart, 7); - assert.equal(textarea.selectionEnd, 11); - }); + await click("button.code"); + assert.equal( + this.get("value"), + "first `line`\n\nsecond line\n\nthird line" + ); + assert.equal(textarea.selectionStart, 7); + assert.equal(textarea.selectionEnd, 11); - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - "first line\n\nsecond line\n\nthird line" - ); - assert.equal(textarea.selectionStart, 6); - assert.equal(textarea.selectionEnd, 10); + await click("button.code"); + assert.equal(this.get("value"), "first line\n\nsecond line\n\nthird line"); + assert.equal(textarea.selectionStart, 6); + assert.equal(textarea.selectionEnd, 10); - textarea.selectionStart = 0; - textarea.selectionEnd = 23; - }); + textarea.selectionStart = 0; + textarea.selectionEnd = 23; - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - " first line\n\n second line\n\nthird line" - ); - assert.equal(textarea.selectionStart, 0); - assert.equal(textarea.selectionEnd, 31); - }); + await click("button.code"); + assert.equal( + this.get("value"), + " first line\n\n second line\n\nthird line" + ); + assert.equal(textarea.selectionStart, 0); + assert.equal(textarea.selectionEnd, 31); - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - "first line\n\nsecond line\n\nthird line" - ); - assert.equal(textarea.selectionStart, 0); - assert.equal(textarea.selectionEnd, 23); - }); + await click("button.code"); + assert.equal(this.get("value"), "first line\n\nsecond line\n\nthird line"); + assert.equal(textarea.selectionStart, 0); + assert.equal(textarea.selectionEnd, 23); } }); @@ -466,117 +383,110 @@ componentTest("code fences", { this.set("value", ""); }, - test(assert) { + async test(assert) { const textarea = jumpEnd(this.$("textarea.d-editor-input")[0]); - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - `\`\`\` + await click("button.code"); + assert.equal( + this.get("value"), + `\`\`\` ${I18n.t("composer.paste_code_text")} \`\`\`` - ); + ); - assert.equal(textarea.selectionStart, 4); - assert.equal(textarea.selectionEnd, 27); + assert.equal(textarea.selectionStart, 4); + assert.equal(textarea.selectionEnd, 27); - this.set("value", "first line\nsecond line\nthird line"); + this.set("value", "first line\nsecond line\nthird line"); - textarea.selectionStart = 0; - textarea.selectionEnd = textarea.value.length; - }); + textarea.selectionStart = 0; + textarea.selectionEnd = textarea.value.length; - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - `\`\`\` + await click("button.code"); + + assert.equal( + this.get("value"), + `\`\`\` first line second line third line \`\`\` ` - ); + ); - assert.equal(textarea.selectionStart, textarea.value.length); - assert.equal(textarea.selectionEnd, textarea.value.length); + assert.equal(textarea.selectionStart, textarea.value.length); + assert.equal(textarea.selectionEnd, textarea.value.length); - this.set("value", "first line\nsecond line\nthird line"); + this.set("value", "first line\nsecond line\nthird line"); - textarea.selectionStart = 0; - textarea.selectionEnd = 0; - }); + textarea.selectionStart = 0; + textarea.selectionEnd = 0; - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - `\`${I18n.t("composer.code_title")}\`first line + await click("button.code"); + + assert.equal( + this.get("value"), + `\`${I18n.t("composer.code_title")}\`first line second line third line` - ); + ); - assert.equal(textarea.selectionStart, 1); - assert.equal( - textarea.selectionEnd, - I18n.t("composer.code_title").length + 1 - ); + assert.equal(textarea.selectionStart, 1); + assert.equal( + textarea.selectionEnd, + I18n.t("composer.code_title").length + 1 + ); - this.set("value", "first line\nsecond line\nthird line"); + this.set("value", "first line\nsecond line\nthird line"); - textarea.selectionStart = 0; - textarea.selectionEnd = 10; - }); + textarea.selectionStart = 0; + textarea.selectionEnd = 10; - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - `\`first line\` + await click("button.code"); + + assert.equal( + this.get("value"), + `\`first line\` second line third line` - ); + ); - assert.equal(textarea.selectionStart, 1); - assert.equal(textarea.selectionEnd, 11); + assert.equal(textarea.selectionStart, 1); + assert.equal(textarea.selectionEnd, 11); - this.set("value", "first line\nsecond line\nthird line"); + this.set("value", "first line\nsecond line\nthird line"); - textarea.selectionStart = 0; - textarea.selectionEnd = 23; - }); + textarea.selectionStart = 0; + textarea.selectionEnd = 23; - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - `\`\`\` + await click("button.code"); + + assert.equal( + this.get("value"), + `\`\`\` first line second line \`\`\` third line` - ); + ); - assert.equal(textarea.selectionStart, 30); - assert.equal(textarea.selectionEnd, 30); + assert.equal(textarea.selectionStart, 30); + assert.equal(textarea.selectionEnd, 30); - this.set("value", "first line\nsecond line\nthird line"); + this.set("value", "first line\nsecond line\nthird line"); - textarea.selectionStart = 6; - textarea.selectionEnd = 17; - }); + textarea.selectionStart = 6; + textarea.selectionEnd = 17; - click("button.code"); - andThen(() => { - assert.equal( - this.get("value"), - `first \n\`\`\`\nline\nsecond\n\`\`\`\n line\nthird line` - ); + await click("button.code"); - assert.equal(textarea.selectionStart, 27); - assert.equal(textarea.selectionEnd, 27); - }); + assert.equal( + this.get("value"), + `first \n\`\`\`\nline\nsecond\n\`\`\`\n line\nthird line` + ); + + assert.equal(textarea.selectionStart, 27); + assert.equal(textarea.selectionEnd, 27); } }); @@ -585,24 +495,19 @@ componentTest("quote button - empty lines", { beforeEach() { this.set("value", "one\n\ntwo\n\nthree"); }, - test(assert) { + async test(assert) { const textarea = jumpEnd(this.$("textarea.d-editor-input")[0]); - andThen(() => { - textarea.selectionStart = 0; - }); + textarea.selectionStart = 0; - click("button.quote"); - andThen(() => { - assert.equal(this.get("value"), "> one\n> \n> two\n> \n> three"); - assert.equal(textarea.selectionStart, 0); - assert.equal(textarea.selectionEnd, 25); - }); + await click("button.quote"); - click("button.quote"); - andThen(() => { - assert.equal(this.get("value"), "one\n\ntwo\n\nthree"); - }); + assert.equal(this.get("value"), "> one\n> \n> two\n> \n> three"); + assert.equal(textarea.selectionStart, 0); + assert.equal(textarea.selectionEnd, 25); + + await click("button.quote"); + assert.equal(this.get("value"), "one\n\ntwo\n\nthree"); } }); @@ -611,172 +516,130 @@ componentTest("quote button - selecting empty lines", { beforeEach() { this.set("value", "one\n\n\n\ntwo"); }, - test(assert) { + async test(assert) { const textarea = jumpEnd(this.$("textarea.d-editor-input")[0]); - andThen(() => { - textarea.selectionStart = 6; - textarea.selectionEnd = 10; - }); + textarea.selectionStart = 6; + textarea.selectionEnd = 10; - click("button.quote"); - andThen(() => { - assert.equal(this.get("value"), "one\n\n\n> \n> two"); - }); + await click("button.quote"); + assert.equal(this.get("value"), "one\n\n\n> \n> two"); } }); -testCase("quote button", function(assert, textarea) { - andThen(() => { - textarea.selectionStart = 6; - textarea.selectionEnd = 9; - }); +testCase("quote button", async function(assert, textarea) { + textarea.selectionStart = 6; + textarea.selectionEnd = 9; - click("button.quote"); - andThen(() => { - assert.equal(this.get("value"), "hello\n\n> wor\n\nld."); - assert.equal(textarea.selectionStart, 7); - assert.equal(textarea.selectionEnd, 12); - }); + await click("button.quote"); + assert.equal(this.get("value"), "hello\n\n> wor\n\nld."); + assert.equal(textarea.selectionStart, 7); + assert.equal(textarea.selectionEnd, 12); - click("button.quote"); + await click("button.quote"); - andThen(() => { - assert.equal(this.get("value"), "hello\n\nwor\n\nld."); - assert.equal(textarea.selectionStart, 7); - assert.equal(textarea.selectionEnd, 10); - }); + assert.equal(this.get("value"), "hello\n\nwor\n\nld."); + assert.equal(textarea.selectionStart, 7); + assert.equal(textarea.selectionEnd, 10); - andThen(() => { - textarea.selectionStart = 15; - textarea.selectionEnd = 15; - }); + textarea.selectionStart = 15; + textarea.selectionEnd = 15; - click("button.quote"); - andThen(() => { - assert.equal(this.get("value"), "hello\n\nwor\n\nld.\n\n> Blockquote"); - }); + await click("button.quote"); + assert.equal(this.get("value"), "hello\n\nwor\n\nld.\n\n> Blockquote"); }); -testCase(`bullet button with no selection`, function(assert, textarea) { +testCase(`bullet button with no selection`, async function(assert, textarea) { const example = I18n.t("composer.list_item"); - click(`button.bullet`); - andThen(() => { - assert.equal(this.get("value"), `hello world.\n\n* ${example}`); - assert.equal(textarea.selectionStart, 14); - assert.equal(textarea.selectionEnd, 16 + example.length); - }); + await click(`button.bullet`); + assert.equal(this.get("value"), `hello world.\n\n* ${example}`); + assert.equal(textarea.selectionStart, 14); + assert.equal(textarea.selectionEnd, 16 + example.length); - click(`button.bullet`); - andThen(() => { - assert.equal(this.get("value"), `hello world.\n\n${example}`); - }); + await click(`button.bullet`); + assert.equal(this.get("value"), `hello world.\n\n${example}`); }); -testCase(`bullet button with a selection`, function(assert, textarea) { +testCase(`bullet button with a selection`, async function(assert, textarea) { textarea.selectionStart = 6; textarea.selectionEnd = 11; - click(`button.bullet`); - andThen(() => { - assert.equal(this.get("value"), `hello\n\n* world\n\n.`); - assert.equal(textarea.selectionStart, 7); - assert.equal(textarea.selectionEnd, 14); - }); + await click(`button.bullet`); + assert.equal(this.get("value"), `hello\n\n* world\n\n.`); + assert.equal(textarea.selectionStart, 7); + assert.equal(textarea.selectionEnd, 14); - click(`button.bullet`); - andThen(() => { - assert.equal(this.get("value"), `hello\n\nworld\n\n.`); - assert.equal(textarea.selectionStart, 7); - assert.equal(textarea.selectionEnd, 12); - }); + await click(`button.bullet`); + assert.equal(this.get("value"), `hello\n\nworld\n\n.`); + assert.equal(textarea.selectionStart, 7); + assert.equal(textarea.selectionEnd, 12); }); -testCase(`bullet button with a multiple line selection`, function( +testCase(`bullet button with a multiple line selection`, async function( assert, textarea ) { this.set("value", "* Hello\n\nWorld\n\nEvil"); - andThen(() => { - textarea.selectionStart = 0; - textarea.selectionEnd = 20; - }); + textarea.selectionStart = 0; + textarea.selectionEnd = 20; - click(`button.bullet`); - andThen(() => { - assert.equal(this.get("value"), "Hello\n\nWorld\n\nEvil"); - assert.equal(textarea.selectionStart, 0); - assert.equal(textarea.selectionEnd, 18); - }); + await click(`button.bullet`); + assert.equal(this.get("value"), "Hello\n\nWorld\n\nEvil"); + assert.equal(textarea.selectionStart, 0); + assert.equal(textarea.selectionEnd, 18); - click(`button.bullet`); - andThen(() => { - assert.equal(this.get("value"), "* Hello\n\n* World\n\n* Evil"); - assert.equal(textarea.selectionStart, 0); - assert.equal(textarea.selectionEnd, 24); - }); + await click(`button.bullet`); + assert.equal(this.get("value"), "* Hello\n\n* World\n\n* Evil"); + assert.equal(textarea.selectionStart, 0); + assert.equal(textarea.selectionEnd, 24); }); -testCase(`list button with no selection`, function(assert, textarea) { +testCase(`list button with no selection`, async function(assert, textarea) { const example = I18n.t("composer.list_item"); - click(`button.list`); - andThen(() => { - assert.equal(this.get("value"), `hello world.\n\n1. ${example}`); - assert.equal(textarea.selectionStart, 14); - assert.equal(textarea.selectionEnd, 17 + example.length); - }); + await click(`button.list`); + assert.equal(this.get("value"), `hello world.\n\n1. ${example}`); + assert.equal(textarea.selectionStart, 14); + assert.equal(textarea.selectionEnd, 17 + example.length); - click(`button.list`); - andThen(() => { - assert.equal(this.get("value"), `hello world.\n\n${example}`); - assert.equal(textarea.selectionStart, 14); - assert.equal(textarea.selectionEnd, 14 + example.length); - }); + await click(`button.list`); + assert.equal(this.get("value"), `hello world.\n\n${example}`); + assert.equal(textarea.selectionStart, 14); + assert.equal(textarea.selectionEnd, 14 + example.length); }); -testCase(`list button with a selection`, function(assert, textarea) { +testCase(`list button with a selection`, async function(assert, textarea) { textarea.selectionStart = 6; textarea.selectionEnd = 11; - click(`button.list`); - andThen(() => { - assert.equal(this.get("value"), `hello\n\n1. world\n\n.`); - assert.equal(textarea.selectionStart, 7); - assert.equal(textarea.selectionEnd, 15); - }); + await click(`button.list`); + assert.equal(this.get("value"), `hello\n\n1. world\n\n.`); + assert.equal(textarea.selectionStart, 7); + assert.equal(textarea.selectionEnd, 15); - click(`button.list`); - andThen(() => { - assert.equal(this.get("value"), `hello\n\nworld\n\n.`); - assert.equal(textarea.selectionStart, 7); - assert.equal(textarea.selectionEnd, 12); - }); + await click(`button.list`); + assert.equal(this.get("value"), `hello\n\nworld\n\n.`); + assert.equal(textarea.selectionStart, 7); + assert.equal(textarea.selectionEnd, 12); }); -testCase(`list button with line sequence`, function(assert, textarea) { +testCase(`list button with line sequence`, async function(assert, textarea) { this.set("value", "Hello\n\nWorld\n\nEvil"); - andThen(() => { - textarea.selectionStart = 0; - textarea.selectionEnd = 18; - }); + textarea.selectionStart = 0; + textarea.selectionEnd = 18; - click(`button.list`); - andThen(() => { - assert.equal(this.get("value"), "1. Hello\n\n2. World\n\n3. Evil"); - assert.equal(textarea.selectionStart, 0); - assert.equal(textarea.selectionEnd, 27); - }); + await click(`button.list`); + assert.equal(this.get("value"), "1. Hello\n\n2. World\n\n3. Evil"); + assert.equal(textarea.selectionStart, 0); + assert.equal(textarea.selectionEnd, 27); - click(`button.list`); - andThen(() => { - assert.equal(this.get("value"), "Hello\n\nWorld\n\nEvil"); - assert.equal(textarea.selectionStart, 0); - assert.equal(textarea.selectionEnd, 18); - }); + await click(`button.list`); + assert.equal(this.get("value"), "Hello\n\nWorld\n\nEvil"); + assert.equal(textarea.selectionStart, 0); + assert.equal(textarea.selectionEnd, 18); }); componentTest("clicking the toggle-direction button toggles the direction", { @@ -786,36 +649,31 @@ componentTest("clicking the toggle-direction button toggles the direction", { this.siteSettings.default_locale = "en"; }, - test(assert) { + async test(assert) { const textarea = this.$("textarea.d-editor-input"); - click("button.toggle-direction"); - andThen(() => { - assert.equal(textarea.attr("dir"), "rtl"); - }); - click("button.toggle-direction"); - andThen(() => { - assert.equal(textarea.attr("dir"), "ltr"); - }); + await click("button.toggle-direction"); + assert.equal(textarea.attr("dir"), "rtl"); + await click("button.toggle-direction"); + assert.equal(textarea.attr("dir"), "ltr"); } }); -testCase(`doesn't jump to bottom with long text`, function(assert, textarea) { +testCase(`doesn't jump to bottom with long text`, async function( + assert, + textarea +) { let longText = "hello world."; for (let i = 0; i < 8; i++) { longText = longText + longText; } this.set("value", longText); - andThen(() => { - $(textarea).scrollTop(0); - textarea.selectionStart = 3; - textarea.selectionEnd = 3; - }); + $(textarea).scrollTop(0); + textarea.selectionStart = 3; + textarea.selectionEnd = 3; - click("button.bold"); - andThen(() => { - assert.equal($(textarea).scrollTop(), 0, "it stays scrolled up"); - }); + await click("button.bold"); + assert.equal($(textarea).scrollTop(), 0, "it stays scrolled up"); }); componentTest("emoji", { @@ -834,45 +692,35 @@ componentTest("emoji", { }); this.set("value", "hello world."); }, - test(assert) { + async test(assert) { jumpEnd(this.$("textarea.d-editor-input")[0]); - click("button.emoji"); + await click("button.emoji"); - click( + await click( '.emoji-picker .section[data-section="people"] button.emoji[title="grinning"]' ); - andThen(() => { - assert.equal(this.get("value"), "hello world.:grinning:"); - }); + assert.equal(this.get("value"), "hello world.:grinning:"); } }); -testCase("replace-text event by default", function(assert) { +testCase("replace-text event by default", async function(assert) { this.set("value", "red green blue"); - andThen(() => { - this.container - .lookup("app-events:main") - .trigger("composer:replace-text", "green", "yellow"); - }); + await this.container + .lookup("app-events:main") + .trigger("composer:replace-text", "green", "yellow"); - andThen(() => { - assert.equal(this.get("value"), "red green blue"); - }); + assert.equal(this.get("value"), "red green blue"); }); -composerTestCase("replace-text event for composer", function(assert) { +composerTestCase("replace-text event for composer", async function(assert) { this.set("value", "red green blue"); - andThen(() => { - this.container - .lookup("app-events:main") - .trigger("composer:replace-text", "green", "yellow"); - }); + await this.container + .lookup("app-events:main") + .trigger("composer:replace-text", "green", "yellow"); - andThen(() => { - assert.equal(this.get("value"), "red yellow blue"); - }); + assert.equal(this.get("value"), "red yellow blue"); }); (() => { @@ -949,39 +797,26 @@ composerTestCase("replace-text event for composer", function(assert) { return [start, end - start]; } - function formatTextWithSelection(text, [start, len]) { - return [ - '"', - text.substr(0, start), - "<", - text.substr(start, len), - ">", - text.substr(start + len), - '"' - ].join(""); - } - for (let i = 0; i < CASES.length; i++) { const CASE = CASES[i]; - composerTestCase(`replace-text event: ${CASE.description}`, function( + // prettier-ignore + composerTestCase(`replace-text event: ${CASE.description}`, async function( // eslint-disable-line no-loop-func assert, textarea ) { this.set("value", BEFORE); - setSelection(textarea, CASE.before); - andThen(() => { - this.container - .lookup("app-events:main") - .trigger("composer:replace-text", "green", "yellow"); - }); - andThen(() => { - let expect = formatTextWithSelection(AFTER, CASE.after); - let actual = formatTextWithSelection( - this.get("value"), - getSelection(textarea) - ); - assert.equal(actual, expect); - }); + await setSelection(textarea, CASE.before); + + this.container + .lookup("app-events:main") + .trigger("composer:replace-text", "green", "yellow"); + + let expect = await formatTextWithSelection(AFTER, CASE.after); // eslint-disable-line no-undef + let actual = await formatTextWithSelection( // eslint-disable-line no-undef + this.get("value"), + getSelection(textarea) + ); + assert.equal(actual, expect); }); } })(); diff --git a/test/javascripts/components/list-setting-test.js.es6 b/test/javascripts/components/list-setting-test.js.es6 index a69d17a8f90..2926c2d4812 100644 --- a/test/javascripts/components/list-setting-test.js.es6 +++ b/test/javascripts/components/list-setting-test.js.es6 @@ -11,20 +11,18 @@ componentTest("default", { }, test(assert) { - andThen(() => { - assert.equal( - selectKit() - .header() - .title(), - "bold,italic" - ); - assert.equal( - selectKit() - .header() - .value(), - "bold,italic" - ); - }); + assert.equal( + selectKit() + .header() + .title(), + "bold,italic" + ); + assert.equal( + selectKit() + .header() + .value(), + "bold,italic" + ); } }); @@ -36,14 +34,12 @@ componentTest("with empty string as value", { }, test(assert) { - andThen(() => { - assert.equal( - selectKit() - .header() - .value(), - "" - ); - }); + assert.equal( + selectKit() + .header() + .value(), + "" + ); } }); @@ -55,14 +51,12 @@ componentTest("with only setting value", { }, test(assert) { - andThen(() => { - assert.equal( - selectKit() - .header() - .value(), - "bold,italic" - ); - }); + assert.equal( + selectKit() + .header() + .value(), + "bold,italic" + ); } }); @@ -74,35 +68,26 @@ componentTest("interactions", { this.set("choices", ["bold", "italic", "underline"]); }, - test(assert) { + async test(assert) { const listSetting = selectKit(); - listSetting.expand().selectRowByValue("underline"); + await listSetting.expand(); + await listSetting.selectRowByValue("underline"); - andThen(() => { - assert.equal(listSetting.header().value(), "bold,italic,underline"); - }); + assert.equal(listSetting.header().value(), "bold,italic,underline"); - listSetting.expand().fillInFilter("strike"); + await listSetting.expand(); + await listSetting.fillInFilter("strike"); - andThen(() => { - assert.equal(listSetting.highlightedRow().value(), "strike"); - }); + assert.equal(listSetting.highlightedRow().value(), "strike"); - listSetting.keyboard().enter(); + await listSetting.keyboard("enter"); - andThen(() => { - assert.equal( - listSetting.header().value(), - "bold,italic,underline,strike" - ); - }); + assert.equal(listSetting.header().value(), "bold,italic,underline,strike"); - listSetting.keyboard().backspace(); - listSetting.keyboard().backspace(); + await listSetting.keyboard("backspace"); + await listSetting.keyboard("backspace"); - andThen(() => { - assert.equal(listSetting.header().value(), "bold,italic,underline"); - }); + assert.equal(listSetting.header().value(), "bold,italic,underline"); } }); diff --git a/test/javascripts/components/multi-select-test.js.es6 b/test/javascripts/components/multi-select-test.js.es6 index cf37448d71b..b1f78fdfae0 100644 --- a/test/javascripts/components/multi-select-test.js.es6 +++ b/test/javascripts/components/multi-select-test.js.es6 @@ -15,14 +15,12 @@ componentTest("with objects and values", { }, test(assert) { - andThen(() => { - assert.equal( - this.get("subject") - .header() - .value(), - "1,2" - ); - }); + assert.equal( + this.get("subject") + .header() + .value(), + "1,2" + ); } }); @@ -34,13 +32,11 @@ componentTest("with title", { }, test(assert) { - andThen(() => - assert.equal( - selectKit() - .header() - .title(), - "My title" - ) + assert.equal( + selectKit() + .header() + .title(), + "My title" ); } }); @@ -58,165 +54,127 @@ componentTest("interactions", { this.set("values", [1, 2]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.equal( - this.get("subject") - .highlightedRow() - .name(), - "robin", - "it highlights the first content row" - ); - }); + assert.equal( + this.get("subject") + .highlightedRow() + .name(), + "robin", + "it highlights the first content row" + ); - this.set("none", "test.none"); + await this.set("none", "test.none"); - andThen(() => { - assert.ok( - this.get("subject") - .noneRow() - .exists() - ); - assert.equal( - this.get("subject") - .highlightedRow() - .name(), - "robin", - "it highlights the first content row" - ); - }); + assert.ok( + this.get("subject") + .noneRow() + .exists() + ); + assert.equal( + this.get("subject") + .highlightedRow() + .name(), + "robin", + "it highlights the first content row" + ); - this.get("subject").selectRowByValue(3); - this.get("subject").expand(); + await this.get("subject").selectRowByValue(3); + await this.get("subject").expand(); - andThen(() => { - assert.equal( - this.get("subject") - .highlightedRow() - .name(), - "none", - "it highlights none row if no content" - ); - }); + assert.equal( + this.get("subject") + .highlightedRow() + .name(), + "none", + "it highlights none row if no content" + ); - this.get("subject").fillInFilter("joffrey"); + await this.get("subject").fillInFilter("joffrey"); - andThen(() => { - assert.equal( - this.get("subject") - .highlightedRow() - .name(), - "joffrey", - "it highlights create row when filling filter" - ); - }); + assert.equal( + this.get("subject") + .highlightedRow() + .name(), + "joffrey", + "it highlights create row when filling filter" + ); - this.get("subject") - .keyboard() - .enter(); + await this.get("subject").keyboard("enter"); - andThen(() => { - assert.equal( - this.get("subject") - .highlightedRow() - .name(), - "none", - "it highlights none row after creating content and no content left" - ); - }); + assert.equal( + this.get("subject") + .highlightedRow() + .name(), + "none", + "it highlights none row after creating content and no content left" + ); - this.get("subject") - .keyboard() - .backspace(); + await this.get("subject").keyboard("backspace"); - andThen(() => { - const $lastSelectedName = this.get("subject") - .header() - .el() - .find(".selected-name") - .last(); - assert.equal($lastSelectedName.attr("data-name"), "joffrey"); - assert.ok( - $lastSelectedName.hasClass("is-highlighted"), - "it highlights the last selected name when using backspace" - ); - }); + const $lastSelectedName = this.get("subject") + .header() + .el() + .find(".selected-name") + .last(); + assert.equal($lastSelectedName.attr("data-name"), "joffrey"); + assert.ok( + $lastSelectedName.hasClass("is-highlighted"), + "it highlights the last selected name when using backspace" + ); - this.get("subject") - .keyboard() - .backspace(); + await this.get("subject").keyboard("backspace"); - andThen(() => { - const $lastSelectedName = this.get("subject") - .header() - .el() - .find(".selected-name") - .last(); - assert.equal( - $lastSelectedName.attr("data-name"), - "robin", - "it removes the previous highlighted selected content" - ); - assert.notOk( - this.get("subject") - .rowByValue("joffrey") - .exists(), - "generated content shouldn’t appear in content when removed" - ); - }); + const $lastSelectedName1 = this.get("subject") + .header() + .el() + .find(".selected-name") + .last(); + assert.equal( + $lastSelectedName1.attr("data-name"), + "robin", + "it removes the previous highlighted selected content" + ); + assert.notOk( + this.get("subject") + .rowByValue("joffrey") + .exists(), + "generated content shouldn’t appear in content when removed" + ); - this.get("subject") - .keyboard() - .selectAll(); + await this.get("subject").keyboard("selectAll"); - andThen(() => { - const $highlightedSelectedNames = this.get("subject") - .header() - .el() - .find(".selected-name.is-highlighted"); - assert.equal( - $highlightedSelectedNames.length, - 3, - "it highlights each selected name" - ); - }); + const $highlightedSelectedNames2 = this.get("subject") + .header() + .el() + .find(".selected-name.is-highlighted"); + assert.equal( + $highlightedSelectedNames2.length, + 3, + "it highlights each selected name" + ); - this.get("subject") - .keyboard() - .backspace(); + await this.get("subject").keyboard("backspace"); - andThen(() => { - const $selectedNames = this.get("subject") - .header() - .el() - .find(".selected-name"); - assert.equal($selectedNames.length, 0, "it removed all selected content"); - }); + const $selectedNames = this.get("subject") + .header() + .el() + .find(".selected-name"); + assert.equal($selectedNames.length, 0, "it removed all selected content"); - andThen(() => { - assert.ok(this.get("subject").isFocused()); - assert.ok(this.get("subject").isExpanded()); - }); + assert.ok(this.get("subject").isFocused()); + assert.ok(this.get("subject").isExpanded()); - this.get("subject") - .keyboard() - .escape(); + await this.get("subject").keyboard("escape"); - andThen(() => { - assert.ok(this.get("subject").isFocused()); - assert.notOk(this.get("subject").isExpanded()); - }); + assert.ok(this.get("subject").isFocused()); + assert.notOk(this.get("subject").isExpanded()); - this.get("subject") - .keyboard() - .escape(); + await this.get("subject").keyboard("escape"); - andThen(() => { - assert.notOk(this.get("subject").isFocused()); - assert.notOk(this.get("subject").isExpanded()); - }); + assert.notOk(this.get("subject").isFocused()); + assert.notOk(this.get("subject").isExpanded()); } }); @@ -227,16 +185,14 @@ componentTest("with limitMatches", { this.set("content", ["sam", "jeff", "neil"]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => - assert.equal( - this.get("subject") - .el() - .find(".select-kit-row").length, - 2 - ) + assert.equal( + this.get("subject") + .el() + .find(".select-kit-row").length, + 2 ); } }); @@ -248,26 +204,22 @@ componentTest("with minimum", { this.set("content", ["sam", "jeff", "neil"]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => - assert.equal( - this.get("subject").validationMessage(), - "Select at least 1 item." - ) + assert.equal( + this.get("subject").validationMessage(), + "Select at least 1 item." ); - this.get("subject").selectRowByValue("sam"); + await this.get("subject").selectRowByValue("sam"); - andThen(() => { - assert.equal( - this.get("subject") - .header() - .label(), - "sam" - ); - }); + assert.equal( + this.get("subject") + .header() + .label(), + "sam" + ); } }); @@ -280,22 +232,18 @@ componentTest("with minimumLabel", { this.set("content", ["sam", "jeff", "neil"]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => - assert.equal(this.get("subject").validationMessage(), "min 1") + assert.equal(this.get("subject").validationMessage(), "min 1"); + + await this.get("subject").selectRowByValue("jeff"); + + assert.equal( + this.get("subject") + .header() + .label(), + "jeff" ); - - this.get("subject").selectRowByValue("jeff"); - - andThen(() => { - assert.equal( - this.get("subject") - .header() - .label(), - "jeff" - ); - }); } }); diff --git a/test/javascripts/components/single-select-test.js.es6 b/test/javascripts/components/single-select-test.js.es6 index 46caaa66169..da1e9fbe56a 100644 --- a/test/javascripts/components/single-select-test.js.es6 +++ b/test/javascripts/components/single-select-test.js.es6 @@ -16,30 +16,24 @@ componentTest("updating the content refreshes the list", { this.set("content", [{ id: 1, name: "BEFORE" }]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.equal( - this.get("subject") - .rowByValue(1) - .name(), - "BEFORE" - ); - }); + assert.equal( + this.get("subject") + .rowByValue(1) + .name(), + "BEFORE" + ); - andThen(() => { - this.set("content", [{ id: 1, name: "AFTER" }]); - }); + await this.set("content", [{ id: 1, name: "AFTER" }]); - andThen(() => { - assert.equal( - this.get("subject") - .rowByValue(1) - .name(), - "AFTER" - ); - }); + assert.equal( + this.get("subject") + .rowByValue(1) + .name(), + "AFTER" + ); } }); @@ -51,24 +45,20 @@ componentTest("accepts a value by reference", { this.set("content", [{ id: 1, name: "robin" }, { id: 2, name: "regis" }]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.equal( - this.get("subject") - .selectedRow() - .name(), - "robin", - "it highlights the row corresponding to the value" - ); - }); + assert.equal( + this.get("subject") + .selectedRow() + .name(), + "robin", + "it highlights the row corresponding to the value" + ); - this.get("subject").selectRowByValue(1); + await this.get("subject").selectRowByValue(1); - andThen(() => { - assert.equal(this.get("value"), 1, "it mutates the value"); - }); + assert.equal(this.get("value"), 1, "it mutates the value"); } }); @@ -89,69 +79,63 @@ componentTest("no default icon", { componentTest("default search icon", { template: "{{single-select filterable=true}}", - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.ok( - exists( - this.get("subject") - .filter() - .icon() - ), - "it has an icon" - ); - }); + assert.ok( + exists( + this.get("subject") + .filter() + .icon() + ), + "it has an icon" + ); } }); componentTest("with no search icon", { template: "{{single-select filterable=true filterIcon=null}}", - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.notOk( - exists( - this.get("subject") - .filter() - .icon() - ), - "it has no icon" - ); - }); + assert.notOk( + exists( + this.get("subject") + .filter() + .icon() + ), + "it has no icon" + ); } }); componentTest("custom search icon", { template: '{{single-select filterable=true filterIcon="shower"}}', - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.ok( - this.get("subject") - .filter() - .icon() - .hasClass("d-icon-shower"), - "it has a the correct icon" - ); - }); + assert.ok( + this.get("subject") + .filter() + .icon() + .hasClass("d-icon-shower"), + "it has a the correct icon" + ); } }); componentTest("is expandable", { template: "{{single-select}}", - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => assert.ok(this.get("subject").isExpanded())); + assert.ok(this.get("subject").isExpanded()); - this.get("subject").collapse(); + await this.get("subject").collapse(); - andThen(() => assert.notOk(this.get("subject").isExpanded())); + assert.notOk(this.get("subject").isExpanded()); } }); @@ -164,17 +148,15 @@ componentTest("accepts custom value/name keys", { this.set("content", [{ identifier: 1, item: "robin" }]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.equal( - this.get("subject") - .selectedRow() - .name(), - "robin" - ); - }); + assert.equal( + this.get("subject") + .selectedRow() + .name(), + "robin" + ); } }); @@ -185,14 +167,12 @@ componentTest("doesn’t render collection content before first expand", { this.set("content", [{ value: 1, name: "robin" }]); }, - test(assert) { + async test(assert) { assert.notOk(exists(find(".select-kit-collection"))); - this.get("subject").expand(); + await this.get("subject").expand(); - andThen(() => { - assert.ok(exists(find(".select-kit-collection"))); - }); + assert.ok(exists(find(".select-kit-collection"))); } }); @@ -203,29 +183,25 @@ componentTest("dynamic headerText", { this.set("content", [{ id: 1, name: "robin" }, { id: 2, name: "regis" }]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.equal( - this.get("subject") - .header() - .name(), - "robin" - ); - }); + assert.equal( + this.get("subject") + .header() + .name(), + "robin" + ); - this.get("subject").selectRowByValue(2); + await this.get("subject").selectRowByValue(2); - andThen(() => { - assert.equal( - this.get("subject") - .header() - .name(), - "regis", - "it changes header text" - ); - }); + assert.equal( + this.get("subject") + .header() + .name(), + "regis", + "it changes header text" + ); } }); @@ -239,19 +215,17 @@ componentTest("supports custom row template", { }); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.equal( - this.get("subject") - .rowByValue(1) - .el() - .html() - .trim(), - "robin" - ); - }); + assert.equal( + this.get("subject") + .rowByValue(1) + .el() + .html() + .trim(), + "robin" + ); } }); @@ -266,31 +240,25 @@ componentTest("supports converting select value to integer", { ]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => - assert.equal( - this.get("subject") - .selectedRow() - .name(), - "régis" - ) + assert.equal( + this.get("subject") + .selectedRow() + .name(), + "régis" ); - andThen(() => { - this.set("value", 1); - }); + await this.set("value", 1); - andThen(() => { - assert.equal( - this.get("subject") - .selectedRow() - .name(), - "robin", - "it works with dynamic content" - ); - }); + assert.equal( + this.get("subject") + .selectedRow() + .name(), + "robin", + "it works with dynamic content" + ); } }); @@ -305,31 +273,25 @@ componentTest("supports converting string as boolean to boolean", { ]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => - assert.equal( - this.get("subject") - .selectedRow() - .name(), - "ASC" - ) + assert.equal( + this.get("subject") + .selectedRow() + .name(), + "ASC" ); - andThen(() => { - this.set("value", false); - }); + await this.set("value", false); - andThen(() => { - assert.equal( - this.get("subject") - .selectedRow() - .name(), - "DESC", - "it works with dynamic content" - ); - }); + assert.equal( + this.get("subject") + .selectedRow() + .name(), + "DESC", + "it works with dynamic content" + ); } }); @@ -340,92 +302,68 @@ componentTest("supports keyboard events", { this.set("content", [{ id: 1, name: "robin" }, { id: 2, name: "regis" }]); }, - test(assert) { - this.get("subject") - .expand() - .keyboard() - .down(); + async test(assert) { + await this.get("subject").expand(); + await this.get("subject").keyboard("down"); - andThen(() => { - assert.equal( - this.get("subject") - .highlightedRow() - .title(), - "regis", - "the next row is highlighted" - ); - }); + assert.equal( + this.get("subject") + .highlightedRow() + .title(), + "regis", + "the next row is highlighted" + ); - this.get("subject") - .keyboard() - .down(); + await this.get("subject").keyboard("down"); - andThen(() => { - assert.equal( - this.get("subject") - .highlightedRow() - .title(), - "robin", - "it returns to the first row" - ); - }); + assert.equal( + this.get("subject") + .highlightedRow() + .title(), + "robin", + "it returns to the first row" + ); - this.get("subject") - .keyboard() - .up(); + await this.get("subject").keyboard("up"); - andThen(() => { - assert.equal( - this.get("subject") - .highlightedRow() - .title(), - "regis", - "it highlights the last row" - ); - }); + assert.equal( + this.get("subject") + .highlightedRow() + .title(), + "regis", + "it highlights the last row" + ); - this.get("subject") - .keyboard() - .enter(); + await this.get("subject").keyboard("enter"); - andThen(() => { - assert.equal( - this.get("subject") - .selectedRow() - .title(), - "regis", - "it selects the row when pressing enter" - ); - assert.notOk( - this.get("subject").isExpanded(), - "it collapses the select box when selecting a row" - ); - }); + assert.equal( + this.get("subject") + .selectedRow() + .title(), + "regis", + "it selects the row when pressing enter" + ); + assert.notOk( + this.get("subject").isExpanded(), + "it collapses the select box when selecting a row" + ); - this.get("subject") - .expand() - .keyboard() - .escape(); + await this.get("subject").expand(); + await this.get("subject").keyboard("escape"); - andThen(() => { - assert.notOk( - this.get("subject").isExpanded(), - "it collapses the select box" - ); - }); + assert.notOk( + this.get("subject").isExpanded(), + "it collapses the select box" + ); - this.get("subject") - .expand() - .fillInFilter("regis") - .keyboard() - .tab(); + await this.get("subject").expand(); + await this.get("subject").fillInFilter("regis"); + await this.get("subject").keyboard("tab"); - andThen(() => { - assert.notOk( - this.get("subject").isExpanded(), - "it collapses the select box when selecting a row" - ); - }); + assert.notOk( + this.get("subject").isExpanded(), + "it collapses the select box when selecting a row" + ); } }); @@ -442,13 +380,11 @@ componentTest("with allowInitialValueMutation", { }, test(assert) { - andThen(() => { - assert.equal( - this.get("value"), - "1", - "it mutates the value on initial rendering" - ); - }); + assert.equal( + this.get("value"), + "1", + "it mutates the value on initial rendering" + ); } }); @@ -464,20 +400,18 @@ componentTest("support appending content through plugin api", { this.set("content", [{ id: "1", name: "robin" }]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.equal(this.get("subject").rows().length, 2); - assert.equal( - this.get("subject") - .rowByIndex(1) - .name(), - "regis" - ); - }); + assert.equal(this.get("subject").rows().length, 2); + assert.equal( + this.get("subject") + .rowByIndex(1) + .name(), + "regis" + ); - andThen(() => clearCallbacks()); + clearCallbacks(); } }); @@ -500,20 +434,18 @@ componentTest("support modifying content through plugin api", { ]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.equal(this.get("subject").rows().length, 3); - assert.equal( - this.get("subject") - .rowByIndex(1) - .name(), - "sam" - ); - }); + assert.equal(this.get("subject").rows().length, 3); + assert.equal( + this.get("subject") + .rowByIndex(1) + .name(), + "sam" + ); - andThen(() => clearCallbacks()); + clearCallbacks(); } }); @@ -530,20 +462,18 @@ componentTest("support prepending content through plugin api", { this.set("content", [{ id: "1", name: "robin" }]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.equal(this.get("subject").rows().length, 2); - assert.equal( - this.get("subject") - .rowByIndex(0) - .name(), - "regis" - ); - }); + assert.equal(this.get("subject").rows().length, 2); + assert.equal( + this.get("subject") + .rowByIndex(0) + .name(), + "regis" + ); - andThen(() => clearCallbacks()); + clearCallbacks(); } }); @@ -561,16 +491,13 @@ componentTest("support modifying on select behavior through plugin api", { this.set("content", [{ id: "1", name: "robin" }]); }, - test(assert) { - this.get("subject") - .expand() - .selectRowByValue(1); + async test(assert) { + await this.get("subject").expand(); + await this.get("subject").selectRowByValue(1); - andThen(() => { - assert.equal(find(".on-select-test").html(), "1"); - }); + assert.equal(find(".on-select-test").html(), "1"); - andThen(() => clearCallbacks()); + clearCallbacks(); } }); @@ -582,30 +509,24 @@ componentTest("with nameChanges", { this.set("content", [this.get("robin")]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.equal( - this.get("subject") - .header() - .name(), - "robin" - ); - }); + assert.equal( + this.get("subject") + .header() + .name(), + "robin" + ); - andThen(() => { - this.set("robin.name", "robin2"); - }); + await this.set("robin.name", "robin2"); - andThen(() => { - assert.equal( - this.get("subject") - .header() - .name(), - "robin2" - ); - }); + assert.equal( + this.get("subject") + .header() + .name(), + "robin2" + ); } }); @@ -616,23 +537,21 @@ componentTest("with null value", { this.set("content", [{ name: "robin" }]); }, - test(assert) { - this.get("subject").expand(); + async test(assert) { + await this.get("subject").expand(); - andThen(() => { - assert.equal( - this.get("subject") - .header() - .name(), - "robin" - ); - assert.equal( - this.get("subject") - .header() - .value(), - undefined - ); - }); + assert.equal( + this.get("subject") + .header() + .name(), + "robin" + ); + assert.equal( + this.get("subject") + .header() + .value(), + undefined + ); } }); @@ -643,10 +562,10 @@ componentTest("with collection header", { this.set("collectionHeader", "