From e36d1c72f185a84ec079e468831b16f430291f2b Mon Sep 17 00:00:00 2001 From: Maja Komel Date: Thu, 19 Jul 2018 11:40:42 +0200 Subject: [PATCH] DEV: migrate acceptance tests to async await - badges, category, composer, customHTML --- .../javascripts/acceptance/badges-test.js.es6 | 22 +- .../acceptance/category-chooser-test.js.es6 | 30 +- .../category-edit-security-test.js.es6 | 152 ++-- .../acceptance/category-edit-test.js.es6 | 84 +-- .../acceptance/category-hashtag-test.js.es6 | 40 +- .../acceptance/composer-test.js.es6 | 680 ++++++++---------- .../composer-topic-links-test.js.es6 | 312 ++++---- .../create-account-user-fields-test.js.es6 | 82 +-- .../acceptance/custom-html-set-test.js.es6 | 36 +- .../custom-html-template-test.js.es6 | 12 +- 10 files changed, 645 insertions(+), 805 deletions(-) diff --git a/test/javascripts/acceptance/badges-test.js.es6 b/test/javascripts/acceptance/badges-test.js.es6 index 8ad8cc1f342..9de24ae3f9c 100644 --- a/test/javascripts/acceptance/badges-test.js.es6 +++ b/test/javascripts/acceptance/badges-test.js.es6 @@ -2,17 +2,15 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Badges"); -QUnit.test("Visit Badge Pages", assert => { - visit("/badges"); - andThen(() => { - assert.ok($("body.badges-page").length, "has body class"); - assert.ok(exists(".badge-groups .badge-card"), "has a list of badges"); - }); +QUnit.test("Visit Badge Pages", async assert => { + await visit("/badges"); - visit("/badges/9/autobiographer"); - andThen(() => { - assert.ok(exists(".badge-card"), "has the badge in the listing"); - assert.ok(exists(".user-info"), "has the list of users with that badge"); - assert.ok(!exists(".badge-card:eq(0) script")); - }); + assert.ok($("body.badges-page").length, "has body class"); + assert.ok(exists(".badge-groups .badge-card"), "has a list of badges"); + + await visit("/badges/9/autobiographer"); + + assert.ok(exists(".badge-card"), "has the badge in the listing"); + assert.ok(exists(".user-info"), "has the list of users with that badge"); + assert.ok(!exists(".badge-card:eq(0) script")); }); diff --git a/test/javascripts/acceptance/category-chooser-test.js.es6 b/test/javascripts/acceptance/category-chooser-test.js.es6 index 13166969f4b..0bc2c597f3e 100644 --- a/test/javascripts/acceptance/category-chooser-test.js.es6 +++ b/test/javascripts/acceptance/category-chooser-test.js.es6 @@ -7,28 +7,24 @@ acceptance("CategoryChooser", { } }); -QUnit.test("does not display uncategorized if not allowed", assert => { +QUnit.test("does not display uncategorized if not allowed", async assert => { const categoryChooser = selectKit(".category-chooser"); - visit("/"); - click("#create-topic"); + await visit("/"); + await click("#create-topic"); - categoryChooser.expand(); + categoryChooser.expandAwait(); - andThen(() => { - assert.ok(categoryChooser.rowByIndex(0).name() !== "uncategorized"); - }); + assert.ok(categoryChooser.rowByIndex(0).name() !== "uncategorized"); }); -QUnit.test("prefill category when category_id is set", assert => { - visit("/new-topic?category_id=1"); +QUnit.test("prefill category when category_id is set", async assert => { + await visit("/new-topic?category_id=1"); - andThen(() => { - assert.equal( - selectKit(".category-chooser") - .header() - .value(), - 1 - ); - }); + assert.equal( + selectKit(".category-chooser") + .header() + .value(), + 1 + ); }); diff --git a/test/javascripts/acceptance/category-edit-security-test.js.es6 b/test/javascripts/acceptance/category-edit-security-test.js.es6 index d73bc250be1..4efc1897ea2 100644 --- a/test/javascripts/acceptance/category-edit-security-test.js.es6 +++ b/test/javascripts/acceptance/category-edit-security-test.js.es6 @@ -4,127 +4,115 @@ acceptance("Category Edit - security", { loggedIn: true }); -QUnit.test("default", assert => { - visit("/c/bug"); +QUnit.test("default", async assert => { + await visit("/c/bug"); - click(".edit-category"); - click("li.edit-category-security a"); + await click(".edit-category"); + await click("li.edit-category-security a"); - andThen(() => { - const $permissionListItems = find(".permission-list li"); + const $permissionListItems = find(".permission-list li"); - const badgeName = $permissionListItems - .eq(0) - .find(".badge-group") - .text(); - assert.equal(badgeName, "everyone"); + const badgeName = $permissionListItems + .eq(0) + .find(".badge-group") + .text(); + assert.equal(badgeName, "everyone"); - const permission = $permissionListItems - .eq(0) - .find(".permission") - .text(); - assert.equal(permission, "Create / Reply / See"); - }); + const permission = $permissionListItems + .eq(0) + .find(".permission") + .text(); + assert.equal(permission, "Create / Reply / See"); }); -QUnit.test("removing a permission", assert => { +QUnit.test("removing a permission", async assert => { const availableGroups = selectKit(".available-groups"); - visit("/c/bug"); + await visit("/c/bug"); - click(".edit-category"); - click("li.edit-category-security a"); - click(".edit-category-tab-security .edit-permission"); + await click(".edit-category"); + await click("li.edit-category-security a"); + await click(".edit-category-tab-security .edit-permission"); availableGroups.expand(); - andThen(() => { - assert.notOk( - availableGroups.rowByValue("everyone").exists(), - "everyone is already used and is not in the available groups" - ); - }); + assert.notOk( + availableGroups.rowByValue("everyone").exists(), + "everyone is already used and is not in the available groups" + ); - click( + await click( ".edit-category-tab-security .permission-list li:first-of-type .remove-permission" ); availableGroups.expand(); - andThen(() => { - assert.ok( - availableGroups.rowByValue("everyone").exists(), - "everyone has been removed and appears in the available groups" - ); - }); + assert.ok( + availableGroups.rowByValue("everyone").exists(), + "everyone has been removed and appears in the available groups" + ); }); -QUnit.test("adding a permission", assert => { +QUnit.test("adding a permission", async assert => { const availableGroups = selectKit(".available-groups"); const permissionSelector = selectKit(".permission-selector"); - visit("/c/bug"); + await visit("/c/bug"); - click(".edit-category"); - click("li.edit-category-security a"); - click(".edit-category-tab-security .edit-permission"); + await click(".edit-category"); + await click("li.edit-category-security a"); + await click(".edit-category-tab-security .edit-permission"); availableGroups.expand().selectRowByValue("staff"); permissionSelector.expand().selectRowByValue("2"); - click(".edit-category-tab-security .add-permission"); + await click(".edit-category-tab-security .add-permission"); - andThen(() => { - const $addedPermissionItem = find( - ".edit-category-tab-security .permission-list li:nth-child(2)" - ); + const $addedPermissionItem = find( + ".edit-category-tab-security .permission-list li:nth-child(2)" + ); - const badgeName = $addedPermissionItem.find(".badge-group").text(); - assert.equal(badgeName, "staff"); + const badgeName = $addedPermissionItem.find(".badge-group").text(); + assert.equal(badgeName, "staff"); - const permission = $addedPermissionItem.find(".permission").text(); - assert.equal(permission, "Reply / See"); - }); + const permission = $addedPermissionItem.find(".permission").text(); + assert.equal(permission, "Reply / See"); }); -QUnit.test("adding a previously removed permission", assert => { +QUnit.test("adding a previously removed permission", async assert => { const availableGroups = selectKit(".available-groups"); - visit("/c/bug"); + await visit("/c/bug"); - click(".edit-category"); - click("li.edit-category-security a"); - click(".edit-category-tab-security .edit-permission"); - click( + await click(".edit-category"); + await await click("li.edit-category-security a"); + await click(".edit-category-tab-security .edit-permission"); + await click( ".edit-category-tab-security .permission-list li:first-of-type .remove-permission" ); - andThen(() => { - assert.equal( - find(".edit-category-tab-security .permission-list li").length, - 0, - "it removes the permission from the list" - ); - }); + assert.equal( + find(".edit-category-tab-security .permission-list li").length, + 0, + "it removes the permission from the list" + ); availableGroups.expand().selectRowByValue("everyone"); - click(".edit-category-tab-security .add-permission"); + await click(".edit-category-tab-security .add-permission"); - andThen(() => { - assert.equal( - find(".edit-category-tab-security .permission-list li").length, - 1, - "it adds the permission to the list" - ); + assert.equal( + find(".edit-category-tab-security .permission-list li").length, + 1, + "it adds the permission to the list" + ); - const $permissionListItems = find(".permission-list li"); + const $permissionListItems = find(".permission-list li"); - const badgeName = $permissionListItems - .eq(0) - .find(".badge-group") - .text(); - assert.equal(badgeName, "everyone"); + const badgeName = $permissionListItems + .eq(0) + .find(".badge-group") + .text(); + assert.equal(badgeName, "everyone"); - const permission = $permissionListItems - .eq(0) - .find(".permission") - .text(); - assert.equal(permission, "Create / Reply / See"); - }); + const permission = $permissionListItems + .eq(0) + .find(".permission") + .text(); + assert.equal(permission, "Create / Reply / See"); }); diff --git a/test/javascripts/acceptance/category-edit-test.js.es6 b/test/javascripts/acceptance/category-edit-test.js.es6 index 48447b773bd..8978edd2fba 100644 --- a/test/javascripts/acceptance/category-edit-test.js.es6 +++ b/test/javascripts/acceptance/category-edit-test.js.es6 @@ -6,64 +6,54 @@ acceptance("Category Edit", { settings: { email_in: true } }); -QUnit.test("Can open the category modal", assert => { - visit("/c/bug"); +QUnit.test("Can open the category modal", async assert => { + await visit("/c/bug"); - click(".edit-category"); - andThen(() => { - assert.ok(visible(".d-modal"), "it pops up a modal"); - }); + await click(".edit-category"); + assert.ok(visible(".d-modal"), "it pops up a modal"); - click("a.close"); - andThen(() => { - assert.ok(!visible(".d-modal"), "it closes the modal"); - }); + await click("a.close"); + assert.ok(!visible(".d-modal"), "it closes the modal"); }); -QUnit.test("Change the category color", assert => { - visit("/c/bug"); +QUnit.test("Change the category color", async assert => { + await visit("/c/bug"); - click(".edit-category"); - fillIn("#edit-text-color", "#ff0000"); - click("#save-category"); - andThen(() => { - assert.ok(!visible(".d-modal"), "it closes the modal"); - assert.equal( - DiscourseURL.redirectedTo, - "/c/bug", - "it does one of the rare full page redirects" - ); - }); + await click(".edit-category"); + await fillIn("#edit-text-color", "#ff0000"); + await click("#save-category"); + assert.ok(!visible(".d-modal"), "it closes the modal"); + assert.equal( + DiscourseURL.redirectedTo, + "/c/bug", + "it does one of the rare full page redirects" + ); }); -QUnit.test("Change the topic template", assert => { - visit("/c/bug"); +QUnit.test("Change the topic template", async assert => { + await visit("/c/bug"); - click(".edit-category"); - click(".edit-category-topic-template"); - fillIn(".d-editor-input", "this is the new topic template"); - click("#save-category"); - andThen(() => { - assert.ok(!visible(".d-modal"), "it closes the modal"); - assert.equal( - DiscourseURL.redirectedTo, - "/c/bug", - "it does one of the rare full page redirects" - ); - }); + await click(".edit-category"); + await click(".edit-category-topic-template"); + await fillIn(".d-editor-input", "this is the new topic template"); + await click("#save-category"); + assert.ok(!visible(".d-modal"), "it closes the modal"); + assert.equal( + DiscourseURL.redirectedTo, + "/c/bug", + "it does one of the rare full page redirects" + ); }); -QUnit.test("Error Saving", assert => { - visit("/c/bug"); +QUnit.test("Error Saving", async assert => { + await visit("/c/bug"); - click(".edit-category"); - click(".edit-category-settings"); - fillIn(".email-in", "duplicate@example.com"); - click("#save-category"); - andThen(() => { - assert.ok(visible("#modal-alert")); - assert.equal(find("#modal-alert").html(), "duplicate email"); - }); + await click(".edit-category"); + await click(".edit-category-settings"); + await fillIn(".email-in", "duplicate@example.com"); + await click("#save-category"); + assert.ok(visible("#modal-alert")); + assert.equal(find("#modal-alert").html(), "duplicate email"); }); QUnit.test("Subcategory list settings", async assert => { diff --git a/test/javascripts/acceptance/category-hashtag-test.js.es6 b/test/javascripts/acceptance/category-hashtag-test.js.es6 index 45864748b35..c2ffdcdcaea 100644 --- a/test/javascripts/acceptance/category-hashtag-test.js.es6 +++ b/test/javascripts/acceptance/category-hashtag-test.js.es6 @@ -2,28 +2,24 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Category hashtag", { loggedIn: true }); -QUnit.test("category hashtag is cooked properly", assert => { - visit("/t/internationalization-localization/280"); - click("#topic-footer-buttons .btn.create"); +QUnit.test("category hashtag is cooked properly", async assert => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); - fillIn(".d-editor-input", "this is a category hashtag #bug"); - andThen(() => { - // TODO: Test that the autocomplete shows - assert.equal( - find(".d-editor-preview:visible") - .html() - .trim(), - '

this is a category hashtag #bug

' - ); - }); + await fillIn(".d-editor-input", "this is a category hashtag #bug"); + // TODO: Test that the autocomplete shows + assert.equal( + find(".d-editor-preview:visible") + .html() + .trim(), + '

this is a category hashtag #bug

' + ); - click("#reply-control .btn.create"); - andThen(() => { - assert.equal( - find(".topic-post:last .cooked p") - .html() - .trim(), - 'this is a category hashtag #bug' - ); - }); + await click("#reply-control .btn.create"); + assert.equal( + find(".topic-post:last .cooked p") + .html() + .trim(), + 'this is a category hashtag #bug' + ); }); diff --git a/test/javascripts/acceptance/composer-test.js.es6 b/test/javascripts/acceptance/composer-test.js.es6 index a42fb87aa9f..ccbe710612f 100644 --- a/test/javascripts/acceptance/composer-test.js.es6 +++ b/test/javascripts/acceptance/composer-test.js.es6 @@ -7,321 +7,255 @@ acceptance("Composer", { } }); -QUnit.test("Tests the Composer controls", assert => { - visit("/"); - andThen(() => { - assert.ok(exists("#create-topic"), "the create button is visible"); - }); +QUnit.test("Tests the Composer controls", async assert => { + await visit("/"); + assert.ok(exists("#create-topic"), "the create button is visible"); - click("#create-topic"); - andThen(() => { - assert.ok(exists(".d-editor-input"), "the composer input is visible"); - assert.ok( - exists(".title-input .popup-tip.bad.hide"), - "title errors are hidden by default" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.bad.hide"), - "body errors are hidden by default" - ); - }); + await click("#create-topic"); + assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.ok( + exists(".title-input .popup-tip.bad.hide"), + "title errors are hidden by default" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.bad.hide"), + "body errors are hidden by default" + ); - click("a.toggle-preview"); - andThen(() => { - assert.ok( - !exists(".d-editor-preview:visible"), - "clicking the toggle hides the preview" - ); - }); + await click("a.toggle-preview"); + assert.ok( + !exists(".d-editor-preview:visible"), + "clicking the toggle hides the preview" + ); - click("a.toggle-preview"); - andThen(() => { - assert.ok( - exists(".d-editor-preview:visible"), - "clicking the toggle shows the preview again" - ); - }); + await click("a.toggle-preview"); + assert.ok( + exists(".d-editor-preview:visible"), + "clicking the toggle shows the preview again" + ); - click("#reply-control button.create"); - andThen(() => { - assert.ok( - !exists(".title-input .popup-tip.bad.hide"), - "it shows the empty title error" - ); - assert.ok( - !exists(".d-editor-wrapper .popup-tip.bad.hide"), - "it shows the empty body error" - ); - }); + await click("#reply-control button.create"); + assert.ok( + !exists(".title-input .popup-tip.bad.hide"), + "it shows the empty title error" + ); + assert.ok( + !exists(".d-editor-wrapper .popup-tip.bad.hide"), + "it shows the empty body error" + ); - fillIn("#reply-title", "this is my new topic title"); - andThen(() => { - assert.ok(exists(".title-input .popup-tip.good"), "the title is now good"); - }); + await fillIn("#reply-title", "this is my new topic title"); + assert.ok(exists(".title-input .popup-tip.good"), "the title is now good"); - fillIn(".d-editor-input", "this is the *content* of a post"); - andThen(() => { - assert.equal( - find(".d-editor-preview") - .html() - .trim(), - "

this is the content of a post

", - "it previews content" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.good"), - "the body is now good" - ); - }); + await fillIn(".d-editor-input", "this is the *content* of a post"); + assert.equal( + find(".d-editor-preview") + .html() + .trim(), + "

this is the content of a post

", + "it previews content" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.good"), + "the body is now good" + ); - andThen(() => { - const textarea = find("#reply-control .d-editor-input")[0]; - textarea.selectionStart = textarea.value.length; - textarea.selectionEnd = textarea.value.length; + const textarea = find("#reply-control .d-editor-input")[0]; + textarea.selectionStart = textarea.value.length; + textarea.selectionEnd = textarea.value.length; - // Testing keyboard events is tough! - const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform); - const event = document.createEvent("Event"); - event.initEvent("keydown", true, true); - event[mac ? "metaKey" : "ctrlKey"] = true; - event.keyCode = 66; + // Testing keyboard events is tough! + const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform); + const event = document.createEvent("Event"); + event.initEvent("keydown", true, true); + event[mac ? "metaKey" : "ctrlKey"] = true; + event.keyCode = 66; - textarea.dispatchEvent(event); - }); + Ember.run(() => textarea.dispatchEvent(event)); - andThen(() => { - const example = I18n.t(`composer.bold_text`); - assert.equal( - find("#reply-control .d-editor-input") - .val() - .trim(), - `this is the *content* of a post**${example}**`, - "it supports keyboard shortcuts" - ); - }); + const example = I18n.t(`composer.bold_text`); + assert.equal( + find("#reply-control .d-editor-input") + .val() + .trim(), + `this is the *content* of a post**${example}**`, + "it supports keyboard shortcuts" + ); - click("#reply-control a.cancel"); - andThen(() => { - assert.ok(exists(".bootbox.modal"), "it pops up a confirmation dialog"); - }); + await click("#reply-control a.cancel"); + assert.ok(exists(".bootbox.modal"), "it pops up a confirmation dialog"); - click(".modal-footer a:eq(1)"); - andThen(() => { - assert.ok(!exists(".bootbox.modal"), "the confirmation can be cancelled"); - }); + await click(".modal-footer a:eq(1)"); + assert.ok(!exists(".bootbox.modal"), "the confirmation can be cancelled"); }); -QUnit.test("Create a topic with server side errors", assert => { - visit("/"); - click("#create-topic"); - fillIn("#reply-title", "this title triggers an error"); - fillIn(".d-editor-input", "this is the *content* of a post"); - click("#reply-control button.create"); - andThen(() => { - assert.ok(exists(".bootbox.modal"), "it pops up an error message"); - }); - click(".bootbox.modal a.btn-primary"); - andThen(() => { - assert.ok(!exists(".bootbox.modal"), "it dismisses the error"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); - }); +QUnit.test("Create a topic with server side errors", async assert => { + await visit("/"); + await click("#create-topic"); + await fillIn("#reply-title", "this title triggers an error"); + await fillIn(".d-editor-input", "this is the *content* of a post"); + await click("#reply-control button.create"); + assert.ok(exists(".bootbox.modal"), "it pops up an error message"); + await click(".bootbox.modal a.btn-primary"); + assert.ok(!exists(".bootbox.modal"), "it dismisses the error"); + assert.ok(exists(".d-editor-input"), "the composer input is visible"); }); -QUnit.test("Create a Topic", assert => { - visit("/"); - click("#create-topic"); - fillIn("#reply-title", "Internationalization Localization"); - fillIn(".d-editor-input", "this is the *content* of a new topic post"); - click("#reply-control button.create"); - andThen(() => { - assert.equal( - currentURL(), - "/t/internationalization-localization/280", - "it transitions to the newly created topic URL" - ); - }); +QUnit.test("Create a Topic", async assert => { + await visit("/"); + await click("#create-topic"); + await fillIn("#reply-title", "Internationalization Localization"); + await fillIn(".d-editor-input", "this is the *content* of a new topic post"); + await click("#reply-control button.create"); + assert.equal( + currentURL(), + "/t/internationalization-localization/280", + "it transitions to the newly created topic URL" + ); }); -QUnit.test("Create an enqueued Topic", assert => { - visit("/"); - click("#create-topic"); - fillIn("#reply-title", "Internationalization Localization"); - fillIn(".d-editor-input", "enqueue this content please"); - click("#reply-control button.create"); - andThen(() => { - assert.ok(visible(".d-modal"), "it pops up a modal"); - assert.equal(currentURL(), "/", "it doesn't change routes"); - }); +QUnit.test("Create an enqueued Topic", async assert => { + await visit("/"); + await click("#create-topic"); + await fillIn("#reply-title", "Internationalization Localization"); + await fillIn(".d-editor-input", "enqueue this content please"); + await click("#reply-control button.create"); + assert.ok(visible(".d-modal"), "it pops up a modal"); + assert.equal(currentURL(), "/", "it doesn't change routes"); - click(".modal-footer button"); - andThen(() => { - assert.ok(invisible(".d-modal"), "the modal can be dismissed"); - }); + await click(".modal-footer button"); + assert.ok(invisible(".d-modal"), "the modal can be dismissed"); }); -QUnit.test("Create a Reply", assert => { - visit("/t/internationalization-localization/280"); +QUnit.test("Create a Reply", async assert => { + await visit("/t/internationalization-localization/280"); - andThen(() => { - assert.ok( - !exists("article[data-post-id=12345]"), - "the post is not in the DOM" - ); - }); + assert.ok( + !exists("article[data-post-id=12345]"), + "the post is not in the DOM" + ); - click("#topic-footer-buttons .btn.create"); - andThen(() => { - assert.ok(exists(".d-editor-input"), "the composer input is visible"); - assert.ok( - !exists("#reply-title"), - "there is no title since this is a reply" - ); - }); + await click("#topic-footer-buttons .btn.create"); + assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.ok(!exists("#reply-title"), "there is no title since this is a reply"); - fillIn(".d-editor-input", "this is the content of my reply"); - click("#reply-control button.create"); - andThen(() => { - assert.equal( - find(".cooked:last p").text(), - "this is the content of my reply" - ); - }); + await fillIn(".d-editor-input", "this is the content of my reply"); + await click("#reply-control button.create"); + assert.equal( + find(".cooked:last p").text(), + "this is the content of my reply" + ); }); -QUnit.test("Posting on a different topic", assert => { - visit("/t/internationalization-localization/280"); - click("#topic-footer-buttons .btn.create"); - fillIn(".d-editor-input", "this is the content for a different topic"); +QUnit.test("Posting on a different topic", async assert => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); + await fillIn(".d-editor-input", "this is the content for a different topic"); - visit("/t/1-3-0beta9-no-rate-limit-popups/28830"); - andThen(function() { - assert.equal(currentURL(), "/t/1-3-0beta9-no-rate-limit-popups/28830"); - }); - click("#reply-control button.create"); - andThen(function() { - assert.ok(visible(".reply-where-modal"), "it pops up a modal"); - }); + await visit("/t/1-3-0beta9-no-rate-limit-popups/28830"); + assert.equal(currentURL(), "/t/1-3-0beta9-no-rate-limit-popups/28830"); + await click("#reply-control button.create"); + assert.ok(visible(".reply-where-modal"), "it pops up a modal"); - click(".btn-reply-here"); - andThen(() => { - assert.equal( - find(".cooked:last p").text(), - "this is the content for a different topic" - ); - }); + await click(".btn-reply-here"); + assert.equal( + find(".cooked:last p").text(), + "this is the content for a different topic" + ); }); -QUnit.test("Create an enqueued Reply", assert => { - visit("/t/internationalization-localization/280"); +QUnit.test("Create an enqueued Reply", async assert => { + await visit("/t/internationalization-localization/280"); - click("#topic-footer-buttons .btn.create"); - andThen(() => { - assert.ok(exists(".d-editor-input"), "the composer input is visible"); - assert.ok( - !exists("#reply-title"), - "there is no title since this is a reply" - ); - }); + await click("#topic-footer-buttons .btn.create"); + assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.ok(!exists("#reply-title"), "there is no title since this is a reply"); - fillIn(".d-editor-input", "enqueue this content please"); - click("#reply-control button.create"); - andThen(() => { - assert.ok( - find(".cooked:last p").text() !== "enqueue this content please", - "it doesn't insert the post" - ); - }); + await fillIn(".d-editor-input", "enqueue this content please"); + await click("#reply-control button.create"); + assert.ok( + find(".cooked:last p").text() !== "enqueue this content please", + "it doesn't insert the post" + ); - andThen(() => { - assert.ok(visible(".d-modal"), "it pops up a modal"); - }); + assert.ok(visible(".d-modal"), "it pops up a modal"); - click(".modal-footer button"); - andThen(() => { - assert.ok(invisible(".d-modal"), "the modal can be dismissed"); - }); + await click(".modal-footer button"); + assert.ok(invisible(".d-modal"), "the modal can be dismissed"); }); -QUnit.test("Edit the first post", assert => { - visit("/t/internationalization-localization/280"); +QUnit.test("Edit the first post", async assert => { + await visit("/t/internationalization-localization/280"); assert.ok( !exists(".topic-post:eq(0) .post-info.edits"), "it has no edits icon at first" ); - click(".topic-post:eq(0) button.show-more-actions"); - click(".topic-post:eq(0) button.edit"); - andThen(() => { - assert.equal( - find(".d-editor-input") - .val() - .indexOf("Any plans to support"), - 0, - "it populates the input with the post text" - ); - }); + await click(".topic-post:eq(0) button.show-more-actions"); + await click(".topic-post:eq(0) button.edit"); + assert.equal( + find(".d-editor-input") + .val() + .indexOf("Any plans to support"), + 0, + "it populates the input with the post text" + ); - fillIn(".d-editor-input", "This is the new text for the post"); - fillIn("#reply-title", "This is the new text for the title"); - click("#reply-control button.create"); - andThen(() => { - assert.ok(!exists(".d-editor-input"), "it closes the composer"); - assert.ok( - exists(".topic-post:eq(0) .post-info.edits"), - "it has the edits icon" - ); - assert.ok( - find("#topic-title h1") - .text() - .indexOf("This is the new text for the title") !== -1, - "it shows the new title" - ); - assert.ok( - find(".topic-post:eq(0) .cooked") - .text() - .indexOf("This is the new text for the post") !== -1, - "it updates the post" - ); - }); + await fillIn(".d-editor-input", "This is the new text for the post"); + await fillIn("#reply-title", "This is the new text for the title"); + await click("#reply-control button.create"); + assert.ok(!exists(".d-editor-input"), "it closes the composer"); + assert.ok( + exists(".topic-post:eq(0) .post-info.edits"), + "it has the edits icon" + ); + assert.ok( + find("#topic-title h1") + .text() + .indexOf("This is the new text for the title") !== -1, + "it shows the new title" + ); + assert.ok( + find(".topic-post:eq(0) .cooked") + .text() + .indexOf("This is the new text for the post") !== -1, + "it updates the post" + ); }); -QUnit.test("Composer can switch between edits", assert => { - visit("/t/this-is-a-test-topic/9"); +QUnit.test("Composer can switch between edits", async assert => { + await visit("/t/this-is-a-test-topic/9"); - click(".topic-post:eq(0) button.edit"); - andThen(() => { - assert.equal( - find(".d-editor-input") - .val() - .indexOf("This is the first post."), - 0, - "it populates the input with the post text" - ); - }); - click(".topic-post:eq(1) button.edit"); - andThen(() => { - assert.equal( - find(".d-editor-input") - .val() - .indexOf("This is the second post."), - 0, - "it populates the input with the post text" - ); - }); + await click(".topic-post:eq(0) button.edit"); + assert.equal( + find(".d-editor-input") + .val() + .indexOf("This is the first post."), + 0, + "it populates the input with the post text" + ); + await click(".topic-post:eq(1) button.edit"); + assert.equal( + find(".d-editor-input") + .val() + .indexOf("This is the second post."), + 0, + "it populates the input with the post text" + ); }); -QUnit.test("Composer with dirty edit can toggle to another edit", assert => { - visit("/t/this-is-a-test-topic/9"); +QUnit.test( + "Composer with dirty edit can toggle to another edit", + async assert => { + await visit("/t/this-is-a-test-topic/9"); - click(".topic-post:eq(0) button.edit"); - fillIn(".d-editor-input", "This is a dirty reply"); - click(".topic-post:eq(1) button.edit"); - andThen(() => { + await click(".topic-post:eq(0) button.edit"); + await fillIn(".d-editor-input", "This is a dirty reply"); + await click(".topic-post:eq(1) button.edit"); assert.ok(exists(".bootbox.modal"), "it pops up a confirmation dialog"); - }); - click(".modal-footer a:eq(0)"); - andThen(() => { + + await click(".modal-footer a:eq(0)"); assert.equal( find(".d-editor-input") .val() @@ -329,107 +263,113 @@ QUnit.test("Composer with dirty edit can toggle to another edit", assert => { 0, "it populates the input with the post text" ); - }); + } +); + +QUnit.test("Composer can toggle between edit and reply", async assert => { + await visit("/t/this-is-a-test-topic/9"); + + await click(".topic-post:eq(0) button.edit"); + assert.equal( + find(".d-editor-input") + .val() + .indexOf("This is the first post."), + 0, + "it populates the input with the post text" + ); + await click(".topic-post:eq(0) button.reply"); + assert.equal(find(".d-editor-input").val(), "", "it clears the input"); + await click(".topic-post:eq(0) button.edit"); + assert.equal( + find(".d-editor-input") + .val() + .indexOf("This is the first post."), + 0, + "it populates the input with the post text" + ); }); -QUnit.test("Composer can toggle between edit and reply", assert => { - visit("/t/this-is-a-test-topic/9"); +QUnit.test( + "Composer can toggle between reply and createTopic", + async assert => { + await visit("/t/this-is-a-test-topic/9"); + await click(".topic-post:eq(0) button.reply"); - click(".topic-post:eq(0) button.edit"); - andThen(() => { - assert.equal( - find(".d-editor-input") - .val() - .indexOf("This is the first post."), - 0, - "it populates the input with the post text" + await selectKit(".toolbar-popup-menu-options").expandAwait(); + await selectKit(".toolbar-popup-menu-options").selectRowByValueAwait( + "toggleWhisper" ); - }); - click(".topic-post:eq(0) button.reply"); - andThen(() => { - assert.equal(find(".d-editor-input").val(), "", "it clears the input"); - }); - click(".topic-post:eq(0) button.edit"); - andThen(() => { - assert.equal( - find(".d-editor-input") - .val() - .indexOf("This is the first post."), - 0, - "it populates the input with the post text" - ); - }); -}); -QUnit.test("Composer can toggle between reply and createTopic", assert => { - visit("/t/this-is-a-test-topic/9"); - click(".topic-post:eq(0) button.reply"); - - selectKit(".toolbar-popup-menu-options") - .expand() - .selectRowByValue("toggleWhisper"); - - andThen(() => { assert.ok( find(".composer-fields .whisper") .text() .indexOf(I18n.t("composer.whisper")) > 0, "it sets the post type to whisper" ); - }); - visit("/"); - andThen(() => { + await visit("/"); assert.ok(exists("#create-topic"), "the create topic button is visible"); - }); - click("#create-topic"); - andThen(() => { + await click("#create-topic"); assert.ok( find(".composer-fields .whisper") .text() .indexOf(I18n.t("composer.whisper")) === -1, "it should reset the state of the composer's model" ); - }); - selectKit(".toolbar-popup-menu-options") - .expand() - .selectRowByValue("toggleInvisible"); + await selectKit(".toolbar-popup-menu-options").expandAwait(); + await selectKit(".toolbar-popup-menu-options").selectRowByValueAwait( + "toggleInvisible" + ); - andThen(() => { assert.ok( find(".composer-fields .whisper") .text() .indexOf(I18n.t("composer.unlist")) > 0, "it sets the topic to unlisted" ); - }); - visit("/t/this-is-a-test-topic/9"); + await visit("/t/this-is-a-test-topic/9"); - click(".topic-post:eq(0) button.reply"); - andThen(() => { + await click(".topic-post:eq(0) button.reply"); assert.ok( find(".composer-fields .whisper") .text() .indexOf(I18n.t("composer.unlist")) === -1, "it should reset the state of the composer's model" ); - }); + } +); + +QUnit.test("Composer with dirty reply can toggle to edit", async assert => { + await visit("/t/this-is-a-test-topic/9"); + + await click(".topic-post:eq(0) button.reply"); + await fillIn(".d-editor-input", "This is a dirty reply"); + await click(".topic-post:eq(0) button.edit"); + assert.ok(exists(".bootbox.modal"), "it pops up a confirmation dialog"); + await click(".modal-footer a:eq(0)"); + assert.equal( + find(".d-editor-input") + .val() + .indexOf("This is the first post."), + 0, + "it populates the input with the post text" + ); }); -QUnit.test("Composer with dirty reply can toggle to edit", assert => { - visit("/t/this-is-a-test-topic/9"); +QUnit.test( + "Composer draft with dirty reply can toggle to edit", + async assert => { + await visit("/t/this-is-a-test-topic/9"); - click(".topic-post:eq(0) button.reply"); - fillIn(".d-editor-input", "This is a dirty reply"); - click(".topic-post:eq(0) button.edit"); - andThen(() => { + await click(".topic-post:eq(0) button.reply"); + await fillIn(".d-editor-input", "This is a dirty reply"); + await click(".toggler"); + await click(".topic-post:eq(0) button.edit"); assert.ok(exists(".bootbox.modal"), "it pops up a confirmation dialog"); - }); - click(".modal-footer a:eq(0)"); - andThen(() => { + await click(".modal-footer a:eq(0)"); assert.equal( find(".d-editor-input") .val() @@ -437,30 +377,8 @@ QUnit.test("Composer with dirty reply can toggle to edit", assert => { 0, "it populates the input with the post text" ); - }); -}); - -QUnit.test("Composer draft with dirty reply can toggle to edit", assert => { - visit("/t/this-is-a-test-topic/9"); - - click(".topic-post:eq(0) button.reply"); - fillIn(".d-editor-input", "This is a dirty reply"); - click(".toggler"); - click(".topic-post:eq(0) button.edit"); - andThen(() => { - assert.ok(exists(".bootbox.modal"), "it pops up a confirmation dialog"); - }); - click(".modal-footer a:eq(0)"); - andThen(() => { - assert.equal( - find(".d-editor-input") - .val() - .indexOf("This is the first post."), - 0, - "it populates the input with the post text" - ); - }); -}); + } +); acceptance("Composer and uncategorized is not allowed", { loggedIn: true, @@ -470,45 +388,41 @@ acceptance("Composer and uncategorized is not allowed", { } }); -QUnit.test("Disable body until category is selected", assert => { +QUnit.test("Disable body until category is selected", async assert => { replaceCurrentUser({ admin: false, staff: false, trust_level: 1 }); - visit("/"); - click("#create-topic"); - andThen(() => { - assert.ok(exists(".d-editor-input"), "the composer input is visible"); - assert.ok( - exists(".title-input .popup-tip.bad.hide"), - "title errors are hidden by default" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.bad.hide"), - "body errors are hidden by default" - ); - assert.ok( - exists(".d-editor-textarea-wrapper.disabled"), - "textarea is disabled" - ); - }); + await visit("/"); + await click("#create-topic"); + assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.ok( + exists(".title-input .popup-tip.bad.hide"), + "title errors are hidden by default" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.bad.hide"), + "body errors are hidden by default" + ); + assert.ok( + exists(".d-editor-textarea-wrapper.disabled"), + "textarea is disabled" + ); const categoryChooser = selectKit(".category-chooser"); - categoryChooser.expand().selectRowByValue(2); + await categoryChooser.expandAwait(); + await categoryChooser.selectRowByValueAwait(2); - andThen(() => { - assert.ok( - find(".d-editor-textarea-wrapper.disabled").length === 0, - "textarea is enabled" - ); - }); + assert.ok( + find(".d-editor-textarea-wrapper.disabled").length === 0, + "textarea is enabled" + ); - fillIn(".d-editor-input", "Now I can type stuff"); - categoryChooser.expand().selectRowByValue("__none__"); + await fillIn(".d-editor-input", "Now I can type stuff"); + await categoryChooser.expandAwait(); + await categoryChooser.selectRowByValue("__none__"); - andThen(() => { - assert.ok( - find(".d-editor-textarea-wrapper.disabled").length === 0, - "textarea is still enabled" - ); - }); + assert.ok( + find(".d-editor-textarea-wrapper.disabled").length === 0, + "textarea is still enabled" + ); }); diff --git a/test/javascripts/acceptance/composer-topic-links-test.js.es6 b/test/javascripts/acceptance/composer-topic-links-test.js.es6 index 5e2d128ed53..f4e0550c7dd 100644 --- a/test/javascripts/acceptance/composer-topic-links-test.js.es6 +++ b/test/javascripts/acceptance/composer-topic-links-test.js.es6 @@ -9,152 +9,140 @@ acceptance("Composer topic featured links", { } }); -QUnit.test("onebox with title", assert => { - visit("/"); - click("#create-topic"); - fillIn("#reply-title", "http://www.example.com/has-title.html"); - andThen(() => { - assert.ok( - find(".d-editor-preview") - .html() - .trim() - .indexOf("onebox") > 0, - "it pastes the link into the body and previews it" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.good"), - "the body is now good" - ); - assert.equal( - find(".title-input input").val(), - "An interesting article", - "title is from the oneboxed article" - ); - }); +QUnit.test("onebox with title", async assert => { + await visit("/"); + await click("#create-topic"); + await fillIn("#reply-title", "http://www.example.com/has-title.html"); + assert.ok( + find(".d-editor-preview") + .html() + .trim() + .indexOf("onebox") > 0, + "it pastes the link into the body and previews it" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.good"), + "the body is now good" + ); + assert.equal( + find(".title-input input").val(), + "An interesting article", + "title is from the oneboxed article" + ); }); -QUnit.test("onebox result doesn't include a title", assert => { - visit("/"); - click("#create-topic"); - fillIn("#reply-title", "http://www.example.com/no-title.html"); - andThen(() => { - assert.ok( - find(".d-editor-preview") - .html() - .trim() - .indexOf("onebox") > 0, - "it pastes the link into the body and previews it" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.good"), - "the body is now good" - ); - assert.equal( - find(".title-input input").val(), - "http://www.example.com/no-title.html", - "title is unchanged" - ); - }); +QUnit.test("onebox result doesn't include a title", async assert => { + await visit("/"); + await click("#create-topic"); + await fillIn("#reply-title", "http://www.example.com/no-title.html"); + assert.ok( + find(".d-editor-preview") + .html() + .trim() + .indexOf("onebox") > 0, + "it pastes the link into the body and previews it" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.good"), + "the body is now good" + ); + assert.equal( + find(".title-input input").val(), + "http://www.example.com/no-title.html", + "title is unchanged" + ); }); -QUnit.test("no onebox result", assert => { - visit("/"); - click("#create-topic"); - fillIn("#reply-title", "http://www.example.com/nope-onebox.html"); - andThen(() => { - assert.ok( - find(".d-editor-preview") - .html() - .trim() - .indexOf("onebox") > 0, - "it pastes the link into the body and previews it" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.good"), - "link is pasted into body" - ); - assert.equal( - find(".title-input input").val(), - "http://www.example.com/nope-onebox.html", - "title is unchanged" - ); - }); +QUnit.test("no onebox result", async assert => { + await visit("/"); + await click("#create-topic"); + await fillIn("#reply-title", "http://www.example.com/nope-onebox.html"); + assert.ok( + find(".d-editor-preview") + .html() + .trim() + .indexOf("onebox") > 0, + "it pastes the link into the body and previews it" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.good"), + "link is pasted into body" + ); + assert.equal( + find(".title-input input").val(), + "http://www.example.com/nope-onebox.html", + "title is unchanged" + ); }); -QUnit.test("ignore internal links", assert => { - visit("/"); - click("#create-topic"); +QUnit.test("ignore internal links", async assert => { + await visit("/"); + await click("#create-topic"); const title = "http://" + window.location.hostname + "/internal-page.html"; - fillIn("#reply-title", title); - andThen(() => { - assert.equal( - find(".d-editor-preview") - .html() - .trim() - .indexOf("onebox"), - -1, - "onebox preview doesn't show" - ); - assert.equal( - find(".d-editor-input").val().length, - 0, - "link isn't put into the post" - ); - assert.equal(find(".title-input input").val(), title, "title is unchanged"); - }); + await fillIn("#reply-title", title); + assert.equal( + find(".d-editor-preview") + .html() + .trim() + .indexOf("onebox"), + -1, + "onebox preview doesn't show" + ); + assert.equal( + find(".d-editor-input").val().length, + 0, + "link isn't put into the post" + ); + assert.equal(find(".title-input input").val(), title, "title is unchanged"); }); -QUnit.test("link is longer than max title length", assert => { - visit("/"); - click("#create-topic"); - fillIn( +QUnit.test("link is longer than max title length", async assert => { + await visit("/"); + await click("#create-topic"); + await fillIn( "#reply-title", "http://www.example.com/has-title-and-a-url-that-is-more-than-80-characters-because-thats-good-for-seo-i-guess.html" ); - andThen(() => { - assert.ok( - find(".d-editor-preview") - .html() - .trim() - .indexOf("onebox") > 0, - "it pastes the link into the body and previews it" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.good"), - "the body is now good" - ); - assert.equal( - find(".title-input input").val(), - "An interesting article", - "title is from the oneboxed article" - ); - }); + assert.ok( + find(".d-editor-preview") + .html() + .trim() + .indexOf("onebox") > 0, + "it pastes the link into the body and previews it" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.good"), + "the body is now good" + ); + assert.equal( + find(".title-input input").val(), + "An interesting article", + "title is from the oneboxed article" + ); }); -QUnit.test("onebox with title but extra words in title field", assert => { - visit("/"); - click("#create-topic"); - fillIn("#reply-title", "http://www.example.com/has-title.html test"); - andThen(() => { - assert.equal( - find(".d-editor-preview") - .html() - .trim() - .indexOf("onebox"), - -1, - "onebox preview doesn't show" - ); - assert.equal( - find(".d-editor-input").val().length, - 0, - "link isn't put into the post" - ); - assert.equal( - find(".title-input input").val(), - "http://www.example.com/has-title.html test", - "title is unchanged" - ); - }); +QUnit.test("onebox with title but extra words in title field", async assert => { + await visit("/"); + await click("#create-topic"); + await fillIn("#reply-title", "http://www.example.com/has-title.html test"); + assert.equal( + find(".d-editor-preview") + .html() + .trim() + .indexOf("onebox"), + -1, + "onebox preview doesn't show" + ); + assert.equal( + find(".d-editor-input").val().length, + 0, + "link isn't put into the post" + ); + assert.equal( + find(".title-input input").val(), + "http://www.example.com/has-title.html test", + "title is unchanged" + ); }); acceptance("Composer topic featured links when uncategorized is not allowed", { @@ -167,38 +155,34 @@ acceptance("Composer topic featured links when uncategorized is not allowed", { } }); -QUnit.test("Pasting a link enables the text input area", assert => { +QUnit.test("Pasting a link enables the text input area", async assert => { replaceCurrentUser({ admin: false, staff: false, trust_level: 1 }); - visit("/"); - click("#create-topic"); - andThen(() => { - assert.ok( - find(".d-editor-textarea-wrapper.disabled").length, - "textarea is disabled" - ); - }); - fillIn("#reply-title", "http://www.example.com/has-title.html"); - andThen(() => { - assert.ok( - find(".d-editor-preview") - .html() - .trim() - .indexOf("onebox") > 0, - "it pastes the link into the body and previews it" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.good"), - "the body is now good" - ); - assert.equal( - find(".title-input input").val(), - "An interesting article", - "title is from the oneboxed article" - ); - assert.ok( - find(".d-editor-textarea-wrapper.disabled").length === 0, - "textarea is enabled" - ); - }); + await visit("/"); + await click("#create-topic"); + assert.ok( + find(".d-editor-textarea-wrapper.disabled").length, + "textarea is disabled" + ); + await fillIn("#reply-title", "http://www.example.com/has-title.html"); + assert.ok( + find(".d-editor-preview") + .html() + .trim() + .indexOf("onebox") > 0, + "it pastes the link into the body and previews it" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.good"), + "the body is now good" + ); + assert.equal( + find(".title-input input").val(), + "An interesting article", + "title is from the oneboxed article" + ); + assert.ok( + find(".d-editor-textarea-wrapper.disabled").length === 0, + "textarea is enabled" + ); }); diff --git a/test/javascripts/acceptance/create-account-user-fields-test.js.es6 b/test/javascripts/acceptance/create-account-user-fields-test.js.es6 index 12a5fcb88bc..3785859ff72 100644 --- a/test/javascripts/acceptance/create-account-user-fields-test.js.es6 +++ b/test/javascripts/acceptance/create-account-user-fields-test.js.es6 @@ -25,57 +25,47 @@ acceptance("Create Account - User Fields", { } }); -QUnit.test("create account with user fields", assert => { - visit("/"); - click("header .sign-up-button"); +QUnit.test("create account with user fields", async assert => { + await visit("/"); + await click("header .sign-up-button"); - andThen(() => { - assert.ok(exists(".create-account"), "it shows the create account modal"); - assert.ok(exists(".user-field"), "it has at least one user field"); - assert.ok( - exists(".modal-footer .btn-primary:disabled"), - "create account is disabled at first" - ); - }); + assert.ok(exists(".create-account"), "it shows the create account modal"); + assert.ok(exists(".user-field"), "it has at least one user field"); + assert.ok( + exists(".modal-footer .btn-primary:disabled"), + "create account is disabled at first" + ); - fillIn("#new-account-name", "Dr. Good Tuna"); - fillIn("#new-account-password", "cool password bro"); - fillIn("#new-account-email", "good.tuna@test.com"); - fillIn("#new-account-username", "goodtuna"); + await fillIn("#new-account-name", "Dr. Good Tuna"); + await fillIn("#new-account-password", "cool password bro"); + await fillIn("#new-account-email", "good.tuna@test.com"); + await fillIn("#new-account-username", "goodtuna"); - andThen(() => { - assert.ok( - exists("#username-validation.good"), - "the username validation is good" - ); - assert.ok( - exists(".modal-footer .btn-primary:disabled"), - "create account is still disabled due to lack of user fields" - ); - }); + assert.ok( + exists("#username-validation.good"), + "the username validation is good" + ); + assert.ok( + exists(".modal-footer .btn-primary:disabled"), + "create account is still disabled due to lack of user fields" + ); - fillIn(".user-field input[type=text]:first", "Barky"); + await fillIn(".user-field input[type=text]:first", "Barky"); - andThen(() => { - assert.ok( - exists(".modal-footer .btn-primary:disabled"), - "create account is disabled because field is not checked" - ); - }); + assert.ok( + exists(".modal-footer .btn-primary:disabled"), + "create account is disabled because field is not checked" + ); - click(".user-field input[type=checkbox]"); - andThen(() => { - assert.not( - exists(".modal-footer .btn-primary:disabled"), - "create account is enabled because field is not checked" - ); - }); + await click(".user-field input[type=checkbox]"); + assert.not( + exists(".modal-footer .btn-primary:disabled"), + "create account is enabled because field is not checked" + ); - click(".user-field input[type=checkbox]"); - andThen(() => { - assert.ok( - exists(".modal-footer .btn-primary:disabled"), - "unclicking the checkbox disables the submit" - ); - }); + await click(".user-field input[type=checkbox]"); + assert.ok( + exists(".modal-footer .btn-primary:disabled"), + "unclicking the checkbox disables the submit" + ); }); diff --git a/test/javascripts/acceptance/custom-html-set-test.js.es6 b/test/javascripts/acceptance/custom-html-set-test.js.es6 index 918b22ed873..8df5e7e3a1c 100644 --- a/test/javascripts/acceptance/custom-html-set-test.js.es6 +++ b/test/javascripts/acceptance/custom-html-set-test.js.es6 @@ -4,37 +4,27 @@ import PreloadStore from "preload-store"; acceptance("CustomHTML set"); -QUnit.test("has no custom HTML in the top", assert => { - visit("/static/faq"); - andThen(() => { - assert.ok(!exists("span.custom-html-test"), "it has no markup"); - }); +QUnit.test("has no custom HTML in the top", async assert => { + await visit("/static/faq"); + assert.ok(!exists("span.custom-html-test"), "it has no markup"); }); -QUnit.test("renders set HTML", assert => { +QUnit.test("renders set HTML", async assert => { setCustomHTML("top", 'HTML'); - visit("/static/faq"); - andThen(() => { - assert.equal( - find("span.custom-html-test").text(), - "HTML", - "it inserted the markup" - ); - }); + await visit("/static/faq"); + assert.equal( + find("span.custom-html-test").text(), + "HTML", + "it inserted the markup" + ); }); -QUnit.test("renders preloaded HTML", assert => { +QUnit.test("renders preloaded HTML", async assert => { PreloadStore.store("customHTML", { top: "monster" }); - visit("/static/faq"); - andThen(() => { - assert.equal( - find("span.cookie").text(), - "monster", - "it inserted the markup" - ); - }); + await visit("/static/faq"); + assert.equal(find("span.cookie").text(), "monster", "it inserted the markup"); }); diff --git a/test/javascripts/acceptance/custom-html-template-test.js.es6 b/test/javascripts/acceptance/custom-html-template-test.js.es6 index ab86bc86d66..d8a27d46ed7 100644 --- a/test/javascripts/acceptance/custom-html-template-test.js.es6 +++ b/test/javascripts/acceptance/custom-html-template-test.js.es6 @@ -12,13 +12,7 @@ acceptance("CustomHTML template", { } }); -QUnit.test("renders custom template", assert => { - visit("/static/faq"); - andThen(() => { - assert.equal( - find("span.top-span").text(), - "TOP", - "it inserted the template" - ); - }); +QUnit.test("renders custom template", async assert => { + await visit("/static/faq"); + assert.equal(find("span.top-span").text(), "TOP", "it inserted the template"); });