DEV: Convert all uses of exists to qunit-dom (#29667)

This commit is contained in:
Jarek Radosz 2024-11-10 01:30:33 +01:00 committed by GitHub
parent b24c8a41ac
commit de6d575d40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
122 changed files with 1285 additions and 1560 deletions

View File

@ -1,6 +1,6 @@
import { visit } from "@ember/test-helpers"; import { visit } from "@ember/test-helpers";
import { test } from "qunit"; 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) { acceptance("Admin - Search Log Term", function (needs) {
needs.user(); needs.user();
@ -8,8 +8,8 @@ acceptance("Admin - Search Log Term", function (needs) {
test("show search log term details", async function (assert) { test("show search log term details", async function (assert) {
await visit("/admin/logs/search_logs/term?term=ruby"); await visit("/admin/logs/search_logs/term?term=ruby");
assert.ok(exists(".search-logs-filter"), "has the search type filter"); assert.dom(".search-logs-filter").exists("has the search type filter");
assert.ok(exists("canvas"), "has graph canvas"); assert.dom("canvas").exists("has graph canvas");
assert.ok(exists("div.header-search-results"), "has header search results"); assert.dom("div.header-search-results").exists("has header search results");
}); });
}); });

View File

@ -3,11 +3,7 @@ import { test } from "qunit";
import { AUTO_GROUPS } from "discourse/lib/constants"; import { AUTO_GROUPS } from "discourse/lib/constants";
import { withPluginApi } from "discourse/lib/plugin-api"; import { withPluginApi } from "discourse/lib/plugin-api";
import PreloadStore from "discourse/lib/preload-store"; import PreloadStore from "discourse/lib/preload-store";
import { import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
acceptance,
count,
exists,
} from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
acceptance("Admin Sidebar - Sections", function (needs) { acceptance("Admin Sidebar - Sections", function (needs) {
@ -88,12 +84,11 @@ acceptance("Admin Sidebar - Sections", function (needs) {
await visit("/admin"); await visit("/admin");
await click(".sidebar-toggle-all-sections"); await click(".sidebar-toggle-all-sections");
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='admin-plugins'] .sidebar-section-link-wrapper[data-list-item-name=\"admin_installed_plugins\"]" ".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) { 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) { test("additional valid links can be added to a section with the plugin API", async function (assert) {
await visit("/admin"); await visit("/admin");
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='admin-root'] .sidebar-section-link-wrapper[data-list-item-name=\"admin_additional_root_test_section_link\"]" ".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 assert
.dom( .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) { test("community section links are added to primary and secondary sections with the plugin API", async function (assert) {
await visit("/"); await visit("/");
assert.ok( assert
exists( .dom(
"#sidebar-section-content-community .sidebar-section-link[data-link-name='primary']" "#sidebar-section-content-community .sidebar-section-link[data-link-name='primary']"
) )
); .exists();
assert assert
.dom( .dom(
"#sidebar-section-content-community .sidebar-section-link[data-link-name='secondary']" "#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']" ".sidebar-more-section-links-details-content .sidebar-section-link[data-link-name='primary']"
) )
.doesNotExist(); .doesNotExist();
assert.ok( assert
exists( .dom(
".sidebar-more-section-links-details-content .sidebar-section-link[data-link-name='secondary']" ".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) { 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"); await visit("/admin");
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='admin-root'] .sidebar-section-link-wrapper[data-list-item-name=\"admin_additional_root_test_section_link\"]" ".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");
);
}); });
} }
); );

View File

@ -11,7 +11,6 @@ import pretender from "discourse/tests/helpers/create-pretender";
import { import {
acceptance, acceptance,
count, count,
exists,
queryAll, queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -48,7 +47,7 @@ acceptance("Admin - Site Settings", function (needs) {
.dom(".row.setting.upload .image-uploader") .dom(".row.setting.upload .image-uploader")
.exists("image uploader is present"); .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) { test("links to staff action log", async function (assert) {
@ -71,7 +70,9 @@ acceptance("Admin - Site Settings", function (needs) {
1, 1,
"filter returns 1 site setting" "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 fillIn(".input-setting-string", "Test");
await click("button.cancel"); await click("button.cancel");

View File

@ -1,6 +1,6 @@
import { visit } from "@ember/test-helpers"; import { visit } from "@ember/test-helpers";
import { test } from "qunit"; 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) { acceptance("Admin - Users Badges", function (needs) {
needs.user(); needs.user();
@ -8,6 +8,6 @@ acceptance("Admin - Users Badges", function (needs) {
test("lists badges", async function (assert) { test("lists badges", async function (assert) {
await visit("/admin/users/1/eviltrout/badges"); 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();
}); });
}); });

View File

@ -1,10 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
acceptance("Admin - Users List", function (needs) { acceptance("Admin - Users List", function (needs) {
@ -14,7 +10,9 @@ acceptance("Admin - Users List", function (needs) {
await visit("/admin/users/list/active"); await visit("/admin/users/list/active");
assert.dom(".users-list .user").exists(); 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) { test("searching users with no matches", async function (assert) {

View File

@ -2,11 +2,7 @@ import { visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import PreloadStore from "discourse/lib/preload-store"; import PreloadStore from "discourse/lib/preload-store";
import discoveryFixtures from "discourse/tests/fixtures/discovery-fixtures"; import discoveryFixtures from "discourse/tests/fixtures/discovery-fixtures";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object"; import { cloneJSON } from "discourse-common/lib/object";
acceptance("Categories - 'categories_only'", function (needs) { acceptance("Categories - 'categories_only'", function (needs) {
@ -80,20 +76,17 @@ acceptance(
}); });
test("basic functionality", async function (assert) { test("basic functionality", async function (assert) {
await visit("/categories"); await visit("/categories");
assert.ok( assert
exists("table.subcategory-list.with-topics thead h3 .category-name"), .dom("table.subcategory-list.with-topics thead h3 .category-name")
"shows heading for top-level category" .exists("shows heading for top-level category");
); assert
assert.ok( .dom(
exists(
"table.subcategory-list.with-topics tr[data-category-id='26'] h3 .category-name" "table.subcategory-list.with-topics tr[data-category-id='26'] h3 .category-name"
), )
"shows table row for subcategories" .exists("shows table row for subcategories");
); assert
assert.ok( .dom("table.category-list.with-topics div[data-topic-id='11994']")
exists("table.category-list.with-topics div[data-topic-id='11994']"), .exists("shows a featured topic");
"shows a featured topic"
);
}); });
} }
); );
@ -107,20 +100,17 @@ acceptance(
}); });
test("basic functionality", async function (assert) { test("basic functionality", async function (assert) {
await visit("/categories"); await visit("/categories");
assert.ok( assert
exists("div.subcategory-list.with-topics h3 .category-name"), .dom("div.subcategory-list.with-topics h3 .category-name")
"shows heading for top-level category" .exists("shows heading for top-level category");
); assert
assert.ok( .dom(
exists(
"div.subcategory-list.with-topics div[data-category-id='26'] h3 .category-name" "div.subcategory-list.with-topics div[data-category-id='26'] h3 .category-name"
), )
"shows element for subcategories" .exists("shows element for subcategories");
); assert
assert.ok( .dom("div.category-list.with-topics a[data-topic-id='11994']")
exists("div.category-list.with-topics a[data-topic-id='11994']"), .exists("shows a featured topic");
"shows a featured topic"
);
}); });
} }
); );

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { import {
acceptance, acceptance,
count, count,
exists,
query, query,
queryAll, queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -76,7 +75,9 @@ acceptance("Category Edit - Security", function (needs) {
await visit("/c/bug/edit/security"); await visit("/c/bug/edit/security");
await click(".row-body .remove-permission"); 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.expand();
await availableGroups.selectRowByValue("everyone"); await availableGroups.selectRowByValue("everyone");

View File

@ -2,7 +2,7 @@ import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import sinon from "sinon"; import sinon from "sinon";
import DiscourseURL from "discourse/lib/url"; 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 selectKit from "discourse/tests/helpers/select-kit-helper";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -69,12 +69,9 @@ acceptance("Category New", function (needs) {
await click(".edit-category-nav .edit-category-tags a"); await click(".edit-category-nav .edit-category-tags a");
assert.ok( assert
exists( .dom(".required-tag-group-row .select-kit-header[data-value='TagGroup1']")
".required-tag-group-row .select-kit-header[data-value='TagGroup1']" .exists("shows saved required tag group");
),
"it shows saved required tag group"
);
assert.dom(".edit-category-title h2").hasText( assert.dom(".edit-category-title h2").hasText(
I18n.t("category.edit_dialog_title", { I18n.t("category.edit_dialog_title", {

View File

@ -6,11 +6,7 @@ import {
waitUntil, waitUntil,
} from "@ember/test-helpers"; } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
import pretender, { response } from "../helpers/create-pretender"; import pretender, { response } from "../helpers/create-pretender";
@ -40,10 +36,9 @@ acceptance("Composer - Messages", function (needs) {
await visit("/u/charlie"); await visit("/u/charlie");
await click("button.compose-pm"); await click("button.compose-pm");
assert.false( assert
exists(".composer-popup"), .dom(".composer-popup")
"composer warning is not shown by default" .doesNotExist("composer warning is not shown by default");
);
await triggerKeyEvent(".d-editor-input", "keyup", "Space"); 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) { test("Shows warning in composer if group hasn't been invited", async function (assert) {
await visit("/t/130"); await visit("/t/130");
await click("button.create"); await click("button.create");
assert.false( assert
exists(".composer-popup"), .dom(".composer-popup")
"composer warning is not shown by default" .doesNotExist("composer warning is not shown by default");
);
await fillIn(".d-editor-input", "Mention @staff"); await fillIn(".d-editor-input", "Mention @staff");
assert.dom(".composer-popup").exists("shows composer warning message"); 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) { 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 visit("/t/130");
await click("button.create"); await click("button.create");
assert.false( assert
exists(".composer-popup"), .dom(".composer-popup")
"composer warning is not shown by default" .doesNotExist("composer warning is not shown by default");
);
await fillIn(".d-editor-input", "Mention @staff2"); await fillIn(".d-editor-input", "Mention @staff2");
assert.dom(".composer-popup").exists("shows composer warning message"); 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 fillIn("#reply-title", "Private message test title");
await triggerKeyEvent(".d-editor-input", "keyup", "Space"); await triggerKeyEvent(".d-editor-input", "keyup", "Space");
assert.false( assert
exists(".composer-popup"), .dom(".composer-popup")
"composer warning is not shown if the target recipients are empty" .doesNotExist(
); "composer warning is not shown if the target recipients are empty"
);
// filling the input with the username of the current user // filling the input with the username of the current user
await privateMessageUsers.expand(); await privateMessageUsers.expand();
@ -274,10 +268,11 @@ acceptance("Composer - Messages - Private Messages", function (needs) {
await fillIn("#reply-title", "Private message test title"); await fillIn("#reply-title", "Private message test title");
await triggerKeyEvent(".d-editor-input", "keyup", "Space"); await triggerKeyEvent(".d-editor-input", "keyup", "Space");
assert.false( assert
exists(".composer-popup"), .dom(".composer-popup")
"composer warning is not shown if the target recipients are empty" .doesNotExist(
); "composer warning is not shown if the target recipients are empty"
);
// filling the input with the username of another user // filling the input with the username of another user
await privateMessageUsers.expand(); await privateMessageUsers.expand();
@ -286,7 +281,7 @@ acceptance("Composer - Messages - Private Messages", function (needs) {
await privateMessageUsers.collapse(); await privateMessageUsers.collapse();
await triggerKeyEvent(".d-editor-input", "keyup", "Space"); 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 // filling the input with the username of the current user
await privateMessageUsers.expand(); await privateMessageUsers.expand();
@ -295,9 +290,10 @@ acceptance("Composer - Messages - Private Messages", function (needs) {
await privateMessageUsers.collapse(); await privateMessageUsers.collapse();
await triggerKeyEvent(".d-editor-input", "keyup", "Space"); await triggerKeyEvent(".d-editor-input", "keyup", "Space");
assert.false( assert
exists(".composer-popup"), .dom(".composer-popup")
"do not show it when the current user is just one of the target recipients" .doesNotExist(
); "do not show it when the current user is just one of the target recipients"
);
}); });
}); });

View File

@ -25,7 +25,6 @@ import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { import {
acceptance, acceptance,
count, count,
exists,
invisible, invisible,
metaModifier, metaModifier,
query, query,
@ -154,10 +153,10 @@ acceptance("Composer", function (needs) {
test("composer controls", async function (assert) { test("composer controls", async function (assert) {
await visit("/"); 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"); 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"); await focus(".title-input input");
assert assert
.dom(".title-input .popup-tip.good.hide") .dom(".title-input .popup-tip.good.hide")
@ -222,10 +221,12 @@ acceptance("Composer", function (needs) {
); );
await click("#reply-control a.cancel"); 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"); 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) { 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("#reply-title", "this title triggers an error");
await fillIn(".d-editor-input", "this is the *content* of a post"); await fillIn(".d-editor-input", "this is the *content* of a post");
await click("#reply-control button.create"); 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"); await click(".dialog-footer .btn-primary");
assert.ok(!exists(".dialog-body"), "it dismisses the error"); assert.dom(".dialog-body").doesNotExist("dismisses the error");
assert.ok(exists(".d-editor-input"), "the composer input is visible"); assert.dom(".d-editor-input").exists("the composer input is visible");
}); });
test("Create a Topic", async function (assert) { test("Create a Topic", async function (assert) {
@ -313,7 +314,7 @@ acceptance("Composer", function (needs) {
.doesNotExist("the post is not in the DOM"); .doesNotExist("the post is not in the DOM");
await click("#topic-footer-buttons .btn.create"); 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 assert
.dom("#reply-title") .dom("#reply-title")
.doesNotExist("there is no title since this is a reply"); .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(); assert.dom(".pending-posts .reviewable-item").doesNotExist();
await click("#topic-footer-buttons .btn.create"); 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 assert
.dom("#reply-title") .dom("#reply-title")
.doesNotExist("there is no title since this is a reply"); .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(".d-editor-input", "This is the new text for the post");
await fillIn("#reply-title", "This is the new text for the title"); await fillIn("#reply-title", "This is the new text for the title");
await click("#reply-control button.create"); 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 assert
.dom(".topic-post:nth-of-type(1) .post-info.edits") .dom(".topic-post:nth-of-type(1) .post-info.edits")
.exists("it has the edits icon"); .exists("it has the edits icon");
@ -723,7 +724,7 @@ acceptance("Composer", function (needs) {
); );
await visit("/"); 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"); await click("#create-topic");
assert assert
@ -862,12 +863,9 @@ acceptance("Composer", function (needs) {
await fillIn(".d-editor-input", longText); await fillIn(".d-editor-input", longText);
assert.ok( assert
exists( .dom('.action-title a[href="/t/internationalization-localization/280"]')
'.action-title a[href="/t/internationalization-localization/280"]' .exists("the mode should be: reply to post");
),
"the mode should be: reply to post"
);
await click("article#post_3 button.reply"); await click("article#post_3 button.reply");
@ -875,19 +873,16 @@ acceptance("Composer", function (needs) {
await composerActions.expand(); await composerActions.expand();
await composerActions.selectRowByValue("reply_as_new_topic"); 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( assert.ok(
query(".d-editor-input").value.includes(longText), query(".d-editor-input").value.includes(longText),
"entered text should still be there" "entered text should still be there"
); );
assert.ok( assert
!exists( .dom('.action-title a[href="/t/internationalization-localization/280"]')
'.action-title a[href="/t/internationalization-localization/280"]' .doesNotExist("mode should have changed");
),
"mode should have changed"
);
}); });
test("Loading draft also replaces the recipients", async function (assert) { 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"); .doesNotExist("Doesn't show the 'group_mentioned' notice in a quote");
await fillIn(".d-editor-input", "@staff"); 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) { 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("#reply-title", "this title triggers an error");
await fillIn(".d-editor-input", "this is the *content* of a post"); await fillIn(".d-editor-input", "this is the *content* of a post");
await click("#reply-control button.create"); 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( assert.ok(
query(".dialog-body").innerText.match(/PLUGIN_ABC ERROR/), query(".dialog-body").innerText.match(/PLUGIN_ABC ERROR/),
"it contains the server side error text" "it contains the server side error text"
); );
await click(".dialog-footer .btn-primary"); await click(".dialog-footer .btn-primary");
assert.ok(!exists(".dialog-body"), "it dismisses the error"); assert.dom(".dialog-body").doesNotExist("dismisses the error");
assert.ok(exists(".d-editor-input"), "the composer input is visible"); 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 visit("/t/internationalization-localization/280");
await click("#topic-footer-buttons .btn.create"); 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: "); await fillIn(".d-editor-input", "and the time now is: ");
const date = moment().format("YYYY-MM-DD"); const date = moment().format("YYYY-MM-DD");

View File

@ -1,10 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
acceptance("Composer topic featured links", function (needs) { acceptance("Composer topic featured links", function (needs) {
needs.user(); needs.user();
@ -173,28 +169,25 @@ acceptance(
test("Pasting a link enables the text input area", async function (assert) { test("Pasting a link enables the text input area", async function (assert) {
await visit("/"); await visit("/");
await click("#create-topic"); await click("#create-topic");
assert.ok( assert
exists(".d-editor-textarea-wrapper.disabled"), .dom(".d-editor-textarea-wrapper.disabled")
"textarea is disabled" .exists("textarea is disabled");
);
await fillIn("#reply-title", "http://www.example.com/has-title.html"); await fillIn("#reply-title", "http://www.example.com/has-title.html");
assert.ok( assert.ok(
query(".d-editor-preview").innerHTML.trim().includes("onebox"), query(".d-editor-preview").innerHTML.trim().includes("onebox"),
"it pastes the link into the body and previews it" "it pastes the link into the body and previews it"
); );
assert.ok( assert
exists(".d-editor-textarea-wrapper .popup-tip.good"), .dom(".d-editor-textarea-wrapper .popup-tip.good")
"the body is now good" .exists("the body is now good");
);
assert.strictEqual( assert.strictEqual(
query(".title-input input").value, query(".title-input input").value,
"An interesting article", "An interesting article",
"title is from the oneboxed article" "title is from the oneboxed article"
); );
assert.ok( assert
!exists(".d-editor-textarea-wrapper.disabled"), .dom(".d-editor-textarea-wrapper.disabled")
"textarea is enabled" .doesNotExist("textarea is enabled");
);
}); });
} }
); );

View File

@ -1,6 +1,6 @@
import { click, fillIn, focus, visit } from "@ember/test-helpers"; import { click, fillIn, focus, visit } from "@ember/test-helpers";
import { test } from "qunit"; 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"; import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance( acceptance(
@ -12,49 +12,42 @@ acceptance(
test("Disable body until category is selected", async function (assert) { test("Disable body until category is selected", async function (assert) {
await visit("/"); await visit("/");
await click("#create-topic"); 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"); await focus(".title-input input");
assert.ok( assert
exists(".title-input .popup-tip.good.hide"), .dom(".title-input .popup-tip.good.hide")
"title errors are hidden by default" .exists("title errors are hidden by default");
); assert
assert.ok( .dom(".d-editor-textarea-wrapper .popup-tip.bad.hide")
exists(".d-editor-textarea-wrapper .popup-tip.bad.hide"), .exists("body errors are hidden by default");
"body errors are hidden by default" assert
); .dom(".d-editor-textarea-wrapper.disabled")
assert.ok( .exists("textarea is disabled");
exists(".d-editor-textarea-wrapper.disabled"),
"textarea is disabled"
);
assert.ok( assert
!exists("button.toggle-fullscreen"), .dom("button.toggle-fullscreen")
"fullscreen button is not present" .doesNotExist("fullscreen button is not present");
);
const categoryChooser = selectKit(".category-chooser"); const categoryChooser = selectKit(".category-chooser");
await categoryChooser.expand(); await categoryChooser.expand();
await categoryChooser.selectRowByValue(2); await categoryChooser.selectRowByValue(2);
assert.ok( assert
!exists(".d-editor-textarea-wrapper.disabled"), .dom(".d-editor-textarea-wrapper.disabled")
"textarea is enabled" .doesNotExist("textarea is enabled");
);
await fillIn(".d-editor-input", "Now I can type stuff"); await fillIn(".d-editor-input", "Now I can type stuff");
await categoryChooser.expand(); await categoryChooser.expand();
await categoryChooser.selectRowByIndex(0); await categoryChooser.selectRowByIndex(0);
assert.ok( assert
!exists(".d-editor-textarea-wrapper.disabled"), .dom(".d-editor-textarea-wrapper.disabled")
"textarea is still enabled" .doesNotExist("textarea is still enabled");
);
assert.ok( assert
exists("button.toggle-fullscreen"), .dom("button.toggle-fullscreen")
"fullscreen button is present" .exists("fullscreen button is present");
);
}); });
} }
); );
@ -89,38 +82,34 @@ acceptance(
}, },
], ],
}); });
test("Enable composer/body if no topic templates present", async function (assert) { test("Enable composer/body if no topic templates present", async function (assert) {
await visit("/"); await visit("/");
await click("#create-topic"); 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");
assert.ok( assert
exists(".category-input .popup-tip.bad.hide"), .dom(".category-input .popup-tip.bad.hide")
"category errors are hidden by default" .exists("category errors are hidden by default");
); assert
assert.ok( .dom(".d-editor-textarea-wrapper.disabled")
!exists(".d-editor-textarea-wrapper.disabled"), .doesNotExist("textarea is enabled");
"textarea is enabled"
);
assert.ok( assert
exists("button.toggle-fullscreen"), .dom("button.toggle-fullscreen")
"fullscreen button is present" .exists("fullscreen button is present");
);
await click("#reply-control button.create"); await click("#reply-control button.create");
assert.ok( assert
exists(".category-input .popup-tip.bad"), .dom(".category-input .popup-tip.bad")
"it shows the choose a category error" .exists("it shows the choose a category error");
);
const categoryChooser = selectKit(".category-chooser"); const categoryChooser = selectKit(".category-chooser");
await categoryChooser.expand(); await categoryChooser.expand();
await categoryChooser.selectRowByValue(1); await categoryChooser.selectRowByValue(1);
assert.ok( assert
!exists(".category-input .popup-tip.bad"), .dom(".category-input .popup-tip.bad")
"category error removed after selecting category" .doesNotExist("category error removed after selecting category");
);
}); });
} }
); );

View File

@ -2,12 +2,12 @@ import { visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { setCustomHTML } from "discourse/helpers/custom-html"; import { setCustomHTML } from "discourse/helpers/custom-html";
import PreloadStore from "discourse/lib/preload-store"; 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 () { acceptance("CustomHTML set", function () {
test("has no custom HTML in the top", async function (assert) { test("has no custom HTML in the top", async function (assert) {
await visit("/static/faq"); 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) { test("renders set HTML", async function (assert) {

View File

@ -1,10 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
acceptance,
count,
exists,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("Dashboard", function (needs) { 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) { test("tabs", async function (assert) {
await visit("/admin"); await visit("/admin");
assert.ok(exists(".dashboard .navigation-item.general"), "general tab"); assert.dom(".dashboard .navigation-item.general").exists("general tab");
assert assert
.dom(".dashboard .navigation-item.moderation") .dom(".dashboard .navigation-item.moderation")
.exists("moderation tab"); .exists("moderation tab");
assert.ok(exists(".dashboard .navigation-item.security"), "security tab"); assert.dom(".dashboard .navigation-item.security").exists("security tab");
assert.ok(exists(".dashboard .navigation-item.reports"), "reports tab"); assert.dom(".dashboard .navigation-item.reports").exists("reports tab");
}); });
test("general tab", async function (assert) { test("general tab", async function (assert) {
await visit("/admin"); await visit("/admin");
assert.ok(exists(".custom-date-range-button"), "custom date range button"); assert.dom(".custom-date-range-button").exists("custom date range button");
assert.ok(exists(".admin-report.signups"), "signups report"); assert.dom(".admin-report.signups").exists("signups report");
assert.ok(exists(".admin-report.posts"), "posts report"); assert.dom(".admin-report.posts").exists("posts report");
assert.ok(exists(".admin-report.dau-by-mau"), "dau-by-mau report"); assert.dom(".admin-report.dau-by-mau").exists("dau-by-mau report");
assert assert
.dom(".admin-report.daily-engaged-users") .dom(".admin-report.daily-engaged-users")
.exists("daily-engaged-users report"); .exists("daily-engaged-users report");
@ -62,7 +52,7 @@ acceptance("Dashboard", function (needs) {
await visit("/admin"); await visit("/admin");
await click(".dashboard .navigation-item.moderation .navigation-link"); 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 assert
.dom(".admin-report.moderators-activity") .dom(".admin-report.moderators-activity")
.exists("moderators activity report"); .exists("moderators activity report");
@ -129,12 +119,12 @@ acceptance("Dashboard: dashboard_visible_tabs", function (needs) {
test("visible tabs", async function (assert) { test("visible tabs", async function (assert) {
await visit("/admin"); await visit("/admin");
assert.ok(exists(".dashboard .navigation-item.general"), "general tab"); assert.dom(".dashboard .navigation-item.general").exists("general tab");
assert assert
.dom(".dashboard .navigation-item.moderation") .dom(".dashboard .navigation-item.moderation")
.doesNotExist("moderation tab"); .doesNotExist("moderation tab");
assert.ok(exists(".dashboard .navigation-item.security"), "security tab"); assert.dom(".dashboard .navigation-item.security").exists("security tab");
assert.ok(exists(".dashboard .navigation-item.reports"), "reports 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) { test("hidden reports", async function (assert) {
await visit("/admin"); 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.posts").doesNotExist("posts report");
assert assert
.dom(".admin-report.is-visible.dau-by-mau") .dom(".admin-report.is-visible.dau-by-mau")

View File

@ -4,7 +4,6 @@ import DoNotDisturb from "discourse/lib/do-not-disturb";
import { import {
acceptance, acceptance,
count, count,
exists,
query, query,
queryAll, queryAll,
updateCurrentUser, updateCurrentUser,
@ -31,7 +30,7 @@ acceptance("Do not disturb", function (needs) {
await click("#user-menu-button-profile"); await click("#user-menu-button-profile");
await click("#quick-access-profile .do-not-disturb .btn"); 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"); let tiles = queryAll(".do-not-disturb-tile");
assert.ok(tiles.length === 4, "There are 4 duration choices"); 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.dom(".d-modal").doesNotExist("modal is hidden");
assert.ok( assert
exists( .dom(
".header-dropdown-toggle .do-not-disturb-background .d-icon-discourse-dnd" ".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) { 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("#user-menu-button-profile");
await click("#quick-access-profile .do-not-disturb .btn"); 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( assert.strictEqual(
count(".do-not-disturb-tile"), count(".do-not-disturb-tile"),
@ -74,12 +72,11 @@ acceptance("Do not disturb", function (needs) {
.dom(".d-modal") .dom(".d-modal")
.doesNotExist("DND modal is hidden after making a choice"); .doesNotExist("DND modal is hidden after making a choice");
assert.ok( assert
exists( .dom(
".header-dropdown-toggle .do-not-disturb-background .d-icon-discourse-dnd" ".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) { test("when turned on, it can be turned off", async function (assert) {

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { import {
acceptance, acceptance,
count, count,
exists,
query, query,
queryAll, queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -24,10 +23,10 @@ acceptance("EmojiPicker", function (needs) {
await click("#topic-footer-buttons .btn.create"); await click("#topic-footer-buttons .btn.create");
await click("button.emoji.btn"); 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"); 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) { test("filters emoji", async function (assert) {
@ -83,12 +82,11 @@ acceptance("EmojiPicker", function (needs) {
await click("button.emoji.btn"); await click("button.emoji.btn");
await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); await click(".emoji-picker-emoji-area img.emoji[title='grinning']");
assert.ok( assert
exists( .dom(
".emoji-picker .section.recent .section-group img.emoji[title='grinning']" ".emoji-picker .section.recent .section-group img.emoji[title='grinning']"
), )
"it shows recent selected emoji" .exists("shows recent selected emoji");
);
assert assert
.dom('.emoji-picker .category-button[data-section="recent"]') .dom('.emoji-picker .category-button[data-section="recent"]')
@ -96,12 +94,11 @@ acceptance("EmojiPicker", function (needs) {
await click(".emoji-picker .trash-recent"); await click(".emoji-picker .trash-recent");
assert.notOk( assert
exists( .dom(
".emoji-picker .section.recent .section-group img.emoji[title='grinning']" ".emoji-picker .section.recent .section-group img.emoji[title='grinning']"
), )
"it has cleared recent emojis" .doesNotExist("has cleared recent emojis");
);
assert assert
.dom('.emoji-picker .section[data-section="recent"]') .dom('.emoji-picker .section[data-section="recent"]')

View File

@ -1,15 +1,13 @@
import { click, fillIn, settled, visit } from "@ember/test-helpers"; import { click, fillIn, settled, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import userFixtures from "discourse/tests/fixtures/user-fixtures"; import userFixtures from "discourse/tests/fixtures/user-fixtures";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
async function openFlagModal() { 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.show-more-actions");
} }
await click(".topic-post:first-child button.create-flag"); await click(".topic-post:first-child button.create-flag");
@ -99,7 +97,7 @@ acceptance("flagging", function (needs) {
test("Flag modal opening", async function (assert) { test("Flag modal opening", async function (assert) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
await openFlagModal(); 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) { test("Flag take action dropdown exists", async function (assert) {
@ -124,7 +122,7 @@ acceptance("flagging", function (needs) {
await click("#radio_inappropriate"); await click("#radio_inappropriate");
await selectKit(".reviewable-action-dropdown").expand(); await selectKit(".reviewable-action-dropdown").expand();
await click("[data-value='agree_and_silence']"); 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"); assert.dom(".suspend-message").hasValue("", "penalty message is empty");
const silenceUntilCombobox = selectKit(".silence-until .combobox"); const silenceUntilCombobox = selectKit(".silence-until .combobox");
await silenceUntilCombobox.expand(); await silenceUntilCombobox.expand();
@ -143,7 +141,7 @@ acceptance("flagging", function (needs) {
await click("#radio_inappropriate"); await click("#radio_inappropriate");
await selectKit(".reviewable-action-dropdown").expand(); await selectKit(".reviewable-action-dropdown").expand();
await click("[data-value='agree_and_silence']"); 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 assert
.dom(".suspend-message") .dom(".suspend-message")
.hasValue( .hasValue(
@ -176,7 +174,7 @@ acceptance("flagging", function (needs) {
await click(".dialog-footer .btn-default"); await click(".dialog-footer .btn-default");
assert.dom(".dialog-body").doesNotExist(); 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"); await click(".d-modal-cancel");
assert.dom(".dialog-body").exists(); assert.dom(".dialog-body").exists();

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { import {
acceptance, acceptance,
count, count,
exists,
queryAll, queryAll,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -19,7 +18,7 @@ acceptance("Group Members - Anonymous", function () {
1, 1,
"it displays the group's avatar flair" "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 assert
.dom(".group-member-dropdown") .dom(".group-member-dropdown")

View File

@ -2,11 +2,7 @@ import { click, currentRouteName, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { GROUP_SMTP_SSL_MODES } from "discourse/lib/constants"; import { GROUP_SMTP_SSL_MODES } from "discourse/lib/constants";
import formKit from "discourse/tests/helpers/form-kit-helper"; import formKit from "discourse/tests/helpers/form-kit-helper";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -44,10 +40,9 @@ acceptance(
"group.manage.email", "group.manage.email",
"it redirects to the group email page" "it redirects to the group email page"
); );
assert.notOk( assert
exists(".group-manage-email-imap-wrapper"), .dom(".group-manage-email-imap-wrapper")
"does not show IMAP settings" .doesNotExist("does not show IMAP settings");
);
}); });
} }
); );
@ -77,10 +72,9 @@ acceptance(
query(".user-secondary-navigation").innerText.includes("Email"), query(".user-secondary-navigation").innerText.includes("Email"),
"email link is shown in the sidebar" "email link is shown in the sidebar"
); );
assert.ok( assert
exists("#enable_imap:disabled"), .dom("#enable_imap")
"IMAP is disabled until SMTP settings are valid" .isDisabled("IMAP is disabled until SMTP settings are valid");
);
await click("#enable_smtp"); await click("#enable_smtp");
assert.dom(".group-smtp-email-settings").exists(); assert.dom(".group-smtp-email-settings").exists();
@ -125,10 +119,9 @@ acceptance(
"Saved!" "Saved!"
); );
assert.notOk( assert
exists("#enable_imap:disabled"), .dom("#enable_imap")
"IMAP is able to be enabled now that SMTP is saved" .isEnabled("IMAP is able to be enabled now that SMTP is saved");
);
await click("#enable_smtp"); await click("#enable_smtp");
assert.strictEqual( assert.strictEqual(
@ -150,17 +143,17 @@ acceptance(
await formKit().submit(); await formKit().submit();
await click(".group-manage-save"); await click(".group-manage-save");
assert.notOk( assert
exists("#enable_imap:disabled"), .dom("#enable_imap")
"IMAP is able to be enabled now that IMAP is saved" .isEnabled("IMAP is able to be enabled now that IMAP is saved");
);
await click("#enable_imap"); await click("#enable_imap");
assert.ok( assert
exists(".test-imap-settings:disabled"), .dom(".test-imap-settings")
"does not allow testing settings if not all fields are filled" .isDisabled(
); "does not allow testing settings if not all fields are filled"
);
await click("#prefill_imap_gmail"); await click("#prefill_imap_gmail");
assert.strictEqual( assert.strictEqual(
@ -173,13 +166,12 @@ acceptance(
"993", "993",
"prefills IMAP port settings for gmail" "prefills IMAP port settings for gmail"
); );
assert.ok( assert
exists("#enable_ssl_imap:checked"), .dom("#enable_ssl_imap")
"prefills IMAP ssl settings for gmail" .isChecked("prefills IMAP ssl settings for gmail");
);
await click(".test-imap-settings"); 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"); await click(".group-manage-save");
@ -188,10 +180,9 @@ acceptance(
"Saved!" "Saved!"
); );
assert.ok( assert
exists(".imap-no-mailbox-selected"), .dom(".imap-no-mailbox-selected")
"shows a message saying no IMAP mailbox is selected" .exists("shows a message saying no IMAP mailbox is selected");
);
await selectKit( await selectKit(
".control-group.group-imap-mailboxes .combo-box" ".control-group.group-imap-mailboxes .combo-box"
@ -201,10 +192,9 @@ acceptance(
).selectRowByValue("All Mail"); ).selectRowByValue("All Mail");
await click(".group-manage-save"); await click(".group-manage-save");
assert.notOk( assert
exists(".imap-no-mailbox-selected"), .dom(".imap-no-mailbox-selected")
"no longer shows a no mailbox selected message" .doesNotExist("no longer shows a no mailbox selected message");
);
await click("#enable_imap"); await click("#enable_imap");
assert.strictEqual( assert.strictEqual(
@ -282,8 +272,8 @@ acceptance(
test("prefills smtp and imap saved settings and shows last updated details", async function (assert) { test("prefills smtp and imap saved settings and shows last updated details", async function (assert) {
await visit("/g/discourse/manage/email"); await visit("/g/discourse/manage/email");
assert.notOk(exists("#enable_smtp:disabled"), "SMTP is not disabled"); assert.dom("#enable_smtp").isNotDisabled("SMTP is not disabled");
assert.notOk(exists("#enable_imap:disabled"), "IMAP is not disabled"); assert.dom("#enable_imap").isNotDisabled("IMAP is not disabled");
assert assert
.form() .form()

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { import {
acceptance, acceptance,
count, count,
exists,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; 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) { test("For a group with a default_notification_level of 0", async function (assert) {
await visit("/g/alternative-group/manage/interaction"); 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( await assert.strictEqual(
selectKit(".groups-form-default-notification-level").header().value(), selectKit(".groups-form-default-notification-level").header().value(),
"0", "0",
@ -112,7 +111,7 @@ acceptance(
test("For a group with a null default_notification_level", async function (assert) { test("For a group with a null default_notification_level", async function (assert) {
await visit("/g/discourse/manage/interaction"); 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( await assert.strictEqual(
selectKit(".groups-form-default-notification-level").header().value(), selectKit(".groups-form-default-notification-level").header().value(),
"3", "3",
@ -123,7 +122,7 @@ acceptance(
test("For a group with a selected default_notification_level", async function (assert) { test("For a group with a selected default_notification_level", async function (assert) {
await visit("/g/support/manage/interaction"); 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( await assert.strictEqual(
selectKit(".groups-form-default-notification-level").header().value(), selectKit(".groups-form-default-notification-level").header().value(),
"2", "2",

View File

@ -1,6 +1,6 @@
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; 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"; import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("Managing Group - Save Button", function (needs) { acceptance("Managing Group - Save Button", function (needs) {
@ -19,11 +19,11 @@ acceptance("Managing Group - Save Button", function (needs) {
await visibilitySelector.expand(); await visibilitySelector.expand();
await visibilitySelector.selectRowByValue("1"); 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.expand();
await visibilitySelector.selectRowByValue("0"); await visibilitySelector.selectRowByValue("0");
assert.notOk(exists(".alert-private-group-name"), "alert is hidden"); assert.dom(".alert-private-group-name").doesNotExist("alert is hidden");
}); });
}); });

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { import {
acceptance, acceptance,
count, count,
exists,
query, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; 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']"); 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']"); 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']"); 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 assert
.dom(".nav-pills li a[title='Edit Group']") .dom(".nav-pills li a[title='Edit Group']")
.doesNotExist("it should not show messages tab if user is not admin"); .doesNotExist("it should not show messages tab if user is not admin");
assert assert
.dom(".nav-pills li a[title='Logs']") .dom(".nav-pills li a[title='Logs']")
.doesNotExist("it should not show Logs tab if user is not admin"); .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"); const groupDropdown = selectKit(".group-dropdown");
await groupDropdown.expand(); await groupDropdown.expand();
@ -212,7 +211,7 @@ acceptance("Group - Authenticated", function (needs) {
"it prefills the group name" "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) { test("Admin viewing group messages when there are no messages", async function (assert) {

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { import {
acceptance, acceptance,
count, count,
exists,
invisible, invisible,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -26,13 +25,13 @@ acceptance("Groups", function () {
); );
await click(".group-index-join"); 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"); await click(".login-modal .modal-close");
assert.ok(invisible(".modal.login-modal"), "it closes the login modal"); assert.ok(invisible(".modal.login-modal"), "it closes the login modal");
await click(".group-index-request"); 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']"); await click("a[href='/g/discourse/members']");
assert assert
@ -40,6 +39,6 @@ acceptance("Groups", function () {
.hasText("Awesome Team", "it displays the group page"); .hasText("Awesome Team", "it displays the group page");
await click(".group-index-join"); 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");
}); });
}); });

View File

@ -1,7 +1,7 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import PreloadStore from "discourse/lib/preload-store"; 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) { acceptance("Accept Invite - User Fields", function (needs) {
needs.site({ needs.site({
@ -42,8 +42,8 @@ acceptance("Accept Invite - User Fields", function (needs) {
}); });
await visit("/invites/myvalidinvitetoken"); await visit("/invites/myvalidinvitetoken");
assert.ok(exists(".invites-show"), "shows the accept invite page"); assert.dom(".invites-show").exists("shows the accept invite page");
assert.ok(exists(".user-field"), "it has at least one user field"); assert.dom(".user-field").exists("has at least one user field");
assert assert
.dom(".invites-show .btn-primary:disabled") .dom(".invites-show .btn-primary:disabled")
.exists("submit is 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-username", "validname");
await fillIn("#new-account-password", "secur3ty4Y0uAndMe"); 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 assert
.dom(".invites-show .btn-primary:disabled") .dom(".invites-show .btn-primary:disabled")
.exists("submit is still disabled due to lack of user fields"); .exists("submit is still disabled due to lack of user fields");

View File

@ -1,11 +1,7 @@
import { click, currentURL, triggerKeyEvent, visit } from "@ember/test-helpers"; import { click, currentURL, triggerKeyEvent, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import DiscoveryFixtures from "discourse/tests/fixtures/discovery-fixtures"; import DiscoveryFixtures from "discourse/tests/fixtures/discovery-fixtures";
import { import { acceptance, chromeTest } from "discourse/tests/helpers/qunit-helpers";
acceptance,
chromeTest,
exists,
} from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object"; import { cloneJSON } from "discourse-common/lib/object";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -202,7 +198,7 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
await visit("/"); await visit("/");
document.getElementById("ember-testing-container").scrollTop = 0; document.getElementById("ember-testing-container").scrollTop = 0;
await visit("/new"); 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 }); await triggerKeyEvent(document, "keydown", "D", { shiftKey: true });
assert.strictEqual(resetNewCalled, 1); assert.strictEqual(resetNewCalled, 1);

View File

@ -1,10 +1,6 @@
import { click, currentRouteName, visit } from "@ember/test-helpers"; import { click, currentRouteName, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
invisible,
} from "discourse/tests/helpers/qunit-helpers";
acceptance("Login Required", function (needs) { acceptance("Login Required", function (needs) {
needs.settings({ login_required: true }); needs.settings({ login_required: true });
@ -25,9 +21,9 @@ acceptance("Login Required", function (needs) {
); );
await click("header .login-button"); 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"); 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");
}); });
}); });

View File

@ -1,13 +1,13 @@
import { visit } from "@ember/test-helpers"; import { visit } from "@ember/test-helpers";
import { test } from "qunit"; 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) { acceptance("Topic Discovery - Mobile", function (needs) {
needs.mobileView(); needs.mobileView();
test("Visit Discovery Pages", async function (assert) { test("Visit Discovery Pages", async function (assert) {
await visit("/"); await visit("/");
assert.ok(exists(".topic-list"), "The list of topics was rendered"); assert.dom(".topic-list").exists("the list of topics is rendered");
assert.ok(exists(".topic-list .topic-list-item"), "has topics"); assert.dom(".topic-list .topic-list-item").exists("has topics");
assert assert
.dom("a[data-user-card=codinghorror] img.avatar") .dom("a[data-user-card=codinghorror] img.avatar")
@ -18,6 +18,6 @@ acceptance("Topic Discovery - Mobile", function (needs) {
); );
await visit("/categories"); await visit("/categories");
assert.ok(exists(".category"), "has a list of categories"); assert.dom(".category").exists("has a list of categories");
}); });
}); });

View File

@ -1,6 +1,6 @@
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; 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) { acceptance("Signing In - Mobile", function (needs) {
needs.mobileView(); needs.mobileView();
@ -8,6 +8,6 @@ acceptance("Signing In - Mobile", function (needs) {
test("sign in", async function (assert) { test("sign in", async function (assert) {
await visit("/"); await visit("/");
await click("header .login-button"); await click("header .login-button");
assert.ok(exists("#login-form"), "it shows the login modal"); assert.dom("#login-form").exists("shows the login modal");
}); });
}); });

View File

@ -1,10 +1,6 @@
import { visit } from "@ember/test-helpers"; import { visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("New Message - Anonymous", function () { acceptance("New Message - Anonymous", function () {
@ -13,7 +9,7 @@ acceptance("New Message - Anonymous", function () {
"/new-message?username=charlie&title=message%20title&body=message%20body" "/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" "/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( assert.strictEqual(
query("#reply-title").value.trim(), query("#reply-title").value.trim(),
"message title", "message title",

View File

@ -1,13 +1,13 @@
import { currentURL, visit, waitFor } from "@ember/test-helpers"; import { currentURL, visit, waitFor } from "@ember/test-helpers";
import { test } from "qunit"; 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"; import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("New Topic - Anonymous", function () { acceptance("New Topic - Anonymous", function () {
test("accessing new-topic route when logged out", async function (assert) { test("accessing new-topic route when logged out", async function (assert) {
await visit("/new-topic?title=topic%20title&body=topic%20body"); 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" "/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 assert
.dom("#reply-title") .dom("#reply-title")

View File

@ -4,11 +4,7 @@ import sinon from "sinon";
import PreloadStore from "discourse/lib/preload-store"; import PreloadStore from "discourse/lib/preload-store";
import DiscourseURL from "discourse/lib/url"; import DiscourseURL from "discourse/lib/url";
import { parsePostData } from "discourse/tests/helpers/create-pretender"; import { parsePostData } from "discourse/tests/helpers/create-pretender";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
acceptance("Password Reset", function (needs) { acceptance("Password Reset", function (needs) {
@ -69,13 +65,13 @@ acceptance("Password Reset", function (needs) {
PreloadStore.store("password_reset", { is_developer: false }); PreloadStore.store("password_reset", { is_developer: false });
await visit("/u/password-reset/myvalidtoken"); 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"); 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"); 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( assert.ok(
query(".password-reset .tip.bad").innerHTML.includes( query(".password-reset .tip.bad").innerHTML.includes(
I18n.t("user.password.too_short", { I18n.t("user.password.too_short", {
@ -87,7 +83,7 @@ acceptance("Password Reset", function (needs) {
await fillIn(".password-reset input", "jonesyAlienSlayer"); await fillIn(".password-reset input", "jonesyAlienSlayer");
await click(".password-reset form button[type='submit']"); 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( assert.ok(
query(".password-reset .tip.bad").innerHTML.includes( query(".password-reset .tip.bad").innerHTML.includes(
"Password is the name of your cat" "Password is the name of your cat"
@ -117,13 +113,13 @@ acceptance("Password Reset", function (needs) {
await visit("/u/password-reset/requiretwofactor"); await visit("/u/password-reset/requiretwofactor");
assert.notOk(exists("#new-account-password"), "does not show the input"); assert.dom("#new-account-password").doesNotExist("does not show the input");
assert.ok(exists("#second-factor"), "shows the second factor prompt"); assert.dom("#second-factor").exists("shows the second factor prompt");
await fillIn("input#second-factor", "0000"); await fillIn("input#second-factor", "0000");
await click(".password-reset form button"); 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( assert.ok(
query(".alert-error").innerHTML.includes("invalid token"), query(".alert-error").innerHTML.includes("invalid token"),
@ -133,8 +129,8 @@ acceptance("Password Reset", function (needs) {
await fillIn("input#second-factor", "123123"); await fillIn("input#second-factor", "123123");
await click(".password-reset form button"); await click(".password-reset form button");
assert.notOk(exists(".alert-error"), "hides error"); assert.dom(".alert-error").doesNotExist("hides error");
assert.ok(exists("#new-account-password"), "shows the input"); assert.dom("#new-account-password").exists("shows the input");
await fillIn(".password-reset input", "perf3ctly5ecur3"); await fillIn(".password-reset input", "perf3ctly5ecur3");

View File

@ -1,19 +1,19 @@
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; 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 () { acceptance("Post - Admin Menu - Anonymous", function () {
test("Enter as a anon user", async function (assert) { test("Enter as a anon user", async function (assert) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
await click(".show-more-actions"); await click(".show-more-actions");
assert.ok(exists("#topic"), "The topic was rendered"); assert.dom("#topic").exists("the topic is rendered");
assert assert
.dom("#post_1 .post-controls .edit") .dom("#post_1 .post-controls .edit")
.exists("The edit button was not rendered"); .exists("the edit button is not rendered");
assert assert
.dom(".show-post-admin-menu") .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 assert
.dom("#post_1 .post-controls .edit") .dom("#post_1 .post-controls .edit")
.exists("The edit button was rendered"); .exists("the edit button is rendered");
assert.ok(exists(".add-notice"), "The add notice button was rendered"); assert.dom(".add-notice").exists("the add notice button is rendered");
}); });
}); });

View File

@ -1,10 +1,6 @@
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
acceptance("Post Table Wrapper Test", function () { acceptance("Post Table Wrapper Test", function () {
test("fullscreen table wrapper appears on post with large table", async function (assert) { 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`) .dom(`${postWithLargeTable} .fullscreen-table-wrapper`)
.exists("The wrapper is present on the post with the large table"); .exists("The wrapper is present on the post with the large table");
assert.ok( assert
exists( .dom(
`${postWithLargeTable} .fullscreen-table-wrapper .fullscreen-table-wrapper__buttons .open-popup-link` `${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( const fullscreenButtonWrapper = query(
`${postWithLargeTable} .fullscreen-table-wrapper .fullscreen-table-wrapper__buttons` `${postWithLargeTable} .fullscreen-table-wrapper .fullscreen-table-wrapper__buttons`

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { import {
acceptance, acceptance,
count, count,
exists,
loggedInUser, loggedInUser,
publishToMessageBus, publishToMessageBus,
query, query,
@ -35,8 +34,8 @@ acceptance("Review", function (needs) {
test("It returns a list of reviewable items", async function (assert) { test("It returns a list of reviewable items", async function (assert) {
await visit("/review"); await visit("/review");
assert.ok(exists(".reviewable-item"), "has a list of items"); assert.dom(".reviewable-item").exists("has a list of items");
assert.ok(exists(user)); assert.dom(user).exists();
assert assert
.dom(`${user}.reviewable-user`) .dom(`${user}.reviewable-user`)
.exists("applies a class for the type"); .exists("applies a class for the type");
@ -88,7 +87,7 @@ acceptance("Review", function (needs) {
test("Settings", async function (assert) { test("Settings", async function (assert) {
await visit("/review/settings"); 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( const field = selectKit(
".reviewable-score-type:nth-of-type(1) .field .combo-box" ".reviewable-score-type:nth-of-type(1) .field .combo-box"
@ -97,7 +96,7 @@ acceptance("Review", function (needs) {
await field.selectRowByValue("5"); await field.selectRowByValue("5");
await click(".save-settings"); 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) { test("Flag related", async function (assert) {
@ -118,13 +117,13 @@ acceptance("Review", function (needs) {
test("Flag related", async function (assert) { test("Flag related", async function (assert) {
await visit("/review/1"); 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) { test("Clicking the buttons triggers actions", async function (assert) {
await visit("/review"); await visit("/review");
await click(`${user} .reviewable-action.approve`); 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) { test("Editing a reviewable", async function (assert) {
@ -132,8 +131,8 @@ acceptance("Review", function (needs) {
await visit("/review"); await visit("/review");
assert.ok(exists(`${topic} .reviewable-action.approve`)); assert.dom(`${topic} .reviewable-action.approve`).exists();
assert.ok(!exists(`${topic} .badge-category__name`)); assert.dom(`${topic} .badge-category__name`).doesNotExist();
assert.strictEqual( assert.strictEqual(
query(`${topic} .discourse-tag:nth-of-type(1)`).innerText, query(`${topic} .discourse-tag:nth-of-type(1)`).innerText,

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { import {
acceptance, acceptance,
count, count,
exists,
query, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -19,7 +18,9 @@ acceptance("Search - Mobile", function (needs) {
.dom("input.full-page-search") .dom("input.full-page-search")
.exists("it shows the full page search form"); .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"); await click(".advanced-filters summary");

View File

@ -13,7 +13,6 @@ import searchFixtures from "discourse/tests/fixtures/search-fixtures";
import { import {
acceptance, acceptance,
count, count,
exists,
query, query,
queryAll, queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -62,7 +61,7 @@ acceptance("Search - Anonymous", function (needs) {
await visit("/"); await visit("/");
await click("#search-button"); await click("#search-button");
assert.ok(exists("#search-term"), "it shows the search input"); assert.dom("#search-term").exists("shows the search input");
assert assert
.dom(".show-advanced-search") .dom(".show-advanced-search")
.exists("it shows full page search button"); .exists("it shows full page search button");
@ -400,12 +399,11 @@ acceptance("Search - Anonymous", function (needs) {
await fillIn("#search-term", "dev"); await fillIn("#search-term", "dev");
await triggerKeyEvent("#search-term", "keyup", "Enter"); await triggerKeyEvent("#search-term", "keyup", "Enter");
assert.ok( assert
exists( .dom(
".search-menu .search-result-topic .item .topic-title span#topic-with-html" ".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) { 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 fillIn("#search-term", "dev");
await triggerKeyEvent("#search-term", "keyup", "Enter"); await triggerKeyEvent("#search-term", "keyup", "Enter");
assert.ok( assert
exists( .dom(".search-menu .search-result-topic .item .topic-title img[alt='+1']")
".search-menu .search-result-topic .item .topic-title img[alt='+1']" .exists(":+1: in the topic title is properly converted to an emoji");
),
":+1: in the topic title is properly converted to an emoji"
);
}); });
}); });
@ -567,7 +562,7 @@ acceptance("Search - Authenticated", function (needs) {
await visit("/"); await visit("/");
await click("#search-button"); await click("#search-button");
await fillIn("#search-term", "dev"); 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"); await triggerKeyEvent("#search-term", "keyup", "Enter");
assert assert
@ -603,7 +598,7 @@ acceptance("Search - Authenticated", function (needs) {
query("#search-button"), query("#search-button"),
"Escaping search returns focus to 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 click("#search-button");
await triggerKeyEvent(document.activeElement, "keyup", "ArrowDown"); await triggerKeyEvent(document.activeElement, "keyup", "ArrowDown");
@ -627,12 +622,12 @@ acceptance("Search - Authenticated", function (needs) {
.dom(query(`.search-menu`)) .dom(query(`.search-menu`))
.doesNotExist("search dropdown is collapsed after second Enter hit"); .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"); 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"); 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) { 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 = const firstItem =
".search-menu .results ul.search-menu-assistant .search-link"; ".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(); const firstTag = query(`${firstItem} .search-item-tag`).textContent.trim();
assert.strictEqual(firstTag, "monkey"); assert.strictEqual(firstTag, "monkey");
@ -1219,13 +1214,13 @@ acceptance("Search - assistant", function (needs) {
await visit("/u/charlie/messages"); await visit("/u/charlie/messages");
await click("#search-button"); 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 fillIn("#search-term", "");
await query("input#search-term").focus(); await query("input#search-term").focus();
await triggerKeyEvent("input#search-term", "keyup", "Backspace"); 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 clickOutside();
await click("#search-button"); await click("#search-button");

View File

@ -1,11 +1,7 @@
import { click, currentURL, fillIn, visit } from "@ember/test-helpers"; import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { SECOND_FACTOR_METHODS } from "discourse/models/user"; import { SECOND_FACTOR_METHODS } from "discourse/models/user";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
const { TOTP, BACKUP_CODE, SECURITY_KEY } = SECOND_FACTOR_METHODS; 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"); 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 assert
.dom(".toggle-second-factor-method.security-key") .dom(".toggle-second-factor-method.security-key")
.exists("security key is now shown as alternative method"); .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"); await visit("/session/2fa?nonce=ok110111");
assert.notOk(exists(".sidebar-container"), "does not display the sidebar"); assert.dom(".sidebar-container").doesNotExist();
}); });
}); });

View File

@ -1,6 +1,6 @@
import { click, tab, triggerKeyEvent, visit } from "@ember/test-helpers"; import { click, tab, triggerKeyEvent, visit } from "@ember/test-helpers";
import { test } from "qunit"; 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"; import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("Select-kit - Composer - Accessibility", function (needs) { 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") .dom(".mini-tag-chooser .select-kit-body .select-kit-row")
.doesNotExist("Hitting Escape dismisses the tag chooser"); .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");
}); });
}); });

View File

@ -1,11 +1,7 @@
import { click, currentURL, visit } from "@ember/test-helpers"; import { click, currentURL, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import CategoryFixtures from "discourse/tests/fixtures/category-fixtures"; import CategoryFixtures from "discourse/tests/fixtures/category-fixtures";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -35,7 +31,7 @@ acceptance("Share and Invite modal", function (needs) {
await click("#topic-footer-button-share-and-invite"); 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 assert
.dom("#modal-alert.alert-warning") .dom("#modal-alert.alert-warning")
@ -66,7 +62,7 @@ acceptance("Share and Invite modal", function (needs) {
); );
await click("#post_2 a.post-date"); 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( assert.strictEqual(
currentURL(), currentURL(),
"/t/short-topic-with-two-posts/54077", "/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"); 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 assert
.dom("#modal-alert.alert-warning") .dom("#modal-alert.alert-warning")
.exists("it shows restricted warning"); .exists("it shows restricted warning");
@ -112,7 +108,7 @@ acceptance("Share and Invite modal - mobile", function (needs) {
await subject.expand(); await subject.expand();
await subject.selectRowByValue("share-and-invite"); 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");
}); });
}); });

View File

@ -1,11 +1,7 @@
import { visit } from "@ember/test-helpers"; import { visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import Site from "discourse/models/site"; import Site from "discourse/models/site";
import { import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
acceptance("Sidebar - Anonymous - Categories Section", function (needs) { acceptance("Sidebar - Anonymous - Categories Section", function (needs) {
needs.settings({ needs.settings({
@ -133,11 +129,12 @@ acceptance("Sidebar - Anonymous - Categories Section", function (needs) {
await visit("/"); await visit("/");
assert.notOk( assert
exists( .dom(
`.sidebar-section[data-section-name='categories'] .sidebar-section-link[data-link-name='${firstCategory.slug}']` `.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"
);
}); });
}); });

View File

@ -1,10 +1,6 @@
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
acceptance("Sidebar - Anonymous user - Community Section", function (needs) { acceptance("Sidebar - Anonymous user - Community Section", function (needs) {
@ -34,12 +30,11 @@ acceptance("Sidebar - Anonymous user - Community Section", function (needs) {
await visit("/"); await visit("/");
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='users']" ".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) { test("users, about, faq, groups and badges section links are shown in more...", async function (assert) {

View File

@ -1,7 +1,6 @@
import { click, triggerEvent, visit, waitFor } from "@ember/test-helpers"; import { click, triggerEvent, visit, waitFor } from "@ember/test-helpers";
import $ from "jquery";
import { test } from "qunit"; 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) { acceptance("Sidebar - Narrow Desktop", function (needs) {
needs.user(); 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) { test("wide sidebar is changed to cloak when resize to narrow screen", async function (assert) {
await visit("/"); 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"); 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"); 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"; document.body.style.width = "767px";
@ -47,7 +46,7 @@ acceptance("Sidebar - Narrow Desktop", function (needs) {
await waitFor("#d-sidebar", { await waitFor("#d-sidebar", {
timeout: 5000, 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) { 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"); await click(".header-dropdown-toggle.current-user button");
$(".header-dropdown-toggle.current-user").click();
assert.dom(".quick-access-panel").exists(); assert.dom(".quick-access-panel").exists();
}); });

View File

@ -8,7 +8,6 @@ import discoveryFixture from "discourse/tests/fixtures/discovery-fixtures";
import { import {
acceptance, acceptance,
count, count,
exists,
publishToMessageBus, publishToMessageBus,
query, query,
queryAll, queryAll,
@ -49,12 +48,11 @@ acceptance(
"there should only be one section link under the section" "there should only be one section link under the section"
); );
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"]` `.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" ".sidebar-section[data-section-name='categories'] .sidebar-section-header"
); );
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='categories'] .sidebar-section-content" ".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) { 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) => { topCategories.forEach((category) => {
assert.ok( assert
exists( .dom(`.sidebar-section-link-wrapper[data-category-id="${category.id}"]`)
`.sidebar-section-link-wrapper[data-category-id=${category.id}]` .exists(`${category.displayName} section link is shown`);
),
`${category.displayName} section link is shown`
);
}); });
}); });
@ -191,12 +185,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) {
await visit("/"); await visit("/");
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${uncategorizedCategory.id}"]` `.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) { 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" "there should only be 4 section link under the section"
); );
assert.ok( assert
exists( .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%)"]` `.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( assert.strictEqual(
query( query(
@ -462,12 +458,11 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` `.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( await click(
`.sidebar-section-link-wrapper[data-category-id="${category2.id}"] a` `.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" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category2.id}"] a.active` `.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( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category3.id}"] .sidebar-section-link-prefix .prefix-badge.d-icon-lock` `.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( assert
exists( .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%)"]` `.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) { 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" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` `.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) { 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" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` `.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) { 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" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` `.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) { 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("/"); await visit("/");
assert.ok( assert
exists( .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%)"]` `.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) { 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" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` `.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) { 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" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` `.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) { 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" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` `.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) { 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" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` `.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) { 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" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a.active` `.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) { 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("/"); await visit("/");
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] .sidebar-section-link-suffix` `.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", { await publishToMessageBus("/unread", {
topic_id: 2, topic_id: 2,
@ -835,12 +831,11 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) {
}, },
}); });
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] .sidebar-section-link-suffix` `.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", { await publishToMessageBus("/unread", {
topic_id: 1, topic_id: 1,
@ -851,12 +846,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) {
}, },
}); });
assert.ok( assert
!exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] .sidebar-section-link-suffix` `.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) { 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( assert
!exists( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] .sidebar-section-link-content-badge` `.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", { await publishToMessageBus("/unread", {
topic_id: 3, topic_id: 3,
@ -1006,12 +1003,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) {
await visit("/"); await visit("/");
assert.ok( assert
exists( .dom(
".sidebar-section-link[data-link-name='configure-default-navigation-menu-categories']" ".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( await click(
".sidebar-section-link[data-link-name='configure-default-navigation-menu-categories']" ".sidebar-section-link[data-link-name='configure-default-navigation-menu-categories']"

View File

@ -11,7 +11,6 @@ import topicFixtures from "discourse/tests/fixtures/discovery-fixtures";
import { import {
acceptance, acceptance,
count, count,
exists,
loggedInUser, loggedInUser,
publishToMessageBus, publishToMessageBus,
query, 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" ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-content" ".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( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary[aria-expanded='true']" ".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( await click(
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary"
); );
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-content" ".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( await click(
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ".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"); await click("#main-outlet");
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-content" ".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( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary[aria-expanded='false']" ".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) { test("clicking on everything link", async function (assert) {
@ -108,7 +108,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
assert.strictEqual( assert.strictEqual(
currentURL(), currentURL(),
"/latest", "/latest",
"it should transition to the latest page" "should transition to the latest page"
); );
assert.strictEqual( assert.strictEqual(
@ -119,12 +119,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" ".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) { 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( assert.strictEqual(
currentURL(), currentURL(),
"/latest", "/latest",
"it should transition to the latest page" "should transition to the latest page"
); );
assert.strictEqual( assert.strictEqual(
@ -152,12 +151,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" ".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) { 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( assert.strictEqual(
currentURL(), currentURL(),
"/new", "/new",
"it should transition to the new page" "should transition to the new page"
); );
assert.strictEqual( assert.strictEqual(
@ -195,12 +193,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" ".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) { 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( assert.strictEqual(
currentURL(), currentURL(),
"/unread", "/unread",
"it should transition to the unread page" "should transition to the unread page"
); );
assert.strictEqual( assert.strictEqual(
@ -246,23 +243,23 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" ".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) { test("clicking on users link", async function (assert) {
await visit("/t/280"); await visit("/t/280");
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='users']" ".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( await click(
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ".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( assert.strictEqual(
currentURL(), currentURL(),
"/u?order=likes_received", "/u?order=likes_received",
"it should transition to the users url" "should transition to the users url"
); );
assert.strictEqual( assert.strictEqual(
@ -286,12 +283,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='users'].active" ".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( assert.strictEqual(
query( query(
@ -303,12 +299,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
await visit("/u"); await visit("/u");
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='users'].active" ".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) { 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" ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary"
); );
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='users']" ".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) { test("clicking on badges link", async function (assert) {
@ -342,7 +336,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
assert.strictEqual( assert.strictEqual(
currentURL(), currentURL(),
"/badges", "/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" ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary"
); );
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='badges']" ".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) { test("clicking on groups link", async function (assert) {
await visit("/t/280"); await visit("/t/280");
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='groups']" ".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( await click(
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ".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( assert.strictEqual(
currentURL(), currentURL(),
"/g", "/g",
"it should transition to the groups url" "should transition to the groups url"
); );
assert.strictEqual( assert.strictEqual(
@ -395,12 +389,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='groups'].active" ".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( assert.strictEqual(
query( query(
@ -412,12 +405,13 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
await visit("/g"); await visit("/g");
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='groups'].active" ".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) { 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" ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary"
); );
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='groups']" ".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) { 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" "navigates to about route correctly"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='about'].active" ".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) { test("navigating to FAQ from sidebar", async function (assert) {
@ -512,11 +506,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
await visit("/"); await visit("/");
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='admin']" ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='admin']"
) )
); .doesNotExist();
}); });
test("clicking on my posts link", async function (assert) { test("clicking on my posts link", async function (assert) {
@ -528,7 +522,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
assert.strictEqual( assert.strictEqual(
currentURL(), currentURL(),
`/u/${loggedInUser().username}/activity`, `/u/${loggedInUser().username}/activity`,
"it should transition to the user's activity url" "should transition to the user's activity url"
); );
assert.strictEqual( assert.strictEqual(
@ -539,21 +533,21 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='my-posts'].active" ".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`); await visit(`/u/${loggedInUser().username}/activity/drafts`);
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='my-posts'].active" ".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) { 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( assert.strictEqual(
currentURL(), currentURL(),
`/u/${loggedInUser().username}/activity/drafts`, `/u/${loggedInUser().username}/activity/drafts`,
"it transitions to the user's activity drafts url" "transitions to the user's activity drafts url"
); );
assert.strictEqual( assert.strictEqual(
@ -581,21 +575,19 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='my-posts'].active" ".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`); await visit(`/u/${loggedInUser().username}/activity`);
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='my-posts'].active" ".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) { 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" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" ".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) { 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" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" ".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) { 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" "only one link is marked as active"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='everything'].active" ".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) { 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("/"); await visit("/");
assert.ok( assert
exists( .dom(
".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-suffix" ".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( const topicTrackingState = this.container.lookup(
"service:topic-tracking-state" "service:topic-tracking-state"
@ -794,17 +782,16 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
}, },
}); });
assert.ok( assert
exists( .dom(
".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-suffix" ".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( assert.strictEqual(
Object.keys(topicTrackingState.stateChangeCallbacks).length, Object.keys(topicTrackingState.stateChangeCallbacks).length,
initialCallbackCount, 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 // simulate reading topic 1
@ -818,12 +805,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
}, },
}); });
assert.ok( assert
!exists( .dom(
".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-suffix" ".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) { 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" ".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-content-badge"
).textContent.trim(), ).textContent.trim(),
"3 unread", "3 unread",
"it displays the right unread count" "displays the right unread count"
); );
// simulate reading topic 2 // 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" ".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-content-badge"
).textContent.trim(), ).textContent.trim(),
"2 unread", "2 unread",
"it updates the unread count" "updates the unread count"
); );
// simulate reading topic 3 // 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" ".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-content-badge"
).textContent.trim(), ).textContent.trim(),
"1 new", "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", { await publishToMessageBus("/unread", {
@ -945,12 +931,11 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
}, },
}); });
assert.ok( assert
!exists( .dom(
".sidebar-section-link[data-link-name='everything'] .sidebar-section-link-content-badge" ".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) { 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("/"); await visit("/");
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='review']" ".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( await click(
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary"
); );
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='review']" ".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) { 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"); await visit("/review");
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='review'].active" ".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("/"); await visit("/");
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='review']" ".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( await click(
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-content .sidebar-section-link[data-link-name='review']" ".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}`, { await publishToMessageBus(`/reviewable_counts/${loggedInUser().id}`, {
reviewable_count: 34, reviewable_count: 34,
}); });
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='review']" ".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( assert.strictEqual(
query( 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" ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary"
); );
assert.notOk( assert
exists( .dom(
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-content .sidebar-section-link[data-link-name='review']" ".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) { 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" "displays the right title for the link"
); );
assert.ok( assert
exists( .dom(
".sidebar-section-link[data-link-name='unread'] .sidebar-section-link-prefix.icon .d-icon-wrench" ".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']"); 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" "displays the right title for the link"
); );
assert.ok( assert
exists( .dom(
".sidebar-section-link[data-link-name='user-summary'] .sidebar-section-link-prefix.icon .d-icon-link" ".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"); await click(".btn-sidebar-toggle");

View File

@ -4,7 +4,6 @@ import { NotificationLevels } from "discourse/lib/notification-levels";
import { import {
acceptance, acceptance,
count, count,
exists,
publishToMessageBus, publishToMessageBus,
query, query,
queryAll, queryAll,
@ -28,10 +27,9 @@ acceptance(
test("clicking on section header button", async function (assert) { test("clicking on section header button", async function (assert) {
await visit("/"); await visit("/");
assert.ok( assert
!exists(".sidebar-section[data-section-name='messages']"), .dom(".sidebar-section[data-section-name='messages']")
"does not display messages section in sidebar" .doesNotExist("does not display messages section in sidebar");
);
}); });
} }
); );
@ -78,10 +76,7 @@ acceptance(
".sidebar-section[data-section-name='messages'] .sidebar-section-header-button" ".sidebar-section[data-section-name='messages'] .sidebar-section-header-button"
); );
assert.ok( assert.dom("#reply-control.private-message").exists("opens the composer");
exists("#reply-control.private-message"),
"it opens the composer"
);
}); });
test("clicking on section header link", async function (assert) { test("clicking on section header link", async function (assert) {
@ -100,12 +95,11 @@ acceptance(
test("personal messages section links", async function (assert) { test("personal messages section links", async function (assert) {
await visit("/"); await visit("/");
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='personal-messages-inbox']" ".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( assert.strictEqual(
count( count(
@ -119,12 +113,11 @@ acceptance(
".sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='personal-messages-inbox']" ".sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='personal-messages-inbox']"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='personal-messages-inbox'].active" ".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( assert.strictEqual(
count( count(
@ -161,19 +154,17 @@ acceptance(
"only two links are marked as active in the sidebar" "only two links are marked as active in the sidebar"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='personal-messages-inbox'].active" ".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( assert
exists( .dom(
`.sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='personal-messages-${type}'].active` `.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 assert
.dom( .dom(
@ -299,19 +290,17 @@ acceptance(
"only two links are marked as active in the sidebar" "only two links are marked as active in the sidebar"
); );
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='group-messages-inbox'].group1.active" ".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( assert
exists( .dom(
`.sidebar-section[data-section-name='messages'] .sidebar-section-link[data-link-name='group-messages-${type}'].group1.active` `.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`);
);
}); });
}); });

View File

@ -5,7 +5,6 @@ import discoveryFixture from "discourse/tests/fixtures/discovery-fixtures";
import { import {
acceptance, acceptance,
count, count,
exists,
publishToMessageBus, publishToMessageBus,
query, query,
updateCurrentUser, updateCurrentUser,
@ -377,26 +376,25 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
await visit("/"); await visit("/");
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-tag-name=tag1] .sidebar-section-link-suffix` `.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( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-tag-name=tag2] .sidebar-section-link-suffix` `.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( assert
!exists( .dom(
`.sidebar-section-link-wrapper[data-tag-name=tag3] .sidebar-section-link-suffix` `.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", { await publishToMessageBus("/unread", {
topic_id: 2, topic_id: 2,
@ -407,12 +405,11 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
}, },
}); });
assert.ok( assert
exists( .dom(
`.sidebar-section-link-wrapper[data-tag-name=tag1] .sidebar-section-link-suffix` `.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", { await publishToMessageBus("/unread", {
topic_id: 1, topic_id: 1,
@ -423,12 +420,11 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
}, },
}); });
assert.ok( assert
!exists( .dom(
`.sidebar-section-link-wrapper[data-tag-name=tag1] .sidebar-section-link-suffix` `.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) { 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` `displays 1 unread count for tag2 section link`
); );
assert.ok( assert
!exists( .dom(
`.sidebar-section-link-wrapper[data-tag-name=tag3] .sidebar-section-link-content-badge` `.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", { await publishToMessageBus("/unread", {
topic_id: 2, topic_id: 2,
@ -536,12 +531,11 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
}, },
}); });
assert.ok( assert
!exists( .dom(
`.sidebar-section-link-wrapper[data-tag-name=tag1] .sidebar-section-link-content-badge` `.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) { 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("/"); await visit("/");
assert.ok( assert
exists( .dom(
".sidebar-section-link[data-link-name='configure-default-navigation-menu-tags']" ".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( await click(
".sidebar-section-link[data-link-name='configure-default-navigation-menu-tags']" ".sidebar-section-link[data-link-name='configure-default-navigation-menu-tags']"

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import Sinon from "sinon"; import Sinon from "sinon";
import { import {
acceptance, acceptance,
exists,
query, query,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -23,10 +22,9 @@ acceptance(
await visit("/"); await visit("/");
await click("#toggle-hamburger-menu"); await click("#toggle-hamburger-menu");
assert.ok( assert
exists(".sidebar-section-header.sidebar-section-header-collapsable"), .dom(".sidebar-section-header.sidebar-section-header-collapsable")
"sections are collapsable" .exists("sections are collapsable");
);
}); });
} }
); );
@ -44,42 +42,39 @@ acceptance(
await visit("/"); await visit("/");
await click("#toggle-hamburger-menu"); await click("#toggle-hamburger-menu");
assert.ok( assert
exists(".sidebar-hamburger-dropdown"), .dom(".sidebar-hamburger-dropdown")
"displays the sidebar dropdown" .exists("displays the sidebar dropdown");
);
await click("#toggle-hamburger-menu"); await click("#toggle-hamburger-menu");
assert.notOk( assert
exists(".sidebar-hamburger-dropdown"), .dom(".sidebar-hamburger-dropdown")
"hides the sidebar dropdown" .doesNotExist("hides the sidebar dropdown");
);
}); });
test("sections are not collapsable", async function (assert) { test("sections are not collapsable", async function (assert) {
await visit("/"); await visit("/");
await click("#toggle-hamburger-menu"); await click("#toggle-hamburger-menu");
assert.notOk( assert
exists(".sidebar-section-header.sidebar-section-header-collapsable"), .dom(".sidebar-section-header.sidebar-section-header-collapsable")
"sections are not collapsable" .doesNotExist("sections are not collapsable");
);
}); });
test("'more' dropdown should display as regular list items in header dropdown mode", async function (assert) { test("'more' dropdown should display as regular list items in header dropdown mode", async function (assert) {
await visit("/"); await visit("/");
await click("#toggle-hamburger-menu"); await click("#toggle-hamburger-menu");
assert.ok( assert
exists("[data-link-name='admin']"), .dom("[data-link-name='admin']")
"the admin link is not within the 'more' dropdown" .exists("the admin link is not within the 'more' dropdown");
);
assert.notOk( assert
exists(".sidebar-more-section-links-details-summary"), .dom(".sidebar-more-section-links-details-summary")
"the 'more' dropdown should not be present in header dropdown mode" .doesNotExist(
); "the 'more' dropdown should not be present in header dropdown mode"
);
}); });
} }
); );
@ -101,19 +96,17 @@ acceptance(
)}"]` )}"]`
); );
assert.ok( assert
exists("#keyboard-shortcuts-help"), .dom("#keyboard-shortcuts-help")
"keyboard shortcuts help is displayed" .exists("keyboard shortcuts help is displayed");
);
}); });
test("sidebar is disabled on wizard route", async function (assert) { test("sidebar is disabled on wizard route", async function (assert) {
await visit("/wizard"); await visit("/wizard");
assert.notOk( assert
exists(".sidebar-container"), .dom(".sidebar-container")
"does not display the sidebar on wizard route" .doesNotExist("does not display the sidebar on wizard route");
);
}); });
test("showing and hiding sidebar", async function (assert) { test("showing and hiding sidebar", async function (assert) {
@ -124,10 +117,9 @@ acceptance(
"adds sidebar utility class to body" "adds sidebar utility class to body"
); );
assert.ok( assert
exists(".sidebar-container"), .dom(".sidebar-container")
"displays the sidebar by default" .exists("displays the sidebar by default");
);
await click(".btn-sidebar-toggle"); await click(".btn-sidebar-toggle");
@ -136,11 +128,11 @@ acceptance(
"removes sidebar utility class from body" "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"); 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) { test("button to toggle between mobile and desktop view on touch devices ", async function (assert) {
@ -149,21 +141,19 @@ acceptance(
await visit("/"); await visit("/");
assert.ok( assert
exists( .dom(
`.sidebar-footer-actions-toggle-mobile-view[title="${I18n.t( `.sidebar-footer-actions-toggle-mobile-view[title="${I18n.t(
"mobile_view" "mobile_view"
)}"]` )}"]`
), )
"displays the right title for the button" .exists("displays the right title for the button");
);
assert.ok( assert
exists( .dom(
".sidebar-footer-actions-toggle-mobile-view .d-icon-mobile-screen-button" ".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) { 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) { test("accessibility of sidebar section header", async function (assert) {
await visit("/"); await visit("/");
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='categories'] .sidebar-section-header[aria-expanded='true'][aria-controls='sidebar-section-content-categories']" ".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"); await click(".sidebar-section-header");
assert.ok( assert
exists( .dom(
".sidebar-section[data-section-name='categories'] .sidebar-section-header[aria-expanded='false'][aria-controls='sidebar-section-content-categories']" ".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) { test("accessibility of sidebar toggle", async function (assert) {
await visit("/"); await visit("/");
assert.ok( assert
exists( .dom(
".btn-sidebar-toggle[aria-expanded='true'][aria-controls='d-sidebar']" ".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( assert.strictEqual(
query(".btn-sidebar-toggle").title, query(".btn-sidebar-toggle").title,
@ -226,12 +219,13 @@ acceptance(
await click(".btn-sidebar-toggle"); await click(".btn-sidebar-toggle");
assert.ok( assert
exists( .dom(
".btn-sidebar-toggle[aria-expanded='false'][aria-controls='d-sidebar']" ".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( assert.strictEqual(
query(".btn-sidebar-toggle").title, query(".btn-sidebar-toggle").title,

View File

@ -1,18 +1,18 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; 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 () { acceptance("Signing In", function () {
test("sign in", async function (assert) { test("sign in", async function (assert) {
await visit("/"); await visit("/");
await click("header .login-button"); 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 // Test invalid password first
await fillIn("#login-account-name", "eviltrout"); await fillIn("#login-account-name", "eviltrout");
await fillIn("#login-account-password", "incorrect"); await fillIn("#login-account-password", "incorrect");
await click(".d-modal__footer .btn-primary"); 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 assert
.dom(".d-modal__footer .btn-primary:disabled") .dom(".d-modal__footer .btn-primary:disabled")
.doesNotExist("enables the login button"); .doesNotExist("enables the login button");
@ -37,7 +37,7 @@ acceptance("Signing In", function () {
test("sign in - not activated", async function (assert) { test("sign in - not activated", async function (assert) {
await visit("/"); await visit("/");
await click("header .login-button"); 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-name", "eviltrout");
await fillIn("#login-account-password", "not-activated"); await fillIn("#login-account-password", "not-activated");
@ -45,19 +45,23 @@ acceptance("Signing In", function () {
assert assert
.dom(".d-modal__body b") .dom(".d-modal__body b")
.hasText("<small>eviltrout@example.com</small>"); .hasText("<small>eviltrout@example.com</small>");
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"); await click(".d-modal__footer button.resend");
assert assert
.dom(".d-modal__body b") .dom(".d-modal__body b")
.hasText("<small>current@example.com</small>"); .hasText("<small>current@example.com</small>");
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) { test("sign in - not activated - edit email", async function (assert) {
await visit("/"); await visit("/");
await click("header .login-button"); 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-name", "eviltrout");
await fillIn("#login-account-password", "not-activated-edit"); await fillIn("#login-account-password", "not-activated-edit");
@ -77,7 +81,7 @@ acceptance("Signing In", function () {
await visit("/"); await visit("/");
await click("header .login-button"); 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-name", "eviltrout");
await fillIn("#login-account-password", "need-second-factor"); await fillIn("#login-account-password", "need-second-factor");
@ -103,7 +107,7 @@ acceptance("Signing In", function () {
await visit("/"); await visit("/");
await click("header .login-button"); 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-name", "eviltrout");
await fillIn("#login-account-password", "need-security-key"); await fillIn("#login-account-password", "need-security-key");
@ -131,7 +135,7 @@ acceptance("Signing In", function () {
assert assert
.dom(".d-modal__footer .btn-primary:disabled") .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) { test("second factor backup - invalid token", async function (assert) {

View File

@ -1,7 +1,7 @@
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; 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) { acceptance("Tags intersection", function (needs) {
needs.user(); needs.user();
@ -28,7 +28,7 @@ acceptance("Tags intersection", function (needs) {
await visit("/tags/intersection/first/second"); await visit("/tags/intersection/first/second");
await click("#create-topic"); 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 assert
.dom(".composer-fields .mini-tag-chooser") .dom(".composer-fields .mini-tag-chooser")
.hasText("first, second", "populates the tags when clicking 'New topic'"); .hasText("first, second", "populates the tags when clicking 'New topic'");

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { import {
acceptance, acceptance,
count, count,
exists,
invisible, invisible,
query, query,
queryAll, queryAll,
@ -112,7 +111,7 @@ acceptance("Tags", function (needs) {
document.body.classList.contains("tags-page"), document.body.classList.contains("tags-page"),
"has the body class" "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) { test("dismiss notifications", async function (assert) {
@ -434,7 +433,7 @@ acceptance("Tag info", function (needs) {
assert.strictEqual(count("#show-tag-info"), 1); assert.strictEqual(count("#show-tag-info"), 1);
await click("#show-tag-info"); 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( assert.ok(
query(".tag-info .tag-associations").innerText.includes("Gardening"), query(".tag-info .tag-associations").innerText.includes("Gardening"),
"show tag group names" "show tag group names"
@ -449,9 +448,9 @@ acceptance("Tag info", function (needs) {
1, 1,
"show the category" "show the category"
); );
assert.ok(!exists("#rename-tag"), "can't rename tag"); assert.dom("#rename-tag").doesNotExist("can't rename tag");
assert.ok(!exists("#edit-synonyms"), "can't edit synonyms"); assert.dom("#edit-synonyms").doesNotExist("can't edit synonyms");
assert.ok(!exists("#delete-tag"), "can't delete tag"); assert.dom("#delete-tag").doesNotExist("can't delete tag");
}); });
test("tag info hides only current tag in synonyms dropdown", async function (assert) { 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); assert.strictEqual(count("#show-tag-info"), 1);
await click("#show-tag-info"); 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"); await click("#edit-synonyms");
@ -483,7 +482,7 @@ acceptance("Tag info", function (needs) {
assert.strictEqual(count("#show-tag-info"), 1); assert.strictEqual(count("#show-tag-info"), 1);
await click("#show-tag-info"); 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"); await click(".edit-tag");
assert.strictEqual( assert.strictEqual(
@ -600,9 +599,9 @@ acceptance("Tag info", function (needs) {
assert.strictEqual(count("#show-tag-info"), 1); assert.strictEqual(count("#show-tag-info"), 1);
await click("#show-tag-info"); await click("#show-tag-info");
assert.ok(exists(".edit-tag"), "can rename tag"); assert.dom(".edit-tag").exists("can rename tag");
assert.ok(exists("#edit-synonyms"), "can edit synonyms"); assert.dom("#edit-synonyms").exists("can edit synonyms");
assert.ok(exists("#delete-tag"), "can delete tag"); assert.dom("#delete-tag").exists("can delete tag");
await click("#edit-synonyms"); await click("#edit-synonyms");
assert.strictEqual( assert.strictEqual(

View File

@ -1,10 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
acceptance("Theme", function (needs) { acceptance("Theme", function (needs) {
@ -189,20 +185,14 @@ acceptance("Theme", function (needs) {
); );
await click(".install-theme-content button.advanced-repo"); await click(".install-theme-content button.advanced-repo");
assert.notOk( assert
exists( .dom(".admin-install-theme-modal .d-modal__footer .install-theme-warning")
".admin-install-theme-modal .d-modal__footer .install-theme-warning" .doesNotExist("no Git warning is displayed");
),
"no Git warning is displayed"
);
await click(".admin-install-theme-modal .d-modal__footer .btn-primary"); await click(".admin-install-theme-modal .d-modal__footer .btn-primary");
assert.ok( assert
exists( .dom(".admin-install-theme-modal .d-modal__footer .install-theme-warning")
".admin-install-theme-modal .d-modal__footer .install-theme-warning" .exists("Git warning is displayed");
),
"Git warning is displayed"
);
await click(".admin-install-theme-modal .d-modal__footer .btn-danger"); await click(".admin-install-theme-modal .d-modal__footer .btn-danger");

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { withPluginApi } from "discourse/lib/plugin-api"; import { withPluginApi } from "discourse/lib/plugin-api";
import { import {
acceptance, acceptance,
exists,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -11,7 +10,7 @@ import I18n from "discourse-i18n";
acceptance("Topic - Admin Menu Anonymous Users", function () { acceptance("Topic - Admin Menu Anonymous Users", function () {
test("Enter as a regular user", async function (assert) { test("Enter as a regular user", async function (assert) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
assert.ok(exists("#topic"), "The topic was rendered"); assert.dom("#topic").exists("the topic is rendered");
assert assert
.dom(".toggle-admin-menu") .dom(".toggle-admin-menu")
.doesNotExist("The admin menu button was not rendered"); .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 }); updateCurrentUser({ moderator: false, admin: false, trust_level: 1 });
await visit("/t/topic-for-group-moderators/2480"); 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 assert
.dom(".toggle-admin-menu") .dom(".toggle-admin-menu")
.exists("The admin menu button was rendered"); .exists("The admin menu button was rendered");
await click(".toggle-admin-menu"); 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) { test("Enter as a user with moderator and admin permissions", async function (assert) {
updateCurrentUser({ moderator: true, admin: true, trust_level: 4 }); updateCurrentUser({ moderator: true, admin: true, trust_level: 4 });
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
assert.ok(exists("#topic"), "The topic was rendered"); assert.dom("#topic").exists("the topic is rendered");
assert assert
.dom(".toggle-admin-menu") .dom(".toggle-admin-menu")
.exists("The admin menu button was rendered"); .exists("The admin menu button was rendered");
@ -61,7 +60,7 @@ acceptance("Topic - Admin Menu", function (needs) {
}); });
await visit("/t/internationalization-localization/280"); 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"); await click(".toggle-admin-menu");
assert assert
.dom(".extra-button svg.d-icon-heart") .dom(".extra-button svg.d-icon-heart")

View File

@ -1,12 +1,12 @@
import { visit } from "@ember/test-helpers"; import { visit } from "@ember/test-helpers";
import { test } from "qunit"; 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 () { acceptance("Topic - Anonymous", function () {
test("Enter a Topic", async function (assert) { test("Enter a Topic", async function (assert) {
await visit("/t/internationalization-localization/280/1"); await visit("/t/internationalization-localization/280/1");
assert.ok(exists("#topic"), "The topic was rendered"); assert.dom("#topic").exists("The topic was rendered");
assert.ok(exists("#topic .cooked"), "The topic has cooked posts"); assert.dom("#topic .cooked").exists("The topic has cooked posts");
assert assert
.dom(".shared-draft-notice") .dom(".shared-draft-notice")
.doesNotExist("no shared draft unless there's a dest category id"); .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) { test("Enter without an id", async function (assert) {
await visit("/t/internationalization-localization"); 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) { test("Enter a 404 topic", async function (assert) {
await visit("/t/not-found/404"); await visit("/t/not-found/404");
assert.ok(!exists("#topic"), "The topic was not rendered"); assert.dom("#topic").doesNotExist("The topic was not rendered");
assert.ok(exists(".topic-error"), "An error message is displayed"); assert.dom(".topic-error").exists("An error message is displayed");
}); });
test("Enter without access", async function (assert) { test("Enter without access", async function (assert) {
await visit("/t/i-dont-have-access/403"); await visit("/t/i-dont-have-access/403");
assert.ok(!exists("#topic"), "The topic was not rendered"); assert.dom("#topic").doesNotExist("The topic was not rendered");
assert.ok(exists(".topic-error"), "An error message is displayed"); assert.dom(".topic-error").exists("An error message is displayed");
}); });
test("Enter with 500 errors", async function (assert) { test("Enter with 500 errors", async function (assert) {
await visit("/t/throws-error/500"); await visit("/t/throws-error/500");
assert.ok(!exists("#topic"), "The topic was not rendered"); assert.dom("#topic").doesNotExist("The topic was not rendered");
assert.ok(exists(".topic-error"), "An error message is displayed"); assert.dom(".topic-error").exists("An error message is displayed");
}); });
}); });

View File

@ -6,7 +6,6 @@ import discoveryFixtures from "discourse/tests/fixtures/discovery-fixtures";
import topFixtures from "discourse/tests/fixtures/top-fixtures"; import topFixtures from "discourse/tests/fixtures/top-fixtures";
import { import {
acceptance, acceptance,
exists,
publishToMessageBus, publishToMessageBus,
query, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -30,8 +29,8 @@ acceptance("Topic Discovery", function (needs) {
document.body.classList.contains("navigation-topics"), document.body.classList.contains("navigation-topics"),
"has the default navigation" "has the default navigation"
); );
assert.ok(exists(".topic-list"), "The list of topics was rendered"); assert.dom(".topic-list").exists("the list of topics was rendered");
assert.ok(exists(".topic-list .topic-list-item"), "has topics"); assert.dom(".topic-list .topic-list-item").exists("has topics");
assert assert
.dom("a[data-user-card=eviltrout] img.avatar") .dom("a[data-user-card=eviltrout] img.avatar")
@ -50,9 +49,9 @@ acceptance("Topic Discovery", function (needs) {
); );
await visit("/c/bug"); await visit("/c/bug");
assert.ok(exists(".topic-list"), "The list of topics was rendered"); assert.dom(".topic-list").exists("the list of topics was rendered");
assert.ok(exists(".topic-list .topic-list-item"), "has topics"); assert.dom(".topic-list .topic-list-item").exists("has topics");
assert.ok(!exists(".category-list"), "doesn't render subcategories"); assert.dom(".category-list").doesNotExist("doesn't render subcategories");
assert.ok( assert.ok(
document.body.classList.contains("category-bug"), document.body.classList.contains("category-bug"),
"has a custom css class for the category id on the body" "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"), !document.body.classList.contains("category-bug"),
"removes the custom category class" "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( assert.ok(
document.body.classList.contains("categories-list"), document.body.classList.contains("categories-list"),
"has a custom class to indicate categories" "has a custom class to indicate categories"
@ -78,16 +77,16 @@ acceptance("Topic Discovery", function (needs) {
!document.body.classList.contains("categories-list"), !document.body.classList.contains("categories-list"),
"removes the `categories-list` class" "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"); 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 assert
.dom(".category-boxes") .dom(".category-boxes")
.exists("The list of subcategories were rendered with box style"); .exists("The list of subcategories were rendered with box style");
await visit("/c/dev"); 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 assert
.dom(".category-boxes-with-topics") .dom(".category-boxes-with-topics")
.exists( .exists(

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import topicFixtures from "discourse/tests/fixtures/topic"; import topicFixtures from "discourse/tests/fixtures/topic";
import { import {
acceptance, acceptance,
exists,
query, query,
queryAll, queryAll,
selectText, 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) { test("Does not show the quote share buttons by default", async function (assert) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
await selectText("#post_5 blockquote"); await selectText("#post_5 blockquote");
assert.ok(exists(".insert-quote"), "it shows the quote button"); assert.dom(".insert-quote").exists("shows the quote button");
assert.ok(!exists(".quote-sharing"), "it does not show quote sharing"); assert.dom(".quote-sharing").doesNotExist("does not show quote sharing");
}); });
test("Shows quote share buttons with the right site settings", async function (assert) { 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 visit("/t/internationalization-localization/280");
await selectText("#post_5 blockquote"); 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 assert
.dom(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`) .dom(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`)
.exists("it includes the twitter share button"); .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) { test("Shows quote button in closed topics", async function (assert) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
await selectText("#post_1 .cooked p:first-child"); 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"); await click(".insert-quote");
assert.ok( assert.ok(
@ -109,7 +108,9 @@ acceptance("Topic - Quote button - anonymous", function (needs) {
assert assert
.dom(`.quote-sharing .btn[title='${I18n.t("share.email")}']`) .dom(`.quote-sharing .btn[title='${I18n.t("share.email")}']`)
.exists("it includes the email share button"); .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) { 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 visit("/t/internationalization-localization/280");
await selectText("#post_5 blockquote"); 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 assert
.dom(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`) .dom(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`)
.exists("it includes the twitter share button"); .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 visit("/t/internationalization-localization/280");
await selectText("#post_5 blockquote"); await selectText("#post_5 blockquote");
assert.ok(!exists(".quote-sharing"), "it does not show quote sharing"); assert.dom(".quote-sharing").doesNotExist("does not show quote sharing");
assert.ok(!exists(".insert-quote"), "it does not show the quote button"); 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 visit("/t/internationalization-localization/280");
await selectText("#post_1 .cooked"); await selectText("#post_1 .cooked");
await triggerKeyEvent(document, "keypress", "Q"); 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( assert.ok(
query(".d-editor-input").value.includes("Any plans to support"), query(".d-editor-input").value.includes("Any plans to support"),

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import topicFixtures from "discourse/tests/fixtures/topic"; import topicFixtures from "discourse/tests/fixtures/topic";
import { import {
acceptance, acceptance,
exists,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; 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" "enabled until combobox is switched to the option Pick Date and Time"
); );
assert.ok(exists("input.date-picker"), "date picker is rendered"); assert.dom("input.date-picker").exists("date picker is rendered");
assert.ok(exists("input.time-input"), "time 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) { test("'Enable' button changes to 'Update' button when slow mode is enabled", async function (assert) {

View File

@ -13,7 +13,6 @@ import {
acceptance, acceptance,
chromeTest, chromeTest,
count, count,
exists,
publishToMessageBus, publishToMessageBus,
query, query,
selectText, selectText,
@ -49,7 +48,7 @@ acceptance("Topic", function (needs) {
await click("button.share:nth-of-type(1)"); await click("button.share:nth-of-type(1)");
await click("button.new-topic"); 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( assert.strictEqual(
query(".d-editor-input").value.trim(), 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.share:nth-of-type(1)");
await click("button.new-topic"); 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( assert.strictEqual(
query(".d-editor-input").value.trim(), query(".d-editor-input").value.trim(),
@ -88,7 +87,7 @@ acceptance("Topic", function (needs) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
await click(".topic-post:first-child button.share"); 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) { test("Copy Link Button", async function (assert) {
@ -105,14 +104,14 @@ acceptance("Topic", function (needs) {
await click("#topic-title .d-icon-pencil"); 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 assert
.dom(".title-wrapper .remove-featured-link") .dom(".title-wrapper .remove-featured-link")
.doesNotExist("link to remove featured link is not shown"); .doesNotExist("link to remove featured link is not shown");
await fillIn("#edit-title", "this is the new title"); await fillIn("#edit-title", "this is the new title");
await click("#topic-title .cancel-edit"); 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) { 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) { test("Marking a topic as wiki", async function (assert) {
await visit("/t/internationalization-localization/280"); 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-more-actions");
await click(".topic-post:nth-of-type(1) button.show-post-admin-menu"); 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(".topic-post:nth-of-type(1) button.show-more-actions");
await click(".widget-button.delete"); await click(".widget-button.delete");
await click(".toggle-admin-menu"); 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) { 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(".widget-button.delete");
await click(".delete-topic-confirm-modal .btn-danger"); await click(".delete-topic-confirm-modal .btn-danger");
await click(".toggle-admin-menu"); 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) { test("Group category moderator posts", async function (assert) {
await visit("/t/topic-for-group-moderators/2480"); await visit("/t/topic-for-group-moderators/2480");
assert.ok(exists(".category-moderator"), "it has a class applied"); assert.dom(".category-moderator").exists("has a class applied");
assert.ok(exists(".d-icon-shield-halved"), "it shows an icon"); assert.dom(".d-icon-shield-halved").exists("shows an icon");
}); });
test("Suspended user posts", async function (assert) { test("Suspended user posts", async function (assert) {
@ -297,14 +296,6 @@ acceptance("Topic featured links", function (needs) {
assert assert
.dom(".title-wrapper .remove-featured-link") .dom(".title-wrapper .remove-featured-link")
.exists("link to 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) { 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 visit("/t/internationalization-localization/280");
await click(".gap"); 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) { test("Quoting a quote keeps the original poster name", async function (assert) {

View File

@ -1,6 +1,6 @@
import { click, currentURL, visit } from "@ember/test-helpers"; import { click, currentURL, visit } from "@ember/test-helpers";
import { test } from "qunit"; 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) { acceptance("Category 404", function (needs) {
needs.pretender((server, helper) => { needs.pretender((server, helper) => {
@ -51,7 +51,7 @@ acceptance("Unknown", function (needs) {
test("Permalink Unknown URL", async function (assert) { test("Permalink Unknown URL", async function (assert) {
await visit("/url-that-doesn't-exist"); 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) { test("Permalink URL to a Topic", async function (assert) {

View File

@ -1,6 +1,6 @@
import { currentRouteName, currentURL, visit } from "@ember/test-helpers"; import { currentRouteName, currentURL, visit } from "@ember/test-helpers";
import { test } from "qunit"; 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 () { acceptance("User Anonymous", function () {
test("Root URL", async function (assert) { test("Root URL", async function (assert) {
@ -23,18 +23,18 @@ acceptance("User Anonymous", function () {
document.body.classList.contains("user-activity-page"), document.body.classList.contains("user-activity-page"),
"has the body class" "has the body class"
); );
assert.ok(exists(".user-main .about"), "it has the about section"); assert.dom(".user-main .about").exists("has the about section");
assert.ok(exists(".user-stream .item"), "it has stream items"); assert.dom(".user-stream .item").exists("has stream items");
await visit("/u/eviltrout/activity/topics"); await visit("/u/eviltrout/activity/topics");
assert.ok(!exists(".user-stream .item"), "has no stream displayed"); assert.dom(".user-stream .item").doesNotExist("has no stream displayed");
assert.ok(exists(".topic-list tr"), "it has a topic list"); assert.dom(".topic-list tr").exists("has a topic list");
await visit("/u/eviltrout/activity/replies"); await visit("/u/eviltrout/activity/replies");
assert.ok(exists(".user-main .about"), "it has the about section"); assert.dom(".user-main .about").exists("has the about section");
assert.ok(exists(".user-stream .item"), "it has stream items"); 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) { test("Badges", async function (assert) {
@ -44,7 +44,7 @@ acceptance("User Anonymous", function () {
document.body.classList.contains("user-badges-page"), document.body.classList.contains("user-badges-page"),
"has the body class" "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) { test("Restricted Routes", async function (assert) {

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { import {
acceptance, acceptance,
count, count,
exists,
queryAll, queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
@ -26,7 +25,7 @@ acceptance("Bookmark - Bulk Actions", function (needs) {
await dropdown.selectRowByValue("clear-reminders"); 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( assert.dom(".dialog-container .dialog-body").includesText(
I18n.t("js.bookmark_bulk_actions.clear_reminders.description", { I18n.t("js.bookmark_bulk_actions.clear_reminders.description", {
count: 2, count: 2,
@ -52,7 +51,7 @@ acceptance("Bookmark - Bulk Actions", function (needs) {
await dropdown.expand(); await dropdown.expand();
await dropdown.selectRowByValue("delete-bookmarks"); 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( assert.dom(".dialog-container .dialog-body").includesText(
I18n.t("js.bookmark_bulk_actions.delete_bookmarks.description", { I18n.t("js.bookmark_bulk_actions.delete_bookmarks.description", {

View File

@ -4,7 +4,6 @@ import { test } from "qunit";
import { import {
acceptance, acceptance,
count, count,
exists,
normalizeHtml, normalizeHtml,
query, query,
visible, visible,
@ -36,7 +35,7 @@ acceptance("User Drafts", function (needs) {
test("Stream - resume draft", async function (assert) { test("Stream - resume draft", async function (assert) {
await visit("/u/eviltrout/activity/drafts"); 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"); await click(".user-stream-item .resume-draft");
assert.strictEqual( assert.strictEqual(
@ -47,7 +46,7 @@ acceptance("User Drafts", function (needs) {
test("Stream - has excerpt", async function (assert) { test("Stream - has excerpt", async function (assert) {
await visit("/u/eviltrout/activity/drafts"); await visit("/u/eviltrout/activity/drafts");
assert.ok(exists(".user-stream-item"), "has drafts"); assert.dom(".user-stream-item").exists("has drafts");
assert.strictEqual( assert.strictEqual(
query(".user-stream-item:nth-child(3) .category").textContent, query(".user-stream-item:nth-child(3) .category").textContent,
"meta" "meta"

View File

@ -17,7 +17,6 @@ import TopicFixtures from "discourse/tests/fixtures/topic";
import UserMenuFixtures from "discourse/tests/fixtures/user-menu"; import UserMenuFixtures from "discourse/tests/fixtures/user-menu";
import { import {
acceptance, acceptance,
exists,
loggedInUser, loggedInUser,
publishToMessageBus, publishToMessageBus,
query, query,
@ -798,7 +797,9 @@ acceptance("User menu", function (needs) {
"/u/eviltrout/notifications", "/u/eviltrout/notifications",
"clicking on active tab navigates to the page it links to" "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 = [ const tabs = [
["#user-menu-button-custom-tab-1", "/u/eviltrout/preferences/account"], ["#user-menu-button-custom-tab-1", "/u/eviltrout/preferences/account"],
@ -820,15 +821,13 @@ acceptance("User menu", function (needs) {
expectedLink, expectedLink,
`clicking on the ${id} tab navigates to ${expectedLink}` `clicking on the ${id} tab navigates to ${expectedLink}`
); );
assert.notOk( assert
exists(".user-menu"), .dom(".user-menu")
"user menu is closed after navigating" .doesNotExist("user menu is closed after navigating");
);
} else { } else {
assert.ok( assert
exists(".user-menu"), .dom(".user-menu")
"user menu remains open if tab doesn't link to anywhere" .exists("user menu remains open if tab doesn't link to anywhere");
);
} }
await click("#site-logo"); await click("#site-logo");
} }
@ -1096,9 +1095,9 @@ acceptance("User menu - Dismiss button", function (needs) {
await click(".user-menu .notifications-dismiss"); await click(".user-menu .notifications-dismiss");
assert.ok( assert
!exists("#user-menu-button-other-notifications .badge-notification") .dom("#user-menu-button-other-notifications .badge-notification")
); .doesNotExist();
assert.ok( assert.ok(
markRead, markRead,
"mark-read request is sent without a confirmation modal" "mark-read request is sent without a confirmation modal"

View File

@ -6,11 +6,7 @@ import pretender, {
fixturesByUrl, fixturesByUrl,
response, response,
} from "discourse/tests/helpers/create-pretender"; } from "discourse/tests/helpers/create-pretender";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object"; import { cloneJSON } from "discourse-common/lib/object";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -269,7 +265,7 @@ acceptance("User Preferences - Account", function (needs) {
await visit("/u/eviltrout/preferences/account"); await visit("/u/eviltrout/preferences/account");
await click(".pref-avatar .btn"); 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"); await click(".avatar-selector-refresh-gravatar");

View File

@ -1,13 +1,13 @@
import { visit } from "@ember/test-helpers"; import { visit } from "@ember/test-helpers";
import { test } from "qunit"; 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) { acceptance("User Preferences Admin", function (needs) {
needs.user({ admin: true }); needs.user({ admin: true });
test("Desktop user admin button", async function (assert) { test("Desktop user admin button", async function (assert) {
await visit("/u/eviltrout"); 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");
}); });
}); });

View File

@ -1,6 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; 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"; import I18n from "discourse-i18n";
acceptance("User Preferences - Email", function (needs) { acceptance("User Preferences - Email", function (needs) {
@ -17,7 +17,7 @@ acceptance("User Preferences - Email", function (needs) {
test("email", async function (assert) { test("email", async function (assert) {
await visit("/u/eviltrout/preferences/email"); 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"); 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) { test("email field always shows up", async function (assert) {
await visit("/u/eviltrout/preferences/email"); 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 fillIn("#change-email", "eviltrout@discourse.org");
await click(".user-preferences button.btn-primary"); 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");
await visit("/u/eviltrout/preferences/email"); 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");
}); });
}); });

View File

@ -7,7 +7,6 @@ import userFixtures from "discourse/tests/fixtures/user-fixtures";
import { import {
acceptance, acceptance,
count, count,
exists,
query, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
@ -28,9 +27,9 @@ acceptance("User Preferences - Interface", function (needs) {
removeCookie("text_size"); removeCookie("text_size");
const savePreferences = async () => { 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"); 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(); 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) { test("does not show option to disable dark mode by default", async function (assert) {
await visit("/u/eviltrout/preferences/interface"); 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) { 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"); 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.ok(exists(".dark-color-scheme"), "has dark color scheme 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) { 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" }]); site.set("user_color_schemes", [{ id: 2, name: "Cool Breeze" }]);
await visit("/u/eviltrout/preferences/interface"); 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( assert.strictEqual(
selectKit(".light-color-scheme .select-kit").header().value(), selectKit(".light-color-scheme .select-kit").header().value(),
@ -132,7 +131,7 @@ acceptance("User Preferences - Interface", function (needs) {
await visit("/u/eviltrout/preferences/interface"); 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"); assert.strictEqual(selectKit(".theme .select-kit").header().value(), "2");
await selectKit(".light-color-scheme .select-kit").expand(); await selectKit(".light-color-scheme .select-kit").expand();
@ -187,10 +186,9 @@ acceptance(
test("show option to disable dark mode", async function (assert) { test("show option to disable dark mode", async function (assert) {
await visit("/u/eviltrout/preferences/interface"); await visit("/u/eviltrout/preferences/interface");
assert.ok( assert
exists(".control-group.dark-mode"), .dom(".control-group.dark-mode")
"it has the option to disable dark mode" .exists("has the option to disable dark mode");
);
}); });
test("no color scheme picker by default", async function (assert) { 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" }]); site.set("user_color_schemes", [{ id: 2, name: "Cool Breeze" }]);
await visit("/u/eviltrout/preferences/interface"); await visit("/u/eviltrout/preferences/interface");
assert.ok(exists(".light-color-scheme"), "has regular picker dropdown"); assert.dom(".light-color-scheme").exists("has regular picker dropdown");
assert.ok( assert
!exists(".dark-color-scheme"), .dom(".dark-color-scheme")
"does not have a dark color scheme picker" .doesNotExist("does not have a dark color scheme picker");
);
}); });
test("light color scheme defaults to custom scheme selected by user", async function (assert) { 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" }]); site.set("user_color_schemes", [{ id: 2, name: "Cool Breeze" }]);
await visit("/u/eviltrout/preferences/interface"); 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( assert.strictEqual(
query(".light-color-scheme .selected-name").dataset.value, query(".light-color-scheme .selected-name").dataset.value,
session.userColorSchemeId.toString(), session.userColorSchemeId.toString(),
@ -243,7 +240,7 @@ acceptance(
await visit("/u/eviltrout/preferences/interface"); 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"); const dropdownObject = selectKit(".light-color-scheme .select-kit");
assert.strictEqual(dropdownObject.header().value(), null); assert.strictEqual(dropdownObject.header().value(), null);
assert.strictEqual( assert.strictEqual(
@ -269,24 +266,23 @@ acceptance(
]); ]);
const savePreferences = async () => { 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"); await click(".save-changes");
assert.ok(exists(".saved"), "it displays the saved message"); assert.dom(".saved").exists("displays the saved message");
query(".saved").remove(); query(".saved").remove();
}; };
await visit("/u/eviltrout/preferences/interface"); 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.ok(exists(".dark-color-scheme"), "has dark color scheme dropdown"); assert.dom(".dark-color-scheme").exists("has dark color scheme dropdown");
assert.strictEqual( assert.strictEqual(
query(".dark-color-scheme .selected-name").dataset.value, query(".dark-color-scheme .selected-name").dataset.value,
session.userDarkSchemeId.toString(), session.userDarkSchemeId.toString(),
"sets site default as selected dark scheme" "sets site default as selected dark scheme"
); );
assert.ok( assert
!exists(".control-group.dark-mode"), .dom(".control-group.dark-mode")
"it does not show disable dark mode checkbox" .doesNotExist("does not show disable dark mode checkbox");
);
removeCookie("color_scheme_id"); removeCookie("color_scheme_id");
removeCookie("dark_scheme_id"); removeCookie("dark_scheme_id");
@ -298,10 +294,9 @@ acceptance(
undefined, undefined,
"cookie is not set" "cookie is not set"
); );
assert.ok( assert
exists(".color-scheme-checkbox input:checked"), .dom(".color-scheme-checkbox input:checked")
"defaults to storing values in user options" .exists("defaults to storing values in user options");
);
await savePreferences(); await savePreferences();
assert.strictEqual( assert.strictEqual(

View File

@ -2,7 +2,6 @@ import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { import {
acceptance, acceptance,
exists,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } 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"); 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) { test("delete backup codes", async function (assert) {

View File

@ -8,7 +8,6 @@ import {
import { test } from "qunit"; import { test } from "qunit";
import { import {
acceptance, acceptance,
exists,
query, query,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } 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 visit("/u/eviltrout/preferences/second-factor");
await click(".new-totp"); 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"); await click(".modal a.show-second-factor-key");
assert assert
@ -85,7 +84,7 @@ acceptance("User Preferences - Second Factor", function (needs) {
await visit("/u/eviltrout/preferences/second-factor"); await visit("/u/eviltrout/preferences/second-factor");
await click(".new-security-key"); 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", ""); await fillIn("#security-key-name", "");

View File

@ -11,7 +11,6 @@ import { fixturesByUrl } from "discourse/tests/helpers/create-pretender";
import { import {
acceptance, acceptance,
count, count,
exists,
publishToMessageBus, publishToMessageBus,
query, query,
updateCurrentUser, updateCurrentUser,
@ -38,10 +37,9 @@ acceptance(
"displays the topic list" "displays the topic list"
); );
assert.ok( assert
!exists(".group-notifications-button"), .dom(".group-notifications-button")
"displays the group notifications button" .doesNotExist("displays the group notifications button");
);
}); });
test("viewing messages of another user", async function (assert) { test("viewing messages of another user", async function (assert) {
@ -49,15 +47,13 @@ acceptance(
await visit("/u/eviltrout/messages"); await visit("/u/eviltrout/messages");
assert.ok( assert
!exists(".messages-nav li a.new"), .dom(".messages-nav li a.new")
"it does not display new filter" .doesNotExist("it does not display new filter");
);
assert.ok( assert
!exists(".messages-nav li a.unread"), .dom(".messages-nav li a.unread")
"it does not display unread filter" .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) { test("order by posts_count", async function (assert) {
await visit("/u/eviltrout/messages"); 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"); 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, actingUserId: 5,
}); });
assert.ok( assert
!exists(".show-mores"), .dom(".show-mores")
`does not display the topic incoming info` .doesNotExist(`does not display the topic incoming info`);
);
}); });
test("incoming group archive message on inbox and archive filter", async function (assert) { test("incoming group archive message on inbox and archive filter", async function (assert) {
@ -341,10 +336,9 @@ acceptance(
await publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 }); await publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 });
assert.ok( assert
exists(".show-mores"), .dom(".show-mores")
`${url} displays the topic incoming info` .exists(`${url} displays the topic incoming info`);
);
} }
for (const url of [ for (const url of [
@ -355,10 +349,9 @@ acceptance(
await publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 }); await publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 });
assert.ok( assert
!exists(".show-mores"), .dom(".show-mores")
`${url} does not display the topic incoming info` .doesNotExist(`${url} does not display the topic incoming info`);
);
} }
}); });
@ -392,7 +385,7 @@ acceptance(
"displays the right count" "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 }); await publishNewToMessageBus({ topicId: 2 });
@ -402,7 +395,7 @@ acceptance(
"displays the right count" "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) { test("incoming unread messages while viewing unread", async function (assert) {
@ -416,7 +409,7 @@ acceptance(
"displays the right count" "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) { test("incoming unread and new messages while viewing group unread", async function (assert) {
@ -439,7 +432,7 @@ acceptance(
"displays the right count" "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"); await visit("/u/charlie/messages/unread");
@ -464,10 +457,9 @@ acceptance(
await visit("/u/charlie/messages"); await visit("/u/charlie/messages");
assert.ok( assert
!exists(".show-mores"), .dom(".show-mores")
"does not display the topic incoming info" .doesNotExist("does not display the topic incoming info");
);
}); });
test("dismissing all unread messages", async function (assert) { test("dismissing all unread messages", async function (assert) {
@ -640,10 +632,9 @@ acceptance(
"displays the right topic list" "displays the right topic list"
); );
assert.ok( assert
exists(".group-notifications-button"), .dom(".group-notifications-button")
"displays the group notifications button" .exists("displays the group notifications button");
);
}); });
test("navigating between user messages route with dropdown", async function (assert) { test("navigating between user messages route with dropdown", async function (assert) {

View File

@ -1,11 +1,7 @@
import { click, currentURL, visit } from "@ember/test-helpers"; import { click, currentURL, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import userFixtures from "discourse/tests/fixtures/user-fixtures"; import userFixtures from "discourse/tests/fixtures/user-fixtures";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object"; import { cloneJSON } from "discourse-common/lib/object";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -17,13 +13,13 @@ acceptance("User Profile - Summary", function (needs) {
test("Viewing Summary", async function (assert) { test("Viewing Summary", async function (assert) {
await visit("/u/eviltrout/summary"); await visit("/u/eviltrout/summary");
assert.ok(exists(".replies-section li a"), "replies"); assert.dom(".replies-section li a").exists("replies");
assert.ok(exists(".topics-section li a"), "topics"); assert.dom(".topics-section li a").exists("topics");
assert.ok(exists(".links-section li a"), "links"); assert.dom(".links-section li a").exists("links");
assert.ok(exists(".replied-section .user-info"), "liked by"); assert.dom(".replied-section .user-info").exists("liked by");
assert.ok(exists(".liked-by-section .user-info"), "liked by"); assert.dom(".liked-by-section .user-info").exists("liked by");
assert.ok(exists(".liked-section .user-info"), "liked"); assert.dom(".liked-section .user-info").exists("liked");
assert.ok(exists(".badges-section .badge-card"), "badges"); assert.dom(".badges-section .badge-card").exists("badges");
assert assert
.dom(".top-categories-section .category-link") .dom(".top-categories-section .category-link")
.exists("top categories"); .exists("top categories");

View File

@ -2,7 +2,6 @@ import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { import {
acceptance, acceptance,
exists,
publishToMessageBus, publishToMessageBus,
query, query,
updateCurrentUser, updateCurrentUser,
@ -122,10 +121,10 @@ acceptance("User Status", function (needs) {
await visit("/"); await visit("/");
await openUserStatusModal(); 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"); 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 fillIn(".emoji-picker-content .filter", userStatusEmoji);
await click(".results .emoji"); await click(".results .emoji");
@ -249,7 +248,7 @@ acceptance("User Status", function (needs) {
await openUserStatusModal(); await openUserStatusModal();
await pickEmoji(userStatusEmoji); 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) { 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 click(".btn.delete-status");
await openUserStatusModal(); 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( assert.equal(
query(".user-status-description").value, 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(".header-dropdown-toggle.current-user button");
await click("#user-menu-button-profile"); 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 assert
.dom("li.set-user-status svg.d-icon-circle-plus") .dom("li.set-user-status svg.d-icon-circle-plus")
.exists("shows the icon on the button"); .exists("shows the icon on the button");

View File

@ -10,7 +10,6 @@ import { test } from "qunit";
import userFixtures from "discourse/tests/fixtures/user-fixtures"; import userFixtures from "discourse/tests/fixtures/user-fixtures";
import { import {
acceptance, acceptance,
exists,
publishToMessageBus, publishToMessageBus,
query, query,
queryAll, queryAll,
@ -112,12 +111,12 @@ acceptance("User Routes", function (needs) {
"userActivity.index", "userActivity.index",
"it defaults to activity" "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) { test("Viewing Drafts", async function (assert) {
await visit("/u/eviltrout/activity/drafts"); await visit("/u/eviltrout/activity/drafts");
assert.ok(exists(".user-stream"), "has drafts stream"); assert.dom(".user-stream").exists("has drafts stream");
assert assert
.dom(".user-stream .user-stream-item-draft-actions") .dom(".user-stream .user-stream-item-draft-actions")
.exists("has draft action buttons"); .exists("has draft action buttons");
@ -168,7 +167,7 @@ acceptance("User Routes - Moderator viewing warnings", function (needs) {
document.body.classList.contains("user-messages-page"), document.body.classList.contains("user-messages-page"),
"has the body class" "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) { test("Notification level is set to normal and can be changed to muted", async function (assert) {
await visit("/u/charlie"); await visit("/u/charlie");
assert.ok( assert
exists(".user-notifications-dropdown"), .dom(".user-notifications-dropdown")
"Notification level dropdown is present" .exists("notification level dropdown is present");
);
const dropdown = selectKit(".user-notifications-dropdown"); const dropdown = selectKit(".user-notifications-dropdown");
await dropdown.expand(); await dropdown.expand();
@ -316,10 +314,9 @@ acceptance(
}); });
test("Notification level can be changed to ignored", async function (assert) { test("Notification level can be changed to ignored", async function (assert) {
await visit("/u/charlie"); await visit("/u/charlie");
assert.ok( assert
exists(".user-notifications-dropdown"), .dom(".user-notifications-dropdown")
"Notification level dropdown is present" .exists("notification level dropdown is present");
);
const notificationLevelDropdown = selectKit( const notificationLevelDropdown = selectKit(
".user-notifications-dropdown" ".user-notifications-dropdown"

View File

@ -4,7 +4,6 @@ import directoryFixtures from "discourse/tests/fixtures/directory-fixtures";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { import {
acceptance, acceptance,
exists,
query, query,
queryAll, queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -25,7 +24,7 @@ acceptance("User Directory", function () {
test("Visit All Time", async function (assert) { test("Visit All Time", async function (assert) {
await visit("/u?period=all"); 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) { test("Visit Without Usernames", async function (assert) {

View File

@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { assert, module, test } from "qunit"; import { assert, module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
module("Addons | truth-helpers | Integration | includes", function (hooks) { module("Addons | truth-helpers | Integration | includes", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -14,14 +13,14 @@ module("Addons | truth-helpers | Integration | includes", function (hooks) {
hbs`{{#if (includes this.foo this.bar)}}<span class="test"></span>{{/if}}` hbs`{{#if (includes this.foo this.bar)}}<span class="test"></span>{{/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; this.bar = 2;
await render( await render(
hbs`{{#if (includes this.foo this.bar)}}<span class="test"></span>{{/if}}` hbs`{{#if (includes this.foo this.bar)}}<span class="test"></span>{{/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 () { 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)}}<span class="test"></span>{{/if}}` hbs`{{#if (includes this.foo this.bar)}}<span class="test"></span>{{/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"; this.bar = "b";
await render( await render(
hbs`{{#if (includes this.foo this.bar)}}<span class="test"></span>{{/if}}` hbs`{{#if (includes this.foo this.bar)}}<span class="test"></span>{{/if}}`
); );
assert.notOk(exists(".test"), "it returns false when element is not found"); assert.dom(".test").doesNotExist("is false when element is not found");
}); });
}); });

View File

@ -5,7 +5,7 @@ import { formattedReminderTime } from "discourse/lib/bookmark";
import { tomorrow } from "discourse/lib/time-utils"; import { tomorrow } from "discourse/lib/time-utils";
import Bookmark from "discourse/models/bookmark"; import Bookmark from "discourse/models/bookmark";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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 I18n from "discourse-i18n";
module("Integration | Component | bookmark-icon", function (hooks) { module("Integration | Component | bookmark-icon", function (hooks) {
@ -22,9 +22,9 @@ module("Integration | Component | bookmark-icon", function (hooks) {
await render(hbs`<BookmarkIcon @bookmark={{this.bookmark}} />`); await render(hbs`<BookmarkIcon @bookmark={{this.bookmark}} />`);
assert.ok( assert
exists(".d-icon-discourse-bookmark-clock.bookmark-icon__bookmarked") .dom(".d-icon-discourse-bookmark-clock.bookmark-icon__bookmarked")
); .exists();
assert.strictEqual( assert.strictEqual(
query(".svg-icon-title").title, query(".svg-icon-title").title,
I18n.t("bookmarks.created_with_reminder_generic", { I18n.t("bookmarks.created_with_reminder_generic", {

View File

@ -3,7 +3,6 @@ import { click, render, triggerKeyEvent } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
import { withSilencedDeprecationsAsync } from "discourse-common/lib/deprecated"; import { withSilencedDeprecationsAsync } from "discourse-common/lib/deprecated";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -13,36 +12,36 @@ module("Integration | Component | d-button", function (hooks) {
test("icon only button", async function (assert) { test("icon only button", async function (assert) {
await render(hbs`<DButton @icon="plus" tabindex="3" />`); await render(hbs`<DButton @icon="plus" tabindex="3" />`);
assert.ok(exists("button.btn.btn-icon.no-text"), "it has all the classes"); assert.dom("button.btn.btn-icon.no-text").exists("has all the classes");
assert.ok(exists("button .d-icon.d-icon-plus"), "it has the icon"); assert.dom("button .d-icon.d-icon-plus").exists("has the icon");
assert.dom("button").hasAttribute("tabindex", "3", "it has the tabindex"); assert.dom("button").hasAttribute("tabindex", "3", "has the tabindex");
}); });
test("icon and text button", async function (assert) { test("icon and text button", async function (assert) {
await render(hbs`<DButton @icon="plus" @label="topic.create" />`); await render(hbs`<DButton @icon="plus" @label="topic.create" />`);
assert.ok(exists("button.btn.btn-icon-text"), "it has all the classes"); assert.dom("button.btn.btn-icon-text").exists("has all the classes");
assert.ok(exists("button .d-icon.d-icon-plus"), "it has the icon"); assert.dom("button .d-icon.d-icon-plus").exists("has the icon");
assert.ok(exists("button span.d-button-label"), "it has the label"); assert.dom("button span.d-button-label").exists("has the label");
}); });
test("text only button", async function (assert) { test("text only button", async function (assert) {
await render(hbs`<DButton @label="topic.create" />`); await render(hbs`<DButton @label="topic.create" />`);
assert.ok(exists("button.btn.btn-text"), "it has all the classes"); assert.dom("button.btn.btn-text").exists("has all the classes");
assert.ok(exists("button span.d-button-label"), "it has the label"); assert.dom("button span.d-button-label").exists("has the label");
}); });
test("form attribute", async function (assert) { test("form attribute", async function (assert) {
await render(hbs`<DButton @form="login-form" />`); await render(hbs`<DButton @form="login-form" />`);
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) { test("link-styled button", async function (assert) {
await render(hbs`<DButton @display="link" />`); await render(hbs`<DButton @display="link" />`);
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) { test("isLoading button", async function (assert) {
@ -52,19 +51,15 @@ module("Integration | Component | d-button", function (hooks) {
assert assert
.dom("button.is-loading .loading-icon") .dom("button.is-loading .loading-icon")
.exists("it has a spinner showing"); .exists("has a spinner showing");
assert assert.dom("button").isDisabled("while loading the button is disabled");
.dom("button[disabled]")
.exists("while loading the button is disabled");
this.set("isLoading", false); this.set("isLoading", false);
assert assert
.dom("button .loading-icon") .dom("button .loading-icon")
.doesNotExist("it doesn't have a spinner showing"); .doesNotExist("doesn't have a spinner showing");
assert assert.dom("button").isEnabled("while not loading the button is enabled");
.dom("button:not([disabled])")
.exists("while not loading the button is enabled");
}); });
test("button without isLoading attribute", async function (assert) { test("button without isLoading attribute", async function (assert) {
@ -72,11 +67,11 @@ module("Integration | Component | d-button", function (hooks) {
assert assert
.dom("button.is-loading") .dom("button.is-loading")
.doesNotExist("it doesn't have class is-loading"); .doesNotExist("doesn't have class is-loading");
assert assert
.dom("button .loading-icon") .dom("button .loading-icon")
.doesNotExist("it doesn't have a spinner showing"); .doesNotExist("doesn't have a spinner showing");
assert.notOk(exists("button[disabled]"), "it isn't disabled"); assert.dom("button").isNotDisabled();
}); });
test("isLoading button explicitly set to undefined state", async function (assert) { test("isLoading button explicitly set to undefined state", async function (assert) {
@ -86,11 +81,11 @@ module("Integration | Component | d-button", function (hooks) {
assert assert
.dom("button.is-loading") .dom("button.is-loading")
.doesNotExist("it doesn't have class is-loading"); .doesNotExist("doesn't have class is-loading");
assert assert
.dom("button .loading-icon") .dom("button .loading-icon")
.doesNotExist("it doesn't have a spinner showing"); .doesNotExist("doesn't have a spinner showing");
assert.notOk(exists("button[disabled]"), "it isn't disabled"); assert.dom("button").isNotDisabled();
}); });
test("disabled button", async function (assert) { test("disabled button", async function (assert) {
@ -98,10 +93,10 @@ module("Integration | Component | d-button", function (hooks) {
await render(hbs`<DButton @disabled={{this.disabled}} />`); await render(hbs`<DButton @disabled={{this.disabled}} />`);
assert.ok(exists("button[disabled]"), "the button is disabled"); assert.dom("button").isDisabled();
this.set("disabled", false); this.set("disabled", false);
assert.ok(exists("button:not([disabled])"), "the button is enabled"); assert.dom("button").isEnabled();
}); });
test("aria-label", async function (assert) { test("aria-label", async function (assert) {

View File

@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
module("Integration | Component | d-toggle-switch", function (hooks) { module("Integration | Component | d-toggle-switch", function (hooks) {
@ -13,7 +12,7 @@ module("Integration | Component | d-toggle-switch", function (hooks) {
await render(hbs`<DToggleSwitch @state={{this.state}}/>`); await render(hbs`<DToggleSwitch @state={{this.state}}/>`);
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"); assert.dom(".d-toggle-switch__checkbox").hasAria("checked", "false");
}); });
@ -22,7 +21,7 @@ module("Integration | Component | d-toggle-switch", function (hooks) {
await render(hbs`<DToggleSwitch @state={{this.state}}/>`); await render(hbs`<DToggleSwitch @state={{this.state}}/>`);
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"); assert.dom(".d-toggle-switch__checkbox").hasAria("checked", "true");
}); });

View File

@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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() { function dateInput() {
return query(".date-picker"); return query(".date-picker");
@ -61,7 +61,7 @@ module("Integration | Component | date-time-input", function (hooks) {
hbs`<DateTimeInput @date={{this.date}} @showTime={{false}} />` hbs`<DateTimeInput @date={{this.date}} @showTime={{false}} />`
); );
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) { test("supports swapping timezone without changing visible date/time", async function (assert) {

View File

@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
module( module(
"Integration | Component | form-template-field | checkbox", "Integration | Component | form-template-field | checkbox",
@ -12,12 +11,11 @@ module(
test("renders a checkbox input", async function (assert) { test("renders a checkbox input", async function (assert) {
await render(hbs`<FormTemplateField::Checkbox />`); await render(hbs`<FormTemplateField::Checkbox />`);
assert.ok( assert
exists( .dom(
".form-template-field[data-field-type='checkbox'] input[type='checkbox']" ".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) { test("renders a checkbox with a label", async function (assert) {
@ -30,12 +28,11 @@ module(
hbs`<FormTemplateField::Checkbox @attributes={{this.attributes}} />` hbs`<FormTemplateField::Checkbox @attributes={{this.attributes}} />`
); );
assert.ok( assert
exists( .dom(
".form-template-field[data-field-type='checkbox'] input[type='checkbox']" ".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"); assert.dom(".form-template-field__label").hasText("Click this box");
}); });

View File

@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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 selectKit from "discourse/tests/helpers/select-kit-helper";
module( module(
@ -21,10 +21,9 @@ module(
await render( await render(
hbs`<FormTemplateField::Dropdown @choices={{this.choices}}/>` hbs`<FormTemplateField::Dropdown @choices={{this.choices}}/>`
); );
assert.ok( assert
exists(".form-template-field__dropdown"), .dom(".form-template-field__dropdown")
"A dropdown component exists" .exists("a dropdown component exists");
);
const dropdown = queryAll( const dropdown = queryAll(
".form-template-field__dropdown option:not(.form-template-field__dropdown-placeholder)" ".form-template-field__dropdown option:not(.form-template-field__dropdown-placeholder)"
@ -60,10 +59,9 @@ module(
await render( await render(
hbs`<FormTemplateField::Dropdown @choices={{this.choices}} @attributes={{this.attributes}} />` hbs`<FormTemplateField::Dropdown @choices={{this.choices}} @attributes={{this.attributes}} />`
); );
assert.ok( assert
exists(".form-template-field__dropdown"), .dom(".form-template-field__dropdown")
"A dropdown component exists" .exists("a dropdown component exists");
);
assert.strictEqual( assert.strictEqual(
query(".form-template-field__dropdown-placeholder").innerText, query(".form-template-field__dropdown-placeholder").innerText,

View File

@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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( module(
"Integration | Component | form-template-field | input", "Integration | Component | form-template-field | input",
@ -12,12 +12,9 @@ module(
test("renders a text input", async function (assert) { test("renders a text input", async function (assert) {
await render(hbs`<FormTemplateField::Input />`); await render(hbs`<FormTemplateField::Input />`);
assert.ok( assert
exists( .dom(".form-template-field[data-field-type='input'] input[type='text']")
".form-template-field[data-field-type='input'] input[type='text']" .exists("a text input component exists");
),
"A text input component exists"
);
}); });
test("renders a text input with attributes", async function (assert) { test("renders a text input with attributes", async function (assert) {
@ -31,12 +28,9 @@ module(
hbs`<FormTemplateField::Input @attributes={{this.attributes}} />` hbs`<FormTemplateField::Input @attributes={{this.attributes}} />`
); );
assert.ok( assert
exists( .dom(".form-template-field[data-field-type='input'] input[type='text']")
".form-template-field[data-field-type='input'] input[type='text']" .exists("a text input component exists");
),
"A text input component exists"
);
assert.dom(".form-template-field__label").hasText("My text label"); assert.dom(".form-template-field__label").hasText("My text label");
assert.strictEqual( assert.strictEqual(

View File

@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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 selectKit from "discourse/tests/helpers/select-kit-helper";
module( module(
@ -22,10 +22,9 @@ module(
await render( await render(
hbs`<FormTemplateField::MultiSelect @choices={{this.choices}}/>` hbs`<FormTemplateField::MultiSelect @choices={{this.choices}}/>`
); );
assert.ok( assert
exists(".form-template-field__multi-select"), .dom(".form-template-field__multi-select")
"A multiselect component exists" .exists("a multiselect component exists");
);
const dropdown = queryAll( const dropdown = queryAll(
".form-template-field__multi-select option:not(.form-template-field__multi-select-placeholder)" ".form-template-field__multi-select option:not(.form-template-field__multi-select-placeholder)"
@ -61,10 +60,9 @@ module(
await render( await render(
hbs`<FormTemplateField::MultiSelect @choices={{this.choices}} @attributes={{this.attributes}} />` hbs`<FormTemplateField::MultiSelect @choices={{this.choices}} @attributes={{this.attributes}} />`
); );
assert.ok( assert
exists(".form-template-field__multi-select"), .dom(".form-template-field__multi-select")
"A multiselect dropdown component exists" .exists("a multiselect dropdown component exists");
);
assert.strictEqual( assert.strictEqual(
query(".form-template-field__multi-select-placeholder").innerText, query(".form-template-field__multi-select-placeholder").innerText,

View File

@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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( module(
"Integration | Component | form-template-field | textarea", "Integration | Component | form-template-field | textarea",
@ -12,10 +12,9 @@ module(
test("renders a textarea input", async function (assert) { test("renders a textarea input", async function (assert) {
await render(hbs`<FormTemplateField::Textarea />`); await render(hbs`<FormTemplateField::Textarea />`);
assert.ok( assert
exists(".form-template-field__textarea"), .dom(".form-template-field__textarea")
"A textarea input component exists" .exists("a textarea input component exists");
);
}); });
test("renders a text input with attributes", async function (assert) { test("renders a text input with attributes", async function (assert) {
@ -29,10 +28,9 @@ module(
hbs`<FormTemplateField::Textarea @attributes={{this.attributes}} />` hbs`<FormTemplateField::Textarea @attributes={{this.attributes}} />`
); );
assert.ok( assert
exists(".form-template-field__textarea"), .dom(".form-template-field__textarea")
"A textarea input component exists" .exists("a textarea input component exists");
);
assert.dom(".form-template-field__label").hasText("My text label"); assert.dom(".form-template-field__label").hasText("My text label");
assert.strictEqual( assert.strictEqual(

View File

@ -3,7 +3,6 @@ import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { exists } from "discourse/tests/helpers/qunit-helpers";
module( module(
"Integration | Component | form-template-field | wrapper", "Integration | Component | form-template-field | wrapper",
@ -19,7 +18,7 @@ module(
assert assert
.dom(".form-template-field") .dom(".form-template-field")
.doesNotExist("A form template field should not exist"); .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) { 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) => { componentTypes.forEach((componentType) => {
assert.ok( assert
exists(`.form-template-field[data-field-type='${componentType}']`), .dom(`.form-template-field[data-field-type='${componentType}']`)
`${componentType} component exists` .exists(`${componentType} component exists`);
);
}); });
}); });
@ -95,10 +93,9 @@ module(
hbs`<FormTemplateField::Wrapper @id={{this.formTemplateId}} />` hbs`<FormTemplateField::Wrapper @id={{this.formTemplateId}} />`
); );
assert.ok( assert
exists(`.form-template-field[data-field-type='checkbox']`), .dom(`.form-template-field[data-field-type='checkbox']`)
`Checkbox component renders` .exists("checkbox component renders");
);
}); });
} }
); );

View File

@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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) { module("Integration | Component | group-membership-button", function (hooks) {
setupRenderingTest(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"); .doesNotExist("can't join group if user is already in the group");
this.set("model.is_group_user", false); 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) { test("canLeaveGroup", async function (assert) {

View File

@ -3,7 +3,7 @@ import { render } from "@ember/test-helpers";
import { module, test } from "qunit"; import { module, test } from "qunit";
import LightDarkImg from "discourse/components/light-dark-img"; import LightDarkImg from "discourse/components/light-dark-img";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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 lightSrc = { url: "/images/light.jpg", width: 376, height: 500 };
const darkSrc = { url: "/images/light.jpg", width: 432, height: 298 }; const darkSrc = { url: "/images/light.jpg", width: 432, height: 298 };
@ -23,9 +23,9 @@ module("Integration | Component | light-dark-img", function (hooks) {
await render(<template><LightDarkImg /></template>); await render(<template><LightDarkImg /></template>);
assert.ok(!exists("picture"), "there is no picture tag"); assert.dom("picture").doesNotExist("there is no picture tag");
assert.ok(!exists("img"), "there is no img tag"); assert.dom("img").doesNotExist("there is no img tag");
assert.ok(!exists("source"), "there are no source tags"); assert.dom("source").doesNotExist("there are no source tags");
}); });
test("light theme with only light image provided | dark mode not available", async function (assert) { 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(<template><LightDarkImg @lightImg={{lightSrc}} /></template>); await render(<template><LightDarkImg @lightImg={{lightSrc}} /></template>);
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(count("img"), 1, "there is an img tag");
assert.strictEqual( assert.strictEqual(
query("img").getAttribute("src"), query("img").getAttribute("src"),
lightSrc.url, lightSrc.url,
"the img src is the light image" "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) { 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) {
<LightDarkImg @lightImg={{lightSrc}} @darkImg={{darkSrc}} /> <LightDarkImg @lightImg={{lightSrc}} @darkImg={{darkSrc}} />
</template>); </template>);
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(count("img"), 1, "there is an img tag");
assert.strictEqual( assert.strictEqual(
query("img").getAttribute("src"), query("img").getAttribute("src"),
lightSrc.url, lightSrc.url,
"the img src is the light image" "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) { 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(<template><LightDarkImg /></template>); await render(<template><LightDarkImg /></template>);
assert.ok(!exists("picture"), "there is no picture tag"); assert.dom("picture").doesNotExist("there is no picture tag");
assert.ok(!exists("img"), "there is no img tag"); assert.dom("img").doesNotExist("there is no img tag");
assert.ok(!exists("source"), "there are no source tags"); assert.dom("source").doesNotExist("there are no source tags");
}); });
test("light theme with only light image provided | dark mode available", async function (assert) { 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(<template><LightDarkImg @lightImg={{lightSrc}} /></template>); await render(<template><LightDarkImg @lightImg={{lightSrc}} /></template>);
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(count("img"), 1, "there is an img tag");
assert.strictEqual( assert.strictEqual(
query("img").getAttribute("src"), query("img").getAttribute("src"),
lightSrc.url, lightSrc.url,
"the img src is the light image" "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) { 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(<template><LightDarkImg /></template>); await render(<template><LightDarkImg /></template>);
assert.ok(!exists("picture"), "there is no picture tag"); assert.dom("picture").doesNotExist("there is no picture tag");
assert.ok(!exists("img"), "there is no img tag"); assert.dom("img").doesNotExist("there is no img tag");
assert.ok(!exists("source"), "there are no source tags"); assert.dom("source").doesNotExist("there are no source tags");
}); });
test("dark theme with only light image provided | dark mode not available", async function (assert) { 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(<template><LightDarkImg @lightImg={{lightSrc}} /></template>); await render(<template><LightDarkImg @lightImg={{lightSrc}} /></template>);
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(count("img"), 1, "there is an img tag");
assert.strictEqual( assert.strictEqual(
query("img").getAttribute("src"), query("img").getAttribute("src"),
lightSrc.url, lightSrc.url,
"the img src is the light image" "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) { 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(<template><LightDarkImg /></template>); await render(<template><LightDarkImg /></template>);
assert.ok(!exists("picture"), "there is no picture tag"); assert.dom("picture").doesNotExist("there is no picture tag");
assert.ok(!exists("img"), "there is no img tag"); assert.dom("img").doesNotExist("there is no img tag");
assert.ok(!exists("source"), "there are no source tags"); assert.dom("source").doesNotExist("there are no source tags");
}); });
test("dark theme with only light image provided | dark mode available", async function (assert) { 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(<template><LightDarkImg @lightImg={{lightSrc}} /></template>); await render(<template><LightDarkImg @lightImg={{lightSrc}} /></template>);
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(count("img"), 1, "there is an img tag");
assert.strictEqual( assert.strictEqual(
query("img").getAttribute("src"), query("img").getAttribute("src"),
lightSrc.url, lightSrc.url,
"the img src is the light image" "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) { test("dark theme with light and dark images provided | dark mode available", async function (assert) {

View File

@ -6,7 +6,7 @@ import SearchMenu, {
import searchFixtures from "discourse/tests/fixtures/search-fixtures"; import searchFixtures from "discourse/tests/fixtures/search-fixtures";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; 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"; import I18n from "discourse-i18n";
// Note this isn't a full-fledge test of the search menu. Those tests are in // 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") .dom(".show-advanced-search")
.exists("it shows full page search button"); .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"); await click("#search-term");
@ -60,7 +60,7 @@ module("Integration | Component | search-menu", function (hooks) {
await triggerKeyEvent("#search-term", "keydown", "Escape"); 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");
await click("#search-term"); await click("#search-term");

View File

@ -2,7 +2,7 @@ import { fillIn, render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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 selectKit from "discourse/tests/helpers/select-kit-helper";
import pretender, { response } from "../../../helpers/create-pretender"; import pretender, { response } from "../../../helpers/create-pretender";
@ -132,7 +132,7 @@ module(
await this.subject.expand(); await this.subject.expand();
await fillIn(".filter-input", "test-user"); 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 assert
.dom(".user-status-message .emoji") .dom(".user-status-message .emoji")
.hasAttribute("alt", status.emoji, "status emoji is correct"); .hasAttribute("alt", status.emoji, "status emoji is correct");

View File

@ -2,11 +2,7 @@ import { fillIn, render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { import { fakeTime, queryAll } from "discourse/tests/helpers/qunit-helpers";
exists,
fakeTime,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
import I18n from "discourse-i18n"; 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( assert.strictEqual(
this.subject.header().label(), this.subject.header().label(),
@ -50,10 +46,9 @@ module(
await this.subject.expand(); await this.subject.expand();
assert.ok( assert
exists(".select-kit-collection"), .dom(".select-kit-collection")
"List of options is rendered" .exists("list of options is rendered");
);
}); });
test("renders default options", async function (assert) { test("renders default options", async function (assert) {

View File

@ -2,7 +2,7 @@ import { click, render, triggerKeyEvent } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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 selectKit from "discourse/tests/helpers/select-kit-helper";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -84,10 +84,9 @@ module(
}) })
); );
await this.subject.fillInFilter("dawg"); await this.subject.fillInFilter("dawg");
assert.notOk( assert
exists(".select-kit-collection .select-kit-row"), .dom(".select-kit-collection .select-kit-row")
"it doesnt show any options" .doesNotExist("doesnt show any options");
);
}); });
test("required_tag_group", async function (assert) { test("required_tag_group", async function (assert) {
@ -122,19 +121,17 @@ module(
await this.subject.expand(); await this.subject.expand();
await this.subject.fillInFilter("#"); await this.subject.fillInFilter("#");
assert.notOk(exists(".select-kit-error"), "it doesnt show any error"); assert.dom(".select-kit-error").doesNotExist("doesnt show any error");
assert.notOk( assert
exists(".select-kit-row[data-value='#']"), .dom(".select-kit-row[data-value='#']")
"it doesnt allow to create this tag" .doesNotExist("doesn't allow to create this tag");
);
await this.subject.fillInFilter("test"); await this.subject.fillInFilter("test");
assert.strictEqual(this.subject.filter().value(), "#test"); assert.strictEqual(this.subject.filter().value(), "#test");
assert.ok( assert
exists(".select-kit-row[data-value='test']"), .dom(".select-kit-row[data-value='test']")
"it filters out the invalid char from the suggested tag" .exists("filters out the invalid char from the suggested tag");
);
}); });
test("creating a tag over the length limit", async function (assert) { test("creating a tag over the length limit", async function (assert) {
@ -143,10 +140,9 @@ module(
await this.subject.expand(); await this.subject.expand();
await this.subject.fillInFilter("foo"); await this.subject.fillInFilter("foo");
assert.ok( assert
exists(".select-kit-row[data-value='f']"), .dom(".select-kit-row[data-value='f']")
"it forces the max length of the tag" .exists("forces the max length of the tag");
);
}); });
test("values in hiddenFromPreview will not display in preview", async function (assert) { test("values in hiddenFromPreview will not display in preview", async function (assert) {

View File

@ -2,7 +2,6 @@ import { click, render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
module("Integration | Component | sidebar | section", function (hooks) { module("Integration | Component | sidebar | section", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -43,7 +42,7 @@ module("Integration | Component | sidebar | section", function (hooks) {
.doesNotExist("section is not displayed"); .doesNotExist("section is not displayed");
this.set("displaySection", true); 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) { 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 = []; this.headerActions = [];
await render(template); 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"); await click(".sidebar-section-header-caret");

View File

@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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) { module("Integration | Component | slow-mode-info", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -12,7 +12,7 @@ module("Integration | Component | slow-mode-info", function (hooks) {
await render(hbs`<SlowModeInfo @topic={{this.topic}} />`); await render(hbs`<SlowModeInfo @topic={{this.topic}} />`);
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) { 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`<SlowModeInfo @topic={{this.topic}} />`); await render(hbs`<SlowModeInfo @topic={{this.topic}} />`);
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) { test("renders if slow mode is enabled", async function (assert) {

View File

@ -3,7 +3,6 @@ import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { import {
exists,
fakeTime, fakeTime,
query, query,
queryAll, queryAll,
@ -59,7 +58,7 @@ module("Integration | Component | time-shortcut-picker", function (hooks) {
await render(hbs`<TimeShortcutPicker @_itsatrap={{this.itsatrap}} />`); await render(hbs`<TimeShortcutPicker @_itsatrap={{this.itsatrap}} />`);
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) { 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`<TimeShortcutPicker @_itsatrap={{this.itsatrap}} />`); await render(hbs`<TimeShortcutPicker @_itsatrap={{this.itsatrap}} />`);
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) { test("does not show 'Later Today' if it is after 5pm", async function (assert) {

View File

@ -2,7 +2,7 @@ import { click, render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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) { module("Integration | Component | uppy-image-uploader", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -48,7 +48,7 @@ module("Integration | Component | uppy-image-uploader", function (hooks) {
"it displays the upload icon" "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 assert
.dom(".image-uploader-lightbox-btn") .dom(".image-uploader-lightbox-btn")
@ -66,7 +66,7 @@ module("Integration | Component | uppy-image-uploader", function (hooks) {
"it displays the upload icon" "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 assert
.dom(".image-uploader-lightbox-btn") .dom(".image-uploader-lightbox-btn")

View File

@ -3,7 +3,6 @@ import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { resetFlair } from "discourse/lib/avatar-flair"; import { resetFlair } from "discourse/lib/avatar-flair";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
function setupSiteGroups(that) { function setupSiteGroups(that) {
that.site.groups = [ that.site.groups = [
@ -60,8 +59,8 @@ module("Integration | Component | user-avatar-flair", function (hooks) {
await render(hbs`<UserAvatarFlair @user={{this.args}} />`); await render(hbs`<UserAvatarFlair @user={{this.args}} />`);
assert.ok(exists(".avatar-flair"), "it has the tag"); assert.dom(".avatar-flair").exists("has the tag");
assert.ok(exists("svg.d-icon-bars"), "it has the svg icon"); assert.dom("svg.d-icon-bars").exists("has the svg icon");
assert.dom(".avatar-flair").hasStyle({ assert.dom(".avatar-flair").hasStyle({
backgroundColor: "rgb(204, 0, 10)", backgroundColor: "rgb(204, 0, 10)",
color: "rgb(255, 255, 250)", color: "rgb(255, 255, 250)",
@ -79,8 +78,8 @@ module("Integration | Component | user-avatar-flair", function (hooks) {
await render(hbs`<UserAvatarFlair @user={{this.args}} />`); await render(hbs`<UserAvatarFlair @user={{this.args}} />`);
assert.ok(exists(".avatar-flair"), "it has the tag"); assert.dom(".avatar-flair").exists("has the tag");
assert.ok(exists("svg.d-icon-bars"), "it has the svg icon"); assert.dom("svg.d-icon-bars").exists("has the svg icon");
assert.dom(".avatar-flair").hasStyle({ assert.dom(".avatar-flair").hasStyle({
backgroundColor: "rgb(204, 0, 5)", backgroundColor: "rgb(204, 0, 5)",
color: "rgb(255, 255, 245)", color: "rgb(255, 255, 245)",
@ -98,8 +97,8 @@ module("Integration | Component | user-avatar-flair", function (hooks) {
await render(hbs`<UserAvatarFlair @user={{this.args}} />`); await render(hbs`<UserAvatarFlair @user={{this.args}} />`);
assert.ok(exists(".avatar-flair"), "it has the tag"); assert.dom(".avatar-flair").exists("has the tag");
assert.ok(exists("svg.d-icon-dice-two"), "it has the svg icon"); assert.dom("svg.d-icon-dice-two").exists("has the svg icon");
assert.dom(".avatar-flair").hasStyle({ assert.dom(".avatar-flair").hasStyle({
backgroundColor: "rgb(204, 0, 2)", backgroundColor: "rgb(204, 0, 2)",
color: "rgb(255, 255, 242)", color: "rgb(255, 255, 242)",
@ -117,7 +116,7 @@ module("Integration | Component | user-avatar-flair", function (hooks) {
await render(hbs`<UserAvatarFlair @user={{this.args}} />`); await render(hbs`<UserAvatarFlair @user={{this.args}} />`);
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) { 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`<UserAvatarFlair @user={{this.args}} />`); await render(hbs`<UserAvatarFlair @user={{this.args}} />`);
assert.ok(exists(".avatar-flair"), "it has the tag"); assert.dom(".avatar-flair").exists("has the tag");
assert.ok(exists("svg.d-icon-dice-two"), "it has the svg icon"); assert.dom("svg.d-icon-dice-two").exists("has the svg icon");
assert.dom(".avatar-flair").hasStyle({ assert.dom(".avatar-flair").hasStyle({
backgroundColor: "rgb(204, 0, 2)", backgroundColor: "rgb(204, 0, 2)",
color: "rgb(255, 255, 242)", color: "rgb(255, 255, 242)",
@ -151,7 +150,7 @@ module("Integration | Component | user-avatar-flair", function (hooks) {
await render(hbs`<UserAvatarFlair @user={{this.args}} />`); await render(hbs`<UserAvatarFlair @user={{this.args}} />`);
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) { 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`<UserAvatarFlair @user={{this.args}} />`); await render(hbs`<UserAvatarFlair @user={{this.args}} />`);
assert.ok(exists(".avatar-flair"), "it has the tag"); assert.dom(".avatar-flair").exists("has the tag");
assert.ok(exists("svg.d-icon-xmark"), "it has the svg icon"); assert.dom("svg.d-icon-xmark").exists("has the svg icon");
assert.dom(".avatar-flair").hasStyle({ assert.dom(".avatar-flair").hasStyle({
backgroundColor: "rgb(18, 52, 86)", backgroundColor: "rgb(18, 52, 86)",
color: "rgb(176, 176, 176)", color: "rgb(176, 176, 176)",
@ -188,6 +187,6 @@ module("Integration | Component | user-avatar-flair", function (hooks) {
await render(hbs`<UserAvatarFlair @user={{this.args}} />`); await render(hbs`<UserAvatarFlair @user={{this.args}} />`);
assert.ok(!exists(".avatar-flair"), "it does not render a flair"); assert.dom(".avatar-flair").doesNotExist("does not render a flair");
}); });
}); });

View File

@ -2,7 +2,7 @@ import { render, triggerEvent } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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) { module("Integration | Component | user-info", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -33,7 +33,7 @@ module("Integration | Component | user-info", function (hooks) {
); );
this.set("includeLink", true); 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); this.set("includeLink", false);
assert assert

View File

@ -4,7 +4,7 @@ import { module, test } from "qunit";
import { NOTIFICATION_TYPES } from "discourse/tests/fixtures/concerns/notification-types"; import { NOTIFICATION_TYPES } from "discourse/tests/fixtures/concerns/notification-types";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; 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"; import I18n from "discourse-i18n";
module( module(
@ -78,10 +78,9 @@ module(
I18n.t("user.no_bookmarks_body", { icon: "" }).trim(), I18n.t("user.no_bookmarks_body", { icon: "" }).trim(),
"empty state body is shown" "empty state body is shown"
); );
assert.ok( assert
exists(".empty-state-body svg.d-icon-bookmark"), .dom(".empty-state-body svg.d-icon-bookmark")
"icon is correctly rendered in the empty state body" .exists("icon is correctly rendered in the empty state body");
);
}); });
} }
); );

View File

@ -11,7 +11,7 @@ import UserMenuReviewable from "discourse/models/user-menu-reviewable";
import { NOTIFICATION_TYPES } from "discourse/tests/fixtures/concerns/notification-types"; import { NOTIFICATION_TYPES } from "discourse/tests/fixtures/concerns/notification-types";
import PrivateMessagesFixture from "discourse/tests/fixtures/private-messages-fixtures"; import PrivateMessagesFixture from "discourse/tests/fixtures/private-messages-fixtures";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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 { cloneJSON, deepMerge } from "discourse-common/lib/object";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -68,14 +68,12 @@ module(
this.item.notification.read = true; this.item.notification.read = true;
await settled(); await settled();
assert.ok( assert
exists("li.read"), .dom("li.read")
"the item re-renders when the read property is updated" .exists("the item re-renders when the read property is updated");
); assert
assert.notOk( .dom("li.unread")
exists("li.unread"), .doesNotExist("the item re-renders when the read property is updated");
"the item re-renders when the read property is updated"
);
}); });
test("pushes the notification type name to the classList", async function (assert) { test("pushes the notification type name to the classList", async function (assert) {
@ -95,10 +93,9 @@ module(
); );
await settled(); await settled();
assert.ok( assert
exists("li.private-message"), .dom("li.private-message")
"replaces underscores in type name with dashes" .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) { 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); await render(template);
assert.ok( assert
exists("li a .item-description img.emoji"), .dom("li a .item-description img.emoji")
"emojis are unescaped when fancy_title is used for description" .exists(
); "emojis are unescaped when fancy_title is used for description"
);
}); });
test("topic_title from data is emoji-unescaped safely", async function (assert) { test("topic_title from data is emoji-unescaped safely", async function (assert) {
@ -232,10 +230,9 @@ module(
"unsafe title with <a> unescaped emoji", "unsafe title with <a> unescaped emoji",
"topic_title is rendered safely" "topic_title is rendered safely"
); );
assert.ok( assert
exists(".item-description img.emoji"), .dom(".item-description img.emoji")
"emoji is rendered correctly" .exists("emoji is rendered correctly");
);
}); });
test("various aspects can be customized according to the notification's render director", async function (assert) { test("various aspects can be customized according to the notification's render director", async function (assert) {
@ -289,10 +286,9 @@ module(
await render(template); await render(template);
assert.ok( assert
exists("li.additional.classes"), .dom("li.additional.classes")
"extra classes are included on the item" .exists("extra classes are included on the item");
);
const link = query("li a"); const link = query("li a");
assert.ok( assert.ok(
@ -305,7 +301,7 @@ module(
"link title is customized and rendered safely" "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"); const label = query("li .item-label");
assert.ok( assert.ok(
@ -356,7 +352,9 @@ module(
); );
await render(template); await render(template);
assert.notOk(exists(".item-description"), "description is not rendered"); assert
.dom(".item-description")
.doesNotExist("description is not rendered");
assert.strictEqual( assert.strictEqual(
query("li").textContent.trim(), query("li").textContent.trim(),
"notification label", "notification label",
@ -395,7 +393,7 @@ module(
"notification description", "notification description",
"only notification description is displayed" "only notification description is displayed"
); );
assert.notOk(exists(".item-label"), "label is not rendered"); assert.dom(".item-label").doesNotExist("label is not rendered");
}); });
} }
); );

View File

@ -5,7 +5,7 @@ import { NOTIFICATION_TYPES } from "discourse/tests/fixtures/concerns/notificati
import NotificationFixtures from "discourse/tests/fixtures/notification-fixtures"; import NotificationFixtures from "discourse/tests/fixtures/notification-fixtures";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; 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 { cloneJSON } from "discourse-common/lib/object";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -120,10 +120,9 @@ module(
2, 2,
"notifications list is refreshed" "notifications list is refreshed"
); );
assert.ok( assert
!exists(".panel-body-bottom .btn.notifications-dismiss"), .dom(".panel-body-bottom .btn.notifications-dismiss")
"dismiss button is not shown" .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) { test("all notifications tab shows pending reviewables and sorts them with unread notifications based on their creation date", async function (assert) {

View File

@ -2,7 +2,7 @@ import { render, triggerEvent } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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() { async function mouseenter() {
await triggerEvent(query(".user-status-message"), "mousemove"); 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) { test("it renders user status emoji", async function (assert) {
await render(hbs`<UserStatusMessage @status={{this.status}} />`); await render(hbs`<UserStatusMessage @status={{this.status}} />`);
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) { test("it renders status description if enabled", async function (assert) {

Some files were not shown because too many files have changed in this diff Show More