diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js index ecda08192a8..bfe19308b3c 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js @@ -1,6 +1,6 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Admin - Search Log Term", function (needs) { needs.user(); @@ -8,8 +8,8 @@ acceptance("Admin - Search Log Term", function (needs) { test("show search log term details", async function (assert) { await visit("/admin/logs/search_logs/term?term=ruby"); - assert.ok(exists(".search-logs-filter"), "has the search type filter"); - assert.ok(exists("canvas"), "has graph canvas"); - assert.ok(exists("div.header-search-results"), "has header search results"); + assert.dom(".search-logs-filter").exists("has the search type filter"); + assert.dom("canvas").exists("has graph canvas"); + assert.dom("div.header-search-results").exists("has header search results"); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js index 1340cfacc8d..77aac7ef562 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js @@ -3,11 +3,7 @@ import { test } from "qunit"; import { AUTO_GROUPS } from "discourse/lib/constants"; import { withPluginApi } from "discourse/lib/plugin-api"; import PreloadStore from "discourse/lib/preload-store"; -import { - acceptance, - count, - exists, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, count } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; acceptance("Admin Sidebar - Sections", function (needs) { @@ -88,12 +84,11 @@ acceptance("Admin Sidebar - Sections", function (needs) { await visit("/admin"); await click(".sidebar-toggle-all-sections"); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='admin-plugins'] .sidebar-section-link-wrapper[data-list-item-name=\"admin_installed_plugins\"]" - ), - "the admin plugin route is added to the plugins section" - ); + ) + .exists("the admin plugin route is added to the plugins section"); }); test("Visit reports page", async function (assert) { @@ -188,12 +183,11 @@ acceptance("Admin Sidebar - Sections - Plugin API", function (needs) { test("additional valid links can be added to a section with the plugin API", async function (assert) { await visit("/admin"); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='admin-root'] .sidebar-section-link-wrapper[data-list-item-name=\"admin_additional_root_test_section_link\"]" - ), - "link is appended to the root section" - ); + ) + .exists("link is appended to the root section"); assert .dom( @@ -223,11 +217,11 @@ acceptance("Admin Sidebar - Sections - Plugin API", function (needs) { test("community section links are added to primary and secondary sections with the plugin API", async function (assert) { await visit("/"); - assert.ok( - exists( + assert + .dom( "#sidebar-section-content-community .sidebar-section-link[data-link-name='primary']" ) - ); + .exists(); assert .dom( "#sidebar-section-content-community .sidebar-section-link[data-link-name='secondary']" @@ -241,11 +235,11 @@ acceptance("Admin Sidebar - Sections - Plugin API", function (needs) { ".sidebar-more-section-links-details-content .sidebar-section-link[data-link-name='primary']" ) .doesNotExist(); - assert.ok( - exists( + assert + .dom( ".sidebar-more-section-links-details-content .sidebar-section-link[data-link-name='secondary']" ) - ); + .exists(); }); }); @@ -280,12 +274,11 @@ acceptance( test("valid links that are yet to be translated can be added to a section with the plugin API because of I18n fallback", async function (assert) { await visit("/admin"); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='admin-root'] .sidebar-section-link-wrapper[data-list-item-name=\"admin_additional_root_test_section_link\"]" - ), - "link is appended to the root section" - ); + ) + .exists("link is appended to the root section"); }); } ); diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js index e2d019b1a9f..e069f02218f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js @@ -11,7 +11,6 @@ import pretender from "discourse/tests/helpers/create-pretender"; import { acceptance, count, - exists, queryAll, } from "discourse/tests/helpers/qunit-helpers"; @@ -48,7 +47,7 @@ acceptance("Admin - Site Settings", function (needs) { .dom(".row.setting.upload .image-uploader") .exists("image uploader is present"); - assert.ok(exists(".row.setting.upload .undo"), "undo button is present"); + assert.dom(".row.setting.upload .undo").exists("undo button is present"); }); test("links to staff action log", async function (assert) { @@ -71,7 +70,9 @@ acceptance("Admin - Site Settings", function (needs) { 1, "filter returns 1 site setting" ); - assert.ok(!exists(".row.setting.overridden"), "setting isn't overridden"); + assert + .dom(".row.setting.overridden") + .doesNotExist("setting isn't overridden"); await fillIn(".input-setting-string", "Test"); await click("button.cancel"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-user-badges-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-user-badges-test.js index ce7c5dbb560..7ca5e122dba 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-user-badges-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-user-badges-test.js @@ -1,6 +1,6 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Admin - Users Badges", function (needs) { needs.user(); @@ -8,6 +8,6 @@ acceptance("Admin - Users Badges", function (needs) { test("lists badges", async function (assert) { await visit("/admin/users/1/eviltrout/badges"); - assert.ok(exists(`span[data-badge-name="Badge 8"]`)); + assert.dom(`span[data-badge-name="Badge 8"]`).exists(); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js index db21edca809..57083ad7920 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js @@ -1,10 +1,6 @@ import { click, fillIn, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; acceptance("Admin - Users List", function (needs) { @@ -14,7 +10,9 @@ acceptance("Admin - Users List", function (needs) { await visit("/admin/users/list/active"); assert.dom(".users-list .user").exists(); - assert.ok(!exists(".user:nth-of-type(1) .email small"), "escapes email"); + assert + .dom(".user:nth-of-type(1) .email small") + .doesNotExist("escapes email"); }); test("searching users with no matches", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/categories-test.js b/app/assets/javascripts/discourse/tests/acceptance/categories-test.js index 0eaa10522ba..7b37c4cf619 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/categories-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/categories-test.js @@ -2,11 +2,7 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; import PreloadStore from "discourse/lib/preload-store"; import discoveryFixtures from "discourse/tests/fixtures/discovery-fixtures"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { cloneJSON } from "discourse-common/lib/object"; acceptance("Categories - 'categories_only'", function (needs) { @@ -80,20 +76,17 @@ acceptance( }); test("basic functionality", async function (assert) { await visit("/categories"); - assert.ok( - exists("table.subcategory-list.with-topics thead h3 .category-name"), - "shows heading for top-level category" - ); - assert.ok( - exists( + assert + .dom("table.subcategory-list.with-topics thead h3 .category-name") + .exists("shows heading for top-level category"); + assert + .dom( "table.subcategory-list.with-topics tr[data-category-id='26'] h3 .category-name" - ), - "shows table row for subcategories" - ); - assert.ok( - exists("table.category-list.with-topics div[data-topic-id='11994']"), - "shows a featured topic" - ); + ) + .exists("shows table row for subcategories"); + assert + .dom("table.category-list.with-topics div[data-topic-id='11994']") + .exists("shows a featured topic"); }); } ); @@ -107,20 +100,17 @@ acceptance( }); test("basic functionality", async function (assert) { await visit("/categories"); - assert.ok( - exists("div.subcategory-list.with-topics h3 .category-name"), - "shows heading for top-level category" - ); - assert.ok( - exists( + assert + .dom("div.subcategory-list.with-topics h3 .category-name") + .exists("shows heading for top-level category"); + assert + .dom( "div.subcategory-list.with-topics div[data-category-id='26'] h3 .category-name" - ), - "shows element for subcategories" - ); - assert.ok( - exists("div.category-list.with-topics a[data-topic-id='11994']"), - "shows a featured topic" - ); + ) + .exists("shows element for subcategories"); + assert + .dom("div.category-list.with-topics a[data-topic-id='11994']") + .exists("shows a featured topic"); }); } ); diff --git a/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js b/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js index 30c07d4fab7..29aa6b16a40 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import { acceptance, count, - exists, query, queryAll, } from "discourse/tests/helpers/qunit-helpers"; @@ -76,7 +75,9 @@ acceptance("Category Edit - Security", function (needs) { await visit("/c/bug/edit/security"); await click(".row-body .remove-permission"); - assert.ok(!exists(".row-body"), "removes the permission from the list"); + assert + .dom(".row-body") + .doesNotExist("removes the permission from the list"); await availableGroups.expand(); await availableGroups.selectRowByValue("everyone"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/category-new-test.js b/app/assets/javascripts/discourse/tests/acceptance/category-new-test.js index 28339d46da7..01d7e923497 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/category-new-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/category-new-test.js @@ -2,7 +2,7 @@ import { click, currentURL, fillIn, visit } from "@ember/test-helpers"; import { test } from "qunit"; import sinon from "sinon"; import DiscourseURL from "discourse/lib/url"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import I18n from "discourse-i18n"; @@ -69,12 +69,9 @@ acceptance("Category New", function (needs) { await click(".edit-category-nav .edit-category-tags a"); - assert.ok( - exists( - ".required-tag-group-row .select-kit-header[data-value='TagGroup1']" - ), - "it shows saved required tag group" - ); + assert + .dom(".required-tag-group-row .select-kit-header[data-value='TagGroup1']") + .exists("shows saved required tag group"); assert.dom(".edit-category-title h2").hasText( I18n.t("category.edit_dialog_title", { diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-messages-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-messages-test.js index 982ec95b683..5f5a1098052 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-messages-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-messages-test.js @@ -6,11 +6,7 @@ import { waitUntil, } from "@ember/test-helpers"; import { test } from "qunit"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import I18n from "discourse-i18n"; import pretender, { response } from "../helpers/create-pretender"; @@ -40,10 +36,9 @@ acceptance("Composer - Messages", function (needs) { await visit("/u/charlie"); await click("button.compose-pm"); - assert.false( - exists(".composer-popup"), - "composer warning is not shown by default" - ); + assert + .dom(".composer-popup") + .doesNotExist("composer warning is not shown by default"); await triggerKeyEvent(".d-editor-input", "keyup", "Space"); @@ -95,10 +90,9 @@ acceptance("Composer - Messages - Cannot see group", function (needs) { test("Shows warning in composer if group hasn't been invited", async function (assert) { await visit("/t/130"); await click("button.create"); - assert.false( - exists(".composer-popup"), - "composer warning is not shown by default" - ); + assert + .dom(".composer-popup") + .doesNotExist("composer warning is not shown by default"); await fillIn(".d-editor-input", "Mention @staff"); assert.dom(".composer-popup").exists("shows composer warning message"); @@ -115,10 +109,9 @@ acceptance("Composer - Messages - Cannot see group", function (needs) { test("Shows warning in composer if group hasn't been invited, but some members have access already", async function (assert) { await visit("/t/130"); await click("button.create"); - assert.false( - exists(".composer-popup"), - "composer warning is not shown by default" - ); + assert + .dom(".composer-popup") + .doesNotExist("composer warning is not shown by default"); await fillIn(".d-editor-input", "Mention @staff2"); assert.dom(".composer-popup").exists("shows composer warning message"); @@ -229,10 +222,11 @@ acceptance("Composer - Messages - Private Messages", function (needs) { await fillIn("#reply-title", "Private message test title"); await triggerKeyEvent(".d-editor-input", "keyup", "Space"); - assert.false( - exists(".composer-popup"), - "composer warning is not shown if the target recipients are empty" - ); + assert + .dom(".composer-popup") + .doesNotExist( + "composer warning is not shown if the target recipients are empty" + ); // filling the input with the username of the current user await privateMessageUsers.expand(); @@ -274,10 +268,11 @@ acceptance("Composer - Messages - Private Messages", function (needs) { await fillIn("#reply-title", "Private message test title"); await triggerKeyEvent(".d-editor-input", "keyup", "Space"); - assert.false( - exists(".composer-popup"), - "composer warning is not shown if the target recipients are empty" - ); + assert + .dom(".composer-popup") + .doesNotExist( + "composer warning is not shown if the target recipients are empty" + ); // filling the input with the username of another user await privateMessageUsers.expand(); @@ -286,7 +281,7 @@ acceptance("Composer - Messages - Private Messages", function (needs) { await privateMessageUsers.collapse(); await triggerKeyEvent(".d-editor-input", "keyup", "Space"); - assert.false(exists(".composer-popup"), "do not show it for other user"); + assert.dom(".composer-popup").doesNotExist("do not show it for other user"); // filling the input with the username of the current user await privateMessageUsers.expand(); @@ -295,9 +290,10 @@ acceptance("Composer - Messages - Private Messages", function (needs) { await privateMessageUsers.collapse(); await triggerKeyEvent(".d-editor-input", "keyup", "Space"); - assert.false( - exists(".composer-popup"), - "do not show it when the current user is just one of the target recipients" - ); + assert + .dom(".composer-popup") + .doesNotExist( + "do not show it when the current user is just one of the target recipients" + ); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js index 509e60a1844..1be7f1af52e 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js @@ -25,7 +25,6 @@ import pretender, { response } from "discourse/tests/helpers/create-pretender"; import { acceptance, count, - exists, invisible, metaModifier, query, @@ -154,10 +153,10 @@ acceptance("Composer", function (needs) { test("composer controls", async function (assert) { await visit("/"); - assert.ok(exists("#create-topic"), "the create button is visible"); + assert.dom("#create-topic").exists("the create button is visible"); await click("#create-topic"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.dom(".d-editor-input").exists("the composer input is visible"); await focus(".title-input input"); assert .dom(".title-input .popup-tip.good.hide") @@ -222,10 +221,12 @@ acceptance("Composer", function (needs) { ); await click("#reply-control a.cancel"); - assert.ok(exists(".d-modal"), "it pops up a confirmation dialog"); + assert.dom(".d-modal").exists("pops up a confirmation dialog"); await click(".d-modal__footer .discard-draft"); - assert.ok(!exists(".d-modal__body"), "the confirmation can be cancelled"); + assert + .dom(".d-modal__body") + .doesNotExist("the confirmation can be cancelled"); }); test("Create a topic with server side errors", async function (assert) { @@ -238,11 +239,11 @@ acceptance("Composer", function (needs) { 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(".dialog-body"), "it pops up an error message"); + assert.dom(".dialog-body").exists("pops up an error message"); await click(".dialog-footer .btn-primary"); - assert.ok(!exists(".dialog-body"), "it dismisses the error"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.dom(".dialog-body").doesNotExist("dismisses the error"); + assert.dom(".d-editor-input").exists("the composer input is visible"); }); test("Create a Topic", async function (assert) { @@ -313,7 +314,7 @@ acceptance("Composer", function (needs) { .doesNotExist("the post is not in the DOM"); await click("#topic-footer-buttons .btn.create"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.dom(".d-editor-input").exists("the composer input is visible"); assert .dom("#reply-title") .doesNotExist("there is no title since this is a reply"); @@ -460,7 +461,7 @@ acceptance("Composer", function (needs) { assert.dom(".pending-posts .reviewable-item").doesNotExist(); await click("#topic-footer-buttons .btn.create"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.dom(".d-editor-input").exists("the composer input is visible"); assert .dom("#reply-title") .doesNotExist("there is no title since this is a reply"); @@ -496,7 +497,7 @@ acceptance("Composer", function (needs) { 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.dom(".d-editor-input").doesNotExist("closes the composer"); assert .dom(".topic-post:nth-of-type(1) .post-info.edits") .exists("it has the edits icon"); @@ -723,7 +724,7 @@ acceptance("Composer", function (needs) { ); await visit("/"); - assert.ok(exists("#create-topic"), "the create topic button is visible"); + assert.dom("#create-topic").exists("the create topic button is visible"); await click("#create-topic"); assert @@ -862,12 +863,9 @@ acceptance("Composer", function (needs) { await fillIn(".d-editor-input", longText); - assert.ok( - exists( - '.action-title a[href="/t/internationalization-localization/280"]' - ), - "the mode should be: reply to post" - ); + assert + .dom('.action-title a[href="/t/internationalization-localization/280"]') + .exists("the mode should be: reply to post"); await click("article#post_3 button.reply"); @@ -875,19 +873,16 @@ acceptance("Composer", function (needs) { await composerActions.expand(); await composerActions.selectRowByValue("reply_as_new_topic"); - assert.ok(!exists(".d-modal__body"), "abandon popup shouldn't come"); + assert.dom(".d-modal__body").doesNotExist("abandon popup shouldn't come"); assert.ok( query(".d-editor-input").value.includes(longText), "entered text should still be there" ); - assert.ok( - !exists( - '.action-title a[href="/t/internationalization-localization/280"]' - ), - "mode should have changed" - ); + assert + .dom('.action-title a[href="/t/internationalization-localization/280"]') + .doesNotExist("mode should have changed"); }); test("Loading draft also replaces the recipients", async function (assert) { @@ -1008,7 +1003,7 @@ acceptance("Composer", function (needs) { .doesNotExist("Doesn't show the 'group_mentioned' notice in a quote"); await fillIn(".d-editor-input", "@staff"); - assert.ok(exists(".composer-popup"), "Shows the 'group_mentioned' notice"); + assert.dom(".composer-popup").exists("shows the 'group_mentioned' notice"); }); test("Does not save invalid draft", async function (assert) { @@ -1119,14 +1114,14 @@ acceptance("Composer - Error Extensibility", function (needs) { 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(".dialog-body"), "it pops up an error message"); + assert.dom(".dialog-body").exists("pops up an error message"); assert.ok( query(".dialog-body").innerText.match(/PLUGIN_ABC ERROR/), "it contains the server side error text" ); await click(".dialog-footer .btn-primary"); - assert.ok(!exists(".dialog-body"), "it dismisses the error"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.dom(".dialog-body").doesNotExist("dismisses the error"); + assert.dom(".d-editor-input").exists("the composer input is visible"); }); }); @@ -1340,7 +1335,7 @@ acceptance("Composer - current time", function (needs) { await visit("/t/internationalization-localization/280"); await click("#topic-footer-buttons .btn.create"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.dom(".d-editor-input").exists("the composer input is visible"); await fillIn(".d-editor-input", "and the time now is: "); const date = moment().format("YYYY-MM-DD"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js index 5456b46ee3d..e9697e3ef4d 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js @@ -1,10 +1,6 @@ import { click, fillIn, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; acceptance("Composer topic featured links", function (needs) { needs.user(); @@ -173,28 +169,25 @@ acceptance( test("Pasting a link enables the text input area", async function (assert) { await visit("/"); await click("#create-topic"); - assert.ok( - exists(".d-editor-textarea-wrapper.disabled"), - "textarea is disabled" - ); + assert + .dom(".d-editor-textarea-wrapper.disabled") + .exists("textarea is disabled"); await fillIn("#reply-title", "http://www.example.com/has-title.html"); assert.ok( query(".d-editor-preview").innerHTML.trim().includes("onebox"), "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 + .dom(".d-editor-textarea-wrapper .popup-tip.good") + .exists("the body is now good"); assert.strictEqual( query(".title-input input").value, "An interesting article", "title is from the oneboxed article" ); - assert.ok( - !exists(".d-editor-textarea-wrapper.disabled"), - "textarea is enabled" - ); + assert + .dom(".d-editor-textarea-wrapper.disabled") + .doesNotExist("textarea is enabled"); }); } ); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js index ea37f14496a..89893fd48cc 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js @@ -1,6 +1,6 @@ import { click, fillIn, focus, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; acceptance( @@ -12,49 +12,42 @@ acceptance( test("Disable body until category is selected", async function (assert) { await visit("/"); await click("#create-topic"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.dom(".d-editor-input").exists("the composer input is visible"); await focus(".title-input input"); - assert.ok( - exists(".title-input .popup-tip.good.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" - ); + assert + .dom(".title-input .popup-tip.good.hide") + .exists("title errors are hidden by default"); + assert + .dom(".d-editor-textarea-wrapper .popup-tip.bad.hide") + .exists("body errors are hidden by default"); + assert + .dom(".d-editor-textarea-wrapper.disabled") + .exists("textarea is disabled"); - assert.ok( - !exists("button.toggle-fullscreen"), - "fullscreen button is not present" - ); + assert + .dom("button.toggle-fullscreen") + .doesNotExist("fullscreen button is not present"); const categoryChooser = selectKit(".category-chooser"); await categoryChooser.expand(); await categoryChooser.selectRowByValue(2); - assert.ok( - !exists(".d-editor-textarea-wrapper.disabled"), - "textarea is enabled" - ); + assert + .dom(".d-editor-textarea-wrapper.disabled") + .doesNotExist("textarea is enabled"); await fillIn(".d-editor-input", "Now I can type stuff"); await categoryChooser.expand(); await categoryChooser.selectRowByIndex(0); - assert.ok( - !exists(".d-editor-textarea-wrapper.disabled"), - "textarea is still enabled" - ); + assert + .dom(".d-editor-textarea-wrapper.disabled") + .doesNotExist("textarea is still enabled"); - assert.ok( - exists("button.toggle-fullscreen"), - "fullscreen button is present" - ); + assert + .dom("button.toggle-fullscreen") + .exists("fullscreen button is present"); }); } ); @@ -89,38 +82,34 @@ acceptance( }, ], }); + test("Enable composer/body if no topic templates present", async function (assert) { await visit("/"); await click("#create-topic"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); - assert.ok( - exists(".category-input .popup-tip.bad.hide"), - "category errors are hidden by default" - ); - assert.ok( - !exists(".d-editor-textarea-wrapper.disabled"), - "textarea is enabled" - ); + assert.dom(".d-editor-input").exists("the composer input is visible"); + assert + .dom(".category-input .popup-tip.bad.hide") + .exists("category errors are hidden by default"); + assert + .dom(".d-editor-textarea-wrapper.disabled") + .doesNotExist("textarea is enabled"); - assert.ok( - exists("button.toggle-fullscreen"), - "fullscreen button is present" - ); + assert + .dom("button.toggle-fullscreen") + .exists("fullscreen button is present"); await click("#reply-control button.create"); - assert.ok( - exists(".category-input .popup-tip.bad"), - "it shows the choose a category error" - ); + assert + .dom(".category-input .popup-tip.bad") + .exists("it shows the choose a category error"); const categoryChooser = selectKit(".category-chooser"); await categoryChooser.expand(); await categoryChooser.selectRowByValue(1); - assert.ok( - !exists(".category-input .popup-tip.bad"), - "category error removed after selecting category" - ); + assert + .dom(".category-input .popup-tip.bad") + .doesNotExist("category error removed after selecting category"); }); } ); diff --git a/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js b/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js index e5317ce5b6d..48708e95180 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js @@ -2,12 +2,12 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; import { setCustomHTML } from "discourse/helpers/custom-html"; import PreloadStore from "discourse/lib/preload-store"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("CustomHTML set", function () { test("has no custom HTML in the top", async function (assert) { await visit("/static/faq"); - assert.ok(!exists("span.custom-html-test"), "it has no markup"); + assert.dom("span.custom-html-test").doesNotExist("has no markup"); }); test("renders set HTML", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js b/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js index 55956cde13e..1927bbfb22e 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js @@ -1,10 +1,6 @@ import { click, fillIn, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { - acceptance, - count, - exists, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, count } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; acceptance("Dashboard", function (needs) { @@ -26,30 +22,24 @@ acceptance("Dashboard", function (needs) { ], }); - test("default", async function (assert) { - await visit("/admin"); - - assert.ok(exists(".dashboard"), "has dashboard-next class"); - }); - test("tabs", async function (assert) { await visit("/admin"); - assert.ok(exists(".dashboard .navigation-item.general"), "general tab"); + assert.dom(".dashboard .navigation-item.general").exists("general tab"); assert .dom(".dashboard .navigation-item.moderation") .exists("moderation tab"); - assert.ok(exists(".dashboard .navigation-item.security"), "security tab"); - assert.ok(exists(".dashboard .navigation-item.reports"), "reports tab"); + assert.dom(".dashboard .navigation-item.security").exists("security tab"); + assert.dom(".dashboard .navigation-item.reports").exists("reports tab"); }); test("general tab", async function (assert) { await visit("/admin"); - assert.ok(exists(".custom-date-range-button"), "custom date range button"); - assert.ok(exists(".admin-report.signups"), "signups report"); - assert.ok(exists(".admin-report.posts"), "posts report"); - assert.ok(exists(".admin-report.dau-by-mau"), "dau-by-mau report"); + assert.dom(".custom-date-range-button").exists("custom date range button"); + assert.dom(".admin-report.signups").exists("signups report"); + assert.dom(".admin-report.posts").exists("posts report"); + assert.dom(".admin-report.dau-by-mau").exists("dau-by-mau report"); assert .dom(".admin-report.daily-engaged-users") .exists("daily-engaged-users report"); @@ -62,7 +52,7 @@ acceptance("Dashboard", function (needs) { await visit("/admin"); await click(".dashboard .navigation-item.moderation .navigation-link"); - assert.ok(exists(".custom-date-range-button"), "custom date range button"); + assert.dom(".custom-date-range-button").exists("custom date range button"); assert .dom(".admin-report.moderators-activity") .exists("moderators activity report"); @@ -129,12 +119,12 @@ acceptance("Dashboard: dashboard_visible_tabs", function (needs) { test("visible tabs", async function (assert) { await visit("/admin"); - assert.ok(exists(".dashboard .navigation-item.general"), "general tab"); + assert.dom(".dashboard .navigation-item.general").exists("general tab"); assert .dom(".dashboard .navigation-item.moderation") .doesNotExist("moderation tab"); - assert.ok(exists(".dashboard .navigation-item.security"), "security tab"); - assert.ok(exists(".dashboard .navigation-item.reports"), "reports tab"); + assert.dom(".dashboard .navigation-item.security").exists("security tab"); + assert.dom(".dashboard .navigation-item.reports").exists("reports tab"); }); }); @@ -148,7 +138,7 @@ acceptance("Dashboard: dashboard_hidden_reports", function (needs) { test("hidden reports", async function (assert) { await visit("/admin"); - assert.ok(exists(".admin-report.signups.is-visible"), "signups report"); + assert.dom(".admin-report.signups.is-visible").exists("signups report"); assert.dom(".admin-report.is-visible.posts").doesNotExist("posts report"); assert .dom(".admin-report.is-visible.dau-by-mau") diff --git a/app/assets/javascripts/discourse/tests/acceptance/do-not-disturb-test.js b/app/assets/javascripts/discourse/tests/acceptance/do-not-disturb-test.js index c102d91223b..0f1e9203ad2 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/do-not-disturb-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/do-not-disturb-test.js @@ -4,7 +4,6 @@ import DoNotDisturb from "discourse/lib/do-not-disturb"; import { acceptance, count, - exists, query, queryAll, updateCurrentUser, @@ -31,7 +30,7 @@ acceptance("Do not disturb", function (needs) { await click("#user-menu-button-profile"); await click("#quick-access-profile .do-not-disturb .btn"); - assert.ok(exists(".do-not-disturb-modal"), "modal to choose time appears"); + assert.dom(".do-not-disturb-modal").exists("modal to choose time appears"); let tiles = queryAll(".do-not-disturb-tile"); assert.ok(tiles.length === 4, "There are 4 duration choices"); @@ -40,12 +39,11 @@ acceptance("Do not disturb", function (needs) { assert.dom(".d-modal").doesNotExist("modal is hidden"); - assert.ok( - exists( + assert + .dom( ".header-dropdown-toggle .do-not-disturb-background .d-icon-discourse-dnd" - ), - "dnd icon is present in header" - ); + ) + .exists("dnd icon is present in header"); }); test("Can be invoked via keyboard", async function (assert) { @@ -56,7 +54,7 @@ acceptance("Do not disturb", function (needs) { await click("#user-menu-button-profile"); await click("#quick-access-profile .do-not-disturb .btn"); - assert.ok(exists(".do-not-disturb-modal"), "DND modal is displayed"); + assert.dom(".do-not-disturb-modal").exists("DND modal is displayed"); assert.strictEqual( count(".do-not-disturb-tile"), @@ -74,12 +72,11 @@ acceptance("Do not disturb", function (needs) { .dom(".d-modal") .doesNotExist("DND modal is hidden after making a choice"); - assert.ok( - exists( + assert + .dom( ".header-dropdown-toggle .do-not-disturb-background .d-icon-discourse-dnd" - ), - "dnd icon is shown in header avatar" - ); + ) + .exists("dnd icon is shown in header avatar"); }); test("when turned on, it can be turned off", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js b/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js index 8589c8bba8d..ec8e03a2f7f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import { acceptance, count, - exists, query, queryAll, } from "discourse/tests/helpers/qunit-helpers"; @@ -24,10 +23,10 @@ acceptance("EmojiPicker", function (needs) { await click("#topic-footer-buttons .btn.create"); await click("button.emoji.btn"); - assert.ok(exists(".emoji-picker.opened"), "it opens the picker"); + assert.dom(".emoji-picker.opened").exists("opens the picker"); await click("button.emoji.btn"); - assert.notOk(exists(".emoji-picker.opened"), "it closes the picker"); + assert.dom(".emoji-picker.opened").doesNotExist("closes the picker"); }); test("filters emoji", async function (assert) { @@ -83,12 +82,11 @@ acceptance("EmojiPicker", function (needs) { await click("button.emoji.btn"); await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); - assert.ok( - exists( + assert + .dom( ".emoji-picker .section.recent .section-group img.emoji[title='grinning']" - ), - "it shows recent selected emoji" - ); + ) + .exists("shows recent selected emoji"); assert .dom('.emoji-picker .category-button[data-section="recent"]') @@ -96,12 +94,11 @@ acceptance("EmojiPicker", function (needs) { await click(".emoji-picker .trash-recent"); - assert.notOk( - exists( + assert + .dom( ".emoji-picker .section.recent .section-group img.emoji[title='grinning']" - ), - "it has cleared recent emojis" - ); + ) + .doesNotExist("has cleared recent emojis"); assert .dom('.emoji-picker .section[data-section="recent"]') diff --git a/app/assets/javascripts/discourse/tests/acceptance/flag-post-test.js b/app/assets/javascripts/discourse/tests/acceptance/flag-post-test.js index e0d577619e8..f5d577546ca 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/flag-post-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/flag-post-test.js @@ -1,15 +1,13 @@ import { click, fillIn, settled, visit } from "@ember/test-helpers"; import { test } from "qunit"; import userFixtures from "discourse/tests/fixtures/user-fixtures"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; async function openFlagModal() { - if (exists(".topic-post:first-child button.show-more-actions")) { + if ( + document.querySelector(".topic-post:first-child button.show-more-actions") + ) { await click(".topic-post:first-child button.show-more-actions"); } await click(".topic-post:first-child button.create-flag"); @@ -99,7 +97,7 @@ acceptance("flagging", function (needs) { test("Flag modal opening", async function (assert) { await visit("/t/internationalization-localization/280"); await openFlagModal(); - assert.ok(exists(".flag-modal-body"), "it shows the flag modal"); + assert.dom(".flag-modal-body").exists("shows the flag modal"); }); test("Flag take action dropdown exists", async function (assert) { @@ -124,7 +122,7 @@ acceptance("flagging", function (needs) { await click("#radio_inappropriate"); await selectKit(".reviewable-action-dropdown").expand(); await click("[data-value='agree_and_silence']"); - assert.ok(exists(".silence-user-modal"), "it shows the silence modal"); + assert.dom(".silence-user-modal").exists("shows the silence modal"); assert.dom(".suspend-message").hasValue("", "penalty message is empty"); const silenceUntilCombobox = selectKit(".silence-until .combobox"); await silenceUntilCombobox.expand(); @@ -143,7 +141,7 @@ acceptance("flagging", function (needs) { await click("#radio_inappropriate"); await selectKit(".reviewable-action-dropdown").expand(); await click("[data-value='agree_and_silence']"); - assert.ok(exists(".silence-user-modal"), "it shows the silence modal"); + assert.dom(".silence-user-modal").exists("shows the silence modal"); assert .dom(".suspend-message") .hasValue( @@ -176,7 +174,7 @@ acceptance("flagging", function (needs) { await click(".dialog-footer .btn-default"); assert.dom(".dialog-body").doesNotExist(); - assert.ok(exists(".silence-user-modal"), "it shows the silence modal"); + assert.dom(".silence-user-modal").exists("shows the silence modal"); await click(".d-modal-cancel"); assert.dom(".dialog-body").exists(); diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js index 405086a7b95..40002500327 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import { acceptance, count, - exists, queryAll, updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; @@ -19,7 +18,7 @@ acceptance("Group Members - Anonymous", function () { 1, "it displays the group's avatar flair" ); - assert.ok(exists(".group-members .group-member"), "it lists group members"); + assert.dom(".group-members .group-member").exists("lists group members"); assert .dom(".group-member-dropdown") diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js index 2c49564ab44..1d2047f131c 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js @@ -2,11 +2,7 @@ import { click, currentRouteName, visit } from "@ember/test-helpers"; import { test } from "qunit"; import { GROUP_SMTP_SSL_MODES } from "discourse/lib/constants"; import formKit from "discourse/tests/helpers/form-kit-helper"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import I18n from "discourse-i18n"; @@ -44,10 +40,9 @@ acceptance( "group.manage.email", "it redirects to the group email page" ); - assert.notOk( - exists(".group-manage-email-imap-wrapper"), - "does not show IMAP settings" - ); + assert + .dom(".group-manage-email-imap-wrapper") + .doesNotExist("does not show IMAP settings"); }); } ); @@ -77,10 +72,9 @@ acceptance( query(".user-secondary-navigation").innerText.includes("Email"), "email link is shown in the sidebar" ); - assert.ok( - exists("#enable_imap:disabled"), - "IMAP is disabled until SMTP settings are valid" - ); + assert + .dom("#enable_imap") + .isDisabled("IMAP is disabled until SMTP settings are valid"); await click("#enable_smtp"); assert.dom(".group-smtp-email-settings").exists(); @@ -125,10 +119,9 @@ acceptance( "Saved!" ); - assert.notOk( - exists("#enable_imap:disabled"), - "IMAP is able to be enabled now that SMTP is saved" - ); + assert + .dom("#enable_imap") + .isEnabled("IMAP is able to be enabled now that SMTP is saved"); await click("#enable_smtp"); assert.strictEqual( @@ -150,17 +143,17 @@ acceptance( await formKit().submit(); await click(".group-manage-save"); - assert.notOk( - exists("#enable_imap:disabled"), - "IMAP is able to be enabled now that IMAP is saved" - ); + assert + .dom("#enable_imap") + .isEnabled("IMAP is able to be enabled now that IMAP is saved"); await click("#enable_imap"); - assert.ok( - exists(".test-imap-settings:disabled"), - "does not allow testing settings if not all fields are filled" - ); + assert + .dom(".test-imap-settings") + .isDisabled( + "does not allow testing settings if not all fields are filled" + ); await click("#prefill_imap_gmail"); assert.strictEqual( @@ -173,13 +166,12 @@ acceptance( "993", "prefills IMAP port settings for gmail" ); - assert.ok( - exists("#enable_ssl_imap:checked"), - "prefills IMAP ssl settings for gmail" - ); + assert + .dom("#enable_ssl_imap") + .isChecked("prefills IMAP ssl settings for gmail"); await click(".test-imap-settings"); - assert.ok(exists(".imap-settings-ok"), "tested settings are ok"); + assert.dom(".imap-settings-ok").exists("tested settings are ok"); await click(".group-manage-save"); @@ -188,10 +180,9 @@ acceptance( "Saved!" ); - assert.ok( - exists(".imap-no-mailbox-selected"), - "shows a message saying no IMAP mailbox is selected" - ); + assert + .dom(".imap-no-mailbox-selected") + .exists("shows a message saying no IMAP mailbox is selected"); await selectKit( ".control-group.group-imap-mailboxes .combo-box" @@ -201,10 +192,9 @@ acceptance( ).selectRowByValue("All Mail"); await click(".group-manage-save"); - assert.notOk( - exists(".imap-no-mailbox-selected"), - "no longer shows a no mailbox selected message" - ); + assert + .dom(".imap-no-mailbox-selected") + .doesNotExist("no longer shows a no mailbox selected message"); await click("#enable_imap"); assert.strictEqual( @@ -282,8 +272,8 @@ acceptance( test("prefills smtp and imap saved settings and shows last updated details", async function (assert) { await visit("/g/discourse/manage/email"); - assert.notOk(exists("#enable_smtp:disabled"), "SMTP is not disabled"); - assert.notOk(exists("#enable_imap:disabled"), "IMAP is not disabled"); + assert.dom("#enable_smtp").isNotDisabled("SMTP is not disabled"); + assert.dom("#enable_imap").isNotDisabled("IMAP is not disabled"); assert .form() diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js index 7cbae017704..b478e55a10a 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import { acceptance, count, - exists, updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; @@ -101,7 +100,7 @@ acceptance( test("For a group with a default_notification_level of 0", async function (assert) { await visit("/g/alternative-group/manage/interaction"); - await assert.ok(exists(".groups-form"), "should have the form"); + await assert.dom(".groups-form").exists("has the form"); await assert.strictEqual( selectKit(".groups-form-default-notification-level").header().value(), "0", @@ -112,7 +111,7 @@ acceptance( test("For a group with a null default_notification_level", async function (assert) { await visit("/g/discourse/manage/interaction"); - await assert.ok(exists(".groups-form"), "should have the form"); + await assert.dom(".groups-form").exists("has the form"); await assert.strictEqual( selectKit(".groups-form-default-notification-level").header().value(), "3", @@ -123,7 +122,7 @@ acceptance( test("For a group with a selected default_notification_level", async function (assert) { await visit("/g/support/manage/interaction"); - await assert.ok(exists(".groups-form"), "should have the form"); + await assert.dom(".groups-form").exists("has the form"); await assert.strictEqual( selectKit(".groups-form-default-notification-level").header().value(), "2", diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-save-button-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-save-button-test.js index 935e577ad61..eb957c69b5f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-save-button-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-save-button-test.js @@ -1,6 +1,6 @@ import { click, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; acceptance("Managing Group - Save Button", function (needs) { @@ -19,11 +19,11 @@ acceptance("Managing Group - Save Button", function (needs) { await visibilitySelector.expand(); await visibilitySelector.selectRowByValue("1"); - assert.ok(exists(".alert-private-group-name"), "alert is shown"); + assert.dom(".alert-private-group-name").exists("alert is shown"); await visibilitySelector.expand(); await visibilitySelector.selectRowByValue("0"); - assert.notOk(exists(".alert-private-group-name"), "alert is hidden"); + assert.dom(".alert-private-group-name").doesNotExist("alert is hidden"); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-test.js index 292609eae0a..b239c09eb95 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import { acceptance, count, - exists, query, } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; @@ -34,7 +33,7 @@ acceptance("Group - Anonymous", function (needs) { await click(".nav-pills li a[title='Activity']"); - assert.ok(exists(".user-stream-item"), "it lists stream items"); + assert.dom(".user-stream-item").exists("lists stream items"); await click(".activity-nav li a[href='/g/discourse/activity/topics']"); @@ -43,14 +42,14 @@ acceptance("Group - Anonymous", function (needs) { await click(".activity-nav li a[href='/g/discourse/activity/mentions']"); - assert.ok(exists(".user-stream-item"), "it lists stream items"); + assert.dom(".user-stream-item").exists("lists stream items"); assert .dom(".nav-pills li a[title='Edit Group']") .doesNotExist("it should not show messages tab if user is not admin"); assert .dom(".nav-pills li a[title='Logs']") .doesNotExist("it should not show Logs tab if user is not admin"); - assert.ok(exists(".user-stream-item"), "it lists stream items"); + assert.dom(".user-stream-item").exists("lists stream items"); const groupDropdown = selectKit(".group-dropdown"); await groupDropdown.expand(); @@ -212,7 +211,7 @@ acceptance("Group - Authenticated", function (needs) { "it prefills the group name" ); - assert.ok(!exists(".add-warning"), "groups can't receive warnings"); + assert.dom(".add-warning").doesNotExist("groups can't receive warnings"); }); test("Admin viewing group messages when there are no messages", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/groups-index-test.js b/app/assets/javascripts/discourse/tests/acceptance/groups-index-test.js index f722aaba560..5a99396ce7d 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/groups-index-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/groups-index-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import { acceptance, count, - exists, invisible, } from "discourse/tests/helpers/qunit-helpers"; @@ -26,13 +25,13 @@ acceptance("Groups", function () { ); await click(".group-index-join"); - assert.ok(exists(".modal.login-modal"), "it shows the login modal"); + assert.dom(".modal.login-modal").exists("shows the login modal"); await click(".login-modal .modal-close"); assert.ok(invisible(".modal.login-modal"), "it closes the login modal"); await click(".group-index-request"); - assert.ok(exists(".modal.login-modal"), "it shows the login modal"); + assert.dom(".modal.login-modal").exists("shows the login modal"); await click("a[href='/g/discourse/members']"); assert @@ -40,6 +39,6 @@ acceptance("Groups", function () { .hasText("Awesome Team", "it displays the group page"); await click(".group-index-join"); - assert.ok(exists(".modal.login-modal"), "it shows the login modal"); + assert.dom(".modal.login-modal").exists("shows the login modal"); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/invite-show-user-fields-test.js b/app/assets/javascripts/discourse/tests/acceptance/invite-show-user-fields-test.js index 0591c4cafa3..6bfee1b2495 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/invite-show-user-fields-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/invite-show-user-fields-test.js @@ -1,7 +1,7 @@ import { click, fillIn, visit } from "@ember/test-helpers"; import { test } from "qunit"; import PreloadStore from "discourse/lib/preload-store"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Accept Invite - User Fields", function (needs) { needs.site({ @@ -42,8 +42,8 @@ acceptance("Accept Invite - User Fields", function (needs) { }); await visit("/invites/myvalidinvitetoken"); - assert.ok(exists(".invites-show"), "shows the accept invite page"); - assert.ok(exists(".user-field"), "it has at least one user field"); + assert.dom(".invites-show").exists("shows the accept invite page"); + assert.dom(".user-field").exists("has at least one user field"); assert .dom(".invites-show .btn-primary:disabled") .exists("submit is disabled"); @@ -52,7 +52,7 @@ acceptance("Accept Invite - User Fields", function (needs) { await fillIn("#new-account-username", "validname"); await fillIn("#new-account-password", "secur3ty4Y0uAndMe"); - assert.ok(exists(".username-input .good"), "username is valid"); + assert.dom(".username-input .good").exists("username is valid"); assert .dom(".invites-show .btn-primary:disabled") .exists("submit is still disabled due to lack of user fields"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js b/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js index 6d8e2358e29..d4824596205 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js @@ -1,11 +1,7 @@ import { click, currentURL, triggerKeyEvent, visit } from "@ember/test-helpers"; import { test } from "qunit"; import DiscoveryFixtures from "discourse/tests/fixtures/discovery-fixtures"; -import { - acceptance, - chromeTest, - exists, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, chromeTest } from "discourse/tests/helpers/qunit-helpers"; import { cloneJSON } from "discourse-common/lib/object"; import I18n from "discourse-i18n"; @@ -202,7 +198,7 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) { await visit("/"); document.getElementById("ember-testing-container").scrollTop = 0; await visit("/new"); - assert.ok(exists("#dismiss-new-top"), "dismiss new top button is present"); + assert.dom("#dismiss-new-top").exists("dismiss new top button is present"); await triggerKeyEvent(document, "keydown", "D", { shiftKey: true }); assert.strictEqual(resetNewCalled, 1); diff --git a/app/assets/javascripts/discourse/tests/acceptance/login-required-test.js b/app/assets/javascripts/discourse/tests/acceptance/login-required-test.js index 0653deb817b..4e51c65158e 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/login-required-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/login-required-test.js @@ -1,10 +1,6 @@ import { click, currentRouteName, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { - acceptance, - exists, - invisible, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Login Required", function (needs) { needs.settings({ login_required: true }); @@ -25,9 +21,9 @@ acceptance("Login Required", function (needs) { ); await click("header .login-button"); - assert.ok(exists(".login-modal"), "they can still access the login modal"); + assert.dom(".login-modal").exists("they can still access the login modal"); await click(".d-modal__header .modal-close"); - assert.ok(invisible(".login-modal"), "it closes the login modal"); + assert.dom(".login-modal").doesNotExist("closes the login modal"); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js b/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js index cb27967db7c..99f4795faa2 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js @@ -1,13 +1,13 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Topic Discovery - Mobile", function (needs) { needs.mobileView(); test("Visit Discovery Pages", async function (assert) { await visit("/"); - assert.ok(exists(".topic-list"), "The list of topics was rendered"); - assert.ok(exists(".topic-list .topic-list-item"), "has topics"); + assert.dom(".topic-list").exists("the list of topics is rendered"); + assert.dom(".topic-list .topic-list-item").exists("has topics"); assert .dom("a[data-user-card=codinghorror] img.avatar") @@ -18,6 +18,6 @@ acceptance("Topic Discovery - Mobile", function (needs) { ); await visit("/categories"); - assert.ok(exists(".category"), "has a list of categories"); + assert.dom(".category").exists("has a list of categories"); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/mobile-sign-in-test.js b/app/assets/javascripts/discourse/tests/acceptance/mobile-sign-in-test.js index 9de028296af..86652bf1de1 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/mobile-sign-in-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/mobile-sign-in-test.js @@ -1,6 +1,6 @@ import { click, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Signing In - Mobile", function (needs) { needs.mobileView(); @@ -8,6 +8,6 @@ acceptance("Signing In - Mobile", function (needs) { test("sign in", async function (assert) { await visit("/"); await click("header .login-button"); - assert.ok(exists("#login-form"), "it shows the login modal"); + assert.dom("#login-form").exists("shows the login modal"); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js b/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js index ea5ec1ebc10..d9e23522308 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js @@ -1,10 +1,6 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; acceptance("New Message - Anonymous", function () { @@ -13,7 +9,7 @@ acceptance("New Message - Anonymous", function () { "/new-message?username=charlie&title=message%20title&body=message%20body" ); - assert.ok(exists(".modal.login-modal"), "it shows the login modal"); + assert.dom(".modal.login-modal").exists("shows the login modal"); }); }); @@ -25,7 +21,7 @@ acceptance("New Message - Authenticated", function (needs) { "/new-message?username=charlie,john&title=message%20title&body=message%20body" ); - assert.ok(exists(".composer-fields"), "it opens composer"); + assert.dom(".composer-fields").exists("opens the composer"); assert.strictEqual( query("#reply-title").value.trim(), "message title", diff --git a/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js index 3d2be01a1fc..d606c9219fa 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js @@ -1,13 +1,13 @@ import { currentURL, visit, waitFor } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; acceptance("New Topic - Anonymous", function () { test("accessing new-topic route when logged out", async function (assert) { await visit("/new-topic?title=topic%20title&body=topic%20body"); - assert.ok(exists(".modal.login-modal"), "it shows the login modal"); + assert.dom(".modal.login-modal").exists("shows the login modal"); }); }); @@ -39,7 +39,7 @@ acceptance("New Topic - Authenticated", function (needs) { "/new-topic?title=topic%20title&body=topic%20body&category=bug" ); - assert.ok(exists(".composer-fields"), "it opens composer"); + assert.dom(".composer-fields").exists("opens composer"); assert .dom("#reply-title") diff --git a/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js b/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js index 57af8d9f29b..751f13190f6 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js @@ -4,11 +4,7 @@ import sinon from "sinon"; import PreloadStore from "discourse/lib/preload-store"; import DiscourseURL from "discourse/lib/url"; import { parsePostData } from "discourse/tests/helpers/create-pretender"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; acceptance("Password Reset", function (needs) { @@ -69,13 +65,13 @@ acceptance("Password Reset", function (needs) { PreloadStore.store("password_reset", { is_developer: false }); await visit("/u/password-reset/myvalidtoken"); - assert.ok(exists(".password-reset input"), "shows the input"); + assert.dom(".password-reset input").exists("shows the input"); await fillIn(".password-reset input", "perf3ctly5ecur3"); - assert.ok(exists(".password-reset .tip.good"), "input looks good"); + assert.dom(".password-reset .tip.good").exists("input looks good"); await fillIn(".password-reset input", "123"); - assert.ok(exists(".password-reset .tip.bad"), "input is not valid"); + assert.dom(".password-reset .tip.bad").exists("input is not valid"); assert.ok( query(".password-reset .tip.bad").innerHTML.includes( I18n.t("user.password.too_short", { @@ -87,7 +83,7 @@ acceptance("Password Reset", function (needs) { await fillIn(".password-reset input", "jonesyAlienSlayer"); await click(".password-reset form button[type='submit']"); - assert.ok(exists(".password-reset .tip.bad"), "input is not valid"); + assert.dom(".password-reset .tip.bad").exists("input is not valid"); assert.ok( query(".password-reset .tip.bad").innerHTML.includes( "Password is the name of your cat" @@ -117,13 +113,13 @@ acceptance("Password Reset", function (needs) { await visit("/u/password-reset/requiretwofactor"); - assert.notOk(exists("#new-account-password"), "does not show the input"); - assert.ok(exists("#second-factor"), "shows the second factor prompt"); + assert.dom("#new-account-password").doesNotExist("does not show the input"); + assert.dom("#second-factor").exists("shows the second factor prompt"); await fillIn("input#second-factor", "0000"); await click(".password-reset form button"); - assert.ok(exists(".alert-error"), "shows 2 factor error"); + assert.dom(".alert-error").exists("shows 2FA error"); assert.ok( query(".alert-error").innerHTML.includes("invalid token"), @@ -133,8 +129,8 @@ acceptance("Password Reset", function (needs) { await fillIn("input#second-factor", "123123"); await click(".password-reset form button"); - assert.notOk(exists(".alert-error"), "hides error"); - assert.ok(exists("#new-account-password"), "shows the input"); + assert.dom(".alert-error").doesNotExist("hides error"); + assert.dom("#new-account-password").exists("shows the input"); await fillIn(".password-reset input", "perf3ctly5ecur3"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/post-admin-menu-test.js b/app/assets/javascripts/discourse/tests/acceptance/post-admin-menu-test.js index 2b9d1174ff4..a20224798ed 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/post-admin-menu-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/post-admin-menu-test.js @@ -1,19 +1,19 @@ import { click, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Post - Admin Menu - Anonymous", function () { test("Enter as a anon user", async function (assert) { await visit("/t/internationalization-localization/280"); await click(".show-more-actions"); - assert.ok(exists("#topic"), "The topic was rendered"); + assert.dom("#topic").exists("the topic is rendered"); assert .dom("#post_1 .post-controls .edit") - .exists("The edit button was not rendered"); + .exists("the edit button is not rendered"); assert .dom(".show-post-admin-menu") - .doesNotExist("The wrench button was not rendered"); + .doesNotExist("the wrench button is not rendered"); }); }); @@ -26,7 +26,7 @@ acceptance("Post - Admin Menu - Authenticated", function (needs) { assert .dom("#post_1 .post-controls .edit") - .exists("The edit button was rendered"); - assert.ok(exists(".add-notice"), "The add notice button was rendered"); + .exists("the edit button is rendered"); + assert.dom(".add-notice").exists("the add notice button is rendered"); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/post-table-wrapper-test.js b/app/assets/javascripts/discourse/tests/acceptance/post-table-wrapper-test.js index 039841ef63e..f38ba9b786c 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/post-table-wrapper-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/post-table-wrapper-test.js @@ -1,10 +1,6 @@ import { click, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; acceptance("Post Table Wrapper Test", function () { test("fullscreen table wrapper appears on post with large table", async function (assert) { @@ -14,12 +10,11 @@ acceptance("Post Table Wrapper Test", function () { .dom(`${postWithLargeTable} .fullscreen-table-wrapper`) .exists("The wrapper is present on the post with the large table"); - assert.ok( - exists( + assert + .dom( `${postWithLargeTable} .fullscreen-table-wrapper .fullscreen-table-wrapper__buttons .open-popup-link` - ), - "buttons for the table wrapper appear inside a separate div" - ); + ) + .exists("buttons for the table wrapper appear inside a separate div"); const fullscreenButtonWrapper = query( `${postWithLargeTable} .fullscreen-table-wrapper .fullscreen-table-wrapper__buttons` diff --git a/app/assets/javascripts/discourse/tests/acceptance/review-test.js b/app/assets/javascripts/discourse/tests/acceptance/review-test.js index d78739c608b..02a9af40bf4 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/review-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/review-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import { acceptance, count, - exists, loggedInUser, publishToMessageBus, query, @@ -35,8 +34,8 @@ acceptance("Review", function (needs) { test("It returns a list of reviewable items", async function (assert) { await visit("/review"); - assert.ok(exists(".reviewable-item"), "has a list of items"); - assert.ok(exists(user)); + assert.dom(".reviewable-item").exists("has a list of items"); + assert.dom(user).exists(); assert .dom(`${user}.reviewable-user`) .exists("applies a class for the type"); @@ -88,7 +87,7 @@ acceptance("Review", function (needs) { test("Settings", async function (assert) { await visit("/review/settings"); - assert.ok(exists(".reviewable-score-type"), "has a list of bonuses"); + assert.dom(".reviewable-score-type").exists("has a list of bonuses"); const field = selectKit( ".reviewable-score-type:nth-of-type(1) .field .combo-box" @@ -97,7 +96,7 @@ acceptance("Review", function (needs) { await field.selectRowByValue("5"); await click(".save-settings"); - assert.ok(exists(".reviewable-settings .saved"), "it saved"); + assert.dom(".reviewable-settings .saved").exists("it saved"); }); test("Flag related", async function (assert) { @@ -118,13 +117,13 @@ acceptance("Review", function (needs) { test("Flag related", async function (assert) { await visit("/review/1"); - assert.ok(exists(".reviewable-flagged-post"), "it shows the flagged post"); + assert.dom(".reviewable-flagged-post").exists("shows the flagged post"); }); test("Clicking the buttons triggers actions", async function (assert) { await visit("/review"); await click(`${user} .reviewable-action.approve`); - assert.ok(!exists(user), "it removes the reviewable on success"); + assert.dom(user).doesNotExist("removes the reviewable on success"); }); test("Editing a reviewable", async function (assert) { @@ -132,8 +131,8 @@ acceptance("Review", function (needs) { await visit("/review"); - assert.ok(exists(`${topic} .reviewable-action.approve`)); - assert.ok(!exists(`${topic} .badge-category__name`)); + assert.dom(`${topic} .reviewable-action.approve`).exists(); + assert.dom(`${topic} .badge-category__name`).doesNotExist(); assert.strictEqual( query(`${topic} .discourse-tag:nth-of-type(1)`).innerText, diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js index 801c77ada6e..d379803269d 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import { acceptance, count, - exists, query, } from "discourse/tests/helpers/qunit-helpers"; @@ -19,7 +18,9 @@ acceptance("Search - Mobile", function (needs) { .dom("input.full-page-search") .exists("it shows the full page search form"); - assert.ok(!exists(".search-results .fps-topic"), "no results by default"); + assert + .dom(".search-results .fps-topic") + .doesNotExist("no results by default"); await click(".advanced-filters summary"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-test.js index 336c0e4d0ac..e33101aac17 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/search-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/search-test.js @@ -13,7 +13,6 @@ import searchFixtures from "discourse/tests/fixtures/search-fixtures"; import { acceptance, count, - exists, query, queryAll, } from "discourse/tests/helpers/qunit-helpers"; @@ -62,7 +61,7 @@ acceptance("Search - Anonymous", function (needs) { await visit("/"); await click("#search-button"); - assert.ok(exists("#search-term"), "it shows the search input"); + assert.dom("#search-term").exists("shows the search input"); assert .dom(".show-advanced-search") .exists("it shows full page search button"); @@ -400,12 +399,11 @@ acceptance("Search - Anonymous", function (needs) { await fillIn("#search-term", "dev"); await triggerKeyEvent("#search-term", "keyup", "Enter"); - assert.ok( - exists( + assert + .dom( ".search-menu .search-result-topic .item .topic-title span#topic-with-html" - ), - "html in the topic title is properly escaped" - ); + ) + .exists("html in the topic title is properly escaped"); }); test("topic results - search result escapes emojis in topic title", async function (assert) { @@ -414,12 +412,9 @@ acceptance("Search - Anonymous", function (needs) { await fillIn("#search-term", "dev"); await triggerKeyEvent("#search-term", "keyup", "Enter"); - assert.ok( - exists( - ".search-menu .search-result-topic .item .topic-title img[alt='+1']" - ), - ":+1: in the topic title is properly converted to an emoji" - ); + assert + .dom(".search-menu .search-result-topic .item .topic-title img[alt='+1']") + .exists(":+1: in the topic title is properly converted to an emoji"); }); }); @@ -567,7 +562,7 @@ acceptance("Search - Authenticated", function (needs) { await visit("/"); await click("#search-button"); await fillIn("#search-term", "dev"); - assert.ok(exists(query(`${container} ul li`)), "has a list of items"); + assert.dom(`${container} ul li`).exists("has a list of items"); await triggerKeyEvent("#search-term", "keyup", "Enter"); assert @@ -603,7 +598,7 @@ acceptance("Search - Authenticated", function (needs) { query("#search-button"), "Escaping search returns focus to search button" ); - assert.ok(!exists(".search-menu:visible"), "Esc removes search dropdown"); + assert.dom(".search-menu").doesNotExist("Esc removes search dropdown"); await click("#search-button"); await triggerKeyEvent(document.activeElement, "keyup", "ArrowDown"); @@ -627,12 +622,12 @@ acceptance("Search - Authenticated", function (needs) { .dom(query(`.search-menu`)) .doesNotExist("search dropdown is collapsed after second Enter hit"); - //new search launched, Enter key should be reset + // new search launched, Enter key should be reset await click("#search-button"); - assert.ok(exists(query(`${container} ul li`)), "has a list of items"); + assert.dom(`${container} ul li`).exists("has a list of items"); await triggerKeyEvent("#search-term", "keyup", "Enter"); - assert.ok(exists(query(`.search-menu`)), "search dropdown is visible"); + assert.dom(`.search-menu`).exists("search dropdown is visible"); }); test("search menu keyboard navigation - while composer is open", async function (assert) { @@ -845,7 +840,7 @@ acceptance("Search - with tagging enabled", function (needs) { const firstItem = ".search-menu .results ul.search-menu-assistant .search-link"; - assert.ok(exists(query(firstItem))); + assert.dom(firstItem).exists(); const firstTag = query(`${firstItem} .search-item-tag`).textContent.trim(); assert.strictEqual(firstTag, "monkey"); @@ -1219,13 +1214,13 @@ acceptance("Search - assistant", function (needs) { await visit("/u/charlie/messages"); await click("#search-button"); - assert.ok(exists(".btn.search-context"), "it shows the button"); + assert.dom(".btn.search-context").exists("shows the button"); await fillIn("#search-term", ""); await query("input#search-term").focus(); await triggerKeyEvent("input#search-term", "keyup", "Backspace"); - assert.notOk(exists(".btn.search-context"), "it removes the button"); + assert.dom(".btn.search-context").doesNotExist("removes the button"); await clickOutside(); await click("#search-button"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/second-factor-auth-test.js b/app/assets/javascripts/discourse/tests/acceptance/second-factor-auth-test.js index 31c69684cf2..628214824fb 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/second-factor-auth-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/second-factor-auth-test.js @@ -1,11 +1,7 @@ import { click, currentURL, fillIn, visit } from "@ember/test-helpers"; import { test } from "qunit"; import { SECOND_FACTOR_METHODS } from "discourse/models/user"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; const { TOTP, BACKUP_CODE, SECURITY_KEY } = SECOND_FACTOR_METHODS; @@ -202,7 +198,7 @@ acceptance("Second Factor Auth Page", function (needs) { ); await click(".toggle-second-factor-method.totp"); - assert.ok(exists("form.totp-token"), "TOTP form is now shown"); + assert.dom("form.totp-token").exists("TOTP form is now shown"); assert .dom(".toggle-second-factor-method.security-key") .exists("security key is now shown as alternative method"); @@ -280,6 +276,6 @@ acceptance("Second Factor Auth Page", function (needs) { await visit("/session/2fa?nonce=ok110111"); - assert.notOk(exists(".sidebar-container"), "does not display the sidebar"); + assert.dom(".sidebar-container").doesNotExist(); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/select-kit-accessibility-test.js b/app/assets/javascripts/discourse/tests/acceptance/select-kit-accessibility-test.js index d4cd9f530d7..bae851485f5 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/select-kit-accessibility-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/select-kit-accessibility-test.js @@ -1,6 +1,6 @@ import { click, tab, triggerKeyEvent, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; acceptance("Select-kit - Composer - Accessibility", function (needs) { @@ -61,6 +61,6 @@ acceptance("Select-kit - Composer - Accessibility", function (needs) { .dom(".mini-tag-chooser .select-kit-body .select-kit-row") .doesNotExist("Hitting Escape dismisses the tag chooser"); - assert.ok(exists(".composer-fields"), "Escape does not dismiss composer"); + assert.dom(".composer-fields").exists("Escape does not dismiss composer"); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js index 1f426dfc0f9..655bc186411 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js @@ -1,11 +1,7 @@ import { click, currentURL, visit } from "@ember/test-helpers"; import { test } from "qunit"; import CategoryFixtures from "discourse/tests/fixtures/category-fixtures"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import I18n from "discourse-i18n"; @@ -35,7 +31,7 @@ acceptance("Share and Invite modal", function (needs) { await click("#topic-footer-button-share-and-invite"); - assert.ok(exists(".share-topic-modal"), "it shows the modal"); + assert.dom(".share-topic-modal").exists("shows the modal"); assert .dom("#modal-alert.alert-warning") @@ -66,7 +62,7 @@ acceptance("Share and Invite modal", function (needs) { ); await click("#post_2 a.post-date"); - assert.ok(exists(".share-topic-modal"), "it shows the share modal"); + assert.dom(".share-topic-modal").exists("shows the share modal"); assert.strictEqual( currentURL(), "/t/short-topic-with-two-posts/54077", @@ -83,7 +79,7 @@ acceptance("Share and Invite modal", function (needs) { await click("#topic-footer-button-share-and-invite"); - assert.ok(exists(".share-topic-modal"), "it shows the modal"); + assert.dom(".share-topic-modal").exists("shows the modal"); assert .dom("#modal-alert.alert-warning") .exists("it shows restricted warning"); @@ -112,7 +108,7 @@ acceptance("Share and Invite modal - mobile", function (needs) { await subject.expand(); await subject.selectRowByValue("share-and-invite"); - assert.ok(exists(".share-topic-modal"), "it shows the modal"); + assert.dom(".share-topic-modal").exists("shows the modal"); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-anonymous-categories-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-anonymous-categories-section-test.js index a907aacaf17..64fded4397d 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-anonymous-categories-section-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-anonymous-categories-section-test.js @@ -1,11 +1,7 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; import Site from "discourse/models/site"; -import { - acceptance, - exists, - queryAll, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers"; acceptance("Sidebar - Anonymous - Categories Section", function (needs) { needs.settings({ @@ -133,11 +129,12 @@ acceptance("Sidebar - Anonymous - Categories Section", function (needs) { await visit("/"); - assert.notOk( - exists( + assert + .dom( `.sidebar-section[data-section-name='categories'] .sidebar-section-link[data-link-name='${firstCategory.slug}']` - ), - "category section link is not shown in sidebar after being marked as uncategorized" - ); + ) + .doesNotExist( + "category section link is not shown in sidebar after being marked as uncategorized" + ); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-anonymous-community-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-anonymous-community-section-test.js index 551df1f908d..646fec455bf 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-anonymous-community-section-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-anonymous-community-section-test.js @@ -1,10 +1,6 @@ import { click, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { - acceptance, - exists, - queryAll, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; acceptance("Sidebar - Anonymous user - Community Section", function (needs) { @@ -34,12 +30,11 @@ acceptance("Sidebar - Anonymous user - Community Section", function (needs) { await visit("/"); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='users']" - ), - "users section link is not shown in sidebar" - ); + ) + .doesNotExist("users section link is not shown in sidebar"); }); test("users, about, faq, groups and badges section links are shown in more...", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-narrow-desktop-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-narrow-desktop-test.js index 183f3cb9de2..3a6d7d77e18 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-narrow-desktop-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-narrow-desktop-test.js @@ -1,7 +1,6 @@ import { click, triggerEvent, visit, waitFor } from "@ember/test-helpers"; -import $ from "jquery"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Sidebar - Narrow Desktop", function (needs) { needs.user(); @@ -16,15 +15,15 @@ acceptance("Sidebar - Narrow Desktop", function (needs) { test("wide sidebar is changed to cloak when resize to narrow screen", async function (assert) { await visit("/"); - assert.ok(exists("#d-sidebar"), "wide sidebar is displayed"); + assert.dom("#d-sidebar").exists("wide sidebar is displayed"); await click(".header-sidebar-toggle .btn"); - assert.ok(!exists("#d-sidebar"), "wide sidebar is collapsed"); + assert.dom("#d-sidebar").doesNotExist("wide sidebar is collapsed"); await click(".header-sidebar-toggle .btn"); - assert.ok(exists("#d-sidebar"), "wide sidebar is displayed"); + assert.dom("#d-sidebar").exists("wide sidebar is displayed"); document.body.style.width = "767px"; @@ -47,7 +46,7 @@ acceptance("Sidebar - Narrow Desktop", function (needs) { await waitFor("#d-sidebar", { timeout: 5000, }); - assert.ok(exists("#d-sidebar"), "wide sidebar is displayed"); + assert.dom("#d-sidebar").exists("wide sidebar is displayed"); }); test("transition from narrow screen to wide screen", async function (assert) { @@ -66,7 +65,6 @@ acceptance("Sidebar - Narrow Desktop", function (needs) { }); await click(".header-dropdown-toggle.current-user button"); - $(".header-dropdown-toggle.current-user").click(); assert.dom(".quick-access-panel").exists(); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-categories-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-categories-section-test.js index 58e357d6b98..7eaa246351a 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-categories-section-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-categories-section-test.js @@ -8,7 +8,6 @@ import discoveryFixture from "discourse/tests/fixtures/discovery-fixtures"; import { acceptance, count, - exists, publishToMessageBus, query, queryAll, @@ -49,12 +48,11 @@ acceptance( "there should only be one section link under the section" ); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"]` - ), - `only the ${category1.slug} section link is shown` - ); + ) + .exists(`only the ${category1.slug} section link is shown`); }); } ); @@ -124,12 +122,11 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { ".sidebar-section[data-section-name='categories'] .sidebar-section-header" ); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='categories'] .sidebar-section-content" - ), - "hides the content of the section" - ); + ) + .doesNotExist("hides the content of the section"); }); test("clicking on section header button", async function (assert) { @@ -171,12 +168,9 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { ); topCategories.forEach((category) => { - assert.ok( - exists( - `.sidebar-section-link-wrapper[data-category-id=${category.id}]` - ), - `${category.displayName} section link is shown` - ); + assert + .dom(`.sidebar-section-link-wrapper[data-category-id="${category.id}"]`) + .exists(`${category.displayName} section link is shown`); }); }); @@ -191,12 +185,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { await visit("/"); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${uncategorizedCategory.id}"]` - ), - `displays the section link for ${uncategorizedCategory.slug} category` - ); + ) + .exists( + `displays the section link for ${uncategorizedCategory.slug} category` + ); }); test("category section links are ordered by category name with child category sorted after parent when site setting to fix category's position is disabled", async function (assert) { @@ -429,12 +424,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { "there should only be 4 section link under the section" ); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] .sidebar-section-link-prefix .prefix-span[style="background: linear-gradient(90deg, #${category1.color} 50%, #${category1.color} 50%)"]` - ), - "category1 section link is rendered with solid prefix icon color" - ); + ) + .exists( + "category1 section link is rendered with solid prefix icon color" + ); assert.strictEqual( query( @@ -462,12 +458,11 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` - ), - "the category1 section link is marked as active" - ); + ) + .exists("the category1 section link is marked as active"); await click( `.sidebar-section-link-wrapper[data-category-id="${category2.id}"] a` @@ -487,26 +482,25 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category2.id}"] a.active` - ), - "the category2 section link is marked as active" - ); + ) + .exists("the category2 section link is marked as active"); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category3.id}"] .sidebar-section-link-prefix .prefix-badge.d-icon-lock` - ), - "category3 section link is rendered with lock prefix badge icon as it is read restricted" - ); + ) + .exists( + "category3 section link is rendered with lock prefix badge icon as it is read restricted" + ); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category4.id}"] .sidebar-section-link-prefix .prefix-span[style="background: linear-gradient(90deg, #${category4.parentCategory.color} 50%, #${category4.color} 50%)"]` - ), - "sub category section link is rendered with double prefix color" - ); + ) + .exists("sub category section link is rendered with double prefix color"); }); test("clicking section links - sidebar_link_to_filtered_list set to true and no unread or new topics", async function (assert) { @@ -537,12 +531,11 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` - ), - "the category1 section link is marked as active" - ); + ) + .exists("the category1 section link is marked as active"); }); test("clicking section links - sidebar_link_to_filtered_list set to true with new topics", async function (assert) { @@ -583,12 +576,11 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` - ), - "the category1 section link is marked as active" - ); + ) + .exists("the category1 section link is marked as active"); }); test("clicking section links - sidebar_link_to_filtered_list set to true with new and unread topics", async function (assert) { @@ -637,12 +629,11 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` - ), - "the category1 section link is marked as active" - ); + ) + .exists("the category1 section link is marked as active"); }); test("category section link for category with 3-digit hex code for color", async function (assert) { @@ -651,12 +642,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { await visit("/"); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] .sidebar-section-link-prefix .prefix-span[style="background: linear-gradient(90deg, #888 50%, #888 50%)"]` - ), - "category1 section link is rendered with the right solid prefix icon color" - ); + ) + .exists( + "category1 section link is rendered with the right solid prefix icon color" + ); }); test("category section link have the right title", async function (assert) { @@ -693,12 +685,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` - ), - "the category1 section link is marked as active for the new route" - ); + ) + .exists( + "the category1 section link is marked as active for the new route" + ); }); test("visiting category discovery unread route", async function (assert) { @@ -714,12 +707,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` - ), - "the category1 section link is marked as active for the unread route" - ); + ) + .exists( + "the category1 section link is marked as active for the unread route" + ); }); test("visiting category discovery top route", async function (assert) { @@ -735,12 +729,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` - ), - "the category1 section link is marked as active for the top route" - ); + ) + .exists( + "the category1 section link is marked as active for the top route" + ); }); test("visiting category discovery no subcategories route", async function (assert) { @@ -756,12 +751,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` - ), - "the category1 section link is marked as active for the none route" - ); + ) + .exists( + "the category1 section link is marked as active for the none route" + ); }); test("visiting category discovery includes all subcategories route", async function (assert) { @@ -777,12 +773,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` - ), - "the category1 section link is marked as active for the all route" - ); + ) + .exists( + "the category1 section link is marked as active for the all route" + ); }); test("show suffix indicator for unread and new content on categories link", async function (assert) { @@ -819,12 +816,11 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { await visit("/"); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] .sidebar-section-link-suffix` - ), - "shows suffix indicator for unread content on categories link" - ); + ) + .exists("shows suffix indicator for unread content on categories link"); await publishToMessageBus("/unread", { topic_id: 2, @@ -835,12 +831,11 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { }, }); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] .sidebar-section-link-suffix` - ), - "shows suffix indicator for new topics on categories link" - ); + ) + .exists("shows suffix indicator for new topics on categories link"); await publishToMessageBus("/unread", { topic_id: 1, @@ -851,12 +846,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { }, }); - assert.ok( - !exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] .sidebar-section-link-suffix` - ), - "hides suffix indicator when there's no new/unread content on category link" - ); + ) + .doesNotExist( + "hides suffix indicator when there's no new/unread content on category link" + ); }); test("new and unread count for categories link", async function (assert) { @@ -955,12 +951,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { }, }); - assert.ok( - !exists( + assert + .dom( `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] .sidebar-section-link-content-badge` - ), - `does not display any badge ${category1.slug} section link` - ); + ) + .doesNotExist( + `does not display any badge ${category1.slug} section link` + ); await publishToMessageBus("/unread", { topic_id: 3, @@ -1006,12 +1003,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { await visit("/"); - assert.ok( - exists( + assert + .dom( ".sidebar-section-link[data-link-name='configure-default-navigation-menu-categories']" - ), - "section link to configure default navigation menu categories is shown" - ); + ) + .exists( + "section link to configure default navigation menu categories is shown" + ); await click( ".sidebar-section-link[data-link-name='configure-default-navigation-menu-categories']" diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js index 74bbfc53ccd..a20c19c87e4 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js @@ -11,7 +11,6 @@ import topicFixtures from "discourse/tests/fixtures/discovery-fixtures"; import { acceptance, count, - exists, loggedInUser, publishToMessageBus, query, @@ -53,30 +52,29 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-content" - ), - "additional section links are displayed" - ); + ) + .exists("additional section links are displayed"); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary[aria-expanded='true']" - ), - "aria-expanded toggles to true when additional links are displayed" - ); + ) + .exists( + "aria-expanded toggles to true when additional links are displayed" + ); await click( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-content" - ), - "additional section links are hidden" - ); + ) + .doesNotExist("additional section links are hidden"); await click( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" @@ -84,19 +82,21 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { await click("#main-outlet"); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-content" - ), - "additional section links are hidden when clicking outside" - ); + ) + .doesNotExist( + "additional section links are hidden when clicking outside" + ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary[aria-expanded='false']" - ), - "aria-expanded toggles to false when additional links are hidden" - ); + ) + .exists( + "aria-expanded toggles to false when additional links are hidden" + ); }); test("clicking on everything link", async function (assert) { @@ -108,7 +108,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { assert.strictEqual( currentURL(), "/latest", - "it should transition to the latest page" + "should transition to the latest page" ); assert.strictEqual( @@ -119,12 +119,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" - ), - "the everything link is marked as active" - ); + ) + .exists("the everything link is marked as active"); }); test("clicking on everything link - sidebar_link_to_filtered_list set to true and no unread or new topics", async function (assert) { @@ -141,7 +140,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { assert.strictEqual( currentURL(), "/latest", - "it should transition to the latest page" + "should transition to the latest page" ); assert.strictEqual( @@ -152,12 +151,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" - ), - "the everything link is marked as active" - ); + ) + .exists("the everything link is marked as active"); }); test("clicking on everything link - sidebar_link_to_filtered_list set to true with new topics", async function (assert) { @@ -184,7 +182,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { assert.strictEqual( currentURL(), "/new", - "it should transition to the new page" + "should transition to the new page" ); assert.strictEqual( @@ -195,12 +193,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" - ), - "the everything link is marked as active" - ); + ) + .exists("the everything link is marked as active"); }); test("clicking on everything link - sidebar_link_to_filtered_list set to true with new and unread topics", async function (assert) { @@ -235,7 +232,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { assert.strictEqual( currentURL(), "/unread", - "it should transition to the unread page" + "should transition to the unread page" ); assert.strictEqual( @@ -246,23 +243,23 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" - ), - "the everything link is marked as active" - ); + ) + .exists("the everything link is marked as active"); }); test("clicking on users link", async function (assert) { await visit("/t/280"); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='users']" - ), - "users link is not displayed in sidebar when it is not the active route" - ); + ) + .doesNotExist( + "users link is not displayed in sidebar when it is not the active route" + ); await click( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" @@ -275,7 +272,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { assert.strictEqual( currentURL(), "/u?order=likes_received", - "it should transition to the users url" + "should transition to the users url" ); assert.strictEqual( @@ -286,12 +283,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='users'].active" - ), - "the users link is marked as active" - ); + ) + .exists("the users link is marked as active"); assert.strictEqual( query( @@ -303,12 +299,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { await visit("/u"); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='users'].active" - ), - "users link is displayed in sidebar when it is the active route" - ); + ) + .exists("users link is displayed in sidebar when it is the active route"); }); test("users section link is not shown when enable_user_directory site setting is disabled", async function (assert) { @@ -320,12 +315,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='users']" - ), - "users section link is not displayed in sidebar" - ); + ) + .doesNotExist("users section link is not displayed in sidebar"); }); test("clicking on badges link", async function (assert) { @@ -342,7 +336,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { assert.strictEqual( currentURL(), "/badges", - "it should transition to the badges url" + "should transition to the badges url" ); }); @@ -355,23 +349,23 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='badges']" - ), - "badges section link is not shown in sidebar" - ); + ) + .doesNotExist("badges section link is not shown in sidebar"); }); test("clicking on groups link", async function (assert) { await visit("/t/280"); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='groups']" - ), - "groups link is not displayed in sidebar when it is not the active route" - ); + ) + .doesNotExist( + "groups link is not displayed in sidebar when it is not the active route" + ); await click( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" @@ -384,7 +378,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { assert.strictEqual( currentURL(), "/g", - "it should transition to the groups url" + "should transition to the groups url" ); assert.strictEqual( @@ -395,12 +389,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='groups'].active" - ), - "the groups link is marked as active" - ); + ) + .exists("the groups link is marked as active"); assert.strictEqual( query( @@ -412,12 +405,13 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { await visit("/g"); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='groups'].active" - ), - "groups link is displayed in sidebar when it is the active route" - ); + ) + .exists( + "groups link is displayed in sidebar when it is the active route" + ); }); test("groups section link is not shown when enable_group_directory site setting has been disabled", async function (assert) { @@ -429,12 +423,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='groups']" - ), - "groups section link is not shown in sidebar" - ); + ) + .doesNotExist("groups section link is not shown in sidebar"); }); test("navigating to about from sidebar", async function (assert) { @@ -454,12 +447,13 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "navigates to about route correctly" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='about'].active" - ), - "about section link link is displayed in the main section and marked as active" - ); + ) + .exists( + "about section link link is displayed in the main section and marked as active" + ); }); test("navigating to FAQ from sidebar", async function (assert) { @@ -512,11 +506,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { await visit("/"); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='admin']" ) - ); + .doesNotExist(); }); test("clicking on my posts link", async function (assert) { @@ -528,7 +522,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { assert.strictEqual( currentURL(), `/u/${loggedInUser().username}/activity`, - "it should transition to the user's activity url" + "should transition to the user's activity url" ); assert.strictEqual( @@ -539,21 +533,21 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='my-posts'].active" - ), - "the my posts link is marked as active" - ); + ) + .exists("the my posts link is marked as active"); await visit(`/u/${loggedInUser().username}/activity/drafts`); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='my-posts'].active" - ), - "the my posts link is not marked as active when user has no drafts and visiting the user activity drafts URL" - ); + ) + .doesNotExist( + "the my posts link is not marked as active when user has no drafts and visiting the user activity drafts URL" + ); }); test("clicking on my posts link when user has a draft", async function (assert) { @@ -570,7 +564,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { assert.strictEqual( currentURL(), `/u/${loggedInUser().username}/activity/drafts`, - "it transitions to the user's activity drafts url" + "transitions to the user's activity drafts url" ); assert.strictEqual( @@ -581,21 +575,19 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='my-posts'].active" - ), - "the my posts link is marked as active" - ); + ) + .exists("the my posts link is marked as active"); await visit(`/u/${loggedInUser().username}/activity`); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='my-posts'].active" - ), - "the my posts link is marked as active" - ); + ) + .exists("the my posts link is marked as active"); }); test("my posts title changes when drafts are present", async function (assert) { @@ -690,12 +682,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" - ), - "the everything link is marked as active" - ); + ) + .exists("the everything link is marked as active"); }); test("visiting unread route", async function (assert) { @@ -709,12 +700,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" - ), - "the everything link is marked as active" - ); + ) + .exists("the everything link is marked as active"); }); test("visiting new route", async function (assert) { @@ -728,12 +718,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "only one link is marked as active" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" - ), - "the everything link is marked as active" - ); + ) + .exists("the everything link is marked as active"); }); test("show suffix indicator for unread and new content on everything link", async function (assert) { @@ -768,12 +757,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { await visit("/"); - assert.ok( - exists( + assert + .dom( ".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-suffix" - ), - "shows suffix indicator for unread posts on everything link" - ); + ) + .exists("shows suffix indicator for unread posts on everything link"); const topicTrackingState = this.container.lookup( "service:topic-tracking-state" @@ -794,17 +782,16 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { }, }); - assert.ok( - exists( + assert + .dom( ".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-suffix" - ), - "shows suffix indicator for new topics on categories link" - ); + ) + .exists("shows suffix indicator for new topics on categories link"); assert.strictEqual( Object.keys(topicTrackingState.stateChangeCallbacks).length, initialCallbackCount, - "it does not add a new topic tracking state callback when the topic is read" + "does not add a new topic tracking state callback when the topic is read" ); // simulate reading topic 1 @@ -818,12 +805,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { }, }); - assert.ok( - !exists( + assert + .dom( ".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-suffix" - ), - "it removes the suffix indicator when all topics are read" - ); + ) + .doesNotExist("removes the suffix indicator when all topics are read"); }); test("new and unread count for everything link", async function (assert) { @@ -883,7 +869,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { ".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-content-badge" ).textContent.trim(), "3 unread", - "it displays the right unread count" + "displays the right unread count" ); // simulate reading topic 2 @@ -902,7 +888,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { ".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-content-badge" ).textContent.trim(), "2 unread", - "it updates the unread count" + "updates the unread count" ); // simulate reading topic 3 @@ -932,7 +918,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { ".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-content-badge" ).textContent.trim(), "1 new", - "it displays the new count once there are no unread topics" + "displays the new count once there are no unread topics" ); await publishToMessageBus("/unread", { @@ -945,12 +931,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { }, }); - assert.ok( - !exists( + assert + .dom( ".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-content-badge" - ), - "it removes new count once there are no new topics" - ); + ) + .doesNotExist("removes new count once there are no new topics"); }); test("review link is not shown when user cannot review", async function (assert) { @@ -958,23 +943,21 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { await visit("/"); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='review']" - ), - "review link is not shown" - ); + ) + .doesNotExist("review link is not shown"); await click( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='review']" - ), - "review link is not shown" - ); + ) + .doesNotExist("review link is not shown"); }); test("review link when user can review", async function (assert) { @@ -985,43 +968,43 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { await visit("/review"); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='review'].active" - ), - "review link is shown as active when visiting the review route even if there are no pending reviewables" - ); + ) + .exists( + "review link is shown as active when visiting the review route even if there are no pending reviewables" + ); await visit("/"); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='review']" - ), - "review link is not shown as part of the main section links" - ); + ) + .doesNotExist( + "review link is not shown as part of the main section links" + ); await click( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-content .sidebar-section-link[data-link-name='review']" - ), - "review link is displayed in the more drawer" - ); + ) + .exists("review link is displayed in the more drawer"); await publishToMessageBus(`/reviewable_counts/${loggedInUser().id}`, { reviewable_count: 34, }); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='review']" - ), - "review link is shown as part of the main section links" - ); + ) + .exists("review link is shown as part of the main section links"); assert.strictEqual( query( @@ -1035,12 +1018,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ); - assert.notOk( - exists( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-content .sidebar-section-link[data-link-name='review']" - ), - "review link is not displayed in the more drawer" - ); + ) + .doesNotExist("review link is not displayed in the more drawer"); }); test("adding section link via plugin API with Object", async function (assert) { @@ -1074,12 +1056,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "displays the right title for the link" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section-link[data-link-name='unread'] .sidebar-section-link-prefix.icon .d-icon-wrench" - ), - "displays the wrench icon for the link" - ); + ) + .exists("displays the wrench icon for the link"); await click(".sidebar-section-link[data-link-name='unread']"); @@ -1147,12 +1128,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "displays the right title for the link" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section-link[data-link-name='user-summary'] .sidebar-section-link-prefix.icon .d-icon-link" - ), - "displays the link icon for the link" - ); + ) + .exists("displays the link icon for the link"); await click(".btn-sidebar-toggle"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-messages-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-messages-section-test.js index e8c1fea1836..33297cc4eca 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-messages-section-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-messages-section-test.js @@ -4,7 +4,6 @@ import { NotificationLevels } from "discourse/lib/notification-levels"; import { acceptance, count, - exists, publishToMessageBus, query, queryAll, @@ -28,10 +27,9 @@ acceptance( test("clicking on section header button", async function (assert) { await visit("/"); - assert.ok( - !exists(".sidebar-section[data-section-name='messages']"), - "does not display messages section in sidebar" - ); + assert + .dom(".sidebar-section[data-section-name='messages']") + .doesNotExist("does not display messages section in sidebar"); }); } ); @@ -78,10 +76,7 @@ acceptance( ".sidebar-section[data-section-name='messages'] .sidebar-section-header-button" ); - assert.ok( - exists("#reply-control.private-message"), - "it opens the composer" - ); + assert.dom("#reply-control.private-message").exists("opens the composer"); }); test("clicking on section header link", async function (assert) { @@ -100,12 +95,11 @@ acceptance( test("personal messages section links", async function (assert) { await visit("/"); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='personal-messages-inbox']" - ), - "displays the personal message inbox link" - ); + ) + .exists("displays the personal message inbox link"); assert.strictEqual( count( @@ -119,12 +113,11 @@ acceptance( ".sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='personal-messages-inbox']" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='personal-messages-inbox'].active" - ), - "personal message inbox link is marked as active" - ); + ) + .exists("personal message inbox link is marked as active"); assert.strictEqual( count( @@ -161,19 +154,17 @@ acceptance( "only two links are marked as active in the sidebar" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='personal-messages-inbox'].active" - ), - "personal message inbox link is marked as active" - ); + ) + .exists("personal message inbox link is marked as active"); - assert.ok( - exists( + assert + .dom( `.sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='personal-messages-${type}'].active` - ), - `personal message ${type} link is marked as active` - ); + ) + .exists(`personal message ${type} link is marked as active`); assert .dom( @@ -299,19 +290,17 @@ acceptance( "only two links are marked as active in the sidebar" ); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='group-messages-inbox'].group1.active" - ), - "group1 group message inbox link is marked as active" - ); + ) + .exists("group1 group message inbox link is marked as active"); - assert.ok( - exists( + assert + .dom( `.sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='group-messages-${type}'].group1.active` - ), - `group1 group message ${type} link is marked as active` - ); + ) + .exists(`group1 group message ${type} link is marked as active`); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-tags-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-tags-section-test.js index 9f3b5637faa..462bd8d41c3 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-tags-section-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-tags-section-test.js @@ -5,7 +5,6 @@ import discoveryFixture from "discourse/tests/fixtures/discovery-fixtures"; import { acceptance, count, - exists, publishToMessageBus, query, updateCurrentUser, @@ -377,26 +376,25 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) { await visit("/"); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-tag-name=tag1] .sidebar-section-link-suffix` - ), - "shows suffix indicator for new content on tag1 link" - ); + ) + .exists("shows suffix indicator for new content on tag1 link"); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-tag-name=tag2] .sidebar-section-link-suffix` - ), - "shows suffix indicator for new content on tag2 link" - ); + ) + .exists("shows suffix indicator for new content on tag2 link"); - assert.ok( - !exists( + assert + .dom( `.sidebar-section-link-wrapper[data-tag-name=tag3] .sidebar-section-link-suffix` - ), - "hides suffix indicator when there's no new content on tag3 link" - ); + ) + .doesNotExist( + "hides suffix indicator when there's no new content on tag3 link" + ); await publishToMessageBus("/unread", { topic_id: 2, @@ -407,12 +405,11 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) { }, }); - assert.ok( - exists( + assert + .dom( `.sidebar-section-link-wrapper[data-tag-name=tag1] .sidebar-section-link-suffix` - ), - "shows suffix indicator for new topic on tag1 link" - ); + ) + .exists("shows suffix indicator for new topic on tag1 link"); await publishToMessageBus("/unread", { topic_id: 1, @@ -423,12 +420,11 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) { }, }); - assert.ok( - !exists( + assert + .dom( `.sidebar-section-link-wrapper[data-tag-name=tag1] .sidebar-section-link-suffix` - ), - "hides suffix indicator for tag1 section link" - ); + ) + .doesNotExist("hides suffix indicator for tag1 section link"); }); test("new and unread count for tag section links", async function (assert) { @@ -503,12 +499,11 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) { `displays 1 unread count for tag2 section link` ); - assert.ok( - !exists( + assert + .dom( `.sidebar-section-link-wrapper[data-tag-name=tag3] .sidebar-section-link-content-badge` - ), - "does not display any badge for tag3 section link" - ); + ) + .doesNotExist("does not display any badge for tag3 section link"); await publishToMessageBus("/unread", { topic_id: 2, @@ -536,12 +531,11 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) { }, }); - assert.ok( - !exists( + assert + .dom( `.sidebar-section-link-wrapper[data-tag-name=tag1] .sidebar-section-link-content-badge` - ), - `does not display any badge tag1 section link` - ); + ) + .doesNotExist(`does not display any badge tag1 section link`); }); test("cleans up topic tracking state state changed callbacks when section is destroyed", async function (assert) { @@ -572,12 +566,11 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) { await visit("/"); - assert.ok( - exists( + assert + .dom( ".sidebar-section-link[data-link-name='configure-default-navigation-menu-tags']" - ), - "section link to configure default sidebar tags is shown" - ); + ) + .exists("section link to configure default sidebar tags is shown"); await click( ".sidebar-section-link[data-link-name='configure-default-navigation-menu-tags']" diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js index a94ea45feeb..1d5b8f05b25 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import Sinon from "sinon"; import { acceptance, - exists, query, updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; @@ -23,10 +22,9 @@ acceptance( await visit("/"); await click("#toggle-hamburger-menu"); - assert.ok( - exists(".sidebar-section-header.sidebar-section-header-collapsable"), - "sections are collapsable" - ); + assert + .dom(".sidebar-section-header.sidebar-section-header-collapsable") + .exists("sections are collapsable"); }); } ); @@ -44,42 +42,39 @@ acceptance( await visit("/"); await click("#toggle-hamburger-menu"); - assert.ok( - exists(".sidebar-hamburger-dropdown"), - "displays the sidebar dropdown" - ); + assert + .dom(".sidebar-hamburger-dropdown") + .exists("displays the sidebar dropdown"); await click("#toggle-hamburger-menu"); - assert.notOk( - exists(".sidebar-hamburger-dropdown"), - "hides the sidebar dropdown" - ); + assert + .dom(".sidebar-hamburger-dropdown") + .doesNotExist("hides the sidebar dropdown"); }); test("sections are not collapsable", async function (assert) { await visit("/"); await click("#toggle-hamburger-menu"); - assert.notOk( - exists(".sidebar-section-header.sidebar-section-header-collapsable"), - "sections are not collapsable" - ); + assert + .dom(".sidebar-section-header.sidebar-section-header-collapsable") + .doesNotExist("sections are not collapsable"); }); test("'more' dropdown should display as regular list items in header dropdown mode", async function (assert) { await visit("/"); await click("#toggle-hamburger-menu"); - assert.ok( - exists("[data-link-name='admin']"), - "the admin link is not within the 'more' dropdown" - ); + assert + .dom("[data-link-name='admin']") + .exists("the admin link is not within the 'more' dropdown"); - assert.notOk( - exists(".sidebar-more-section-links-details-summary"), - "the 'more' dropdown should not be present in header dropdown mode" - ); + assert + .dom(".sidebar-more-section-links-details-summary") + .doesNotExist( + "the 'more' dropdown should not be present in header dropdown mode" + ); }); } ); @@ -101,19 +96,17 @@ acceptance( )}"]` ); - assert.ok( - exists("#keyboard-shortcuts-help"), - "keyboard shortcuts help is displayed" - ); + assert + .dom("#keyboard-shortcuts-help") + .exists("keyboard shortcuts help is displayed"); }); test("sidebar is disabled on wizard route", async function (assert) { await visit("/wizard"); - assert.notOk( - exists(".sidebar-container"), - "does not display the sidebar on wizard route" - ); + assert + .dom(".sidebar-container") + .doesNotExist("does not display the sidebar on wizard route"); }); test("showing and hiding sidebar", async function (assert) { @@ -124,10 +117,9 @@ acceptance( "adds sidebar utility class to body" ); - assert.ok( - exists(".sidebar-container"), - "displays the sidebar by default" - ); + assert + .dom(".sidebar-container") + .exists("displays the sidebar by default"); await click(".btn-sidebar-toggle"); @@ -136,11 +128,11 @@ acceptance( "removes sidebar utility class from body" ); - assert.ok(!exists(".sidebar-container"), "hides the sidebar"); + assert.dom(".sidebar-container").doesNotExist("hides the sidebar"); await click(".btn-sidebar-toggle"); - assert.ok(exists(".sidebar-container"), "displays the sidebar"); + assert.dom(".sidebar-container").exists("displays the sidebar"); }); test("button to toggle between mobile and desktop view on touch devices ", async function (assert) { @@ -149,21 +141,19 @@ acceptance( await visit("/"); - assert.ok( - exists( + assert + .dom( `.sidebar-footer-actions-toggle-mobile-view[title="${I18n.t( "mobile_view" )}"]` - ), - "displays the right title for the button" - ); + ) + .exists("displays the right title for the button"); - assert.ok( - exists( + assert + .dom( ".sidebar-footer-actions-toggle-mobile-view .d-icon-mobile-screen-button" - ), - "displays the mobile icon for the button" - ); + ) + .exists("displays the mobile icon for the button"); }); test("clean up topic tracking state state changed callbacks when sidebar is destroyed", async function (assert) { @@ -191,32 +181,35 @@ acceptance( test("accessibility of sidebar section header", async function (assert) { await visit("/"); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='categories'] .sidebar-section-header[aria-expanded='true'][aria-controls='sidebar-section-content-categories']" - ), - "accessibility attributes are set correctly on sidebar section header when section is expanded" - ); + ) + .exists( + "accessibility attributes are set correctly on sidebar section header when section is expanded" + ); await click(".sidebar-section-header"); - assert.ok( - exists( + assert + .dom( ".sidebar-section[data-section-name='categories'] .sidebar-section-header[aria-expanded='false'][aria-controls='sidebar-section-content-categories']" - ), - "accessibility attributes are set correctly on sidebar section header when section is collapsed" - ); + ) + .exists( + "accessibility attributes are set correctly on sidebar section header when section is collapsed" + ); }); test("accessibility of sidebar toggle", async function (assert) { await visit("/"); - assert.ok( - exists( + assert + .dom( ".btn-sidebar-toggle[aria-expanded='true'][aria-controls='d-sidebar']" - ), - "has the right accessibility attributes set when sidebar is expanded" - ); + ) + .exists( + "has the right accessibility attributes set when sidebar is expanded" + ); assert.strictEqual( query(".btn-sidebar-toggle").title, @@ -226,12 +219,13 @@ acceptance( await click(".btn-sidebar-toggle"); - assert.ok( - exists( + assert + .dom( ".btn-sidebar-toggle[aria-expanded='false'][aria-controls='d-sidebar']" - ), - "has the right accessibility attributes set when sidebar is collapsed" - ); + ) + .exists( + "has the right accessibility attributes set when sidebar is collapsed" + ); assert.strictEqual( query(".btn-sidebar-toggle").title, diff --git a/app/assets/javascripts/discourse/tests/acceptance/sign-in-test.js b/app/assets/javascripts/discourse/tests/acceptance/sign-in-test.js index d435be5ac7a..72d22ddfa73 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sign-in-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sign-in-test.js @@ -1,18 +1,18 @@ import { click, fillIn, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Signing In", function () { test("sign in", async function (assert) { await visit("/"); await click("header .login-button"); - assert.ok(exists(".login-modal"), "it shows the login modal"); + assert.dom(".login-modal").exists("shows the login modal"); // Test invalid password first await fillIn("#login-account-name", "eviltrout"); await fillIn("#login-account-password", "incorrect"); await click(".d-modal__footer .btn-primary"); - assert.ok(exists("#modal-alert:visible"), "it displays the login error"); + assert.dom("#modal-alert").exists("displays the login error"); assert .dom(".d-modal__footer .btn-primary:disabled") .doesNotExist("enables the login button"); @@ -37,7 +37,7 @@ acceptance("Signing In", function () { test("sign in - not activated", async function (assert) { await visit("/"); await click("header .login-button"); - assert.ok(exists(".login-modal"), "it shows the login modal"); + assert.dom(".login-modal").exists("shows the login modal"); await fillIn("#login-account-name", "eviltrout"); await fillIn("#login-account-password", "not-activated"); @@ -45,19 +45,23 @@ acceptance("Signing In", function () { assert .dom(".d-modal__body b") .hasText("eviltrout@example.com"); - assert.ok(!exists(".d-modal__body small"), "it escapes the email address"); + assert + .dom(".d-modal__body small") + .doesNotExist("escapes the email address"); await click(".d-modal__footer button.resend"); assert .dom(".d-modal__body b") .hasText("current@example.com"); - assert.ok(!exists(".d-modal__body small"), "it escapes the email address"); + assert + .dom(".d-modal__body small") + .doesNotExist("escapes the email address"); }); test("sign in - not activated - edit email", async function (assert) { await visit("/"); await click("header .login-button"); - assert.dom(".login-modal").exists("it shows the login modal"); + assert.dom(".login-modal").exists("shows the login modal"); await fillIn("#login-account-name", "eviltrout"); await fillIn("#login-account-password", "not-activated-edit"); @@ -77,7 +81,7 @@ acceptance("Signing In", function () { await visit("/"); await click("header .login-button"); - assert.ok(exists(".login-modal"), "it shows the login modal"); + assert.dom(".login-modal").exists("shows the login modal"); await fillIn("#login-account-name", "eviltrout"); await fillIn("#login-account-password", "need-second-factor"); @@ -103,7 +107,7 @@ acceptance("Signing In", function () { await visit("/"); await click("header .login-button"); - assert.ok(exists(".login-modal"), "it shows the login modal"); + assert.dom(".login-modal").exists("shows the login modal"); await fillIn("#login-account-name", "eviltrout"); await fillIn("#login-account-password", "need-security-key"); @@ -131,7 +135,7 @@ acceptance("Signing In", function () { assert .dom(".d-modal__footer .btn-primary:disabled") - .exists("it closes the modal when the code is valid"); + .exists("closes the modal when the code is valid"); }); test("second factor backup - invalid token", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js b/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js index 2b18857a0af..27aa6a795e0 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js @@ -1,7 +1,7 @@ import { click, visit } from "@ember/test-helpers"; import { test } from "qunit"; import pretender, { response } from "discourse/tests/helpers/create-pretender"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Tags intersection", function (needs) { needs.user(); @@ -28,7 +28,7 @@ acceptance("Tags intersection", function (needs) { await visit("/tags/intersection/first/second"); await click("#create-topic"); - assert.ok(exists(".mini-tag-chooser"), "The tag selector appears"); + assert.dom(".mini-tag-chooser").exists("the tag selector appears"); assert .dom(".composer-fields .mini-tag-chooser") .hasText("first, second", "populates the tags when clicking 'New topic'"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/tags-test.js b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js index 8b49d2c80d4..0bebef6874b 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/tags-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import { acceptance, count, - exists, invisible, query, queryAll, @@ -112,7 +111,7 @@ acceptance("Tags", function (needs) { document.body.classList.contains("tags-page"), "has the body class" ); - assert.ok(exists(`[data-tag-name="eviltrout"]`), "shows the eviltrout tag"); + assert.dom(`[data-tag-name="eviltrout"]`).exists("shows the eviltrout tag"); }); test("dismiss notifications", async function (assert) { @@ -434,7 +433,7 @@ acceptance("Tag info", function (needs) { assert.strictEqual(count("#show-tag-info"), 1); await click("#show-tag-info"); - assert.ok(exists(".tag-info .tag-name"), "show tag"); + assert.dom(".tag-info .tag-name").exists("show tag"); assert.ok( query(".tag-info .tag-associations").innerText.includes("Gardening"), "show tag group names" @@ -449,9 +448,9 @@ acceptance("Tag info", function (needs) { 1, "show the category" ); - assert.ok(!exists("#rename-tag"), "can't rename tag"); - assert.ok(!exists("#edit-synonyms"), "can't edit synonyms"); - assert.ok(!exists("#delete-tag"), "can't delete tag"); + assert.dom("#rename-tag").doesNotExist("can't rename tag"); + assert.dom("#edit-synonyms").doesNotExist("can't edit synonyms"); + assert.dom("#delete-tag").doesNotExist("can't delete tag"); }); test("tag info hides only current tag in synonyms dropdown", async function (assert) { @@ -461,7 +460,7 @@ acceptance("Tag info", function (needs) { assert.strictEqual(count("#show-tag-info"), 1); await click("#show-tag-info"); - assert.ok(exists(".tag-info .tag-name"), "show tag"); + assert.dom(".tag-info .tag-name").exists("show tag"); await click("#edit-synonyms"); @@ -483,7 +482,7 @@ acceptance("Tag info", function (needs) { assert.strictEqual(count("#show-tag-info"), 1); await click("#show-tag-info"); - assert.ok(exists(".tag-info .tag-name"), "show tag"); + assert.dom(".tag-info .tag-name").exists("show tag"); await click(".edit-tag"); assert.strictEqual( @@ -600,9 +599,9 @@ acceptance("Tag info", function (needs) { assert.strictEqual(count("#show-tag-info"), 1); await click("#show-tag-info"); - assert.ok(exists(".edit-tag"), "can rename tag"); - assert.ok(exists("#edit-synonyms"), "can edit synonyms"); - assert.ok(exists("#delete-tag"), "can delete tag"); + assert.dom(".edit-tag").exists("can rename tag"); + assert.dom("#edit-synonyms").exists("can edit synonyms"); + assert.dom("#delete-tag").exists("can delete tag"); await click("#edit-synonyms"); assert.strictEqual( diff --git a/app/assets/javascripts/discourse/tests/acceptance/themes-test.js b/app/assets/javascripts/discourse/tests/acceptance/themes-test.js index da17793fbb5..ddfcb55f7d7 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/themes-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/themes-test.js @@ -1,10 +1,6 @@ import { click, fillIn, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; acceptance("Theme", function (needs) { @@ -189,20 +185,14 @@ acceptance("Theme", function (needs) { ); await click(".install-theme-content button.advanced-repo"); - assert.notOk( - exists( - ".admin-install-theme-modal .d-modal__footer .install-theme-warning" - ), - "no Git warning is displayed" - ); + assert + .dom(".admin-install-theme-modal .d-modal__footer .install-theme-warning") + .doesNotExist("no Git warning is displayed"); await click(".admin-install-theme-modal .d-modal__footer .btn-primary"); - assert.ok( - exists( - ".admin-install-theme-modal .d-modal__footer .install-theme-warning" - ), - "Git warning is displayed" - ); + assert + .dom(".admin-install-theme-modal .d-modal__footer .install-theme-warning") + .exists("Git warning is displayed"); await click(".admin-install-theme-modal .d-modal__footer .btn-danger"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-admin-menu-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-admin-menu-test.js index 02e4acc9986..4c22ee93645 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-admin-menu-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-admin-menu-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import { withPluginApi } from "discourse/lib/plugin-api"; import { acceptance, - exists, updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; @@ -11,7 +10,7 @@ import I18n from "discourse-i18n"; acceptance("Topic - Admin Menu Anonymous Users", function () { test("Enter as a regular user", async function (assert) { await visit("/t/internationalization-localization/280"); - assert.ok(exists("#topic"), "The topic was rendered"); + assert.dom("#topic").exists("the topic is rendered"); assert .dom(".toggle-admin-menu") .doesNotExist("The admin menu button was not rendered"); @@ -24,20 +23,20 @@ acceptance("Topic - Admin Menu", function (needs) { updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); await visit("/t/topic-for-group-moderators/2480"); - assert.ok(exists("#topic"), "The topic was rendered"); + assert.dom("#topic").exists("the topic is rendered"); assert .dom(".toggle-admin-menu") .exists("The admin menu button was rendered"); await click(".toggle-admin-menu"); - assert.ok(exists(".topic-admin-delete"), "The delete item was rendered"); + assert.dom(".topic-admin-delete").exists("the delete item is rendered"); }); test("Enter as a user with moderator and admin permissions", async function (assert) { updateCurrentUser({ moderator: true, admin: true, trust_level: 4 }); await visit("/t/internationalization-localization/280"); - assert.ok(exists("#topic"), "The topic was rendered"); + assert.dom("#topic").exists("the topic is rendered"); assert .dom(".toggle-admin-menu") .exists("The admin menu button was rendered"); @@ -61,7 +60,7 @@ acceptance("Topic - Admin Menu", function (needs) { }); await visit("/t/internationalization-localization/280"); - assert.ok(exists("#topic"), "The topic was rendered"); + assert.dom("#topic").exists("the topic is rendered"); await click(".toggle-admin-menu"); assert .dom(".extra-button svg.d-icon-heart") diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-anonymous-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-anonymous-test.js index 60ba7e88e6d..9895e0ebddf 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-anonymous-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-anonymous-test.js @@ -1,12 +1,12 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Topic - Anonymous", function () { test("Enter a Topic", async function (assert) { await visit("/t/internationalization-localization/280/1"); - assert.ok(exists("#topic"), "The topic was rendered"); - assert.ok(exists("#topic .cooked"), "The topic has cooked posts"); + assert.dom("#topic").exists("The topic was rendered"); + assert.dom("#topic .cooked").exists("The topic has cooked posts"); assert .dom(".shared-draft-notice") .doesNotExist("no shared draft unless there's a dest category id"); @@ -14,24 +14,24 @@ acceptance("Topic - Anonymous", function () { test("Enter without an id", async function (assert) { await visit("/t/internationalization-localization"); - assert.ok(exists("#topic"), "The topic was rendered"); + assert.dom("#topic").exists("The topic was rendered"); }); test("Enter a 404 topic", async function (assert) { await visit("/t/not-found/404"); - assert.ok(!exists("#topic"), "The topic was not rendered"); - assert.ok(exists(".topic-error"), "An error message is displayed"); + assert.dom("#topic").doesNotExist("The topic was not rendered"); + assert.dom(".topic-error").exists("An error message is displayed"); }); test("Enter without access", async function (assert) { await visit("/t/i-dont-have-access/403"); - assert.ok(!exists("#topic"), "The topic was not rendered"); - assert.ok(exists(".topic-error"), "An error message is displayed"); + assert.dom("#topic").doesNotExist("The topic was not rendered"); + assert.dom(".topic-error").exists("An error message is displayed"); }); test("Enter with 500 errors", async function (assert) { await visit("/t/throws-error/500"); - assert.ok(!exists("#topic"), "The topic was not rendered"); - assert.ok(exists(".topic-error"), "An error message is displayed"); + assert.dom("#topic").doesNotExist("The topic was not rendered"); + assert.dom(".topic-error").exists("An error message is displayed"); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js index 140da0989b6..5a45560d8c2 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js @@ -6,7 +6,6 @@ import discoveryFixtures from "discourse/tests/fixtures/discovery-fixtures"; import topFixtures from "discourse/tests/fixtures/top-fixtures"; import { acceptance, - exists, publishToMessageBus, query, } from "discourse/tests/helpers/qunit-helpers"; @@ -30,8 +29,8 @@ acceptance("Topic Discovery", function (needs) { document.body.classList.contains("navigation-topics"), "has the default navigation" ); - assert.ok(exists(".topic-list"), "The list of topics was rendered"); - assert.ok(exists(".topic-list .topic-list-item"), "has topics"); + assert.dom(".topic-list").exists("the list of topics was rendered"); + assert.dom(".topic-list .topic-list-item").exists("has topics"); assert .dom("a[data-user-card=eviltrout] img.avatar") @@ -50,9 +49,9 @@ acceptance("Topic Discovery", function (needs) { ); await visit("/c/bug"); - assert.ok(exists(".topic-list"), "The list of topics was rendered"); - assert.ok(exists(".topic-list .topic-list-item"), "has topics"); - assert.ok(!exists(".category-list"), "doesn't render subcategories"); + assert.dom(".topic-list").exists("the list of topics was rendered"); + assert.dom(".topic-list .topic-list-item").exists("has topics"); + assert.dom(".category-list").doesNotExist("doesn't render subcategories"); assert.ok( document.body.classList.contains("category-bug"), "has a custom css class for the category id on the body" @@ -67,7 +66,7 @@ acceptance("Topic Discovery", function (needs) { !document.body.classList.contains("category-bug"), "removes the custom category class" ); - assert.ok(exists(".category"), "has a list of categories"); + assert.dom(".category").exists("has a list of categories"); assert.ok( document.body.classList.contains("categories-list"), "has a custom class to indicate categories" @@ -78,16 +77,16 @@ acceptance("Topic Discovery", function (needs) { !document.body.classList.contains("categories-list"), "removes the `categories-list` class" ); - assert.ok(exists(".topic-list .topic-list-item"), "has topics"); + assert.dom(".topic-list .topic-list-item").exists("has topics"); await visit("/c/feature"); - assert.ok(exists(".topic-list"), "The list of topics was rendered"); + assert.dom(".topic-list").exists("The list of topics was rendered"); assert .dom(".category-boxes") .exists("The list of subcategories were rendered with box style"); await visit("/c/dev"); - assert.ok(exists(".topic-list"), "The list of topics was rendered"); + assert.dom(".topic-list").exists("The list of topics was rendered"); assert .dom(".category-boxes-with-topics") .exists( diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js index c029084d7fd..8b9cd259e88 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import topicFixtures from "discourse/tests/fixtures/topic"; import { acceptance, - exists, query, queryAll, selectText, @@ -34,8 +33,8 @@ acceptance("Topic - Quote button - logged in", function (needs) { test("Does not show the quote share buttons by default", async function (assert) { await visit("/t/internationalization-localization/280"); await selectText("#post_5 blockquote"); - assert.ok(exists(".insert-quote"), "it shows the quote button"); - assert.ok(!exists(".quote-sharing"), "it does not show quote sharing"); + assert.dom(".insert-quote").exists("shows the quote button"); + assert.dom(".quote-sharing").doesNotExist("does not show quote sharing"); }); test("Shows quote share buttons with the right site settings", async function (assert) { @@ -44,7 +43,7 @@ acceptance("Topic - Quote button - logged in", function (needs) { await visit("/t/internationalization-localization/280"); await selectText("#post_5 blockquote"); - assert.ok(exists(".quote-sharing"), "it shows the quote sharing options"); + assert.dom(".quote-sharing").exists("shows the quote sharing options"); assert .dom(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`) .exists("it includes the twitter share button"); @@ -80,7 +79,7 @@ acceptance("Closed Topic - Quote button - logged in", function (needs) { test("Shows quote button in closed topics", async function (assert) { await visit("/t/internationalization-localization/280"); await selectText("#post_1 .cooked p:first-child"); - assert.ok(exists(".insert-quote"), "it shows the quote button"); + assert.dom(".insert-quote").exists("shows the quote button"); await click(".insert-quote"); assert.ok( @@ -109,7 +108,9 @@ acceptance("Topic - Quote button - anonymous", function (needs) { assert .dom(`.quote-sharing .btn[title='${I18n.t("share.email")}']`) .exists("it includes the email share button"); - assert.ok(!exists(".insert-quote"), "it does not show the quote button"); + assert + .dom(".insert-quote") + .doesNotExist("it does not show the quote button"); }); test("Shows single share button when site setting only has one item", async function (assert) { @@ -118,7 +119,7 @@ acceptance("Topic - Quote button - anonymous", function (needs) { await visit("/t/internationalization-localization/280"); await selectText("#post_5 blockquote"); - assert.ok(exists(".quote-sharing"), "it shows the quote sharing options"); + assert.dom(".quote-sharing").exists("shows the quote sharing options"); assert .dom(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`) .exists("it includes the twitter share button"); @@ -133,8 +134,8 @@ acceptance("Topic - Quote button - anonymous", function (needs) { await visit("/t/internationalization-localization/280"); await selectText("#post_5 blockquote"); - assert.ok(!exists(".quote-sharing"), "it does not show quote sharing"); - assert.ok(!exists(".insert-quote"), "it does not show the quote button"); + assert.dom(".quote-sharing").doesNotExist("does not show quote sharing"); + assert.dom(".insert-quote").doesNotExist("does not show the quote button"); }); }); @@ -145,7 +146,7 @@ acceptance("Topic - Quote button - keyboard shortcut", function (needs) { await visit("/t/internationalization-localization/280"); await selectText("#post_1 .cooked"); await triggerKeyEvent(document, "keypress", "Q"); - assert.ok(exists(".d-editor-input"), "the editor is open"); + assert.dom(".d-editor-input").exists("the editor is open"); assert.ok( query(".d-editor-input").value.includes("Any plans to support"), diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-slow-mode-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-slow-mode-test.js index eecf7416e73..3ea1bc47dd7 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-slow-mode-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-slow-mode-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import topicFixtures from "discourse/tests/fixtures/topic"; import { acceptance, - exists, updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; @@ -56,8 +55,8 @@ acceptance("Topic - Slow Mode - enabled", function (needs) { "enabled until combobox is switched to the option Pick Date and Time" ); - assert.ok(exists("input.date-picker"), "date picker is rendered"); - assert.ok(exists("input.time-input"), "time picker is rendered"); + assert.dom("input.date-picker").exists("date picker is rendered"); + assert.dom("input.time-input").exists("time picker is rendered"); }); test("'Enable' button changes to 'Update' button when slow mode is enabled", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js index 91dfe3f3078..056fa23705c 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js @@ -13,7 +13,6 @@ import { acceptance, chromeTest, count, - exists, publishToMessageBus, query, selectText, @@ -49,7 +48,7 @@ acceptance("Topic", function (needs) { await click("button.share:nth-of-type(1)"); await click("button.new-topic"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.dom(".d-editor-input").exists("the composer input is visible"); assert.strictEqual( query(".d-editor-input").value.trim(), @@ -68,7 +67,7 @@ acceptance("Topic", function (needs) { await click("button.share:nth-of-type(1)"); await click("button.new-topic"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.dom(".d-editor-input").exists("the composer input is visible"); assert.strictEqual( query(".d-editor-input").value.trim(), @@ -88,7 +87,7 @@ acceptance("Topic", function (needs) { await visit("/t/internationalization-localization/280"); await click(".topic-post:first-child button.share"); - assert.ok(exists(".share-topic-modal"), "it shows the share modal"); + assert.dom(".share-topic-modal").exists("shows the share modal"); }); test("Copy Link Button", async function (assert) { @@ -105,14 +104,14 @@ acceptance("Topic", function (needs) { await click("#topic-title .d-icon-pencil"); - assert.ok(exists("#edit-title"), "it shows the editing controls"); + assert.dom("#edit-title").exists("shows the editing controls"); assert .dom(".title-wrapper .remove-featured-link") .doesNotExist("link to remove featured link is not shown"); await fillIn("#edit-title", "this is the new title"); await click("#topic-title .cancel-edit"); - assert.ok(!exists("#edit-title"), "it hides the editing controls"); + assert.dom("#edit-title").doesNotExist("hides the editing controls"); }); test("Updating the topic title and category", async function (assert) { @@ -137,7 +136,7 @@ acceptance("Topic", function (needs) { test("Marking a topic as wiki", async function (assert) { await visit("/t/internationalization-localization/280"); - assert.ok(!exists("a.wiki"), "it does not show the wiki icon"); + assert.dom("a.wiki").doesNotExist("does not show the wiki icon"); await click(".topic-post:nth-of-type(1) button.show-more-actions"); await click(".topic-post:nth-of-type(1) button.show-post-admin-menu"); @@ -222,7 +221,7 @@ acceptance("Topic", function (needs) { await click(".topic-post:nth-of-type(1) button.show-more-actions"); await click(".widget-button.delete"); await click(".toggle-admin-menu"); - assert.ok(exists(".topic-admin-recover"), "it shows the recover button"); + assert.dom(".topic-admin-recover").exists("shows the recover button"); }); test("Deleting a popular topic displays confirmation modal", async function (assert) { @@ -243,14 +242,14 @@ acceptance("Topic", function (needs) { await click(".widget-button.delete"); await click(".delete-topic-confirm-modal .btn-danger"); await click(".toggle-admin-menu"); - assert.ok(exists(".topic-admin-recover"), "it shows the recover button"); + assert.dom(".topic-admin-recover").exists("shows the recover button"); }); test("Group category moderator posts", async function (assert) { await visit("/t/topic-for-group-moderators/2480"); - assert.ok(exists(".category-moderator"), "it has a class applied"); - assert.ok(exists(".d-icon-shield-halved"), "it shows an icon"); + assert.dom(".category-moderator").exists("has a class applied"); + assert.dom(".d-icon-shield-halved").exists("shows an icon"); }); test("Suspended user posts", async function (assert) { @@ -297,14 +296,6 @@ acceptance("Topic featured links", function (needs) { assert .dom(".title-wrapper .remove-featured-link") .exists("link to remove featured link"); - - // TODO: decide if we want to test this, test is flaky so it - // was commented out. - // If not fixed by May 2021, delete this code block - // - //await click(".title-wrapper .remove-featured-link"); - //await click(".title-wrapper .submit-edit"); - //assert.ok(!exists(".title-wrapper .topic-featured-link"), "link is gone"); }); test("Converting to a public topic", async function (assert) { @@ -380,7 +371,7 @@ acceptance("Topic featured links", function (needs) { await visit("/t/internationalization-localization/280"); await click(".gap"); - assert.ok(!exists(".gap"), "it hides gap"); + assert.dom(".gap").doesNotExist("hides gap"); }); test("Quoting a quote keeps the original poster name", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/unknown-test.js b/app/assets/javascripts/discourse/tests/acceptance/unknown-test.js index 620239a6c9c..f73b51bbfaa 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/unknown-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/unknown-test.js @@ -1,6 +1,6 @@ import { click, currentURL, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Category 404", function (needs) { needs.pretender((server, helper) => { @@ -51,7 +51,7 @@ acceptance("Unknown", function (needs) { test("Permalink Unknown URL", async function (assert) { await visit("/url-that-doesn't-exist"); - assert.ok(exists(".page-not-found"), "The not found content is present"); + assert.dom(".page-not-found").exists("the not found content is present"); }); test("Permalink URL to a Topic", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js index 599275f56c6..40376326916 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js @@ -1,6 +1,6 @@ import { currentRouteName, currentURL, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("User Anonymous", function () { test("Root URL", async function (assert) { @@ -23,18 +23,18 @@ acceptance("User Anonymous", function () { document.body.classList.contains("user-activity-page"), "has the body class" ); - assert.ok(exists(".user-main .about"), "it has the about section"); - assert.ok(exists(".user-stream .item"), "it has stream items"); + assert.dom(".user-main .about").exists("has the about section"); + assert.dom(".user-stream .item").exists("has stream items"); await visit("/u/eviltrout/activity/topics"); - assert.ok(!exists(".user-stream .item"), "has no stream displayed"); - assert.ok(exists(".topic-list tr"), "it has a topic list"); + assert.dom(".user-stream .item").doesNotExist("has no stream displayed"); + assert.dom(".topic-list tr").exists("has a topic list"); await visit("/u/eviltrout/activity/replies"); - assert.ok(exists(".user-main .about"), "it has the about section"); - assert.ok(exists(".user-stream .item"), "it has stream items"); + assert.dom(".user-main .about").exists("has the about section"); + assert.dom(".user-stream .item").exists("has stream items"); - assert.ok(exists(".user-stream.filter-5"), "stream has filter class"); + assert.dom(".user-stream.filter-5").exists("stream has filter class"); }); test("Badges", async function (assert) { @@ -44,7 +44,7 @@ acceptance("User Anonymous", function () { document.body.classList.contains("user-badges-page"), "has the body class" ); - assert.ok(exists(".badge-group-list .badge-card"), "shows a badge"); + assert.dom(".badge-group-list .badge-card").exists("shows a badge"); }); test("Restricted Routes", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-bookmark-bulk-actions-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-bookmark-bulk-actions-test.js index 5c17d3ba361..a779fd8952b 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-bookmark-bulk-actions-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-bookmark-bulk-actions-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import { acceptance, count, - exists, queryAll, } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; @@ -26,7 +25,7 @@ acceptance("Bookmark - Bulk Actions", function (needs) { await dropdown.selectRowByValue("clear-reminders"); - assert.ok(exists(".dialog-container"), "it should show the modal"); + assert.dom(".dialog-container").exists("shows the modal"); assert.dom(".dialog-container .dialog-body").includesText( I18n.t("js.bookmark_bulk_actions.clear_reminders.description", { count: 2, @@ -52,7 +51,7 @@ acceptance("Bookmark - Bulk Actions", function (needs) { await dropdown.expand(); await dropdown.selectRowByValue("delete-bookmarks"); - assert.ok(exists(".dialog-container"), "it should show the modal"); + assert.dom(".dialog-container").exists("shows the modal"); assert.dom(".dialog-container .dialog-body").includesText( I18n.t("js.bookmark_bulk_actions.delete_bookmarks.description", { diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js index e8b78497ac8..27b04f9dcdb 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js @@ -4,7 +4,6 @@ import { test } from "qunit"; import { acceptance, count, - exists, normalizeHtml, query, visible, @@ -36,7 +35,7 @@ acceptance("User Drafts", function (needs) { test("Stream - resume draft", async function (assert) { await visit("/u/eviltrout/activity/drafts"); - assert.ok(exists(".user-stream-item"), "has drafts"); + assert.dom(".user-stream-item").exists("has drafts"); await click(".user-stream-item .resume-draft"); assert.strictEqual( @@ -47,7 +46,7 @@ acceptance("User Drafts", function (needs) { test("Stream - has excerpt", async function (assert) { await visit("/u/eviltrout/activity/drafts"); - assert.ok(exists(".user-stream-item"), "has drafts"); + assert.dom(".user-stream-item").exists("has drafts"); assert.strictEqual( query(".user-stream-item:nth-child(3) .category").textContent, "meta" diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js index 97feec1d962..9b47c914996 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js @@ -17,7 +17,6 @@ import TopicFixtures from "discourse/tests/fixtures/topic"; import UserMenuFixtures from "discourse/tests/fixtures/user-menu"; import { acceptance, - exists, loggedInUser, publishToMessageBus, query, @@ -798,7 +797,9 @@ acceptance("User menu", function (needs) { "/u/eviltrout/notifications", "clicking on active tab navigates to the page it links to" ); - assert.notOk(exists(".user-menu"), "user menu is closed after navigating"); + assert + .dom(".user-menu") + .doesNotExist("user menu is closed after navigating"); const tabs = [ ["#user-menu-button-custom-tab-1", "/u/eviltrout/preferences/account"], @@ -820,15 +821,13 @@ acceptance("User menu", function (needs) { expectedLink, `clicking on the ${id} tab navigates to ${expectedLink}` ); - assert.notOk( - exists(".user-menu"), - "user menu is closed after navigating" - ); + assert + .dom(".user-menu") + .doesNotExist("user menu is closed after navigating"); } else { - assert.ok( - exists(".user-menu"), - "user menu remains open if tab doesn't link to anywhere" - ); + assert + .dom(".user-menu") + .exists("user menu remains open if tab doesn't link to anywhere"); } await click("#site-logo"); } @@ -1096,9 +1095,9 @@ acceptance("User menu - Dismiss button", function (needs) { await click(".user-menu .notifications-dismiss"); - assert.ok( - !exists("#user-menu-button-other-notifications .badge-notification") - ); + assert + .dom("#user-menu-button-other-notifications .badge-notification") + .doesNotExist(); assert.ok( markRead, "mark-read request is sent without a confirmation modal" diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js index a4ea4aa695e..e964a14ab81 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js @@ -6,11 +6,7 @@ import pretender, { fixturesByUrl, response, } from "discourse/tests/helpers/create-pretender"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { cloneJSON } from "discourse-common/lib/object"; import I18n from "discourse-i18n"; @@ -269,7 +265,7 @@ acceptance("User Preferences - Account", function (needs) { await visit("/u/eviltrout/preferences/account"); await click(".pref-avatar .btn"); - assert.ok(exists(".avatar-choice"), "opens the avatar selection modal"); + assert.dom(".avatar-choice").exists("opens the avatar selection modal"); await click(".avatar-selector-refresh-gravatar"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-admin-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-admin-test.js index 70de7ac28de..bd6856dedf5 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-admin-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-admin-test.js @@ -1,13 +1,13 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("User Preferences Admin", function (needs) { needs.user({ admin: true }); test("Desktop user admin button", async function (assert) { await visit("/u/eviltrout"); - assert.ok(exists(".user-admin"), "desktop user admin nav button exists"); + assert.dom(".user-admin").exists("desktop user admin nav button exists"); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-email-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-email-test.js index 0818c7d1bd8..87c3da97fac 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-email-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-email-test.js @@ -1,6 +1,6 @@ import { click, fillIn, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; acceptance("User Preferences - Email", function (needs) { @@ -17,7 +17,7 @@ acceptance("User Preferences - Email", function (needs) { test("email", async function (assert) { await visit("/u/eviltrout/preferences/email"); - assert.ok(exists("#change-email"), "it has the input element"); + assert.dom("#change-email").exists("has the input element"); await fillIn("#change-email", "invalid-email"); @@ -32,7 +32,7 @@ acceptance("User Preferences - Email", function (needs) { test("email field always shows up", async function (assert) { await visit("/u/eviltrout/preferences/email"); - assert.ok(exists("#change-email"), "it has the input element"); + assert.dom("#change-email").exists("has the input element"); await fillIn("#change-email", "eviltrout@discourse.org"); await click(".user-preferences button.btn-primary"); @@ -40,6 +40,6 @@ acceptance("User Preferences - Email", function (needs) { await visit("/u/eviltrout/preferences"); await visit("/u/eviltrout/preferences/email"); - assert.ok(exists("#change-email"), "it has the input element"); + assert.dom("#change-email").exists("has the input element"); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js index 3ca03b64690..f784ead50f5 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js @@ -7,7 +7,6 @@ import userFixtures from "discourse/tests/fixtures/user-fixtures"; import { acceptance, count, - exists, query, } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; @@ -28,9 +27,9 @@ acceptance("User Preferences - Interface", function (needs) { removeCookie("text_size"); const savePreferences = async () => { - assert.ok(!exists(".saved"), "it hasn't been saved yet"); + assert.dom(".saved").doesNotExist("hasn't been saved yet"); await click(".save-changes"); - assert.ok(exists(".saved"), "it displays the saved message"); + assert.dom(".saved").exists("it displays the saved message"); query(".saved").remove(); }; @@ -72,7 +71,7 @@ acceptance("User Preferences - Interface", function (needs) { test("does not show option to disable dark mode by default", async function (assert) { await visit("/u/eviltrout/preferences/interface"); - assert.ok(!exists(".control-group.dark-mode"), "option not visible"); + assert.dom(".control-group.dark-mode").doesNotExist("option not visible"); }); test("shows light/dark color scheme pickers", async function (assert) { @@ -83,8 +82,8 @@ acceptance("User Preferences - Interface", function (needs) { ]); await visit("/u/eviltrout/preferences/interface"); - assert.ok(exists(".light-color-scheme"), "has regular dropdown"); - assert.ok(exists(".dark-color-scheme"), "has dark color scheme dropdown"); + assert.dom(".light-color-scheme").exists("has regular dropdown"); + assert.dom(".dark-color-scheme").exists("has dark color scheme dropdown"); }); test("shows light color scheme default option when theme's color scheme is not user selectable", async function (assert) { @@ -96,7 +95,7 @@ acceptance("User Preferences - Interface", function (needs) { site.set("user_color_schemes", [{ id: 2, name: "Cool Breeze" }]); await visit("/u/eviltrout/preferences/interface"); - assert.ok(exists(".light-color-scheme"), "has regular dropdown"); + assert.dom(".light-color-scheme").exists("has regular dropdown"); assert.strictEqual( selectKit(".light-color-scheme .select-kit").header().value(), @@ -132,7 +131,7 @@ acceptance("User Preferences - Interface", function (needs) { await visit("/u/eviltrout/preferences/interface"); - assert.ok(exists(".light-color-scheme"), "has regular dropdown"); + assert.dom(".light-color-scheme").exists("has regular dropdown"); assert.strictEqual(selectKit(".theme .select-kit").header().value(), "2"); await selectKit(".light-color-scheme .select-kit").expand(); @@ -187,10 +186,9 @@ acceptance( test("show option to disable dark mode", async function (assert) { await visit("/u/eviltrout/preferences/interface"); - assert.ok( - exists(".control-group.dark-mode"), - "it has the option to disable dark mode" - ); + assert + .dom(".control-group.dark-mode") + .exists("has the option to disable dark mode"); }); test("no color scheme picker by default", async function (assert) { @@ -206,11 +204,10 @@ acceptance( site.set("user_color_schemes", [{ id: 2, name: "Cool Breeze" }]); await visit("/u/eviltrout/preferences/interface"); - assert.ok(exists(".light-color-scheme"), "has regular picker dropdown"); - assert.ok( - !exists(".dark-color-scheme"), - "does not have a dark color scheme picker" - ); + assert.dom(".light-color-scheme").exists("has regular picker dropdown"); + assert + .dom(".dark-color-scheme") + .doesNotExist("does not have a dark color scheme picker"); }); test("light color scheme defaults to custom scheme selected by user", async function (assert) { @@ -220,7 +217,7 @@ acceptance( site.set("user_color_schemes", [{ id: 2, name: "Cool Breeze" }]); await visit("/u/eviltrout/preferences/interface"); - assert.ok(exists(".light-color-scheme"), "has light scheme dropdown"); + assert.dom(".light-color-scheme").exists("has light scheme dropdown"); assert.strictEqual( query(".light-color-scheme .selected-name").dataset.value, session.userColorSchemeId.toString(), @@ -243,7 +240,7 @@ acceptance( await visit("/u/eviltrout/preferences/interface"); - assert.ok(exists(".light-color-scheme"), "has regular dropdown"); + assert.dom(".light-color-scheme").exists("has regular dropdown"); const dropdownObject = selectKit(".light-color-scheme .select-kit"); assert.strictEqual(dropdownObject.header().value(), null); assert.strictEqual( @@ -269,24 +266,23 @@ acceptance( ]); const savePreferences = async () => { - assert.ok(!exists(".saved"), "it hasn't been saved yet"); + assert.dom(".saved").doesNotExist("hasn't been saved yet"); await click(".save-changes"); - assert.ok(exists(".saved"), "it displays the saved message"); + assert.dom(".saved").exists("displays the saved message"); query(".saved").remove(); }; await visit("/u/eviltrout/preferences/interface"); - assert.ok(exists(".light-color-scheme"), "has regular dropdown"); - assert.ok(exists(".dark-color-scheme"), "has dark color scheme dropdown"); + assert.dom(".light-color-scheme").exists("has regular dropdown"); + assert.dom(".dark-color-scheme").exists("has dark color scheme dropdown"); assert.strictEqual( query(".dark-color-scheme .selected-name").dataset.value, session.userDarkSchemeId.toString(), "sets site default as selected dark scheme" ); - assert.ok( - !exists(".control-group.dark-mode"), - "it does not show disable dark mode checkbox" - ); + assert + .dom(".control-group.dark-mode") + .doesNotExist("does not show disable dark mode checkbox"); removeCookie("color_scheme_id"); removeCookie("dark_scheme_id"); @@ -298,10 +294,9 @@ acceptance( undefined, "cookie is not set" ); - assert.ok( - exists(".color-scheme-checkbox input:checked"), - "defaults to storing values in user options" - ); + assert + .dom(".color-scheme-checkbox input:checked") + .exists("defaults to storing values in user options"); await savePreferences(); assert.strictEqual( diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-second-factor-backup-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-second-factor-backup-test.js index 2f5526eb116..2978d832c82 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-second-factor-backup-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-second-factor-backup-test.js @@ -2,7 +2,6 @@ import { click, visit } from "@ember/test-helpers"; import { test } from "qunit"; import { acceptance, - exists, updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; @@ -39,7 +38,7 @@ acceptance("User Preferences - Second Factor Backup", function (needs) { await click(".second-factor-backup-edit-modal .btn-primary"); - assert.ok(exists(".backup-codes-area"), "shows backup codes"); + assert.dom(".backup-codes-area").exists("shows backup codes"); }); test("delete backup codes", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-second-factor-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-second-factor-test.js index 848ea55acf2..37f1e16d19d 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-second-factor-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-second-factor-test.js @@ -8,7 +8,6 @@ import { import { test } from "qunit"; import { acceptance, - exists, query, updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; @@ -67,7 +66,7 @@ acceptance("User Preferences - Second Factor", function (needs) { await visit("/u/eviltrout/preferences/second-factor"); await click(".new-totp"); - assert.ok(exists(".qr-code img"), "shows qr code image"); + assert.dom(".qr-code img").exists("shows qr code image"); await click(".modal a.show-second-factor-key"); assert @@ -85,7 +84,7 @@ acceptance("User Preferences - Second Factor", function (needs) { await visit("/u/eviltrout/preferences/second-factor"); await click(".new-security-key"); - assert.ok(exists("#security-key-name"), "shows security key name input"); + assert.dom("#security-key-name").exists("shows security key name input"); await fillIn("#security-key-name", ""); diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js index 27d61e5f5c2..f466e443f96 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js @@ -11,7 +11,6 @@ import { fixturesByUrl } from "discourse/tests/helpers/create-pretender"; import { acceptance, count, - exists, publishToMessageBus, query, updateCurrentUser, @@ -38,10 +37,9 @@ acceptance( "displays the topic list" ); - assert.ok( - !exists(".group-notifications-button"), - "displays the group notifications button" - ); + assert + .dom(".group-notifications-button") + .doesNotExist("displays the group notifications button"); }); test("viewing messages of another user", async function (assert) { @@ -49,15 +47,13 @@ acceptance( await visit("/u/eviltrout/messages"); - assert.ok( - !exists(".messages-nav li a.new"), - "it does not display new filter" - ); + assert + .dom(".messages-nav li a.new") + .doesNotExist("it does not display new filter"); - assert.ok( - !exists(".messages-nav li a.unread"), - "it does not display unread filter" - ); + assert + .dom(".messages-nav li a.unread") + .doesNotExist("it does not display unread filter"); }); } ); @@ -304,11 +300,11 @@ acceptance("User Private Messages - sorting", function (needs) { test("order by posts_count", async function (assert) { await visit("/u/eviltrout/messages"); - assert.ok(exists(".topic-list-header th.posts.sortable"), "is sortable"); + assert.dom(".topic-list-header th.posts.sortable").exists("is sortable"); await click(".topic-list-header th.posts.sortable"); - assert.ok(exists(".topic-list-header th.posts.sortable.sorting"), "sorted"); + assert.dom(".topic-list-header th.posts.sortable.sorting").exists("sorted"); }); }); @@ -326,10 +322,9 @@ acceptance( actingUserId: 5, }); - assert.ok( - !exists(".show-mores"), - `does not display the topic incoming info` - ); + assert + .dom(".show-mores") + .doesNotExist(`does not display the topic incoming info`); }); test("incoming group archive message on inbox and archive filter", async function (assert) { @@ -341,10 +336,9 @@ acceptance( await publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 }); - assert.ok( - exists(".show-mores"), - `${url} displays the topic incoming info` - ); + assert + .dom(".show-mores") + .exists(`${url} displays the topic incoming info`); } for (const url of [ @@ -355,10 +349,9 @@ acceptance( await publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 }); - assert.ok( - !exists(".show-mores"), - `${url} does not display the topic incoming info` - ); + assert + .dom(".show-mores") + .doesNotExist(`${url} does not display the topic incoming info`); } }); @@ -392,7 +385,7 @@ acceptance( "displays the right count" ); - assert.ok(exists(".show-mores"), "displays the topic incoming info"); + assert.dom(".show-mores").exists("displays the topic incoming info"); await publishNewToMessageBus({ topicId: 2 }); @@ -402,7 +395,7 @@ acceptance( "displays the right count" ); - assert.ok(exists(".show-mores"), "displays the topic incoming info"); + assert.dom(".show-mores").exists("displays the topic incoming info"); }); test("incoming unread messages while viewing unread", async function (assert) { @@ -416,7 +409,7 @@ acceptance( "displays the right count" ); - assert.ok(exists(".show-mores"), "displays the topic incoming info"); + assert.dom(".show-mores").exists("displays the topic incoming info"); }); test("incoming unread and new messages while viewing group unread", async function (assert) { @@ -439,7 +432,7 @@ acceptance( "displays the right count" ); - assert.ok(exists(".show-mores"), "displays the topic incoming info"); + assert.dom(".show-mores").exists("displays the topic incoming info"); await visit("/u/charlie/messages/unread"); @@ -464,10 +457,9 @@ acceptance( await visit("/u/charlie/messages"); - assert.ok( - !exists(".show-mores"), - "does not display the topic incoming info" - ); + assert + .dom(".show-mores") + .doesNotExist("does not display the topic incoming info"); }); test("dismissing all unread messages", async function (assert) { @@ -640,10 +632,9 @@ acceptance( "displays the right topic list" ); - assert.ok( - exists(".group-notifications-button"), - "displays the group notifications button" - ); + assert + .dom(".group-notifications-button") + .exists("displays the group notifications button"); }); test("navigating between user messages route with dropdown", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js index 599a29bea69..ab334350f24 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js @@ -1,11 +1,7 @@ import { click, currentURL, visit } from "@ember/test-helpers"; import { test } from "qunit"; import userFixtures from "discourse/tests/fixtures/user-fixtures"; -import { - acceptance, - exists, - query, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { cloneJSON } from "discourse-common/lib/object"; import I18n from "discourse-i18n"; @@ -17,13 +13,13 @@ acceptance("User Profile - Summary", function (needs) { test("Viewing Summary", async function (assert) { await visit("/u/eviltrout/summary"); - assert.ok(exists(".replies-section li a"), "replies"); - assert.ok(exists(".topics-section li a"), "topics"); - assert.ok(exists(".links-section li a"), "links"); - assert.ok(exists(".replied-section .user-info"), "liked by"); - assert.ok(exists(".liked-by-section .user-info"), "liked by"); - assert.ok(exists(".liked-section .user-info"), "liked"); - assert.ok(exists(".badges-section .badge-card"), "badges"); + assert.dom(".replies-section li a").exists("replies"); + assert.dom(".topics-section li a").exists("topics"); + assert.dom(".links-section li a").exists("links"); + assert.dom(".replied-section .user-info").exists("liked by"); + assert.dom(".liked-by-section .user-info").exists("liked by"); + assert.dom(".liked-section .user-info").exists("liked"); + assert.dom(".badges-section .badge-card").exists("badges"); assert .dom(".top-categories-section .category-link") .exists("top categories"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-status-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-status-test.js index 85d7118a66b..a6d6500d140 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-status-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-status-test.js @@ -2,7 +2,6 @@ import { click, fillIn, visit } from "@ember/test-helpers"; import { test } from "qunit"; import { acceptance, - exists, publishToMessageBus, query, updateCurrentUser, @@ -122,10 +121,10 @@ acceptance("User Status", function (needs) { await visit("/"); await openUserStatusModal(); - assert.ok(exists(`.d-icon-discourse-emojis`), "empty status icon is shown"); + assert.dom(".d-icon-discourse-emojis").exists("empty status icon is shown"); await click(".btn-emoji"); - assert.ok(exists(".emoji-picker.opened"), "emoji picker is opened"); + assert.dom(".emoji-picker.opened").exists("emoji picker is opened"); await fillIn(".emoji-picker-content .filter", userStatusEmoji); await click(".results .emoji"); @@ -249,7 +248,7 @@ acceptance("User Status", function (needs) { await openUserStatusModal(); await pickEmoji(userStatusEmoji); - assert.ok(exists(`.btn-primary[disabled]`), "the save button is disabled"); + assert.dom(".btn-primary").isDisabled("the save button is disabled"); }); test("sets default status emoji automatically after user started inputting status description", async function (assert) { @@ -323,7 +322,7 @@ acceptance("User Status", function (needs) { await click(".btn.delete-status"); await openUserStatusModal(); - assert.ok(exists(`.d-icon-discourse-emojis`), "empty status icon is shown"); + assert.dom(".d-icon-discourse-emojis").exists("empty status icon is shown"); assert.equal( query(".user-status-description").value, "", @@ -496,7 +495,7 @@ acceptance("User Status - user menu", function (needs) { await click(".header-dropdown-toggle.current-user button"); await click("#user-menu-button-profile"); - assert.ok(exists("li.set-user-status .btn"), "shows the button"); + assert.dom("li.set-user-status .btn").exists("shows the button"); assert .dom("li.set-user-status svg.d-icon-circle-plus") .exists("shows the icon on the button"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-test.js index 4d39bc902eb..bce764e6b74 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-test.js @@ -10,7 +10,6 @@ import { test } from "qunit"; import userFixtures from "discourse/tests/fixtures/user-fixtures"; import { acceptance, - exists, publishToMessageBus, query, queryAll, @@ -112,12 +111,12 @@ acceptance("User Routes", function (needs) { "userActivity.index", "it defaults to activity" ); - assert.ok(exists(".container.viewing-self"), "has the viewing-self class"); + assert.dom(".container.viewing-self").exists("has the viewing-self class"); }); test("Viewing Drafts", async function (assert) { await visit("/u/eviltrout/activity/drafts"); - assert.ok(exists(".user-stream"), "has drafts stream"); + assert.dom(".user-stream").exists("has drafts stream"); assert .dom(".user-stream .user-stream-item-draft-actions") .exists("has draft action buttons"); @@ -168,7 +167,7 @@ acceptance("User Routes - Moderator viewing warnings", function (needs) { document.body.classList.contains("user-messages-page"), "has the body class" ); - assert.ok(exists("div.alert-info"), "has the permissions alert"); + assert.dom("div.alert-info").exists("has the permissions alert"); }); }); @@ -276,10 +275,9 @@ acceptance( test("Notification level is set to normal and can be changed to muted", async function (assert) { await visit("/u/charlie"); - assert.ok( - exists(".user-notifications-dropdown"), - "Notification level dropdown is present" - ); + assert + .dom(".user-notifications-dropdown") + .exists("notification level dropdown is present"); const dropdown = selectKit(".user-notifications-dropdown"); await dropdown.expand(); @@ -316,10 +314,9 @@ acceptance( }); test("Notification level can be changed to ignored", async function (assert) { await visit("/u/charlie"); - assert.ok( - exists(".user-notifications-dropdown"), - "Notification level dropdown is present" - ); + assert + .dom(".user-notifications-dropdown") + .exists("notification level dropdown is present"); const notificationLevelDropdown = selectKit( ".user-notifications-dropdown" diff --git a/app/assets/javascripts/discourse/tests/acceptance/users-test.js b/app/assets/javascripts/discourse/tests/acceptance/users-test.js index 47543737508..3f722a6caa5 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/users-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/users-test.js @@ -4,7 +4,6 @@ import directoryFixtures from "discourse/tests/fixtures/directory-fixtures"; import pretender, { response } from "discourse/tests/helpers/create-pretender"; import { acceptance, - exists, query, queryAll, } from "discourse/tests/helpers/qunit-helpers"; @@ -25,7 +24,7 @@ acceptance("User Directory", function () { test("Visit All Time", async function (assert) { await visit("/u?period=all"); - assert.ok(exists(".time-read"), "has time read column"); + assert.dom(".time-read").exists("has time read column"); }); test("Visit Without Usernames", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/addons/truth-helpers/integration/helpers/includes-test.js b/app/assets/javascripts/discourse/tests/addons/truth-helpers/integration/helpers/includes-test.js index 2e305494b74..bb5e91046a2 100644 --- a/app/assets/javascripts/discourse/tests/addons/truth-helpers/integration/helpers/includes-test.js +++ b/app/assets/javascripts/discourse/tests/addons/truth-helpers/integration/helpers/includes-test.js @@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { assert, module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; module("Addons | truth-helpers | Integration | includes", function (hooks) { setupRenderingTest(hooks); @@ -14,14 +13,14 @@ module("Addons | truth-helpers | Integration | includes", function (hooks) { hbs`{{#if (includes this.foo this.bar)}}{{/if}}` ); - assert.ok(exists(".test"), "it returns true when element is found"); + assert.dom(".test").exists("is true when element is found"); this.bar = 2; await render( hbs`{{#if (includes this.foo this.bar)}}{{/if}}` ); - assert.notOk(exists(".test"), "it returns false when element is not found"); + assert.dom(".test").doesNotExist("is false when element is not found"); }); test("when using a string", async function () { @@ -31,13 +30,13 @@ module("Addons | truth-helpers | Integration | includes", function (hooks) { hbs`{{#if (includes this.foo this.bar)}}{{/if}}` ); - assert.ok(exists(".test"), "it returns true when element is found"); + assert.dom(".test").exists("is true when element is found"); this.bar = "b"; await render( hbs`{{#if (includes this.foo this.bar)}}{{/if}}` ); - assert.notOk(exists(".test"), "it returns false when element is not found"); + assert.dom(".test").doesNotExist("is false when element is not found"); }); }); diff --git a/app/assets/javascripts/discourse/tests/integration/components/bookmark-icon-test.js b/app/assets/javascripts/discourse/tests/integration/components/bookmark-icon-test.js index 82355059c3f..f36735feb3c 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/bookmark-icon-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/bookmark-icon-test.js @@ -5,7 +5,7 @@ import { formattedReminderTime } from "discourse/lib/bookmark"; import { tomorrow } from "discourse/lib/time-utils"; import Bookmark from "discourse/models/bookmark"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { query } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; module("Integration | Component | bookmark-icon", function (hooks) { @@ -22,9 +22,9 @@ module("Integration | Component | bookmark-icon", function (hooks) { await render(hbs``); - assert.ok( - exists(".d-icon-discourse-bookmark-clock.bookmark-icon__bookmarked") - ); + assert + .dom(".d-icon-discourse-bookmark-clock.bookmark-icon__bookmarked") + .exists(); assert.strictEqual( query(".svg-icon-title").title, I18n.t("bookmarks.created_with_reminder_generic", { diff --git a/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js index 97cb045dbf3..410d36dc0ae 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js @@ -3,7 +3,6 @@ import { click, render, triggerKeyEvent } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; import { withSilencedDeprecationsAsync } from "discourse-common/lib/deprecated"; import I18n from "discourse-i18n"; @@ -13,36 +12,36 @@ module("Integration | Component | d-button", function (hooks) { test("icon only button", async function (assert) { await render(hbs``); - assert.ok(exists("button.btn.btn-icon.no-text"), "it has all the classes"); - assert.ok(exists("button .d-icon.d-icon-plus"), "it has the icon"); - assert.dom("button").hasAttribute("tabindex", "3", "it has the tabindex"); + assert.dom("button.btn.btn-icon.no-text").exists("has all the classes"); + assert.dom("button .d-icon.d-icon-plus").exists("has the icon"); + assert.dom("button").hasAttribute("tabindex", "3", "has the tabindex"); }); test("icon and text button", async function (assert) { await render(hbs``); - assert.ok(exists("button.btn.btn-icon-text"), "it has all the classes"); - assert.ok(exists("button .d-icon.d-icon-plus"), "it has the icon"); - assert.ok(exists("button span.d-button-label"), "it has the label"); + assert.dom("button.btn.btn-icon-text").exists("has all the classes"); + assert.dom("button .d-icon.d-icon-plus").exists("has the icon"); + assert.dom("button span.d-button-label").exists("has the label"); }); test("text only button", async function (assert) { await render(hbs``); - assert.ok(exists("button.btn.btn-text"), "it has all the classes"); - assert.ok(exists("button span.d-button-label"), "it has the label"); + assert.dom("button.btn.btn-text").exists("has all the classes"); + assert.dom("button span.d-button-label").exists("has the label"); }); test("form attribute", async function (assert) { await render(hbs``); - assert.ok(exists("button[form=login-form]"), "it has the form attribute"); + assert.dom("button[form=login-form]").exists("has the form attribute"); }); test("link-styled button", async function (assert) { await render(hbs``); - assert.ok(exists("button.btn-link:not(.btn)"), "it has the right classes"); + assert.dom("button.btn-link:not(.btn)").exists("has the right classes"); }); test("isLoading button", async function (assert) { @@ -52,19 +51,15 @@ module("Integration | Component | d-button", function (hooks) { assert .dom("button.is-loading .loading-icon") - .exists("it has a spinner showing"); - assert - .dom("button[disabled]") - .exists("while loading the button is disabled"); + .exists("has a spinner showing"); + assert.dom("button").isDisabled("while loading the button is disabled"); this.set("isLoading", false); assert .dom("button .loading-icon") - .doesNotExist("it doesn't have a spinner showing"); - assert - .dom("button:not([disabled])") - .exists("while not loading the button is enabled"); + .doesNotExist("doesn't have a spinner showing"); + assert.dom("button").isEnabled("while not loading the button is enabled"); }); test("button without isLoading attribute", async function (assert) { @@ -72,11 +67,11 @@ module("Integration | Component | d-button", function (hooks) { assert .dom("button.is-loading") - .doesNotExist("it doesn't have class is-loading"); + .doesNotExist("doesn't have class is-loading"); assert .dom("button .loading-icon") - .doesNotExist("it doesn't have a spinner showing"); - assert.notOk(exists("button[disabled]"), "it isn't disabled"); + .doesNotExist("doesn't have a spinner showing"); + assert.dom("button").isNotDisabled(); }); test("isLoading button explicitly set to undefined state", async function (assert) { @@ -86,11 +81,11 @@ module("Integration | Component | d-button", function (hooks) { assert .dom("button.is-loading") - .doesNotExist("it doesn't have class is-loading"); + .doesNotExist("doesn't have class is-loading"); assert .dom("button .loading-icon") - .doesNotExist("it doesn't have a spinner showing"); - assert.notOk(exists("button[disabled]"), "it isn't disabled"); + .doesNotExist("doesn't have a spinner showing"); + assert.dom("button").isNotDisabled(); }); test("disabled button", async function (assert) { @@ -98,10 +93,10 @@ module("Integration | Component | d-button", function (hooks) { await render(hbs``); - assert.ok(exists("button[disabled]"), "the button is disabled"); + assert.dom("button").isDisabled(); this.set("disabled", false); - assert.ok(exists("button:not([disabled])"), "the button is enabled"); + assert.dom("button").isEnabled(); }); test("aria-label", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/d-toggle-switch-test.js b/app/assets/javascripts/discourse/tests/integration/components/d-toggle-switch-test.js index ad50e5d1789..dfcea668ce1 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/d-toggle-switch-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/d-toggle-switch-test.js @@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; module("Integration | Component | d-toggle-switch", function (hooks) { @@ -13,7 +12,7 @@ module("Integration | Component | d-toggle-switch", function (hooks) { await render(hbs``); - assert.ok(exists(".d-toggle-switch"), "it renders a toggle switch"); + assert.dom(".d-toggle-switch").exists("renders a toggle switch"); assert.dom(".d-toggle-switch__checkbox").hasAria("checked", "false"); }); @@ -22,7 +21,7 @@ module("Integration | Component | d-toggle-switch", function (hooks) { await render(hbs``); - assert.ok(exists(".d-toggle-switch"), "it renders a toggle switch"); + assert.dom(".d-toggle-switch").exists("renders a toggle switch"); assert.dom(".d-toggle-switch__checkbox").hasAria("checked", "true"); }); diff --git a/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js index 1c3bce47457..6b9d60e3fd4 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js @@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { query } from "discourse/tests/helpers/qunit-helpers"; function dateInput() { return query(".date-picker"); @@ -61,7 +61,7 @@ module("Integration | Component | date-time-input", function (hooks) { hbs`` ); - assert.notOk(exists(timeInput())); + assert.dom(".d-time-input .combo-box-header").doesNotExist(); }); test("supports swapping timezone without changing visible date/time", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/checkbox-test.js b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/checkbox-test.js index 56ce883557b..c7d094c6c3c 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/checkbox-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/checkbox-test.js @@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; module( "Integration | Component | form-template-field | checkbox", @@ -12,12 +11,11 @@ module( test("renders a checkbox input", async function (assert) { await render(hbs``); - assert.ok( - exists( + assert + .dom( ".form-template-field[data-field-type='checkbox'] input[type='checkbox']" - ), - "A checkbox component exists" - ); + ) + .exists("a checkbox component exists"); }); test("renders a checkbox with a label", async function (assert) { @@ -30,12 +28,11 @@ module( hbs`` ); - assert.ok( - exists( + assert + .dom( ".form-template-field[data-field-type='checkbox'] input[type='checkbox']" - ), - "A checkbox component exists" - ); + ) + .exists("a checkbox component exists"); assert.dom(".form-template-field__label").hasText("Click this box"); }); diff --git a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/dropdown-test.js b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/dropdown-test.js index a85f2309c86..998bedcf833 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/dropdown-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/dropdown-test.js @@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query, queryAll } from "discourse/tests/helpers/qunit-helpers"; +import { query, queryAll } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; module( @@ -21,10 +21,9 @@ module( await render( hbs`` ); - assert.ok( - exists(".form-template-field__dropdown"), - "A dropdown component exists" - ); + assert + .dom(".form-template-field__dropdown") + .exists("a dropdown component exists"); const dropdown = queryAll( ".form-template-field__dropdown option:not(.form-template-field__dropdown-placeholder)" @@ -60,10 +59,9 @@ module( await render( hbs`` ); - assert.ok( - exists(".form-template-field__dropdown"), - "A dropdown component exists" - ); + assert + .dom(".form-template-field__dropdown") + .exists("a dropdown component exists"); assert.strictEqual( query(".form-template-field__dropdown-placeholder").innerText, diff --git a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/input-test.js b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/input-test.js index 00549fdd9b2..5e2a76c27c3 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/input-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/input-test.js @@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { query } from "discourse/tests/helpers/qunit-helpers"; module( "Integration | Component | form-template-field | input", @@ -12,12 +12,9 @@ module( test("renders a text input", async function (assert) { await render(hbs``); - assert.ok( - exists( - ".form-template-field[data-field-type='input'] input[type='text']" - ), - "A text input component exists" - ); + assert + .dom(".form-template-field[data-field-type='input'] input[type='text']") + .exists("a text input component exists"); }); test("renders a text input with attributes", async function (assert) { @@ -31,12 +28,9 @@ module( hbs`` ); - assert.ok( - exists( - ".form-template-field[data-field-type='input'] input[type='text']" - ), - "A text input component exists" - ); + assert + .dom(".form-template-field[data-field-type='input'] input[type='text']") + .exists("a text input component exists"); assert.dom(".form-template-field__label").hasText("My text label"); assert.strictEqual( diff --git a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/multi-select-test.js b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/multi-select-test.js index 414d5ed77bc..27f3e2b3d34 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/multi-select-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/multi-select-test.js @@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query, queryAll } from "discourse/tests/helpers/qunit-helpers"; +import { query, queryAll } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; module( @@ -22,10 +22,9 @@ module( await render( hbs`` ); - assert.ok( - exists(".form-template-field__multi-select"), - "A multiselect component exists" - ); + assert + .dom(".form-template-field__multi-select") + .exists("a multiselect component exists"); const dropdown = queryAll( ".form-template-field__multi-select option:not(.form-template-field__multi-select-placeholder)" @@ -61,10 +60,9 @@ module( await render( hbs`` ); - assert.ok( - exists(".form-template-field__multi-select"), - "A multiselect dropdown component exists" - ); + assert + .dom(".form-template-field__multi-select") + .exists("a multiselect dropdown component exists"); assert.strictEqual( query(".form-template-field__multi-select-placeholder").innerText, diff --git a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/textarea-test.js b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/textarea-test.js index 4ee04f96407..ca8e95c9f8d 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/textarea-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/textarea-test.js @@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { query } from "discourse/tests/helpers/qunit-helpers"; module( "Integration | Component | form-template-field | textarea", @@ -12,10 +12,9 @@ module( test("renders a textarea input", async function (assert) { await render(hbs``); - assert.ok( - exists(".form-template-field__textarea"), - "A textarea input component exists" - ); + assert + .dom(".form-template-field__textarea") + .exists("a textarea input component exists"); }); test("renders a text input with attributes", async function (assert) { @@ -29,10 +28,9 @@ module( hbs`` ); - assert.ok( - exists(".form-template-field__textarea"), - "A textarea input component exists" - ); + assert + .dom(".form-template-field__textarea") + .exists("a textarea input component exists"); assert.dom(".form-template-field__label").hasText("My text label"); assert.strictEqual( diff --git a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/wrapper-test.js b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/wrapper-test.js index c289de94d84..6c3af8452c9 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/form-template-field/wrapper-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/form-template-field/wrapper-test.js @@ -3,7 +3,6 @@ import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import pretender, { response } from "discourse/tests/helpers/create-pretender"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; module( "Integration | Component | form-template-field | wrapper", @@ -19,7 +18,7 @@ module( assert .dom(".form-template-field") .doesNotExist("A form template field should not exist"); - assert.ok(exists(".alert"), "An alert message should exist"); + assert.dom(".alert").exists("an alert message should exist"); }); test("renders a component based on the component type found in the content YAML", async function (assert) { @@ -44,10 +43,9 @@ module( ); componentTypes.forEach((componentType) => { - assert.ok( - exists(`.form-template-field[data-field-type='${componentType}']`), - `${componentType} component exists` - ); + assert + .dom(`.form-template-field[data-field-type='${componentType}']`) + .exists(`${componentType} component exists`); }); }); @@ -95,10 +93,9 @@ module( hbs`` ); - assert.ok( - exists(`.form-template-field[data-field-type='checkbox']`), - `Checkbox component renders` - ); + assert + .dom(`.form-template-field[data-field-type='checkbox']`) + .exists("checkbox component renders"); }); } ); diff --git a/app/assets/javascripts/discourse/tests/integration/components/group-membership-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/group-membership-button-test.js index d40186ad103..41b64884164 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/group-membership-button-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/group-membership-button-test.js @@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { count, exists } from "discourse/tests/helpers/qunit-helpers"; +import { count } from "discourse/tests/helpers/qunit-helpers"; module("Integration | Component | group-membership-button", function (hooks) { setupRenderingTest(hooks); @@ -22,7 +22,7 @@ module("Integration | Component | group-membership-button", function (hooks) { .doesNotExist("can't join group if user is already in the group"); this.set("model.is_group_user", false); - assert.ok(exists(".group-index-join"), "allowed to join group"); + assert.dom(".group-index-join").exists("allowed to join group"); }); test("canLeaveGroup", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/light-dark-img-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/light-dark-img-test.gjs index 571f4004d7a..707303d780a 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/light-dark-img-test.gjs +++ b/app/assets/javascripts/discourse/tests/integration/components/light-dark-img-test.gjs @@ -3,7 +3,7 @@ import { render } from "@ember/test-helpers"; import { module, test } from "qunit"; import LightDarkImg from "discourse/components/light-dark-img"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { count, exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { count, query } from "discourse/tests/helpers/qunit-helpers"; const lightSrc = { url: "/images/light.jpg", width: 376, height: 500 }; const darkSrc = { url: "/images/light.jpg", width: 432, height: 298 }; @@ -23,9 +23,9 @@ module("Integration | Component | light-dark-img", function (hooks) { await render(); - assert.ok(!exists("picture"), "there is no picture tag"); - assert.ok(!exists("img"), "there is no img tag"); - assert.ok(!exists("source"), "there are no source tags"); + assert.dom("picture").doesNotExist("there is no picture tag"); + assert.dom("img").doesNotExist("there is no img tag"); + assert.dom("source").doesNotExist("there are no source tags"); }); test("light theme with only light image provided | dark mode not available", async function (assert) { @@ -34,14 +34,14 @@ module("Integration | Component | light-dark-img", function (hooks) { await render(); - assert.ok(!exists("picture"), "there is no picture tag"); + assert.dom("picture").doesNotExist("there is no picture tag"); assert.strictEqual(count("img"), 1, "there is an img tag"); assert.strictEqual( query("img").getAttribute("src"), lightSrc.url, "the img src is the light image" ); - assert.ok(!exists("source"), "there are no source tags"); + assert.dom("source").doesNotExist("there are no source tags"); }); test("light theme with light and dark images provided | dark mode not available", async function (assert) { @@ -52,14 +52,14 @@ module("Integration | Component | light-dark-img", function (hooks) { ); - assert.ok(!exists("picture"), "there is no picture tag"); + assert.dom("picture").doesNotExist("there is no picture tag"); assert.strictEqual(count("img"), 1, "there is an img tag"); assert.strictEqual( query("img").getAttribute("src"), lightSrc.url, "the img src is the light image" ); - assert.ok(!exists("source"), "there are no source tags"); + assert.dom("source").doesNotExist("there are no source tags"); }); test("light theme with no images provided | dark mode available", async function (assert) { @@ -68,9 +68,9 @@ module("Integration | Component | light-dark-img", function (hooks) { await render(); - assert.ok(!exists("picture"), "there is no picture tag"); - assert.ok(!exists("img"), "there is no img tag"); - assert.ok(!exists("source"), "there are no source tags"); + assert.dom("picture").doesNotExist("there is no picture tag"); + assert.dom("img").doesNotExist("there is no img tag"); + assert.dom("source").doesNotExist("there are no source tags"); }); test("light theme with only light image provided | dark mode available", async function (assert) { @@ -79,14 +79,14 @@ module("Integration | Component | light-dark-img", function (hooks) { await render(); - assert.ok(!exists("picture"), "there is no picture tag"); + assert.dom("picture").doesNotExist("there is no picture tag"); assert.strictEqual(count("img"), 1, "there is an img tag"); assert.strictEqual( query("img").getAttribute("src"), lightSrc.url, "the img src is the light image" ); - assert.ok(!exists("source"), "there are no source tags"); + assert.dom("source").doesNotExist("there are no source tags"); }); test("light theme with light and dark images provided | dark mode available", async function (assert) { @@ -118,9 +118,9 @@ module("Integration | Component | light-dark-img", function (hooks) { await render(); - assert.ok(!exists("picture"), "there is no picture tag"); - assert.ok(!exists("img"), "there is no img tag"); - assert.ok(!exists("source"), "there are no source tags"); + assert.dom("picture").doesNotExist("there is no picture tag"); + assert.dom("img").doesNotExist("there is no img tag"); + assert.dom("source").doesNotExist("there are no source tags"); }); test("dark theme with only light image provided | dark mode not available", async function (assert) { @@ -129,14 +129,14 @@ module("Integration | Component | light-dark-img", function (hooks) { await render(); - assert.ok(!exists("picture"), "there is no picture tag"); + assert.dom("picture").doesNotExist("there is no picture tag"); assert.strictEqual(count("img"), 1, "there is an img tag"); assert.strictEqual( query("img").getAttribute("src"), lightSrc.url, "the img src is the light image" ); - assert.ok(!exists("source"), "there are no source tags"); + assert.dom("source").doesNotExist("there are no source tags"); }); test("dark theme with light and dark images provided | dark mode not available", async function (assert) { @@ -168,9 +168,9 @@ module("Integration | Component | light-dark-img", function (hooks) { await render(); - assert.ok(!exists("picture"), "there is no picture tag"); - assert.ok(!exists("img"), "there is no img tag"); - assert.ok(!exists("source"), "there are no source tags"); + assert.dom("picture").doesNotExist("there is no picture tag"); + assert.dom("img").doesNotExist("there is no img tag"); + assert.dom("source").doesNotExist("there are no source tags"); }); test("dark theme with only light image provided | dark mode available", async function (assert) { @@ -179,14 +179,14 @@ module("Integration | Component | light-dark-img", function (hooks) { await render(); - assert.ok(!exists("picture"), "there is no picture tag"); + assert.dom("picture").doesNotExist("there is no picture tag"); assert.strictEqual(count("img"), 1, "there is an img tag"); assert.strictEqual( query("img").getAttribute("src"), lightSrc.url, "the img src is the light image" ); - assert.ok(!exists("source"), "there are no source tags"); + assert.dom("source").doesNotExist("there are no source tags"); }); test("dark theme with light and dark images provided | dark mode available", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/search-menu-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/search-menu-test.gjs index 6ca7aac74ac..92fafffe0a7 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/search-menu-test.gjs +++ b/app/assets/javascripts/discourse/tests/integration/components/search-menu-test.gjs @@ -6,7 +6,7 @@ import SearchMenu, { import searchFixtures from "discourse/tests/fixtures/search-fixtures"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import pretender, { response } from "discourse/tests/helpers/create-pretender"; -import { exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { query } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; // Note this isn't a full-fledge test of the search menu. Those tests are in @@ -36,7 +36,7 @@ module("Integration | Component | search-menu", function (hooks) { .dom(".show-advanced-search") .exists("it shows full page search button"); - assert.notOk(exists(".menu-panel"), "Menu panel is not rendered yet"); + assert.dom(".menu-panel").doesNotExist("Menu panel is not rendered yet"); await click("#search-term"); @@ -60,7 +60,7 @@ module("Integration | Component | search-menu", function (hooks) { await triggerKeyEvent("#search-term", "keydown", "Escape"); - assert.notOk(exists(".menu-panel"), "Menu panel is gone"); + assert.dom(".menu-panel").doesNotExist("Menu panel is gone"); await click("#search-term"); await click("#search-term"); diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/email-group-user-chooser-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/email-group-user-chooser-test.js index 7ba5a345e0b..c14c55ed595 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/email-group-user-chooser-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/email-group-user-chooser-test.js @@ -2,7 +2,7 @@ import { fillIn, render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, paste, query } from "discourse/tests/helpers/qunit-helpers"; +import { paste, query } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import pretender, { response } from "../../../helpers/create-pretender"; @@ -132,7 +132,7 @@ module( await this.subject.expand(); await fillIn(".filter-input", "test-user"); - assert.ok(exists(".user-status-message"), "user status is rendered"); + assert.dom(".user-status-message").exists("user status is rendered"); assert .dom(".user-status-message .emoji") .hasAttribute("alt", status.emoji, "status emoji is correct"); diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-test.js index e9111216eed..3314655765a 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-test.js @@ -2,11 +2,7 @@ import { fillIn, render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { - exists, - fakeTime, - queryAll, -} from "discourse/tests/helpers/qunit-helpers"; +import { fakeTime, queryAll } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import I18n from "discourse-i18n"; @@ -40,7 +36,7 @@ module( /> `); - assert.ok(exists(".future-date-input-selector"), "Selector is rendered"); + assert.dom(".future-date-input-selector").exists("selector is rendered"); assert.strictEqual( this.subject.header().label(), @@ -50,10 +46,9 @@ module( await this.subject.expand(); - assert.ok( - exists(".select-kit-collection"), - "List of options is rendered" - ); + assert + .dom(".select-kit-collection") + .exists("list of options is rendered"); }); test("renders default options", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/mini-tag-chooser-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/mini-tag-chooser-test.js index 2f3bea79758..94053f71711 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/mini-tag-chooser-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/mini-tag-chooser-test.js @@ -2,7 +2,7 @@ import { click, render, triggerKeyEvent } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query, queryAll } from "discourse/tests/helpers/qunit-helpers"; +import { query, queryAll } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import I18n from "discourse-i18n"; @@ -84,10 +84,9 @@ module( }) ); await this.subject.fillInFilter("dawg"); - assert.notOk( - exists(".select-kit-collection .select-kit-row"), - "it doesn’t show any options" - ); + assert + .dom(".select-kit-collection .select-kit-row") + .doesNotExist("doesn’t show any options"); }); test("required_tag_group", async function (assert) { @@ -122,19 +121,17 @@ module( await this.subject.expand(); await this.subject.fillInFilter("#"); - assert.notOk(exists(".select-kit-error"), "it doesn’t show any error"); - assert.notOk( - exists(".select-kit-row[data-value='#']"), - "it doesn’t allow to create this tag" - ); + assert.dom(".select-kit-error").doesNotExist("doesn’t show any error"); + assert + .dom(".select-kit-row[data-value='#']") + .doesNotExist("doesn't allow to create this tag"); await this.subject.fillInFilter("test"); assert.strictEqual(this.subject.filter().value(), "#test"); - assert.ok( - exists(".select-kit-row[data-value='test']"), - "it filters out the invalid char from the suggested tag" - ); + assert + .dom(".select-kit-row[data-value='test']") + .exists("filters out the invalid char from the suggested tag"); }); test("creating a tag over the length limit", async function (assert) { @@ -143,10 +140,9 @@ module( await this.subject.expand(); await this.subject.fillInFilter("foo"); - assert.ok( - exists(".select-kit-row[data-value='f']"), - "it forces the max length of the tag" - ); + assert + .dom(".select-kit-row[data-value='f']") + .exists("forces the max length of the tag"); }); test("values in hiddenFromPreview will not display in preview", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/sidebar/section-test.js b/app/assets/javascripts/discourse/tests/integration/components/sidebar/section-test.js index 09d52aeda9d..2ac58a46f49 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/sidebar/section-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/sidebar/section-test.js @@ -2,7 +2,6 @@ import { click, render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; module("Integration | Component | sidebar | section", function (hooks) { setupRenderingTest(hooks); @@ -43,7 +42,7 @@ module("Integration | Component | sidebar | section", function (hooks) { .doesNotExist("section is not displayed"); this.set("displaySection", true); - assert.ok(exists(".sidebar-section-wrapper"), "section is displayed"); + assert.dom(".sidebar-section-wrapper").exists("section is displayed"); }); test("can expand and collapse content when section is collapsible", async function (assert) { @@ -59,7 +58,7 @@ module("Integration | Component | sidebar | section", function (hooks) { this.headerActions = []; await render(template); - assert.ok(exists(".sidebar-section-content"), "shows content by default"); + assert.dom(".sidebar-section-content").exists("shows content by default"); await click(".sidebar-section-header-caret"); diff --git a/app/assets/javascripts/discourse/tests/integration/components/slow-mode-info-test.js b/app/assets/javascripts/discourse/tests/integration/components/slow-mode-info-test.js index 4423d218fc1..8f1200f0647 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/slow-mode-info-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/slow-mode-info-test.js @@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { count, exists } from "discourse/tests/helpers/qunit-helpers"; +import { count } from "discourse/tests/helpers/qunit-helpers"; module("Integration | Component | slow-mode-info", function (hooks) { setupRenderingTest(hooks); @@ -12,7 +12,7 @@ module("Integration | Component | slow-mode-info", function (hooks) { await render(hbs``); - assert.ok(!exists(".slow-mode-heading"), "it doesn't render the notice"); + assert.dom(".slow-mode-heading").doesNotExist("doesn't render the notice"); }); test("doesn't render if the slow mode is disabled", async function (assert) { @@ -20,7 +20,7 @@ module("Integration | Component | slow-mode-info", function (hooks) { await render(hbs``); - assert.ok(!exists(".slow-mode-heading"), "it doesn't render the notice"); + assert.dom(".slow-mode-heading").doesNotExist("doesn't render the notice"); }); test("renders if slow mode is enabled", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/time-shortcut-picker-test.js b/app/assets/javascripts/discourse/tests/integration/components/time-shortcut-picker-test.js index 46f78854324..6df1cef8075 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/time-shortcut-picker-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/time-shortcut-picker-test.js @@ -3,7 +3,6 @@ import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { - exists, fakeTime, query, queryAll, @@ -59,7 +58,7 @@ module("Integration | Component | time-shortcut-picker", function (hooks) { await render(hbs``); - assert.ok(exists("#tap_tile_later_this_week"), "it has later this week"); + assert.dom("#tap_tile_later_this_week").exists("has later this week"); }); test("does not show 'Later This Week' if today is >= Thursday", async function (assert) { @@ -100,7 +99,7 @@ module("Integration | Component | time-shortcut-picker", function (hooks) { await render(hbs``); - assert.ok(exists("#tap_tile_later_today"), "it does have later today"); + assert.dom("#tap_tile_later_today").exists("has later today"); }); test("does not show 'Later Today' if it is after 5pm", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/uppy-image-uploader-test.js b/app/assets/javascripts/discourse/tests/integration/components/uppy-image-uploader-test.js index 6ebb137575c..07c9064dd85 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/uppy-image-uploader-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/uppy-image-uploader-test.js @@ -2,7 +2,7 @@ import { click, render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { count, exists } from "discourse/tests/helpers/qunit-helpers"; +import { count } from "discourse/tests/helpers/qunit-helpers"; module("Integration | Component | uppy-image-uploader", function (hooks) { setupRenderingTest(hooks); @@ -48,7 +48,7 @@ module("Integration | Component | uppy-image-uploader", function (hooks) { "it displays the upload icon" ); - assert.ok(!exists(".d-icon-trash-can"), "it does not display trash icon"); + assert.dom(".d-icon-trash-can").doesNotExist("does not display trash icon"); assert .dom(".image-uploader-lightbox-btn") @@ -66,7 +66,7 @@ module("Integration | Component | uppy-image-uploader", function (hooks) { "it displays the upload icon" ); - assert.ok(!exists(".d-icon-trash-can"), "it does not display trash icon"); + assert.dom(".d-icon-trash-can").doesNotExist("does not display trash icon"); assert .dom(".image-uploader-lightbox-btn") diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-avatar-flair-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-avatar-flair-test.js index f902309bb4e..332aacda2bb 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-avatar-flair-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-avatar-flair-test.js @@ -3,7 +3,6 @@ import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { resetFlair } from "discourse/lib/avatar-flair"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; function setupSiteGroups(that) { that.site.groups = [ @@ -60,8 +59,8 @@ module("Integration | Component | user-avatar-flair", function (hooks) { await render(hbs``); - assert.ok(exists(".avatar-flair"), "it has the tag"); - assert.ok(exists("svg.d-icon-bars"), "it has the svg icon"); + assert.dom(".avatar-flair").exists("has the tag"); + assert.dom("svg.d-icon-bars").exists("has the svg icon"); assert.dom(".avatar-flair").hasStyle({ backgroundColor: "rgb(204, 0, 10)", color: "rgb(255, 255, 250)", @@ -79,8 +78,8 @@ module("Integration | Component | user-avatar-flair", function (hooks) { await render(hbs``); - assert.ok(exists(".avatar-flair"), "it has the tag"); - assert.ok(exists("svg.d-icon-bars"), "it has the svg icon"); + assert.dom(".avatar-flair").exists("has the tag"); + assert.dom("svg.d-icon-bars").exists("has the svg icon"); assert.dom(".avatar-flair").hasStyle({ backgroundColor: "rgb(204, 0, 5)", color: "rgb(255, 255, 245)", @@ -98,8 +97,8 @@ module("Integration | Component | user-avatar-flair", function (hooks) { await render(hbs``); - assert.ok(exists(".avatar-flair"), "it has the tag"); - assert.ok(exists("svg.d-icon-dice-two"), "it has the svg icon"); + assert.dom(".avatar-flair").exists("has the tag"); + assert.dom("svg.d-icon-dice-two").exists("has the svg icon"); assert.dom(".avatar-flair").hasStyle({ backgroundColor: "rgb(204, 0, 2)", color: "rgb(255, 255, 242)", @@ -117,7 +116,7 @@ module("Integration | Component | user-avatar-flair", function (hooks) { await render(hbs``); - assert.ok(!exists(".avatar-flair"), "it does not render a flair"); + assert.dom(".avatar-flair").doesNotExist("does not render a flair"); }); test("avatar flair for trust level with fallback", async function (assert) { @@ -131,8 +130,8 @@ module("Integration | Component | user-avatar-flair", function (hooks) { await render(hbs``); - assert.ok(exists(".avatar-flair"), "it has the tag"); - assert.ok(exists("svg.d-icon-dice-two"), "it has the svg icon"); + assert.dom(".avatar-flair").exists("has the tag"); + assert.dom("svg.d-icon-dice-two").exists("has the svg icon"); assert.dom(".avatar-flair").hasStyle({ backgroundColor: "rgb(204, 0, 2)", color: "rgb(255, 255, 242)", @@ -151,7 +150,7 @@ module("Integration | Component | user-avatar-flair", function (hooks) { await render(hbs``); - assert.ok(!exists(".avatar-flair"), "it does not render a flair"); + assert.dom(".avatar-flair").doesNotExist("does not render a flair"); }); test("avatar flair for primary group flair", async function (assert) { @@ -170,8 +169,8 @@ module("Integration | Component | user-avatar-flair", function (hooks) { await render(hbs``); - assert.ok(exists(".avatar-flair"), "it has the tag"); - assert.ok(exists("svg.d-icon-xmark"), "it has the svg icon"); + assert.dom(".avatar-flair").exists("has the tag"); + assert.dom("svg.d-icon-xmark").exists("has the svg icon"); assert.dom(".avatar-flair").hasStyle({ backgroundColor: "rgb(18, 52, 86)", color: "rgb(176, 176, 176)", @@ -188,6 +187,6 @@ module("Integration | Component | user-avatar-flair", function (hooks) { await render(hbs``); - assert.ok(!exists(".avatar-flair"), "it does not render a flair"); + assert.dom(".avatar-flair").doesNotExist("does not render a flair"); }); }); diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-info-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-info-test.js index 00c9e0a2e5a..7b891b7534d 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-info-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-info-test.js @@ -2,7 +2,7 @@ import { render, triggerEvent } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { query } from "discourse/tests/helpers/qunit-helpers"; module("Integration | Component | user-info", function (hooks) { setupRenderingTest(hooks); @@ -33,7 +33,7 @@ module("Integration | Component | user-info", function (hooks) { ); this.set("includeLink", true); - assert.ok(exists(`.name-line a[href="/u/${this.currentUser.username}"]`)); + assert.dom(`.name-line a[href="/u/${this.currentUser.username}"]`).exists(); this.set("includeLink", false); assert diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js index 23953dcc0e7..bc5ab83ac40 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js @@ -4,7 +4,7 @@ import { module, test } from "qunit"; import { NOTIFICATION_TYPES } from "discourse/tests/fixtures/concerns/notification-types"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import pretender, { response } from "discourse/tests/helpers/create-pretender"; -import { exists, query, queryAll } from "discourse/tests/helpers/qunit-helpers"; +import { query, queryAll } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; module( @@ -78,10 +78,9 @@ module( I18n.t("user.no_bookmarks_body", { icon: "" }).trim(), "empty state body is shown" ); - assert.ok( - exists(".empty-state-body svg.d-icon-bookmark"), - "icon is correctly rendered in the empty state body" - ); + assert + .dom(".empty-state-body svg.d-icon-bookmark") + .exists("icon is correctly rendered in the empty state body"); }); } ); diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.js index 23e1ec2f5dc..2be97ea7093 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.js @@ -11,7 +11,7 @@ import UserMenuReviewable from "discourse/models/user-menu-reviewable"; import { NOTIFICATION_TYPES } from "discourse/tests/fixtures/concerns/notification-types"; import PrivateMessagesFixture from "discourse/tests/fixtures/private-messages-fixtures"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { query } from "discourse/tests/helpers/qunit-helpers"; import { cloneJSON, deepMerge } from "discourse-common/lib/object"; import I18n from "discourse-i18n"; @@ -68,14 +68,12 @@ module( this.item.notification.read = true; await settled(); - assert.ok( - exists("li.read"), - "the item re-renders when the read property is updated" - ); - assert.notOk( - exists("li.unread"), - "the item re-renders when the read property is updated" - ); + assert + .dom("li.read") + .exists("the item re-renders when the read property is updated"); + assert + .dom("li.unread") + .doesNotExist("the item re-renders when the read property is updated"); }); test("pushes the notification type name to the classList", async function (assert) { @@ -95,10 +93,9 @@ module( ); await settled(); - assert.ok( - exists("li.private-message"), - "replaces underscores in type name with dashes" - ); + assert + .dom("li.private-message") + .exists("replaces underscores in type name with dashes"); }); test("pushes is-warning to the classList if the notification originates from a warning PM", async function (assert) { @@ -208,10 +205,11 @@ module( }) ); await render(template); - assert.ok( - exists("li a .item-description img.emoji"), - "emojis are unescaped when fancy_title is used for description" - ); + assert + .dom("li a .item-description img.emoji") + .exists( + "emojis are unescaped when fancy_title is used for description" + ); }); test("topic_title from data is emoji-unescaped safely", async function (assert) { @@ -232,10 +230,9 @@ module( "unsafe title with unescaped emoji", "topic_title is rendered safely" ); - assert.ok( - exists(".item-description img.emoji"), - "emoji is rendered correctly" - ); + assert + .dom(".item-description img.emoji") + .exists("emoji is rendered correctly"); }); test("various aspects can be customized according to the notification's render director", async function (assert) { @@ -289,10 +286,9 @@ module( await render(template); - assert.ok( - exists("li.additional.classes"), - "extra classes are included on the item" - ); + assert + .dom("li.additional.classes") + .exists("extra classes are included on the item"); const link = query("li a"); assert.ok( @@ -305,7 +301,7 @@ module( "link title is customized and rendered safely" ); - assert.ok(exists("svg.d-icon-wrench"), "icon is customized"); + assert.dom("svg.d-icon-wrench").exists("icon is customized"); const label = query("li .item-label"); assert.ok( @@ -356,7 +352,9 @@ module( ); await render(template); - assert.notOk(exists(".item-description"), "description is not rendered"); + assert + .dom(".item-description") + .doesNotExist("description is not rendered"); assert.strictEqual( query("li").textContent.trim(), "notification label", @@ -395,7 +393,7 @@ module( "notification description", "only notification description is displayed" ); - assert.notOk(exists(".item-label"), "label is not rendered"); + assert.dom(".item-label").doesNotExist("label is not rendered"); }); } ); diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js index 800c373586a..3ab8d53d66b 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js @@ -5,7 +5,7 @@ import { NOTIFICATION_TYPES } from "discourse/tests/fixtures/concerns/notificati import NotificationFixtures from "discourse/tests/fixtures/notification-fixtures"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import pretender, { response } from "discourse/tests/helpers/create-pretender"; -import { exists, query, queryAll } from "discourse/tests/helpers/qunit-helpers"; +import { query, queryAll } from "discourse/tests/helpers/qunit-helpers"; import { cloneJSON } from "discourse-common/lib/object"; import I18n from "discourse-i18n"; @@ -120,10 +120,9 @@ module( 2, "notifications list is refreshed" ); - assert.ok( - !exists(".panel-body-bottom .btn.notifications-dismiss"), - "dismiss button is not shown" - ); + assert + .dom(".panel-body-bottom .btn.notifications-dismiss") + .doesNotExist("dismiss button is not shown"); }); test("all notifications tab shows pending reviewables and sorts them with unread notifications based on their creation date", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-status-message-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-status-message-test.js index 39aa996a3b0..2fa74806454 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-status-message-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-status-message-test.js @@ -2,7 +2,7 @@ import { render, triggerEvent } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, fakeTime, query } from "discourse/tests/helpers/qunit-helpers"; +import { fakeTime, query } from "discourse/tests/helpers/qunit-helpers"; async function mouseenter() { await triggerEvent(query(".user-status-message"), "mousemove"); @@ -24,7 +24,7 @@ module("Integration | Component | user-status-message", function (hooks) { test("it renders user status emoji", async function (assert) { await render(hbs``); - assert.ok(exists("img.emoji[alt='tooth']"), "the status emoji is shown"); + assert.dom("img.emoji[alt='tooth']").exists("the status emoji is shown"); }); test("it renders status description if enabled", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/avatar-flair-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/avatar-flair-test.js index 6827c8ff4ef..f60951ff57c 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/widgets/avatar-flair-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/avatar-flair-test.js @@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; module("Integration | Component | Widget | avatar-flair", function (hooks) { setupRenderingTest(hooks); @@ -18,8 +17,8 @@ module("Integration | Component | Widget | avatar-flair", function (hooks) { hbs`` ); - assert.ok(exists(".avatar-flair"), "it has the tag"); - assert.ok(exists("svg.d-icon-bars"), "it has the svg icon"); + assert.dom(".avatar-flair").exists("has the tag"); + assert.dom("svg.d-icon-bars").exists("has the svg icon"); assert.dom(".avatar-flair").hasStyle({ backgroundColor: "rgb(204, 0, 0)", color: "rgb(255, 255, 255)", @@ -35,7 +34,7 @@ module("Integration | Component | Widget | avatar-flair", function (hooks) { hbs`` ); - assert.ok(exists(".avatar-flair"), "it has the tag"); - assert.ok(!exists("svg"), "it does not have an svg icon"); + assert.dom(".avatar-flair").exists("has the tag"); + assert.dom("svg").doesNotExist("does not have an svg icon"); }); }); diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/button-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/button-test.js index a2eabb0347c..017eef8c0f3 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/widgets/button-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/button-test.js @@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; module("Integration | Component | Widget | button", function (hooks) { setupRenderingTest(hooks); @@ -12,10 +11,8 @@ module("Integration | Component | Widget | button", function (hooks) { await render(hbs``); - assert.ok(exists("button.btn.btn-icon.no-text"), "it has all the classes"); - assert - .dom("button .d-icon.d-icon-far-face-smile") - .exists("it has the icon"); + assert.dom("button.btn.btn-icon.no-text").exists("has all the classes"); + assert.dom("button .d-icon.d-icon-far-face-smile").exists("has the icon"); }); test("icon and text button", async function (assert) { @@ -23,9 +20,9 @@ module("Integration | Component | Widget | button", function (hooks) { await render(hbs``); - assert.ok(exists("button.btn.btn-icon-text"), "it has all the classes"); - assert.ok(exists("button .d-icon.d-icon-plus"), "it has the icon"); - assert.ok(exists("button span.d-button-label"), "it has the label"); + assert.dom("button.btn.btn-icon-text").exists("has all the classes"); + assert.dom("button .d-icon.d-icon-plus").exists("has the icon"); + assert.dom("button span.d-button-label").exists("has the label"); }); test("emoji and text button", async function (assert) { @@ -33,9 +30,9 @@ module("Integration | Component | Widget | button", function (hooks) { await render(hbs``); - assert.ok(exists("button.widget-button"), "renders the widget"); - assert.ok(exists("button img.emoji"), "it renders the emoji"); - assert.ok(exists("button span.d-button-label"), "it renders the label"); + assert.dom("button.widget-button").exists("renders the widget"); + assert.dom("button img.emoji").exists("it renders the emoji"); + assert.dom("button span.d-button-label").exists("it renders the label"); }); test("text only button", async function (assert) { @@ -43,8 +40,8 @@ module("Integration | Component | Widget | button", function (hooks) { await render(hbs``); - assert.ok(exists("button.btn.btn-text"), "it has all the classes"); - assert.ok(exists("button span.d-button-label"), "it has the label"); + assert.dom("button.btn.btn-text").exists("has all the classes"); + assert.dom("button span.d-button-label").exists("has the label"); }); test("translatedLabel", async function (assert) { @@ -68,6 +65,8 @@ module("Integration | Component | Widget | button", function (hooks) { await render(hbs``); - assert.ok(!exists("button.btn.btn-icon.no-text"), "skips no-text class"); + assert + .dom("button.btn.btn-icon-text") + .doesNotHaveClass("no-text", "skips no-text class"); }); }); diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-menu-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-menu-test.js index d0d863af037..f57a6e665a9 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-menu-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-menu-test.js @@ -4,7 +4,7 @@ import { module, test } from "qunit"; import { h } from "virtual-dom"; import { withPluginApi } from "discourse/lib/plugin-api"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { count, exists } from "discourse/tests/helpers/qunit-helpers"; +import { count } from "discourse/tests/helpers/qunit-helpers"; import { resetPostMenuExtraButtons } from "discourse/widgets/post-menu"; import { createWidget } from "discourse/widgets/widget"; @@ -91,7 +91,7 @@ module("Integration | Component | Widget | post-menu", function (hooks) { await render(hbs``); - assert.ok(!exists(".actions .reply"), "it removes reply button"); + assert.dom(".actions .reply").doesNotExist("removes reply button"); }); test("does not remove button", async function (assert) { @@ -105,7 +105,7 @@ module("Integration | Component | Widget | post-menu", function (hooks) { await render(hbs``); - assert.ok(exists(".actions .reply"), "it does not remove reply button"); + assert.dom(".actions .reply").exists("does not remove reply button"); }); test("removes button", async function (assert) { @@ -117,7 +117,7 @@ module("Integration | Component | Widget | post-menu", function (hooks) { await render(hbs``); - assert.ok(!exists(".actions .reply"), "it removes reply button"); + assert.dom(".actions .reply").doesNotExist("removes reply button"); }); test("removes button when any callback evaluates to true", async function (assert) { @@ -130,7 +130,7 @@ module("Integration | Component | Widget | post-menu", function (hooks) { await render(hbs``); - assert.ok(!exists(".actions .reply"), "it removes reply button"); + assert.dom(".actions .reply").doesNotExist("removes reply button"); }); createWidget("post-menu-replacement", { @@ -154,8 +154,10 @@ module("Integration | Component | Widget | post-menu", function (hooks) { await render(hbs``); - assert.ok(exists("h1.post-menu-replacement"), "replacement is rendered"); - assert.ok(!exists(".actions .reply"), "reply button is replaced button"); + assert.dom("h1.post-menu-replacement").exists("replacement is rendered"); + assert + .dom(".actions .reply") + .doesNotExist("reply button is replaced button"); }); test("buttons are not replaced when shouldRender is false", async function (assert) { @@ -176,6 +178,6 @@ module("Integration | Component | Widget | post-menu", function (hooks) { assert .dom("h1.post-menu-replacement") .doesNotExist("replacement is not rendered"); - assert.ok(exists(".actions .reply"), "reply button is present"); + assert.dom(".actions .reply").exists("reply button is present"); }); }); diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-small-action-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-small-action-test.js index 19533e6f276..2a5883b1701 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-small-action-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-small-action-test.js @@ -3,7 +3,6 @@ import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { withPluginApi } from "discourse/lib/plugin-api"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; import { resetPostSmallActionClassesCallbacks } from "discourse/widgets/post-small-action"; module( @@ -30,10 +29,9 @@ module( hbs`` ); - assert.ok( - exists(".small-action-desc .small-action-edit"), - "it adds the edit small action button" - ); + assert + .dom(".small-action-desc .small-action-edit") + .exists("adds the edit small action button"); }); test("uses custom widget if actionDescriptionWidget", async function (assert) { @@ -43,10 +41,9 @@ module( hbs`` ); - assert.ok( - exists(".small-action .widget-button"), - "it adds the custom widget" - ); + assert + .dom(".small-action .widget-button") + .exists("adds the custom widget"); }); test("does not show edit button if canRecover even if canEdit", async function (assert) { @@ -56,14 +53,12 @@ module( hbs`` ); - assert.ok( - !exists(".small-action-desc .small-action-edit"), - "it does not add the edit small action button" - ); - assert.ok( - exists(".small-action-desc .small-action-recover"), - "it adds the recover small action button" - ); + assert + .dom(".small-action-desc .small-action-edit") + .doesNotExist("does not add the edit small action button"); + assert + .dom(".small-action-desc .small-action-recover") + .exists("adds the recover small action button"); }); test("shows delete button if canDelete", async function (assert) { @@ -73,10 +68,9 @@ module( hbs`` ); - assert.ok( - exists(".small-action-desc .small-action-delete"), - "it adds the delete small action button" - ); + assert + .dom(".small-action-desc .small-action-delete") + .exists("adds the delete small action button"); }); test("shows undo button if canRecover", async function (assert) { @@ -86,10 +80,9 @@ module( hbs`` ); - assert.ok( - exists(".small-action-desc .small-action-recover"), - "it adds the recover small action button" - ); + assert + .dom(".small-action-desc .small-action-recover") + .exists("adds the recover small action button"); }); test("`addPostSmallActionClassesCallback` plugin api", async function (assert) { @@ -120,10 +113,9 @@ module( hbs`` ); - assert.ok( - exists(".abcde"), - "it adds custom CSS class as registered from the plugin API" - ); + assert + .dom(".abcde") + .exists("adds custom CSS class as registered from the plugin API"); } finally { resetPostSmallActionClassesCallbacks(); } diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-test.js index c9e2e228d39..7dcaafc4c35 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-test.js @@ -4,7 +4,7 @@ import { click, render, triggerEvent } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { count, exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { count, query } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; module("Integration | Component | Widget | post", function (hooks) { @@ -21,8 +21,8 @@ module("Integration | Component | Widget | post", function (hooks) { await render(hbs``); - assert.ok(exists(".names"), "includes poster name"); - assert.ok(exists("a.post-date"), "includes post date"); + assert.dom(".names").exists("includes poster name"); + assert.dom("a.post-date").exists("includes post date"); }); test("post - links", async function (assert) { @@ -220,7 +220,7 @@ module("Integration | Component | Widget | post", function (hooks) { await render(hbs``); - assert.ok(exists(".actions button.share"), "it renders a share button"); + assert.dom(".actions button.share").exists("renders a share button"); }); test("copy link button", async function (assert) { @@ -301,7 +301,7 @@ module("Integration | Component | Widget | post", function (hooks) { await render(hbs``); - assert.ok(!exists("button.edit"), "button is not displayed"); + assert.dom("button.edit").doesNotExist("button is not displayed"); }); test("recover button", async function (assert) { @@ -333,7 +333,7 @@ module("Integration | Component | Widget | post", function (hooks) { await render(hbs``); - assert.ok(!exists("button.delete"), `button is not displayed`); + assert.dom("button.delete").doesNotExist("button is not displayed"); }); test(`delete topic button - can't delete when topic author without permission`, async function (assert) { @@ -375,7 +375,7 @@ module("Integration | Component | Widget | post", function (hooks) { await render(hbs``); - assert.ok(!exists("button.recover"), `button is not displayed`); + assert.dom("button.recover").doesNotExist("button is not displayed"); }); test("delete post button", async function (assert) { @@ -396,7 +396,7 @@ module("Integration | Component | Widget | post", function (hooks) { await render(hbs``); - assert.ok(!exists("button.delete"), `button is not displayed`); + assert.dom("button.delete").doesNotExist("button is not displayed"); }); test(`delete post button - can't delete, can't flag`, async function (assert) { @@ -408,8 +408,10 @@ module("Integration | Component | Widget | post", function (hooks) { await render(hbs``); - assert.ok(!exists("button.delete"), `delete button is not displayed`); - assert.ok(!exists("button.create-flag"), `flag button is not displayed`); + assert.dom("button.delete").doesNotExist("delete button is not displayed"); + assert + .dom("button.create-flag") + .doesNotExist("flag button is not displayed"); }); test("recover post button", async function (assert) { @@ -429,7 +431,7 @@ module("Integration | Component | Widget | post", function (hooks) { await render(hbs``); - assert.ok(!exists("button.recover"), `button is not displayed`); + assert.dom("button.recover").doesNotExist("button is not displayed"); }); test(`flagging`, async function (assert) { @@ -487,8 +489,8 @@ module("Integration | Component | Widget | post", function (hooks) { await render(hbs``); - assert.ok(!exists("a.reply-to-tab"), "hides the tab"); - assert.ok(!exists(".avoid-tab"), "doesn't have the avoid tab class"); + assert.dom("a.reply-to-tab").doesNotExist("hides the tab"); + assert.dom(".avoid-tab").doesNotExist("doesn't have the avoid tab class"); }); test("reply a few posts above (suppressed)", async function (assert) { @@ -500,7 +502,7 @@ module("Integration | Component | Widget | post", function (hooks) { await render(hbs``); - assert.ok(exists("a.reply-to-tab"), "shows the tab"); + assert.dom("a.reply-to-tab").exists("shows the tab"); assert.strictEqual(count(".avoid-tab"), 1, "has the avoid tab class"); }); @@ -540,7 +542,9 @@ module("Integration | Component | Widget | post", function (hooks) { `); - assert.ok(!exists(".topic-body .expand-hidden"), "button is not displayed"); + assert + .dom(".topic-body .expand-hidden") + .doesNotExist("button is not displayed"); }); test("expand first post", async function (assert) { @@ -553,7 +557,7 @@ module("Integration | Component | Widget | post", function (hooks) { ); await click(".topic-body .expand-post"); - assert.ok(!exists(".expand-post"), "button is gone"); + assert.dom(".expand-post").doesNotExist("button is gone"); }); test("can't bookmark", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/topic-status-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/topic-status-test.js index 5027b19bad7..8ea21e52b4d 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/widgets/topic-status-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/topic-status-test.js @@ -4,7 +4,6 @@ import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import TopicStatusIcons from "discourse/helpers/topic-status-icons"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; module("Integration | Component | Widget | topic-status", function (hooks) { setupRenderingTest(hooks); @@ -54,19 +53,21 @@ module("Integration | Component | Widget | topic-status", function (hooks) { hbs`` ); - assert.ok(exists(".topic-statuses .pinned"), "pinned icon is shown"); + assert.dom(".topic-statuses .pinned").exists("pinned icon is shown"); assert .dom(".topic-statuses .unpinned") .doesNotExist("unpinned icon is not shown"); await click(".topic-statuses .pin-toggle-button"); - assert.ok(!exists(".topic-statuses .pinned"), "pinned icon is not shown"); - assert.ok(exists(".topic-statuses .unpinned"), "unpinned icon is shown"); + assert + .dom(".topic-statuses .pinned") + .doesNotExist("pinned icon is not shown"); + assert.dom(".topic-statuses .unpinned").exists("unpinned icon is shown"); await click(".topic-statuses .pin-toggle-button"); - assert.ok(exists(".topic-statuses .pinned"), "pinned icon is shown"); + assert.dom(".topic-statuses .pinned").exists("pinned icon is shown"); assert .dom(".topic-statuses .unpinned") .doesNotExist("unpinned icon is not shown"); diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/widget-dropdown-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/widget-dropdown-test.js index bd0041b5cfd..393f90799db 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/widgets/widget-dropdown-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/widget-dropdown-test.js @@ -2,7 +2,7 @@ import { click, render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { query } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; const DEFAULT_CONTENT = { @@ -148,7 +148,7 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) { await render(TEMPLATE); - assert.ok(exists(header().querySelector(".d-icon-xmark"))); + assert.dom(".d-icon-xmark", header()).exists(); }); test("class", async function (assert) { @@ -185,7 +185,7 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) { await render(TEMPLATE); await toggle(); - assert.ok(exists(rowById(3).querySelector(".d-icon-xmark"))); + assert.dom(".d-icon-xmark", rowById(3)).exists(); }); test("content with html", async function (assert) { @@ -248,9 +248,9 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) { await render(TEMPLATE); - assert.ok( - exists("#my-dropdown .widget-dropdown-header .d-icon-caret-down") - ); + assert + .dom("#my-dropdown .widget-dropdown-header .d-icon-caret-down") + .exists(); }); test("disabled widget", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/helpers/category-badge-test.js b/app/assets/javascripts/discourse/tests/integration/helpers/category-badge-test.js index 28d18673949..604c6666b97 100644 --- a/app/assets/javascripts/discourse/tests/integration/helpers/category-badge-test.js +++ b/app/assets/javascripts/discourse/tests/integration/helpers/category-badge-test.js @@ -3,7 +3,6 @@ import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import Category from "discourse/models/category"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; module("Integration | Helper | category-badge", function (hooks) { setupRenderingTest(hooks); @@ -21,10 +20,10 @@ module("Integration | Helper | category-badge", function (hooks) { await render(hbs`{{category-badge this.category link=true}}`); - assert.ok( - exists( + assert + .dom( `a.badge-category__wrapper[href="/c/${this.category.slug}/${this.category.id}"]` ) - ); + .exists(); }); }); diff --git a/app/assets/javascripts/discourse/tests/integration/helpers/emoji-test.js b/app/assets/javascripts/discourse/tests/integration/helpers/emoji-test.js index 6023eed4179..e46cbc98cd9 100644 --- a/app/assets/javascripts/discourse/tests/integration/helpers/emoji-test.js +++ b/app/assets/javascripts/discourse/tests/integration/helpers/emoji-test.js @@ -2,14 +2,13 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; module("Integration | Helper | emoji", function (hooks) { setupRenderingTest(hooks); test("it renders", async function (assert) { await render(hbs`{{emoji "tada"}}`); - assert.ok(exists(`.emoji[title="tada"]`)); + assert.dom(`.emoji[title="tada"]`).exists(); }); test("it renders custom title", async function (assert) { @@ -18,6 +17,6 @@ module("Integration | Helper | emoji", function (hooks) { await render(hbs`{{emoji "tada" title=this.title}}`); - assert.ok(exists(`.emoji[title="${title}"]`)); + assert.dom(`.emoji[title="${title}"]`).exists(); }); }); diff --git a/app/assets/javascripts/discourse/tests/integration/helpers/html-safe-test.js b/app/assets/javascripts/discourse/tests/integration/helpers/html-safe-test.js index df614bbe01d..66c09dc3f1e 100644 --- a/app/assets/javascripts/discourse/tests/integration/helpers/html-safe-test.js +++ b/app/assets/javascripts/discourse/tests/integration/helpers/html-safe-test.js @@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; module("Integration | Helper | html-safe", function (hooks) { setupRenderingTest(hooks); @@ -12,6 +11,6 @@ module("Integration | Helper | html-safe", function (hooks) { await render(hbs`{{html-safe this.string}}`); - assert.ok(exists("p.cookies"), "it displays the string as html"); + assert.dom("p.cookies").exists("displays the string as html"); }); }); diff --git a/app/assets/javascripts/discourse/tests/unit/utils/decorators-test.js b/app/assets/javascripts/discourse/tests/unit/utils/decorators-test.js index b227eb34354..ba3745acc22 100644 --- a/app/assets/javascripts/discourse/tests/unit/utils/decorators-test.js +++ b/app/assets/javascripts/discourse/tests/unit/utils/decorators-test.js @@ -5,7 +5,6 @@ import { observes as nativeClassObserves } from "@ember-decorators/object"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; import { withSilencedDeprecations } from "discourse-common/lib/deprecated"; import discourseComputed, { afterRender, @@ -121,12 +120,12 @@ module("Unit | Utils | decorators", function (hooks) { await render(hbs``); - assert.ok(exists(document.querySelector(".foo-component"))); + assert.dom(".foo-component").exists(); assert.strictEqual(this.baz, 1); await clearRender(); - assert.ok(!exists(document.querySelector(".foo-component"))); + assert.dom(".foo-component").doesNotExist(); assert.strictEqual(this.baz, 1); }); diff --git a/plugins/automation/test/javascripts/integration/components/da-email-group-user-field-test.js b/plugins/automation/test/javascripts/integration/components/da-email-group-user-field-test.js index f69f57856f4..d082e3a79c4 100644 --- a/plugins/automation/test/javascripts/integration/components/da-email-group-user-field-test.js +++ b/plugins/automation/test/javascripts/integration/components/da-email-group-user-field-test.js @@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; module("Integration | Component | email-group-user-field", function (hooks) { setupRenderingTest(hooks); @@ -13,11 +12,10 @@ module("Integration | Component | email-group-user-field", function (hooks) { await render(template); assert.dom(".control-label").hasText("a label"); - assert.ok( - exists( + assert + .dom( ".controls details.select-kit.multi-select.user-chooser.email-group-user-chooser" - ), - "has email-group-user-chooser" - ); + ) + .exists("has email-group-user-chooser"); }); }); diff --git a/plugins/chat/test/javascripts/acceptance/chat-live-pane-test.js b/plugins/chat/test/javascripts/acceptance/chat-live-pane-test.js index 996c6ab4861..2c08102b1a2 100644 --- a/plugins/chat/test/javascripts/acceptance/chat-live-pane-test.js +++ b/plugins/chat/test/javascripts/acceptance/chat-live-pane-test.js @@ -1,6 +1,6 @@ import { click, visit } from "@ember/test-helpers"; import { skip } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance( "Discourse Chat - Chat live pane - handling 429 errors", @@ -57,7 +57,7 @@ acceptance( skip("Handles 429 errors by displaying an alert", async function (assert) { await visit("/chat/c/cat/1"); - assert.ok(exists(".dialog-content"), "We displayed a 429 error"); + assert.dom(".dialog-content").exists("displays the 429 error"); await click(".dialog-footer .btn-primary"); }); } diff --git a/plugins/chat/test/javascripts/components/channel-icon-test.gjs b/plugins/chat/test/javascripts/components/channel-icon-test.gjs index 8a5fce60e75..df328546d77 100644 --- a/plugins/chat/test/javascripts/components/channel-icon-test.gjs +++ b/plugins/chat/test/javascripts/components/channel-icon-test.gjs @@ -3,7 +3,7 @@ import { render } from "@ember/test-helpers"; import { module, test } from "qunit"; import CoreFabricators from "discourse/lib/fabricators"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { query } from "discourse/tests/helpers/qunit-helpers"; import ChannelIcon from "discourse/plugins/chat/discourse/components/channel-icon"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators"; import { CHATABLE_TYPES } from "discourse/plugins/chat/discourse/models/chat-channel"; @@ -30,7 +30,7 @@ module("Discourse Chat | Component | ", function (hooks) { await render(); - assert.false(exists(".xss")); + assert.dom(".xss").doesNotExist(); }); test("category channel - read restricted", async function (assert) { @@ -54,7 +54,7 @@ module("Discourse Chat | Component | ", function (hooks) { await render(); - assert.false(exists(".d-icon-lock")); + assert.dom(".d-icon-lock").doesNotExist(); }); test("dm channel - one user", async function (assert) { diff --git a/plugins/chat/test/javascripts/components/channel-name-test.gjs b/plugins/chat/test/javascripts/components/channel-name-test.gjs index ff0678d5f2f..cfde1462d14 100644 --- a/plugins/chat/test/javascripts/components/channel-name-test.gjs +++ b/plugins/chat/test/javascripts/components/channel-name-test.gjs @@ -3,7 +3,7 @@ import { render } from "@ember/test-helpers"; import { module, test } from "qunit"; import CoreFabricators from "discourse/lib/fabricators"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { query } from "discourse/tests/helpers/qunit-helpers"; import ChannelName from "discourse/plugins/chat/discourse/components/channel-name"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators"; import { CHATABLE_TYPES } from "discourse/plugins/chat/discourse/models/chat-channel"; @@ -29,7 +29,7 @@ module("Discourse Chat | Component | ", function (hooks) { await render(); - assert.false(exists(".xss")); + assert.dom(".xss").doesNotExist(); }); test("dm channel - one user", async function (assert) { @@ -121,6 +121,6 @@ module("Discourse Chat | Component | ", function (hooks) { ); - assert.false(exists(".chat-channel-unread-indicator")); + assert.dom(".chat-channel-unread-indicator").doesNotExist(); }); }); diff --git a/plugins/chat/test/javascripts/components/chat-channel-card-test.js b/plugins/chat/test/javascripts/components/chat-channel-card-test.js index db80cd150ea..0cd45e22b43 100644 --- a/plugins/chat/test/javascripts/components/chat-channel-card-test.js +++ b/plugins/chat/test/javascripts/components/chat-channel-card-test.js @@ -3,7 +3,7 @@ import { render } from "@ember/test-helpers"; import hbs from "htmlbars-inline-precompile"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { query } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators"; @@ -21,7 +21,7 @@ module("Discourse Chat | Component | chat-channel-card", function (hooks) { await render(hbs``); - assert.false(exists(".xss")); + assert.dom(".xss").doesNotExist(); }); test("escapes channel description", async function (assert) { @@ -29,7 +29,7 @@ module("Discourse Chat | Component | chat-channel-card", function (hooks) { await render(hbs``); - assert.false(exists(".xss")); + assert.dom(".xss").doesNotExist(); }); test("Closed channel", async function (assert) { @@ -80,7 +80,7 @@ module("Discourse Chat | Component | chat-channel-card", function (hooks) { this.channel.description = null; await render(hbs``); - assert.false(exists(".chat-channel-card__description")); + assert.dom(".chat-channel-card__description").doesNotExist(); }); test("Description", async function (assert) { diff --git a/plugins/chat/test/javascripts/components/chat-channel-preview-card-test.js b/plugins/chat/test/javascripts/components/chat-channel-preview-card-test.js index b58b542242f..b4d793fb742 100644 --- a/plugins/chat/test/javascripts/components/chat-channel-preview-card-test.js +++ b/plugins/chat/test/javascripts/components/chat-channel-preview-card-test.js @@ -3,7 +3,7 @@ import { render } from "@ember/test-helpers"; import hbs from "htmlbars-inline-precompile"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { query } from "discourse/tests/helpers/qunit-helpers"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators"; module( @@ -55,10 +55,11 @@ module( await render(hbs``); - assert.false( - exists(".chat-channel-preview-card__description"), - "no line is left for the channel description if there is none" - ); + assert + .dom(".chat-channel-preview-card__description") + .doesNotExist( + "no line is left for the channel description if there is none" + ); assert .dom(".chat-channel-preview-card.-no-description") @@ -85,10 +86,9 @@ module( this.channel.status = "closed"; await render(hbs``); - assert.false( - exists(".chat-channel-preview-card__join-channel-btn"), - "it does not show the join channel button" - ); + assert + .dom(".chat-channel-preview-card__join-channel-btn") + .doesNotExist("it does not show the join channel button"); }); } ); diff --git a/plugins/chat/test/javascripts/components/chat-composer-uploads-test.js b/plugins/chat/test/javascripts/components/chat-composer-uploads-test.js index c97dfa9ab59..1ae08e688c0 100644 --- a/plugins/chat/test/javascripts/components/chat-composer-uploads-test.js +++ b/plugins/chat/test/javascripts/components/chat-composer-uploads-test.js @@ -3,11 +3,7 @@ import hbs from "htmlbars-inline-precompile"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import pretender from "discourse/tests/helpers/create-pretender"; -import { - count, - createFile, - exists, -} from "discourse/tests/helpers/qunit-helpers"; +import { count, createFile } from "discourse/tests/helpers/qunit-helpers"; const fakeUpload = { type: ".png", @@ -53,7 +49,7 @@ module("Discourse Chat | Component | chat-composer-uploads", function (hooks) { `); assert.strictEqual(count(".chat-composer-upload"), 1); - assert.strictEqual(exists(".chat-composer-upload"), true); + assert.dom(".chat-composer-upload").exists(); }); test("upload starts and completes", async function (assert) { diff --git a/plugins/chat/test/javascripts/components/chat-message-reaction-test.js b/plugins/chat/test/javascripts/components/chat-message-reaction-test.js index 98b836ed333..18f141573b8 100644 --- a/plugins/chat/test/javascripts/components/chat-message-reaction-test.js +++ b/plugins/chat/test/javascripts/components/chat-message-reaction-test.js @@ -2,7 +2,7 @@ import { click, render } from "@ember/test-helpers"; import hbs from "htmlbars-inline-precompile"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists, query } from "discourse/tests/helpers/qunit-helpers"; +import { query } from "discourse/tests/helpers/qunit-helpers"; module("Discourse Chat | Component | chat-message-reaction", function (hooks) { setupRenderingTest(hooks); @@ -35,7 +35,7 @@ module("Discourse Chat | Component | chat-message-reaction", function (hooks) { `); - assert.false(exists(".chat-message-reaction .count")); + assert.dom(".chat-message-reaction .count").doesNotExist(); this.set("count", 2); assert.dom(".chat-message-reaction .count").hasText("2"); @@ -58,7 +58,7 @@ module("Discourse Chat | Component | chat-message-reaction", function (hooks) { `); - assert.false(exists(".chat-message-reaction .count")); + assert.dom(".chat-message-reaction .count").doesNotExist(); await click(".chat-message-reaction"); assert.dom(".chat-message-reaction .count").hasText("1"); diff --git a/plugins/chat/test/javascripts/components/chat-message-text-test.js b/plugins/chat/test/javascripts/components/chat-message-text-test.js index 3e22a94f7f7..ab3364dd672 100644 --- a/plugins/chat/test/javascripts/components/chat-message-text-test.js +++ b/plugins/chat/test/javascripts/components/chat-message-text-test.js @@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers"; import hbs from "htmlbars-inline-precompile"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; module("Discourse Chat | Component | chat-message-text", function (hooks) { setupRenderingTest(hooks); @@ -37,7 +36,7 @@ module("Discourse Chat | Component | chat-message-text", function (hooks) { await render(hbs``); - assert.false(exists(".chat-message-collapser")); + assert.dom(".chat-message-collapser").doesNotExist(); }); test("shows edits - regular message", async function (assert) { diff --git a/plugins/chat/test/javascripts/components/dc-filter-input-test.js b/plugins/chat/test/javascripts/components/dc-filter-input-test.js index ef1c4319cc5..5f3010bdd30 100644 --- a/plugins/chat/test/javascripts/components/dc-filter-input-test.js +++ b/plugins/chat/test/javascripts/components/dc-filter-input-test.js @@ -2,7 +2,6 @@ import { fillIn, render, triggerEvent } from "@ember/test-helpers"; import hbs from "htmlbars-inline-precompile"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { exists } from "discourse/tests/helpers/qunit-helpers"; module("Discourse Chat | Component | dc-filter-input", function (hooks) { setupRenderingTest(hooks); @@ -51,6 +50,6 @@ module("Discourse Chat | Component | dc-filter-input", function (hooks) { await triggerEvent(".dc-filter-input", "focusout"); - assert.false(exists(".dc-filter-input-container.is-focused")); + assert.dom(".dc-filter-input-container.is-focused").doesNotExist(); }); }); diff --git a/plugins/poll/test/javascripts/acceptance/poll-in-reply-history-test.js b/plugins/poll/test/javascripts/acceptance/poll-in-reply-history-test.js index bf423ce80f3..fce312c1c0e 100644 --- a/plugins/poll/test/javascripts/acceptance/poll-in-reply-history-test.js +++ b/plugins/poll/test/javascripts/acceptance/poll-in-reply-history-test.js @@ -1,6 +1,6 @@ import { click, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Poll in a post reply history", function (needs) { needs.user(); @@ -439,7 +439,7 @@ acceptance("Poll in a post reply history", function (needs) { test("renders and extends", async function (assert) { await visit("/t/-/topic_with_poll_in_post_reply_history"); await click(".reply-to-tab"); - assert.ok(exists(".poll"), "poll is rendered"); - assert.ok(exists(".poll-buttons"), "poll is extended"); + assert.dom(".poll").exists("poll is rendered"); + assert.dom(".poll-buttons").exists("poll is extended"); }); });