DEV: Update more asserts to qunit-dom (#29326)

regex find&replace + removing now-unused imports + manually fixing incorrect css selectors (that now got flagged 😌) + manually updating selectors that relied on jq
This commit is contained in:
Jarek Radosz 2024-10-22 11:34:23 +02:00 committed by GitHub
parent d991378218
commit b9ec9c7e4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
97 changed files with 1433 additions and 1878 deletions

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";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
acceptance("Admin - Badges - Mass Award", function (needs) { acceptance("Admin - Badges - Mass Award", function (needs) {
@ -24,9 +20,8 @@ acceptance("Admin - Badges - Mass Award", function (needs) {
test("when the badge can not be granted multiple times", async function (assert) { test("when the badge can not be granted multiple times", async function (assert) {
await visit("/admin/badges/award/new"); await visit("/admin/badges/award/new");
await click('.admin-badge-list-item span[data-badge-name="Only icon"]'); await click('.admin-badge-list-item span[data-badge-name="Only icon"]');
assert.ok( assert
!exists(".grant-existing-holders"), .dom(".grant-existing-holders")
"checkbox for granting existing holders is not displayed" .doesNotExist("checkbox for granting existing holders is not displayed");
);
}); });
}); });

View File

@ -33,69 +33,55 @@ acceptance("Admin Sidebar - Sections", function (needs) {
test("default sections are loaded", async function (assert) { test("default sections are loaded", async function (assert) {
await visit("/admin"); await visit("/admin");
assert.ok( assert
exists(".sidebar-section[data-section-name='admin-root']"), .dom(".sidebar-section[data-section-name='admin-root']")
"root section is displayed" .exists("root section is displayed");
); assert
assert.ok( .dom(".sidebar-section[data-section-name='admin-account']")
exists(".sidebar-section[data-section-name='admin-account']"), .exists("account section is displayed");
"account section is displayed" assert
); .dom(".sidebar-section[data-section-name='admin-reports']")
assert.ok( .exists("reports section is displayed");
exists(".sidebar-section[data-section-name='admin-reports']"), assert
"reports section is displayed" .dom(".sidebar-section[data-section-name='admin-community']")
); .exists("community section is displayed");
assert.ok( assert
exists(".sidebar-section[data-section-name='admin-community']"), .dom(".sidebar-section[data-section-name='admin-appearance']")
"community section is displayed" .exists("appearance section is displayed");
); assert
assert.ok( .dom(".sidebar-section[data-section-name='admin-email_settings']")
exists(".sidebar-section[data-section-name='admin-appearance']"), .exists("email settings section is displayed");
"appearance section is displayed" assert
); .dom(".sidebar-section[data-section-name='admin-email_logs']")
assert.ok( .exists("email logs settings section is displayed");
exists(".sidebar-section[data-section-name='admin-email_settings']"), assert
"email settings section is displayed" .dom(".sidebar-section[data-section-name='admin-security']")
); .exists("security settings section is displayed");
assert.ok( assert
exists(".sidebar-section[data-section-name='admin-email_logs']"), .dom(".sidebar-section[data-section-name='admin-plugins']")
"email logs settings section is displayed" .exists("plugins section is displayed");
); assert
assert.ok( .dom(".sidebar-section[data-section-name='admin-advanced']")
exists(".sidebar-section[data-section-name='admin-security']"), .exists("advanced section is displayed");
"security settings section is displayed"
);
assert.ok(
exists(".sidebar-section[data-section-name='admin-plugins']"),
"plugins section is displayed"
);
assert.ok(
exists(".sidebar-section[data-section-name='admin-advanced']"),
"advanced section is displayed"
);
}); });
test("filter sections and clear filter with ESC", async function (assert) { test("filter sections and clear filter with ESC", async function (assert) {
await visit("/admin"); await visit("/admin");
await fillIn(".sidebar-filter__input", "advanced"); await fillIn(".sidebar-filter__input", "advanced");
assert.notOk( assert
exists(".sidebar-section[data-section-name='admin-plugins']"), .dom(".sidebar-section[data-section-name='admin-plugins']")
"plugins section is hidden" .doesNotExist("plugins section is hidden");
); assert
assert.ok( .dom(".sidebar-section[data-section-name='admin-advanced']")
exists(".sidebar-section[data-section-name='admin-advanced']"), .exists("advanced section is displayed");
"advanced section is displayed"
);
await triggerKeyEvent(".sidebar-filter__input", "keydown", "Escape"); await triggerKeyEvent(".sidebar-filter__input", "keydown", "Escape");
assert.ok( assert
exists(".sidebar-section[data-section-name='admin-plugins']"), .dom(".sidebar-section[data-section-name='admin-plugins']")
"plugins section is displayed" .exists("plugins section is displayed");
); assert
assert.ok( .dom(".sidebar-section[data-section-name='admin-advanced']")
exists(".sidebar-section[data-section-name='admin-advanced']"), .exists("advanced section is displayed");
"advanced section is displayed"
);
}); });
test("enabled plugin admin routes have links added", async function (assert) { test("enabled plugin admin routes have links added", async function (assert) {

View File

@ -45,10 +45,9 @@ acceptance("Admin - Site Settings", function (needs) {
test("upload site setting", async function (assert) { test("upload site setting", async function (assert) {
await visit("/admin/site_settings"); await visit("/admin/site_settings");
assert.ok( assert
exists(".row.setting.upload .image-uploader"), .dom(".row.setting.upload .image-uploader")
"image uploader is present" .exists("image uploader is present");
);
assert.ok(exists(".row.setting.upload .undo"), "undo button is present"); assert.ok(exists(".row.setting.upload .undo"), "undo button is present");
}); });
@ -75,43 +74,37 @@ acceptance("Admin - Site Settings", function (needs) {
await fillIn(".input-setting-string", "Test"); await fillIn(".input-setting-string", "Test");
await click("button.cancel"); await click("button.cancel");
assert.ok( assert
!exists(".row.setting.overridden"), .dom(".row.setting.overridden")
"canceling doesn't mark setting as overridden" .doesNotExist("canceling doesn't mark setting as overridden");
);
await fillIn(".input-setting-string", "Test"); await fillIn(".input-setting-string", "Test");
await click("button.ok"); await click("button.ok");
assert.ok( assert
exists(".row.setting.overridden"), .dom(".row.setting.overridden")
"saving marks setting as overridden" .exists("saving marks setting as overridden");
);
await click("button.undo"); await click("button.undo");
assert.ok( assert
!exists(".row.setting.overridden"), .dom(".row.setting.overridden")
"setting isn't marked as overridden after undo" .doesNotExist("setting isn't marked as overridden after undo");
);
await click("button.cancel"); await click("button.cancel");
assert.ok( assert
exists(".row.setting.overridden"), .dom(".row.setting.overridden")
"setting is marked as overridden after cancel" .exists("setting is marked as overridden after cancel");
);
await click("button.undo"); await click("button.undo");
await click("button.ok"); await click("button.ok");
assert.ok( assert
!exists(".row.setting.overridden"), .dom(".row.setting.overridden")
"setting isn't marked as overridden after undo" .doesNotExist("setting isn't marked as overridden after undo");
);
await fillIn(".input-setting-string", "Test"); await fillIn(".input-setting-string", "Test");
await triggerKeyEvent(".input-setting-string", "keydown", "Enter"); await triggerKeyEvent(".input-setting-string", "keydown", "Enter");
assert.ok( assert
exists(".row.setting.overridden"), .dom(".row.setting.overridden")
"saving via Enter key marks setting as overridden" .exists("saving via Enter key marks setting as overridden");
);
}); });
test("always shows filtered site settings if a filter is set", async function (assert) { test("always shows filtered site settings if a filter is set", async function (assert) {

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";
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";
@ -173,10 +169,9 @@ acceptance("Admin - User Index", function (needs) {
assert.dom(".post-edits-count .value").hasText("6"); assert.dom(".post-edits-count .value").hasText("6");
assert.ok( assert
exists(".post-edits-count .controls .btn.btn-icon"), .dom(".post-edits-count .controls .btn.btn-icon")
"View edits button exists" .exists("View edits button exists");
);
}); });
test("a link to view post edits report exists", async function (assert) { test("a link to view post edits report exists", async function (assert) {
@ -196,10 +191,9 @@ acceptance("Admin - User Index", function (needs) {
test("hides the 'view Edits' button if the count is zero", async function (assert) { test("hides the 'view Edits' button if the count is zero", async function (assert) {
await visit("/admin/users/2/sam"); await visit("/admin/users/2/sam");
assert.ok( assert
!exists(".post-edits-count .controls .btn.btn-icon"), .dom(".post-edits-count .controls .btn.btn-icon")
"View Edits button not present" .doesNotExist("View Edits button not present");
);
}); });
test("will clear unsaved groups when switching user", async function (assert) { test("will clear unsaved groups when switching user", async function (assert) {
@ -224,10 +218,9 @@ acceptance("Admin - User Index", function (needs) {
.dom(".display-row.username .value") .dom(".display-row.username .value")
.hasText("eviltrout", "the name should be correct"); .hasText("eviltrout", "the name should be correct");
assert.ok( assert
!exists('.group-chooser span[title="Macdonald"]'), .dom('.group-chooser span[title="Macdonald"]')
"group should not be set" .doesNotExist("group should not be set");
);
}); });
test("grant admin - shows the confirmation dialog", async function (assert) { test("grant admin - shows the confirmation dialog", async function (assert) {
@ -247,10 +240,9 @@ acceptance("Admin - User Index", function (needs) {
await click(".grant-admin"); await click(".grant-admin");
assert.dom(".dialog-content").exists(); assert.dom(".dialog-content").exists();
assert.ok( assert
exists(".dialog-content .dialog-body strong"), .dom(".dialog-content .dialog-body strong")
"HTML is rendered in the dialog" .exists("HTML is rendered in the dialog");
);
}); });
test("grant admin - redirects to the 2fa page", async function (assert) { test("grant admin - redirects to the 2fa page", async function (assert) {

View File

@ -15,10 +15,9 @@ acceptance("Categories - 'categories_only'", function (needs) {
}); });
test("basic functionality", async function (assert) { test("basic functionality", async function (assert) {
await visit("/categories"); await visit("/categories");
assert.ok( assert
exists("table.category-list tr[data-category-id=1]"), .dom("table.category-list tr[data-category-id='1']")
"shows the topic list" .exists("shows the topic list");
);
}); });
}); });
@ -28,14 +27,12 @@ acceptance("Categories - 'categories_and_latest_topics'", function (needs) {
}); });
test("basic functionality", async function (assert) { test("basic functionality", async function (assert) {
await visit("/categories"); await visit("/categories");
assert.ok( assert
exists("table.category-list tr[data-category-id=1]"), .dom("table.category-list tr[data-category-id='1']")
"shows a category" .exists("shows a category");
); assert
assert.ok( .dom("div.latest-topic-list div[data-topic-id='8']")
exists("div.latest-topic-list div[data-topic-id=8]"), .exists("shows the topic list");
"shows the topic list"
);
assert.notOk( assert.notOk(
query(".more-topics a").href.endsWith("?order=created"), query(".more-topics a").href.endsWith("?order=created"),
"the load more button doesn't include the order=created param" "the load more button doesn't include the order=created param"
@ -66,14 +63,12 @@ acceptance("Categories - 'categories_with_featured_topics'", function (needs) {
}); });
test("basic functionality", async function (assert) { test("basic functionality", async function (assert) {
await visit("/categories"); await visit("/categories");
assert.ok( assert
exists("table.category-list.with-topics tr[data-category-id=1]"), .dom("table.category-list.with-topics tr[data-category-id='1']")
"shows a category" .exists("shows a category");
); 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"
);
}); });
}); });
@ -91,12 +86,12 @@ acceptance(
); );
assert.ok( assert.ok(
exists( 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" "shows table row for subcategories"
); );
assert.ok( assert.ok(
exists("table.category-list.with-topics div[data-topic-id=11994]"), exists("table.category-list.with-topics div[data-topic-id='11994']"),
"shows a featured topic" "shows a featured topic"
); );
}); });
@ -118,12 +113,12 @@ acceptance(
); );
assert.ok( assert.ok(
exists( 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" "shows element for subcategories"
); );
assert.ok( assert.ok(
exists("div.category-list.with-topics a[data-topic-id=11994]"), exists("div.category-list.with-topics a[data-topic-id='11994']"),
"shows a featured topic" "shows a featured topic"
); );
}); });

View File

@ -83,16 +83,14 @@ acceptance("Category New", function (needs) {
); );
await click(".edit-category-security a"); await click(".edit-category-security a");
assert.ok( assert
exists(".permission-row button.reply-toggle"), .dom(".permission-row button.reply-toggle")
"it can switch to the security tab" .exists("it can switch to the security tab");
);
await click(".edit-category-settings a"); await click(".edit-category-settings a");
assert.ok( assert
exists("#category-search-priority"), .dom("#category-search-priority")
"it can switch to the settings tab" .exists("it can switch to the settings tab");
);
sinon.stub(DiscourseURL, "routeTo"); sinon.stub(DiscourseURL, "routeTo");

View File

@ -7,7 +7,6 @@ import userFixtures from "discourse/tests/fixtures/user-fixtures";
import { import {
acceptance, acceptance,
count, count,
exists,
query, query,
selectText, selectText,
updateCurrentUser, updateCurrentUser,
@ -90,10 +89,9 @@ acceptance("Composer Actions", function (needs) {
"test replying as whisper to topic when initially not a whisper" "test replying as whisper to topic when initially not a whisper"
); );
assert.ok( assert
!exists(".composer-actions svg.d-icon-far-eye-slash"), .dom(".composer-actions svg.d-icon-far-eye-slash")
"whisper icon is not visible" .doesNotExist("whisper icon is not visible");
);
assert.strictEqual( assert.strictEqual(
count(".composer-actions svg.d-icon-share"), count(".composer-actions svg.d-icon-share"),
1, 1,
@ -108,10 +106,9 @@ acceptance("Composer Actions", function (needs) {
1, 1,
"whisper icon is visible" "whisper icon is visible"
); );
assert.ok( assert
!exists(".composer-actions svg.d-icon-share"), .dom(".composer-actions svg.d-icon-share")
"reply icon is not visible" .doesNotExist("reply icon is not visible");
);
}); });
test("replying to post - reply_as_new_topic", async function (assert) { test("replying to post - reply_as_new_topic", async function (assert) {
@ -155,10 +152,9 @@ acceptance("Composer Actions", function (needs) {
await click(".create.reply"); await click(".create.reply");
const composerActions = selectKit(".composer-actions"); const composerActions = selectKit(".composer-actions");
await composerActions.expand(); await composerActions.expand();
assert.ok( assert
!exists(".composer-actions svg.d-icon-plus"), .dom(".composer-actions svg.d-icon-plus")
"reply as new topic icon is not visible" .doesNotExist("reply as new topic icon is not visible");
);
}); });
test("reply_as_new_group_message", async function (assert) { test("reply_as_new_group_message", async function (assert) {
@ -247,10 +243,9 @@ acceptance("Composer Actions", function (needs) {
await visit("/t/short-topic-with-two-posts/54077"); await visit("/t/short-topic-with-two-posts/54077");
await click("article#post_2 button.reply"); await click("article#post_2 button.reply");
assert.ok( assert
!exists(".composer-actions svg.d-icon-anchor"), .dom(".composer-actions svg.d-icon-anchor")
"no-bump icon is not visible" .doesNotExist("no-bump icon is not visible");
);
assert.strictEqual( assert.strictEqual(
count(".composer-actions svg.d-icon-share"), count(".composer-actions svg.d-icon-share"),
1, 1,
@ -265,18 +260,16 @@ acceptance("Composer Actions", function (needs) {
1, 1,
"no-bump icon is visible" "no-bump icon is visible"
); );
assert.ok( assert
!exists(".composer-actions svg.d-icon-share"), .dom(".composer-actions svg.d-icon-share")
"reply icon is not visible" .doesNotExist("reply icon is not visible");
);
await composerActions.expand(); await composerActions.expand();
await composerActions.selectRowByValue("toggle_topic_bump"); await composerActions.selectRowByValue("toggle_topic_bump");
assert.ok( assert
!exists(".composer-actions svg.d-icon-anchor"), .dom(".composer-actions svg.d-icon-anchor")
"no-bump icon is not visible" .doesNotExist("no-bump icon is not visible");
);
assert.strictEqual( assert.strictEqual(
count(".composer-actions svg.d-icon-share"), count(".composer-actions svg.d-icon-share"),
1, 1,
@ -290,14 +283,12 @@ acceptance("Composer Actions", function (needs) {
await visit("/t/short-topic-with-two-posts/54077"); await visit("/t/short-topic-with-two-posts/54077");
await click("article#post_2 button.reply"); await click("article#post_2 button.reply");
assert.ok( assert
!exists(".composer-actions svg.d-icon-far-eye-slash"), .dom(".composer-actions svg.d-icon-far-eye-slash")
"whisper icon is not visible" .doesNotExist("whisper icon is not visible");
); assert
assert.ok( .dom(".reply-details .whisper .d-icon-anchor")
!exists(".reply-details .whisper .d-icon-anchor"), .doesNotExist("no-bump icon is not visible");
"no-bump icon is not visible"
);
assert.strictEqual( assert.strictEqual(
count(".composer-actions svg.d-icon-share"), count(".composer-actions svg.d-icon-share"),
1, 1,
@ -319,10 +310,9 @@ acceptance("Composer Actions", function (needs) {
1, 1,
"no-bump icon is visible" "no-bump icon is visible"
); );
assert.ok( assert
!exists(".composer-actions svg.d-icon-share"), .dom(".composer-actions svg.d-icon-share")
"reply icon is not visible" .doesNotExist("reply icon is not visible");
);
}); });
test("replying to post as staff", async function (assert) { test("replying to post as staff", async function (assert) {

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("Composer - Draft saving", function (needs) { acceptance("Composer - Draft saving", function (needs) {
@ -24,10 +24,9 @@ acceptance("Composer - Draft saving", function (needs) {
await fillIn(".d-editor-input", draftThatWillBeSaved); await fillIn(".d-editor-input", draftThatWillBeSaved);
assert.notOk( assert
exists("div#draft-status span"), .dom("div#draft-status span")
"the draft was saved, there's no warning" .doesNotExist("the draft was saved, there's no warning");
);
await fillIn(".d-editor-input", "This won't be saved because of error"); await fillIn(".d-editor-input", "This won't be saved because of error");
assert assert
@ -36,15 +35,13 @@ acceptance("Composer - Draft saving", function (needs) {
I18n.t("composer.drafts_offline"), I18n.t("composer.drafts_offline"),
"the draft wasn't saved, a warning is rendered" "the draft wasn't saved, a warning is rendered"
); );
assert.ok( assert
exists("div#draft-status svg.d-icon-triangle-exclamation"), .dom("div#draft-status svg.d-icon-triangle-exclamation")
"an exclamation icon is rendered" .exists("an exclamation icon is rendered");
);
await fillIn(".d-editor-input", draftThatWillBeSaved); await fillIn(".d-editor-input", draftThatWillBeSaved);
assert.notOk( assert
exists("div#draft-status span"), .dom("div#draft-status span")
"the draft was saved again, the warning has disappeared" .doesNotExist("the draft was saved again, the warning has disappeared");
);
}); });
}); });

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { setCaretPosition } from "discourse/lib/utilities"; import { setCaretPosition } from "discourse/lib/utilities";
import { import {
acceptance, acceptance,
exists,
fakeTime, fakeTime,
loggedInUser, loggedInUser,
query, query,
@ -116,10 +115,9 @@ acceptance("Composer - editor mentions", function (needs) {
await simulateKeys(editor, "@u"); await simulateKeys(editor, "@u");
assert.ok( assert
exists(`.autocomplete .emoji[alt='${status.emoji}']`), .dom(`.autocomplete .emoji[alt='${status.emoji}']`)
"status emoji is shown" .exists("status emoji is shown");
);
assert.equal( assert.equal(
query( query(

View File

@ -4,7 +4,6 @@ import { withPluginApi } from "discourse/lib/plugin-api";
import { import {
acceptance, acceptance,
count, count,
exists,
invisible, invisible,
query, query,
visible, visible,
@ -148,10 +147,9 @@ acceptance("Composer - Image Preview", function (needs) {
); );
assert.dom(".button-wrapper").doesNotExist(); assert.dom(".button-wrapper").doesNotExist();
assert.ok( assert
!exists("script"), .dom("script")
"it does not unescape script tags in code blocks" .doesNotExist("it does not unescape script tags in code blocks");
);
}); });
test("Editing alt text (with enter key) for single image in preview updates alt text in composer", async function (assert) { test("Editing alt text (with enter key) for single image in preview updates alt text in composer", async function (assert) {
@ -420,10 +418,9 @@ acceptance("Composer - Image Preview - Plugin API", function (needs) {
"![image_example_0|666x500](upload://q4iRxcuSAzfnbUaCsbjMXcGrpaK.jpeg)" "![image_example_0|666x500](upload://q4iRxcuSAzfnbUaCsbjMXcGrpaK.jpeg)"
); );
assert.ok( assert
exists(".image-wrapper .custom-button-class"), .dom(".image-wrapper .custom-button-class")
"The custom button is added to the image preview wrapper" .exists("The custom button is added to the image preview wrapper");
);
await click(".custom-button-class"); await click(".custom-button-class");

View File

@ -159,52 +159,44 @@ acceptance("Composer", function (needs) {
await click("#create-topic"); await click("#create-topic");
assert.ok(exists(".d-editor-input"), "the composer input is visible"); assert.ok(exists(".d-editor-input"), "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"
);
await click(".toggle-preview"); await click(".toggle-preview");
assert.ok( assert
!exists(".d-editor-preview:visible"), .dom(".d-editor-preview")
"clicking the toggle hides the preview" .isNotVisible("clicking the toggle hides the preview");
);
await click(".toggle-preview"); await click(".toggle-preview");
assert.ok( assert
exists(".d-editor-preview:visible"), .dom(".d-editor-preview")
"clicking the toggle shows the preview again" .isVisible("clicking the toggle shows the preview again");
);
await click("#reply-control button.create"); await click("#reply-control button.create");
assert.ok( assert
exists(".title-input .popup-tip.bad"), .dom(".title-input .popup-tip.bad")
"it shows the empty title error" .exists("it shows the empty title error");
); assert
assert.ok( .dom(".d-editor-textarea-wrapper .popup-tip.bad")
exists(".d-editor-textarea-wrapper .popup-tip.bad"), .exists("it shows the empty body error");
"it shows the empty body error"
);
await fillIn("#reply-title", "this is my new topic title"); await fillIn("#reply-title", "this is my new topic title");
assert.ok( assert
exists(".title-input .popup-tip.good.hide"), .dom(".title-input .popup-tip.good.hide")
"the title is now good" .exists("the title is now good");
);
await triggerKeyEvent( await triggerKeyEvent(
".d-editor-textarea-wrapper .popup-tip.bad", ".d-editor-textarea-wrapper .popup-tip.bad",
"keydown", "keydown",
"Enter" "Enter"
); );
assert.ok( assert
exists(".d-editor-textarea-wrapper .popup-tip.bad.hide"), .dom(".d-editor-textarea-wrapper .popup-tip.bad.hide")
"body error is dismissed via keyboard" .exists("body error is dismissed via keyboard");
);
await fillIn(".d-editor-input", "this is the *content* of a post"); await fillIn(".d-editor-input", "this is the *content* of a post");
assert.strictEqual( assert.strictEqual(
@ -212,10 +204,9 @@ acceptance("Composer", function (needs) {
"<p>this is the <em>content</em> of a post</p>", "<p>this is the <em>content</em> of a post</p>",
"it previews content" "it previews content"
); );
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");
);
const textarea = query("#reply-control .d-editor-input"); const textarea = query("#reply-control .d-editor-input");
textarea.selectionStart = textarea.value.length; textarea.selectionStart = textarea.value.length;
@ -317,17 +308,15 @@ acceptance("Composer", function (needs) {
test("Create a Reply", async function (assert) { test("Create a Reply", async function (assert) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
assert.ok( assert
!exists('article[data-post-id="12345"]'), .dom('article[data-post-id="12345"]')
"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.ok(exists(".d-editor-input"), "the composer input is visible");
assert.ok( assert
!exists("#reply-title"), .dom("#reply-title")
"there is no title since this is a reply" .doesNotExist("there is no title since this is a reply");
);
await fillIn(".d-editor-input", "this is the content of my reply"); await fillIn(".d-editor-input", "this is the content of my reply");
await click("#reply-control button.create"); await click("#reply-control button.create");
@ -434,19 +423,17 @@ acceptance("Composer", function (needs) {
"moves to second topic" "moves to second topic"
); );
await click("#topic-footer-buttons .btn.create"); await click("#topic-footer-buttons .btn.create");
assert.ok( assert
exists(".discard-draft-modal.modal"), .dom(".discard-draft-modal.modal")
"it pops up the discard drafts modal" .exists("it pops up the discard drafts modal");
);
await click(".d-modal__footer button.keep-editing"); await click(".d-modal__footer button.keep-editing");
assert.ok(invisible(".discard-draft-modal.modal"), "hides modal"); assert.ok(invisible(".discard-draft-modal.modal"), "hides modal");
await click("#topic-footer-buttons .btn.create"); await click("#topic-footer-buttons .btn.create");
assert.ok( assert
exists(".discard-draft-modal.modal"), .dom(".discard-draft-modal.modal")
"it pops up the modal again" .exists("it pops up the modal again");
);
await click(".d-modal__footer button.discard-draft"); await click(".d-modal__footer button.discard-draft");
@ -474,10 +461,9 @@ acceptance("Composer", function (needs) {
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.ok(exists(".d-editor-input"), "the composer input is visible");
assert.ok( assert
!exists("#reply-title"), .dom("#reply-title")
"there is no title since this is a reply" .doesNotExist("there is no title since this is a reply");
);
await fillIn(".d-editor-input", "enqueue this content please"); await fillIn(".d-editor-input", "enqueue this content please");
await click("#reply-control button.create"); await click("#reply-control button.create");
@ -496,10 +482,9 @@ acceptance("Composer", function (needs) {
test("Edit the first post", async function (assert) { test("Edit the first post", async function (assert) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
assert.ok( assert
!exists(".topic-post:nth-of-type(1) .post-info.edits"), .dom(".topic-post:nth-of-type(1) .post-info.edits")
"it has no edits icon at first" .doesNotExist("it has no edits icon at first");
);
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.edit"); await click(".topic-post:nth-of-type(1) button.edit");
@ -512,10 +497,9 @@ acceptance("Composer", function (needs) {
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.ok(!exists(".d-editor-input"), "it closes the composer");
assert.ok( assert
exists(".topic-post:nth-of-type(1) .post-info.edits"), .dom(".topic-post:nth-of-type(1) .post-info.edits")
"it has the edits icon" .exists("it has the edits icon");
);
assert.ok( assert.ok(
query("#topic-title h1").innerText.includes( query("#topic-title h1").innerText.includes(
"This is the new text for the title" "This is the new text for the title"
@ -577,10 +561,9 @@ acceptance("Composer", function (needs) {
await click(".topic-post:nth-of-type(1) button.edit"); await click(".topic-post:nth-of-type(1) button.edit");
await fillIn(".d-editor-input", "This is a dirty reply"); await fillIn(".d-editor-input", "This is a dirty reply");
await click(".topic-post:nth-of-type(2) button.edit"); await click(".topic-post:nth-of-type(2) button.edit");
assert.ok( assert
exists(".discard-draft-modal.modal"), .dom(".discard-draft-modal.modal")
"it pops up a confirmation dialog" .exists("it pops up a confirmation dialog");
);
await click(".d-modal__footer button.discard-draft"); await click(".d-modal__footer button.discard-draft");
assert.ok( assert.ok(
@ -628,10 +611,9 @@ acceptance("Composer", function (needs) {
await menu.expand(); await menu.expand();
await menu.selectRowByName("toggle-whisper"); await menu.selectRowByName("toggle-whisper");
assert.ok( assert
!exists(".composer-actions svg.d-icon-far-eye-slash"), .dom(".composer-actions svg.d-icon-far-eye-slash")
"it removes the whisper mode" .doesNotExist("it removes the whisper mode");
);
await menu.expand(); await menu.expand();
await menu.selectRowByName("toggle-whisper"); await menu.selectRowByName("toggle-whisper");
@ -744,10 +726,9 @@ acceptance("Composer", function (needs) {
assert.ok(exists("#create-topic"), "the create topic button is visible"); assert.ok(exists("#create-topic"), "the create topic button is visible");
await click("#create-topic"); await click("#create-topic");
assert.ok( assert
!exists(".reply-details .whisper .d-icon-far-eye-slash"), .dom(".reply-details .whisper .d-icon-far-eye-slash")
"it should reset the state of the composer's model" .doesNotExist("it should reset the state of the composer's model");
);
await selectKit(".toolbar-popup-menu-options").expand(); await selectKit(".toolbar-popup-menu-options").expand();
await selectKit(".toolbar-popup-menu-options").selectRowByName( await selectKit(".toolbar-popup-menu-options").selectRowByName(
@ -764,10 +745,9 @@ acceptance("Composer", function (needs) {
await visit("/t/this-is-a-test-topic/9"); await visit("/t/this-is-a-test-topic/9");
await click(".topic-post:nth-of-type(1) button.reply"); await click(".topic-post:nth-of-type(1) button.reply");
assert.ok( assert
!exists(".reply-details .whisper"), .dom(".reply-details .whisper")
"it should reset the state of the composer's model" .doesNotExist("it should reset the state of the composer's model");
);
}); });
test("Composer can toggle whisper when switching from reply to whisper to reply to topic", async function (assert) { test("Composer can toggle whisper when switching from reply to whisper to reply to topic", async function (assert) {
@ -775,16 +755,14 @@ acceptance("Composer", function (needs) {
await click(".topic-post:nth-of-type(3) button.reply"); await click(".topic-post:nth-of-type(3) button.reply");
await click(".reply-details summary div"); await click(".reply-details summary div");
assert.ok( assert
!exists('.reply-details li[data-value="toggle_whisper"]'), .dom('.reply-details li[data-value="toggle_whisper"]')
"toggle whisper is not available when reply to whisper" .doesNotExist("toggle whisper is not available when reply to whisper");
);
await click('.reply-details li[data-value="reply_to_topic"]'); await click('.reply-details li[data-value="reply_to_topic"]');
await click(".reply-details summary div"); await click(".reply-details summary div");
assert.ok( assert
exists('.reply-details li[data-value="toggle_whisper"]'), .dom('.reply-details li[data-value="toggle_whisper"]')
"toggle whisper is available when reply to topic" .exists("toggle whisper is available when reply to topic");
);
}); });
test("Composer can toggle whisper when clicking reply to topic after reply to whisper", async function (assert) { test("Composer can toggle whisper when clicking reply to topic after reply to whisper", async function (assert) {
@ -794,10 +772,9 @@ acceptance("Composer", function (needs) {
await click("#reply-control .save-or-cancel a.cancel"); await click("#reply-control .save-or-cancel a.cancel");
await click(".topic-footer-main-buttons button.create"); await click(".topic-footer-main-buttons button.create");
await click(".reply-details summary div"); await click(".reply-details summary div");
assert.ok( assert
exists('.reply-details li[data-value="toggle_whisper"]'), .dom('.reply-details li[data-value="toggle_whisper"]')
"toggle whisper is available when reply to topic" .exists("toggle whisper is available when reply to topic");
);
}); });
test("Composer draft with dirty reply can toggle to edit", async function (assert) { test("Composer draft with dirty reply can toggle to edit", async function (assert) {
@ -807,10 +784,9 @@ acceptance("Composer", function (needs) {
await fillIn(".d-editor-input", "This is a dirty reply"); await fillIn(".d-editor-input", "This is a dirty reply");
await click(".toggler"); await click(".toggler");
await click(".topic-post:nth-of-type(2) button.edit"); await click(".topic-post:nth-of-type(2) button.edit");
assert.ok( assert
exists(".discard-draft-modal.modal"), .dom(".discard-draft-modal.modal")
"it pops up a confirmation dialog" .exists("it pops up a confirmation dialog");
);
assert.ok(invisible(".d-modal__footer button.save-draft")); assert.ok(invisible(".d-modal__footer button.save-draft"));
assert assert
.dom(".d-modal__footer button.keep-editing") .dom(".d-modal__footer button.keep-editing")
@ -834,10 +810,9 @@ acceptance("Composer", function (needs) {
await click("#site-logo"); await click("#site-logo");
await click("#create-topic"); await click("#create-topic");
assert.ok( assert
exists(".discard-draft-modal.modal"), .dom(".discard-draft-modal.modal")
"it pops up a confirmation dialog" .exists("it pops up a confirmation dialog");
);
assert assert
.dom(".d-modal__footer button.save-draft") .dom(".d-modal__footer button.save-draft")
.hasText( .hasText(
@ -1026,10 +1001,9 @@ acceptance("Composer", function (needs) {
await click("#topic-footer-buttons .create"); await click("#topic-footer-buttons .create");
await fillIn(".d-editor-input", "[quote]\n@staff\n[/quote]"); await fillIn(".d-editor-input", "[quote]\n@staff\n[/quote]");
assert.notOk( assert
exists(".composer-popup"), .dom(".composer-popup")
"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.ok(exists(".composer-popup"), "Shows the 'group_mentioned' notice");

View File

@ -22,10 +22,9 @@ acceptance("Composer topic featured links", function (needs) {
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",
@ -41,10 +40,9 @@ acceptance("Composer topic featured links", function (needs) {
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,
"http://www.example.com/no-title.html", "http://www.example.com/no-title.html",
@ -71,10 +69,9 @@ acceptance("Composer topic featured links", function (needs) {
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")
"link is pasted into body" .exists("link is pasted into body");
);
assert.strictEqual( assert.strictEqual(
query(".title-input input").value, query(".title-input input").value,
"http://www.example.com/nope-onebox.html", "http://www.example.com/nope-onebox.html",
@ -114,10 +111,9 @@ acceptance("Composer topic featured links", function (needs) {
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",
@ -156,10 +152,9 @@ acceptance("Composer topic featured links", function (needs) {
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.blank(query(".title-input input").value, "title is blank"); assert.blank(query(".title-input input").value, "title is blank");
}); });
}); });

View File

@ -36,10 +36,9 @@ acceptance("Dashboard", function (needs) {
await visit("/admin"); await visit("/admin");
assert.ok(exists(".dashboard .navigation-item.general"), "general tab"); assert.ok(exists(".dashboard .navigation-item.general"), "general tab");
assert.ok( assert
exists(".dashboard .navigation-item.moderation"), .dom(".dashboard .navigation-item.moderation")
"moderation tab" .exists("moderation tab");
);
assert.ok(exists(".dashboard .navigation-item.security"), "security tab"); assert.ok(exists(".dashboard .navigation-item.security"), "security tab");
assert.ok(exists(".dashboard .navigation-item.reports"), "reports tab"); assert.ok(exists(".dashboard .navigation-item.reports"), "reports tab");
}); });
@ -51,14 +50,12 @@ acceptance("Dashboard", function (needs) {
assert.ok(exists(".admin-report.signups"), "signups report"); assert.ok(exists(".admin-report.signups"), "signups report");
assert.ok(exists(".admin-report.posts"), "posts report"); assert.ok(exists(".admin-report.posts"), "posts report");
assert.ok(exists(".admin-report.dau-by-mau"), "dau-by-mau report"); assert.ok(exists(".admin-report.dau-by-mau"), "dau-by-mau report");
assert.ok( assert
exists(".admin-report.daily-engaged-users"), .dom(".admin-report.daily-engaged-users")
"daily-engaged-users report" .exists("daily-engaged-users report");
); assert
assert.ok( .dom(".admin-report.new-contributors")
exists(".admin-report.new-contributors"), .exists("new-contributors report");
"new-contributors report"
);
}); });
test("moderation tab", async function (assert) { test("moderation tab", async function (assert) {
@ -66,10 +63,9 @@ acceptance("Dashboard", function (needs) {
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.ok(exists(".custom-date-range-button"), "custom date range button");
assert.ok( assert
exists(".admin-report.moderators-activity"), .dom(".admin-report.moderators-activity")
"moderators activity report" .exists("moderators activity report");
);
}); });
test("activity metrics", async function (assert) { test("activity metrics", async function (assert) {
@ -134,10 +130,9 @@ acceptance("Dashboard: dashboard_visible_tabs", function (needs) {
await visit("/admin"); await visit("/admin");
assert.ok(exists(".dashboard .navigation-item.general"), "general tab"); assert.ok(exists(".dashboard .navigation-item.general"), "general tab");
assert.notOk( assert
exists(".dashboard .navigation-item.moderation"), .dom(".dashboard .navigation-item.moderation")
"moderation tab" .doesNotExist("moderation tab");
);
assert.ok(exists(".dashboard .navigation-item.security"), "security tab"); assert.ok(exists(".dashboard .navigation-item.security"), "security tab");
assert.ok(exists(".dashboard .navigation-item.reports"), "reports tab"); assert.ok(exists(".dashboard .navigation-item.reports"), "reports tab");
}); });
@ -155,9 +150,8 @@ acceptance("Dashboard: dashboard_hidden_reports", function (needs) {
assert.ok(exists(".admin-report.signups.is-visible"), "signups report"); assert.ok(exists(".admin-report.signups.is-visible"), "signups report");
assert.notOk(exists(".admin-report.is-visible.posts"), "posts report"); assert.notOk(exists(".admin-report.is-visible.posts"), "posts report");
assert.notOk( assert
exists(".admin-report.is-visible.dau-by-mau"), .dom(".admin-report.is-visible.dau-by-mau")
"dau-by-mau report" .doesNotExist("dau-by-mau report");
);
}); });
}); });

View File

@ -89,10 +89,9 @@ acceptance("Do not disturb", function (needs) {
await visit("/"); await visit("/");
assert.ok( assert
exists(".do-not-disturb-background"), .dom(".do-not-disturb-background")
"The active dnd icon is shown" .exists("The active dnd icon is shown");
);
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");
@ -101,25 +100,23 @@ acceptance("Do not disturb", function (needs) {
"1h", "1h",
"the Do Not Disturb button shows how much time is left for DND mode" "the Do Not Disturb button shows how much time is left for DND mode"
); );
assert.ok( assert
exists(".do-not-disturb .d-icon-toggle-on"), .dom(".do-not-disturb .d-icon-toggle-on")
"the Do Not Disturb button has the toggle-on icon" .exists("the Do Not Disturb button has the toggle-on icon");
);
await click("#quick-access-profile .do-not-disturb .btn"); await click("#quick-access-profile .do-not-disturb .btn");
assert.notOk( assert
exists(".do-not-disturb-background"), .dom(".do-not-disturb-background")
"The active dnd icon is removed" .doesNotExist("The active dnd icon is removed");
); assert
assert.notOk( .dom(".do-not-disturb .relative-date")
exists(".do-not-disturb .relative-date"), .doesNotExist(
"the text showing how much time is left for DND mode is gone" "the text showing how much time is left for DND mode is gone"
); );
assert.ok( assert
exists(".do-not-disturb .d-icon-toggle-off"), .dom(".do-not-disturb .d-icon-toggle-off")
"the Do Not Disturb button has the toggle-off icon" .exists("the Do Not Disturb button has the toggle-off icon");
);
}); });
test("user menu gets closed when the DnD modal is opened", async function (assert) { test("user menu gets closed when the DnD modal is opened", async function (assert) {

View File

@ -2,7 +2,6 @@ import { 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";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -13,19 +12,17 @@ acceptance("Email Disabled Banner", function (needs) {
test("when disabled", async function (assert) { test("when disabled", async function (assert) {
this.siteSettings.disable_emails = "no"; this.siteSettings.disable_emails = "no";
await visit("/"); await visit("/");
assert.notOk( assert
exists(".alert-emails-disabled"), .dom(".alert-emails-disabled")
"alert is not displayed when email enabled" .doesNotExist("alert is not displayed when email enabled");
);
}); });
test("when enabled", async function (assert) { test("when enabled", async function (assert) {
this.siteSettings.disable_emails = "yes"; this.siteSettings.disable_emails = "yes";
await visit("/latest"); await visit("/latest");
assert.ok( assert
exists(".alert-emails-disabled"), .dom(".alert-emails-disabled")
"alert is displayed when email disabled" .exists("alert is displayed when email disabled");
);
assert assert
.dom(".alert-emails-disabled .text") .dom(".alert-emails-disabled .text")
.hasText(I18n.t("emails_are_disabled"), "alert uses the correct text"); .hasText(I18n.t("emails_are_disabled"), "alert uses the correct text");
@ -34,10 +31,9 @@ acceptance("Email Disabled Banner", function (needs) {
test("when non-staff", async function (assert) { test("when non-staff", async function (assert) {
this.siteSettings.disable_emails = "non-staff"; this.siteSettings.disable_emails = "non-staff";
await visit("/"); await visit("/");
assert.ok( assert
exists(".alert-emails-disabled"), .dom(".alert-emails-disabled")
"alert is displayed when email disabled for non-staff" .exists("alert is displayed when email disabled for non-staff");
);
assert assert
.dom(".alert-emails-disabled .text") .dom(".alert-emails-disabled .text")
.hasText( .hasText(
@ -47,10 +43,9 @@ acceptance("Email Disabled Banner", function (needs) {
updateCurrentUser({ moderator: true }); updateCurrentUser({ moderator: true });
await visit("/"); await visit("/");
assert.ok( assert
exists(".alert-emails-disabled"), .dom(".alert-emails-disabled")
"alert is displayed to staff when email disabled for non-staff" .exists("alert is displayed to staff when email disabled for non-staff");
);
assert assert
.dom(".alert-emails-disabled .text") .dom(".alert-emails-disabled .text")
.hasText( .hasText(

View File

@ -90,10 +90,9 @@ acceptance("EmojiPicker", function (needs) {
"it shows recent selected emoji" "it shows recent selected emoji"
); );
assert.ok( assert
exists('.emoji-picker .category-button[data-section="recent"]'), .dom('.emoji-picker .category-button[data-section="recent"]')
"it shows recent category icon" .exists("it shows recent category icon");
);
await click(".emoji-picker .trash-recent"); await click(".emoji-picker .trash-recent");
@ -104,15 +103,13 @@ acceptance("EmojiPicker", function (needs) {
"it has cleared recent emojis" "it has cleared recent emojis"
); );
assert.notOk( assert
exists('.emoji-picker .section[data-section="recent"]'), .dom('.emoji-picker .section[data-section="recent"]')
"it hides recent section" .doesNotExist("it hides recent section");
);
assert.notOk( assert
exists('.emoji-picker .category-button[data-section="recent"]'), .dom('.emoji-picker .category-button[data-section="recent"]')
"it hides recent category icon" .doesNotExist("it hides recent category icon");
);
}); });
test("emoji picker correctly orders recently used emojis", async function (assert) { test("emoji picker correctly orders recently used emojis", async function (assert) {
@ -174,10 +171,9 @@ acceptance("EmojiPicker", function (needs) {
await click("button.emoji.btn"); await click("button.emoji.btn");
await click("button.emoji.btn"); await click("button.emoji.btn");
assert.ok( assert
exists(".emoji-picker button.diversity-scale.medium-dark .d-icon"), .dom(".emoji-picker button.diversity-scale.medium-dark .d-icon")
"it stores diversity scale" .exists("it stores diversity scale");
);
}); });
test("emoji can be selected with keyboard", async function (assert) { test("emoji can be selected with keyboard", async function (assert) {

View File

@ -107,18 +107,15 @@ acceptance("flagging", function (needs) {
await openFlagModal(); await openFlagModal();
await click("#radio_inappropriate"); await click("#radio_inappropriate");
await selectKit(".reviewable-action-dropdown").expand(); await selectKit(".reviewable-action-dropdown").expand();
assert.ok( assert
exists("[data-value='agree_and_silence']"), .dom("[data-value='agree_and_silence']")
"it shows the silence action option" .exists("it shows the silence action option");
); assert
assert.ok( .dom("[data-value='agree_and_suspend']")
exists("[data-value='agree_and_suspend']"), .exists("it shows the suspend action option");
"it shows the suspend action option" assert
); .dom("[data-value='agree_and_hide']")
assert.ok( .exists("it shows the hide action option");
exists("[data-value='agree_and_hide']"),
"it shows the hide action option"
);
}); });
test("Can silence from take action", async function (assert) { test("Can silence from take action", async function (assert) {
@ -197,14 +194,13 @@ acceptance("flagging", function (needs) {
const modal = query(".d-modal"); const modal = query(".d-modal");
await pressEnter(modal, "ctrlKey"); await pressEnter(modal, "ctrlKey");
assert.ok( assert
exists(".d-modal:visible"), .dom(".d-modal")
"The modal wasn't closed because the accept button was disabled" .exists("The modal wasn't closed because the accept button was disabled");
);
await click("#radio_inappropriate"); // this enables the accept button await click("#radio_inappropriate"); // this enables the accept button
await pressEnter(modal, "ctrlKey"); await pressEnter(modal, "ctrlKey");
assert.ok(!exists(".d-modal:visible"), "The modal was closed"); assert.dom(".d-modal").doesNotExist("The modal was closed");
}); });
test("CMD or WINDOWS-KEY + ENTER accepts the modal", async function (assert) { test("CMD or WINDOWS-KEY + ENTER accepts the modal", async function (assert) {
@ -213,13 +209,12 @@ acceptance("flagging", function (needs) {
const modal = query(".d-modal"); const modal = query(".d-modal");
await pressEnter(modal, "metaKey"); await pressEnter(modal, "metaKey");
assert.ok( assert
exists(".d-modal:visible"), .dom(".d-modal")
"The modal wasn't closed because the accept button was disabled" .exists("The modal wasn't closed because the accept button was disabled");
);
await click("#radio_inappropriate"); // this enables the accept button await click("#radio_inappropriate"); // this enables the accept button
await pressEnter(modal, "ctrlKey"); await pressEnter(modal, "ctrlKey");
assert.ok(!exists(".d-modal:visible"), "The modal was closed"); assert.dom(".d-modal").doesNotExist("The modal was closed");
}); });
}); });

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";
let userFound = false; let userFound = false;
@ -56,10 +52,9 @@ acceptance("Forgot password", function (needs) {
await click(".forgot-password-reset"); await click(".forgot-password-reset");
assert.notOk( assert
exists(".alert-error"), .dom(".alert-error")
"it should remove the flash error when succeeding" .doesNotExist("it should remove the flash error when succeeding");
);
assert.strictEqual( assert.strictEqual(
query(".d-modal__body").innerHTML.trim(), query(".d-modal__body").innerHTML.trim(),

View File

@ -22,10 +22,9 @@ acceptance("Group Members - Anonymous", function () {
); );
assert.ok(exists(".group-members .group-member"), "it lists group members"); assert.ok(exists(".group-members .group-member"), "it lists group members");
assert.ok( assert
!exists(".group-member-dropdown"), .dom(".group-member-dropdown")
"it does not allow anon user to manage group members" .doesNotExist("it does not allow anon user to manage group members");
);
assert.strictEqual( assert.strictEqual(
query(".group-username-filter").getAttribute("placeholder"), query(".group-username-filter").getAttribute("placeholder"),
@ -60,10 +59,9 @@ acceptance("Group Members", function (needs) {
test("Viewing Members as an admin user", async function (assert) { test("Viewing Members as an admin user", async function (assert) {
await visit("/g/discourse"); await visit("/g/discourse");
assert.ok( assert
exists(".group-member-dropdown"), .dom(".group-member-dropdown")
"it allows admin user to manage group members" .exists("it allows admin user to manage group members");
);
assert.strictEqual( assert.strictEqual(
query(".group-username-filter").getAttribute("placeholder"), query(".group-username-filter").getAttribute("placeholder"),
@ -83,20 +81,17 @@ acceptance("Group Members", function (needs) {
const memberDropdown = selectKit(".bulk-group-member-dropdown"); const memberDropdown = selectKit(".bulk-group-member-dropdown");
await memberDropdown.expand(); await memberDropdown.expand();
assert.ok( assert
exists('[data-value="removeMembers"]'), .dom('[data-value="removeMembers"]')
"it includes remove member option" .exists("it includes remove member option");
);
assert.ok( assert
exists('[data-value="makeOwners"]'), .dom('[data-value="makeOwners"]')
"it includes make owners option" .exists("it includes make owners option");
);
assert.ok( assert
exists('[data-value="setPrimary"]'), .dom('[data-value="setPrimary"]')
"it includes set primary option" .exists("it includes set primary option");
);
}); });
test("Shows bulk actions as a group owner", async function (assert) { test("Shows bulk actions as a group owner", async function (assert) {
@ -112,37 +107,32 @@ acceptance("Group Members", function (needs) {
const memberDropdown = selectKit(".bulk-group-member-dropdown"); const memberDropdown = selectKit(".bulk-group-member-dropdown");
await memberDropdown.expand(); await memberDropdown.expand();
assert.ok( assert
exists('[data-value="removeMembers"]'), .dom('[data-value="removeMembers"]')
"it includes remove member option" .exists("it includes remove member option");
);
assert.ok( assert
exists('[data-value="makeOwners"]'), .dom('[data-value="makeOwners"]')
"it includes make owners option" .exists("it includes make owners option");
);
assert.notOk( assert
exists('[data-value="setPrimary"]'), .dom('[data-value="setPrimary"]')
"it does not include set primary (staff only) option" .doesNotExist("it does not include set primary (staff only) option");
);
}); });
test("Bulk actions - Menu, Select all and Clear all buttons", async function (assert) { test("Bulk actions - Menu, Select all and Clear all buttons", async function (assert) {
await visit("/g/discourse"); await visit("/g/discourse");
assert.ok( assert
!exists(".bulk-select-buttons-wrap details"), .dom(".bulk-select-buttons-wrap details")
"it does not show menu button if nothing is selected" .doesNotExist("it does not show menu button if nothing is selected");
);
await click("button.bulk-select"); await click("button.bulk-select");
await click(".bulk-select-all"); await click(".bulk-select-all");
assert.ok( assert
exists(".bulk-select-buttons-wrap details"), .dom(".bulk-select-buttons-wrap details")
"it shows menu button if something is selected" .exists("it shows menu button if something is selected");
);
}); });
}); });

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";
@ -11,10 +10,9 @@ acceptance("Managing Group Category Notification Defaults", function () {
test("As an anonymous user", async function (assert) { test("As an anonymous user", async function (assert) {
await visit("/g/discourse/manage/categories"); await visit("/g/discourse/manage/categories");
assert.ok( assert
exists(".group-members .group-member"), .dom(".group-members .group-member")
"it should redirect to members page for an anonymous user" .exists("it should redirect to members page for an anonymous user");
);
}); });
}); });

View File

@ -4,7 +4,6 @@ import Site from "discourse/models/site";
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";
@ -88,10 +87,9 @@ acceptance("Managing Group Membership", function (needs) {
"it should disable group public admission input" "it should disable group public admission input"
); );
assert.ok( assert
!exists(".group-form-public-exit[disabled]"), .dom(".group-form-public-exit[disabled]")
"it should not disable group public exit input" .doesNotExist("it should not disable group public exit input");
);
assert.strictEqual( assert.strictEqual(
count(".group-form-membership-request-template"), count(".group-form-membership-request-template"),
@ -133,8 +131,9 @@ acceptance("Managing Group Membership", function (needs) {
await visit("/g/alternative-group/manage/membership"); await visit("/g/alternative-group/manage/membership");
assert.ok( assert
!exists('label[for="automatic_membership_associated_groups"]'), .dom('label[for="automatic_membership_associated_groups"]')
.doesNotExist(
"it should not display associated groups automatic membership label" "it should not display associated groups automatic membership label"
); );
}); });
@ -144,30 +143,29 @@ acceptance("Managing Group Membership", function (needs) {
await visit("/g/discourse/manage/membership"); await visit("/g/discourse/manage/membership");
assert.ok( assert
!exists('label[for="automatic_membership"]'), .dom('label[for="automatic_membership"]')
"it should not display automatic membership label" .doesNotExist("it should not display automatic membership label");
);
assert.ok( assert
!exists('label[for="automatic_membership_associated_groups"]'), .dom('label[for="automatic_membership_associated_groups"]')
.doesNotExist(
"it should not display associated groups automatic membership label" "it should not display associated groups automatic membership label"
); );
assert.ok( assert
!exists(".groups-form-automatic-membership-retroactive"), .dom(".groups-form-automatic-membership-retroactive")
.doesNotExist(
"it should not display automatic membership retroactive checkbox" "it should not display automatic membership retroactive checkbox"
); );
assert.ok( assert
!exists(".groups-form-primary-group"), .dom(".groups-form-primary-group")
"it should not display set as primary group checkbox" .doesNotExist("it should not display set as primary group checkbox");
);
assert.ok( assert
!exists(".groups-form-grant-trust-level"), .dom(".groups-form-grant-trust-level")
"it should not display grant trust level selector" .doesNotExist("it should not display grant trust level selector");
);
assert.strictEqual( assert.strictEqual(
count(".group-form-public-admission"), count(".group-form-public-admission"),

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";
@ -11,10 +10,9 @@ acceptance("Managing Group Profile", function () {
test("As an anonymous user", async function (assert) { test("As an anonymous user", async function (assert) {
await visit("/g/discourse/manage/profile"); await visit("/g/discourse/manage/profile");
assert.ok( assert
exists(".group-members .group-member"), .dom(".group-members .group-member")
"it should redirect to members page for an anonymous user" .exists("it should redirect to members page for an anonymous user");
);
}); });
}); });
@ -50,9 +48,8 @@ acceptance("Managing Group Profile", function (needs) {
await visit("/g/discourse/manage/profile"); await visit("/g/discourse/manage/profile");
assert.ok( assert
!exists(".group-form-name"), .dom(".group-form-name")
"it should not display group name input" .doesNotExist("it should not display group name input");
);
}); });
}); });

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";
@ -11,10 +10,9 @@ acceptance("Managing Group Tag Notification Defaults", function () {
test("As an anonymous user", async function (assert) { test("As an anonymous user", async function (assert) {
await visit("/g/discourse/manage/tags"); await visit("/g/discourse/manage/tags");
assert.ok( assert
exists(".group-members .group-member"), .dom(".group-members .group-member")
"it should redirect to members page for an anonymous user" .exists("it should redirect to members page for an anonymous user");
);
}); });
}); });

View File

@ -28,10 +28,9 @@ acceptance("Group - Anonymous", function (needs) {
test("Anonymous Viewing Group", async function (assert) { test("Anonymous Viewing Group", async function (assert) {
await visit("/g/discourse"); await visit("/g/discourse");
assert.ok( assert
!exists(".nav-pills li a[title='Messages']"), .dom(".nav-pills li a[title='Messages']")
"it does not show group messages navigation link" .doesNotExist("it does not show group messages navigation link");
);
await click(".nav-pills li a[title='Activity']"); await click(".nav-pills li a[title='Activity']");
@ -45,14 +44,12 @@ 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.ok(exists(".user-stream-item"), "it lists stream items");
assert.ok( assert
!exists(".nav-pills li a[title='Edit Group']"), .dom(".nav-pills li a[title='Edit Group']")
"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.ok( .dom(".nav-pills li a[title='Logs']")
!exists(".nav-pills li a[title='Logs']"), .doesNotExist("it should not show Logs tab if user is not admin");
"it should not show Logs tab if user is not admin"
);
assert.ok(exists(".user-stream-item"), "it lists stream items"); assert.ok(exists(".user-stream-item"), "it lists stream items");
const groupDropdown = selectKit(".group-dropdown"); const groupDropdown = selectKit(".group-dropdown");
@ -72,19 +69,17 @@ acceptance("Group - Anonymous", function (needs) {
await groupDropdown.expand(); await groupDropdown.expand();
assert.ok( assert
!exists(".group-dropdown-filter"), .dom(".group-dropdown-filter")
"it should not display the default header" .doesNotExist("it should not display the default header");
);
}); });
test("Anonymous Viewing Automatic Group", async function (assert) { test("Anonymous Viewing Automatic Group", async function (assert) {
await visit("/g/moderators"); await visit("/g/moderators");
assert.ok( assert
!exists(".nav-pills li a[title='Manage']"), .dom(".nav-pills li a[title='Manage']")
"it does not show group messages navigation link" .doesNotExist("it does not show group messages navigation link");
);
}); });
}); });
@ -301,10 +296,9 @@ acceptance("Group - Authenticated", function (needs) {
await click(".group-members-add.btn"); await click(".group-members-add.btn");
assert.ok( assert
exists(".group-add-members-modal #set-owner"), .dom(".group-add-members-modal #set-owner")
"it allows moderators to set group owners" .exists("it allows moderators to set group owners");
);
await click(".group-add-members-modal .modal-close"); await click(".group-add-members-modal .modal-close");

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 I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -12,10 +11,9 @@ acceptance("New Group - Anonymous", function () {
test("As an anon user", async function (assert) { test("As an anon user", async function (assert) {
await visit("/g"); await visit("/g");
assert.ok( assert
!exists(".groups-header-new"), .dom(".groups-header-new")
"it should not display the button to create a group" .doesNotExist("it should not display the button to create a group");
);
}); });
}); });
@ -79,10 +77,9 @@ acceptance("New Group - Authenticated", function (needs) {
await click(".group-form-public-admission"); await click(".group-form-public-admission");
assert.ok( assert
!exists("groups-new-allow-membership-requests"), .dom("groups-new-allow-membership-requests")
"it should disable the membership requests checkbox" .doesNotExist("it should disable the membership requests checkbox");
);
assert.strictEqual( assert.strictEqual(
query( query(

View File

@ -44,38 +44,33 @@ 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.ok(exists(".invites-show"), "shows the accept invite page");
assert.ok(exists(".user-field"), "it has at least one user field"); assert.ok(exists(".user-field"), "it has at least one user field");
assert.ok( assert
exists(".invites-show .btn-primary:disabled"), .dom(".invites-show .btn-primary:disabled")
"submit is disabled" .exists("submit is disabled");
);
await fillIn("#new-account-name", "John Doe"); await fillIn("#new-account-name", "John Doe");
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.ok(exists(".username-input .good"), "username is valid");
assert.ok( assert
exists(".invites-show .btn-primary:disabled"), .dom(".invites-show .btn-primary:disabled")
"submit is still disabled due to lack of user fields" .exists("submit is still disabled due to lack of user fields");
);
await fillIn(".user-field input[type=text]:nth-of-type(1)", "Barky"); await fillIn(".user-field input[type=text]:nth-of-type(1)", "Barky");
assert.ok( assert
exists(".invites-show .btn-primary:disabled"), .dom(".invites-show .btn-primary:disabled")
"submit is disabled because field is not checked" .exists("submit is disabled because field is not checked");
);
await click(".user-field input[type=checkbox]"); await click(".user-field input[type=checkbox]");
assert.notOk( assert
exists(".invites-show .btn-primary:disabled"), .dom(".invites-show .btn-primary:disabled")
"submit is enabled because field is checked" .doesNotExist("submit is enabled because field is checked");
);
await click(".user-field input[type=checkbox]"); await click(".user-field input[type=checkbox]");
assert.ok( assert
exists(".invites-show .btn-primary:disabled"), .dom(".invites-show .btn-primary:disabled")
"unclicking the checkbox disables the submit" .exists("unclicking the checkbox disables the submit");
);
}); });
}); });

View File

@ -52,22 +52,19 @@ acceptance("Keyboard Shortcuts - Anonymous Users", function (needs) {
test("j/k navigation moves selection up/down", async function (assert) { test("j/k navigation moves selection up/down", async function (assert) {
await visit("/t/this-is-a-test-topic/9"); await visit("/t/this-is-a-test-topic/9");
await triggerKeyEvent(document, "keypress", "J"); await triggerKeyEvent(document, "keypress", "J");
assert.ok( assert
exists(".post-stream .topic-post.selected #post_1"), .dom(".post-stream .topic-post.selected #post_1")
"first post is selected" .exists("first post is selected");
);
await triggerKeyEvent(document, "keypress", "J"); await triggerKeyEvent(document, "keypress", "J");
assert.ok( assert
exists(".post-stream .topic-post.selected #post_2"), .dom(".post-stream .topic-post.selected #post_2")
"pressing j moves selection to next post" .exists("pressing j moves selection to next post");
);
await triggerKeyEvent(document, "keypress", "K"); await triggerKeyEvent(document, "keypress", "K");
assert.ok( assert
exists(".post-stream .topic-post.selected #post_1"), .dom(".post-stream .topic-post.selected #post_1")
"pressing k moves selection to previous post" .exists("pressing k moves selection to previous post");
);
}); });
// FIXME: For reasons unknown this test if flaky on firefox // FIXME: For reasons unknown this test if flaky on firefox
@ -148,15 +145,13 @@ 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("/unread"); await visit("/unread");
assert.ok( assert
exists("#dismiss-topics-top"), .dom("#dismiss-topics-top")
"dismiss unread top button is present" .exists("dismiss unread top button is present");
);
await triggerKeyEvent(document, "keydown", "D", { shiftKey: true }); await triggerKeyEvent(document, "keydown", "D", { shiftKey: true });
assert.ok( assert
exists("#dismiss-read-confirm"), .dom("#dismiss-read-confirm")
"confirmation modal to dismiss unread is present" .exists("confirmation modal to dismiss unread is present");
);
assert assert
.dom(".d-modal__body") .dom(".d-modal__body")
.hasText(I18n.t("topics.bulk.also_dismiss_topics")); .hasText(I18n.t("topics.bulk.also_dismiss_topics"));
@ -176,16 +171,14 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
// visit root first so topic list starts fresh // visit root first so topic list starts fresh
await visit("/"); await visit("/");
await visit("/unread"); await visit("/unread");
assert.notOk( assert
exists("#dismiss-topics-bottom"), .dom("#dismiss-topics-bottom")
"dismiss unread bottom button is hidden" .doesNotExist("dismiss unread bottom button is hidden");
);
await triggerKeyEvent(document, "keydown", "D", { shiftKey: true }); await triggerKeyEvent(document, "keydown", "D", { shiftKey: true });
assert.ok( assert
exists("#dismiss-read-confirm"), .dom("#dismiss-read-confirm")
"confirmation modal to dismiss unread is present" .exists("confirmation modal to dismiss unread is present");
);
assert assert
.dom(".d-modal__body") .dom(".d-modal__body")
.hasText( .hasText(
@ -223,10 +216,9 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
// visit root first so topic list starts fresh // visit root first so topic list starts fresh
await visit("/"); await visit("/");
await visit("/new"); await visit("/new");
assert.notOk( assert
exists("#dismiss-new-bottom"), .dom("#dismiss-new-bottom")
"dismiss new bottom button has been hidden" .doesNotExist("dismiss new bottom button has been hidden");
);
await triggerKeyEvent(document, "keydown", "D", { shiftKey: true }); await triggerKeyEvent(document, "keydown", "D", { shiftKey: true });
assert.strictEqual(resetNewCalled, 2); assert.strictEqual(resetNewCalled, 2);
@ -241,14 +233,12 @@ 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( assert
exists("#dismiss-new-top"), .dom("#dismiss-new-top")
"dismiss new top button is present before double click test" .exists("dismiss new top button is present before double click test");
); assert
assert.ok( .dom("#dismiss-new-bottom")
exists("#dismiss-new-bottom"), .exists("dismiss new bottom button is present");
"dismiss new bottom button is present"
);
await triggerKeyEvent(document, "keydown", "D", { shiftKey: true }); await triggerKeyEvent(document, "keydown", "D", { shiftKey: true });
@ -258,16 +248,14 @@ acceptance("Keyboard Shortcuts - Authenticated Users", function (needs) {
test("share shortcuts", async function (assert) { test("share shortcuts", async function (assert) {
await visit("/t/this-is-a-test-topic/9"); await visit("/t/this-is-a-test-topic/9");
await triggerKeyEvent(document, "keypress", "J"); await triggerKeyEvent(document, "keypress", "J");
assert.ok( assert
exists(".post-stream .topic-post.selected #post_1"), .dom(".post-stream .topic-post.selected #post_1")
"first post is selected" .exists("first post is selected");
);
await triggerKeyEvent(document, "keypress", "J"); await triggerKeyEvent(document, "keypress", "J");
assert.ok( assert
exists(".post-stream .topic-post.selected #post_2"), .dom(".post-stream .topic-post.selected #post_2")
"pressing j moves selection to next post" .exists("pressing j moves selection to next post");
);
await triggerKeyEvent(document, "keypress", "S"); await triggerKeyEvent(document, "keypress", "S");
assert assert

View File

@ -1,15 +1,14 @@
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 Directory - Mobile", function (needs) { acceptance("User Directory - Mobile", function (needs) {
needs.mobileView(); needs.mobileView();
test("Visit Page", async function (assert) { test("Visit Page", async function (assert) {
await visit("/u"); await visit("/u");
assert.ok( assert
exists(".directory .directory-table__row"), .dom(".directory .directory-table__row")
"has a list of users" .exists("has a list of users");
);
}); });
}); });

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("Login with email disabled", function (needs) { acceptance("Login with email disabled", function (needs) {
needs.settings({ needs.settings({
@ -12,14 +12,12 @@ acceptance("Login with email disabled", function (needs) {
await visit("/"); await visit("/");
await click("header .login-button"); await click("header .login-button");
assert.ok( assert
exists(".btn-social.facebook"), .dom(".btn-social.facebook")
"it displays the facebook login button" .exists("it displays the facebook login button");
);
assert.notOk( assert
exists("#email-login-link"), .dom("#email-login-link")
"it displays the login with email button" .doesNotExist("it displays the login with email button");
);
}); });
}); });

View File

@ -2,11 +2,7 @@ import { click, 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 { 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";
const TOKEN = "sometoken"; const TOKEN = "sometoken";
@ -42,15 +38,13 @@ acceptance("Login with email", function (needs) {
await visit("/"); await visit("/");
await click("header .login-button"); await click("header .login-button");
assert.ok( assert
exists(".btn-social.facebook"), .dom(".btn-social.facebook")
"it displays the facebook login button" .exists("it displays the facebook login button");
);
assert.ok( assert
exists("#email-login-link"), .dom("#email-login-link")
"it displays the login with email button" .exists("it displays the login with email button");
);
await fillIn("#login-account-name", "someuser"); await fillIn("#login-account-name", "someuser");
await click("#email-login-link"); await click("#email-login-link");

View File

@ -95,15 +95,13 @@ acceptance("Password Reset", function (needs) {
"server validation error message shows" "server validation error message shows"
); );
assert.ok( assert
exists("#new-account-password[type='password']"), .dom("#new-account-password[type='password']")
"password is masked by default" .exists("password is masked by default");
);
await click(".toggle-password-mask"); await click(".toggle-password-mask");
assert.ok( assert
exists("#new-account-password[type='text']"), .dom("#new-account-password[type='text']")
"password is unmasked after toggle is clicked" .exists("password is unmasked after toggle is clicked");
);
await fillIn(".password-reset input", "perf3ctly5ecur3"); await fillIn(".password-reset input", "perf3ctly5ecur3");
sinon.stub(DiscourseURL, "redirectTo"); sinon.stub(DiscourseURL, "redirectTo");

View File

@ -8,14 +8,12 @@ acceptance("Post - Admin Menu - Anonymous", function () {
await click(".show-more-actions"); await click(".show-more-actions");
assert.ok(exists("#topic"), "The topic was rendered"); assert.ok(exists("#topic"), "The topic was rendered");
assert.ok( assert
exists("#post_1 .post-controls .edit"), .dom("#post_1 .post-controls .edit")
"The edit button was not rendered" .exists("The edit button was not rendered");
); assert
assert.ok( .dom(".show-post-admin-menu")
!exists(".show-post-admin-menu"), .doesNotExist("The wrench button was not rendered");
"The wrench button was not rendered"
);
}); });
}); });
@ -26,10 +24,9 @@ acceptance("Post - Admin Menu - Authenticated", function (needs) {
await click(".show-more-actions"); await click(".show-more-actions");
await click(".show-post-admin-menu"); await click(".show-post-admin-menu");
assert.ok( assert
exists("#post_1 .post-controls .edit"), .dom("#post_1 .post-controls .edit")
"The edit button was rendered" .exists("The edit button was rendered");
);
assert.ok(exists(".add-notice"), "The add notice button was rendered"); assert.ok(exists(".add-notice"), "The add notice button was rendered");
}); });
}); });

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { import {
acceptance, acceptance,
exists,
publishToMessageBus, publishToMessageBus,
query, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -50,10 +49,9 @@ acceptance("Post inline mentions", function (needs) {
await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`); await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`);
assert.ok( assert
exists(".topic-post .cooked .mention .user-status-message"), .dom(".topic-post .cooked .mention .user-status-message")
"user status is shown" .exists("user status is shown");
);
const statusElement = query( const statusElement = query(
".topic-post .cooked .mention .user-status-message img" ".topic-post .cooked .mention .user-status-message img"
); );
@ -69,10 +67,9 @@ acceptance("Post inline mentions", function (needs) {
}); });
await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`); await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`);
assert.notOk( assert
exists(".topic-post .cooked .mention .user-status-message"), .dom(".topic-post .cooked .mention .user-status-message")
"user status isn't shown" .doesNotExist("user status isn't shown");
);
await publishToMessageBus("/user-status", { await publishToMessageBus("/user-status", {
[mentionedUserId]: { [mentionedUserId]: {
@ -81,10 +78,9 @@ acceptance("Post inline mentions", function (needs) {
}, },
}); });
assert.ok( assert
exists(".topic-post .cooked .mention .user-status-message"), .dom(".topic-post .cooked .mention .user-status-message")
"user status is shown" .exists("user status is shown");
);
const statusElement = query( const statusElement = query(
".topic-post .cooked .mention .user-status-message img" ".topic-post .cooked .mention .user-status-message img"
); );
@ -100,10 +96,9 @@ acceptance("Post inline mentions", function (needs) {
}); });
await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`); await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`);
assert.ok( assert
exists(".topic-post .cooked .mention .user-status-message"), .dom(".topic-post .cooked .mention .user-status-message")
"initial user status is shown" .exists("initial user status is shown");
);
const newStatus = { const newStatus = {
description: "off to dentist", description: "off to dentist",
@ -116,10 +111,9 @@ acceptance("Post inline mentions", function (needs) {
}, },
}); });
assert.ok( assert
exists(".topic-post .cooked .mention .user-status-message"), .dom(".topic-post .cooked .mention .user-status-message")
"updated user status is shown" .exists("updated user status is shown");
);
const statusElement = query( const statusElement = query(
".topic-post .cooked .mention .user-status-message img" ".topic-post .cooked .mention .user-status-message img"
); );
@ -135,19 +129,17 @@ acceptance("Post inline mentions", function (needs) {
}); });
await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`); await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`);
assert.ok( assert
exists(".topic-post .cooked .mention .user-status-message"), .dom(".topic-post .cooked .mention .user-status-message")
"initial user status is shown" .exists("initial user status is shown");
);
await publishToMessageBus("/user-status", { await publishToMessageBus("/user-status", {
[mentionedUserId]: null, [mentionedUserId]: null,
}); });
assert.notOk( assert
exists(".topic-post .cooked .mention .user-status-message"), .dom(".topic-post .cooked .mention .user-status-message")
"updated user has disappeared" .doesNotExist("updated user has disappeared");
);
}); });
}); });
@ -172,10 +164,9 @@ acceptance("Post inline mentions user status tooltip", function (needs) {
}); });
await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`); await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`);
assert.ok( assert
exists(".topic-post .cooked .mention .user-status-message"), .dom(".topic-post .cooked .mention .user-status-message")
"user status is shown" .exists("user status is shown");
);
await mouseMove(".user-status-message"); await mouseMove(".user-status-message");
const statusTooltip = document.querySelector( const statusTooltip = document.querySelector(
@ -210,10 +201,9 @@ acceptance("Post inline mentions as an anonymous user", function () {
}); });
await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`); await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`);
assert.ok( assert
exists(".topic-post .cooked .mention .user-status-message"), .dom(".topic-post .cooked .mention .user-status-message")
"user status is shown" .exists("user status is shown");
);
}); });
test("an anonymous user can see user status with an end date on mentions", async function (assert) { test("an anonymous user can see user status with an end date on mentions", async function (assert) {
@ -230,9 +220,8 @@ acceptance("Post inline mentions as an anonymous user", function () {
}); });
await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`); await visit(`/t/lorem-ipsum-dolor-sit-amet/${topicId}`);
assert.ok( assert
exists(".topic-post .cooked .mention .user-status-message"), .dom(".topic-post .cooked .mention .user-status-message")
"user status is shown" .exists("user status is shown");
);
}); });
}); });

View File

@ -10,10 +10,9 @@ 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) {
await visit("/t/54081"); await visit("/t/54081");
const postWithLargeTable = ".post-stream .topic-post:first-child"; const postWithLargeTable = ".post-stream .topic-post:first-child";
assert.ok( assert
exists(`${postWithLargeTable} .fullscreen-table-wrapper`), .dom(`${postWithLargeTable} .fullscreen-table-wrapper`)
"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.ok(
exists( exists(
@ -38,23 +37,20 @@ acceptance("Post Table Wrapper Test", function () {
`${postWithLargeTable} .fullscreen-table-wrapper .btn-expand-table` `${postWithLargeTable} .fullscreen-table-wrapper .btn-expand-table`
); );
assert.ok( assert
exists(".fullscreen-table-modal"), .dom(".fullscreen-table-modal")
"The fullscreen table modal appears" .exists("The fullscreen table modal appears");
); assert
assert.ok( .dom(".fullscreen-table-modal table")
exists(".fullscreen-table-modal table"), .exists("The table is present inside the modal");
"The table is present inside the modal"
);
await click(".fullscreen-table-modal .modal-close"); await click(".fullscreen-table-modal .modal-close");
await click( await click(
`${postWithLargeTable} .fullscreen-table-wrapper .btn-expand-table svg` `${postWithLargeTable} .fullscreen-table-wrapper .btn-expand-table svg`
); );
assert.ok( assert
exists(".fullscreen-table-modal"), .dom(".fullscreen-table-modal")
"Fullscreen table modal appears on clicking svg icon" .exists("Fullscreen table modal appears on clicking svg icon");
);
}); });
}); });

View File

@ -37,26 +37,22 @@ acceptance("Review", function (needs) {
assert.ok(exists(".reviewable-item"), "has a list of items"); assert.ok(exists(".reviewable-item"), "has a list of items");
assert.ok(exists(user)); assert.ok(exists(user));
assert.ok( assert
exists(`${user}.reviewable-user`), .dom(`${user}.reviewable-user`)
"applies a class for the type" .exists("applies a class for the type");
); assert
assert.ok( .dom(`${user} .reviewable-action.approve`)
exists(`${user} .reviewable-action.approve`), .exists("creates a button for approve");
"creates a button for approve" assert
); .dom(`${user} .reviewable-action.reject`)
assert.ok( .exists("creates a button for reject");
exists(`${user} .reviewable-action.reject`),
"creates a button for reject"
);
}); });
test("Grouped by topic", async function (assert) { test("Grouped by topic", async function (assert) {
await visit("/review/topics"); await visit("/review/topics");
assert.ok( assert
exists(".reviewable-topic"), .dom(".reviewable-topic")
"it has a list of reviewable topics" .exists("it has a list of reviewable topics");
);
}); });
test("Reject user", async function (assert) { test("Reject user", async function (assert) {
@ -107,10 +103,9 @@ acceptance("Review", function (needs) {
test("Flag related", async function (assert) { test("Flag related", async function (assert) {
await visit("/review"); await visit("/review");
assert.ok( assert
exists(".reviewable-flagged-post .post-contents .username a[href]"), .dom(".reviewable-flagged-post .post-contents .username a[href]")
"it has a link to the user" .exists("it has a link to the user");
);
assert.strictEqual( assert.strictEqual(
query(".reviewable-flagged-post .post-body").innerHTML.trim(), query(".reviewable-flagged-post .post-body").innerHTML.trim(),
@ -158,17 +153,15 @@ acceptance("Review", function (needs) {
await click(`${topic} .reviewable-action.edit`); await click(`${topic} .reviewable-action.edit`);
await click(`${topic} .reviewable-action.save-edit`); await click(`${topic} .reviewable-action.save-edit`);
assert.ok( assert
exists(`${topic} .reviewable-action.approve`), .dom(`${topic} .reviewable-action.approve`)
"saving without changes is a cancel" .exists("saving without changes is a cancel");
);
await click(`${topic} .reviewable-action.edit`); await click(`${topic} .reviewable-action.edit`);
assert.ok( assert
!exists(`${topic} .reviewable-action.approve`), .dom(`${topic} .reviewable-action.approve`)
"when editing actions are disabled" .doesNotExist("when editing actions are disabled");
);
await fillIn(".editable-field.payload-raw textarea", "new raw contents"); await fillIn(".editable-field.payload-raw textarea", "new raw contents");
await click(`${topic} .reviewable-action.cancel-edit`); await click(`${topic} .reviewable-action.cancel-edit`);

View File

@ -15,29 +15,26 @@ acceptance("Search - Mobile", function (needs) {
await click("#search-button"); await click("#search-button");
assert.ok( assert
exists("input.full-page-search"), .dom("input.full-page-search")
"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.ok(!exists(".search-results .fps-topic"), "no results by default");
await click(".advanced-filters summary"); await click(".advanced-filters summary");
assert.ok( assert
exists(".advanced-filters[open]"), .dom(".advanced-filters[open]")
"it should expand advanced search filters" .exists("it should expand advanced search filters");
);
await fillIn(".search-query", "discourse"); await fillIn(".search-query", "discourse");
await click(".search-cta"); await click(".search-cta");
assert.strictEqual(count(".fps-topic"), 1, "has one post"); assert.strictEqual(count(".fps-topic"), 1, "has one post");
assert.notOk( assert
exists(".advanced-filters[open]"), .dom(".advanced-filters[open]")
"it should collapse advanced search filters" .doesNotExist("it should collapse advanced search filters");
);
await click("#search-button"); await click("#search-button");

View File

@ -63,10 +63,9 @@ acceptance("Search - Anonymous", function (needs) {
await click("#search-button"); await click("#search-button");
assert.ok(exists("#search-term"), "it shows the search input"); assert.ok(exists("#search-term"), "it shows the search input");
assert.ok( assert
exists(".show-advanced-search"), .dom(".show-advanced-search")
"it shows full page search button" .exists("it shows full page search button");
);
}); });
test("random quick tips", async function (assert) { test("random quick tips", async function (assert) {
@ -74,10 +73,9 @@ acceptance("Search - Anonymous", function (needs) {
await click("#search-button"); await click("#search-button");
await fillIn("#search-term", "dev"); await fillIn("#search-term", "dev");
assert.ok( assert
!exists(".search-menu .results ul li.search-random-quick-tip"), .dom(".search-menu .results ul li.search-random-quick-tip")
"quick tip is no longer shown" .doesNotExist("quick tip is no longer shown");
);
}); });
test("advanced search", async function (assert) { test("advanced search", async function (assert) {
@ -98,10 +96,9 @@ acceptance("Search - Anonymous", function (needs) {
.dom(".search-menu .search-menu-panel") .dom(".search-menu .search-menu-panel")
.doesNotExist("closes search menu after clicking advanced search button"); .doesNotExist("closes search menu after clicking advanced search button");
assert.ok( assert
exists(".search-advanced-options"), .dom(".search-advanced-options")
"advanced search is expanded" .exists("advanced search is expanded");
);
}); });
test("search button toggles search menu", async function (assert) { test("search button toggles search menu", async function (assert) {
@ -141,15 +138,13 @@ acceptance("Search - Anonymous", function (needs) {
"first dropdown item includes correct suffix" "first dropdown item includes correct suffix"
); );
assert.ok( assert
exists(".search-menu .search-result-category ul li"), .dom(".search-menu .search-result-category ul li")
"shows matching category results" .exists("shows matching category results");
);
assert.ok( assert
exists(".search-menu .search-result-user ul li"), .dom(".search-menu .search-result-user ul li")
"shows matching user results" .exists("shows matching user results");
);
}); });
test("initial options - tag search scope", async function (assert) { test("initial options - tag search scope", async function (assert) {
@ -216,10 +211,9 @@ acceptance("Search - Anonymous", function (needs) {
"second option includes category slug" "second option includes category slug"
); );
assert.ok( assert
exists(`${contextSelector} span.badge-category__wrapper`), .dom(`${contextSelector} span.badge-category__wrapper`)
"category badge is a span (i.e. not a link)" .exists("category badge is a span (i.e. not a link)");
);
}); });
test("initial options - topic search scope", async function (assert) { test("initial options - topic search scope", async function (assert) {
@ -250,10 +244,9 @@ acceptance("Search - Anonymous", function (needs) {
await click( await click(
".search-menu .results .search-menu-initial-options .search-menu-assistant-item:first-child" ".search-menu .results .search-menu-initial-options .search-menu-assistant-item:first-child"
); );
assert.ok( assert
exists(".search-result-topic"), .dom(".search-result-topic")
"search result is a list of topics" .exists("search result is a list of topics");
);
}); });
test("initial options - topic search scope - 'in this topic' searches posts within topic", async function (assert) { test("initial options - topic search scope - 'in this topic' searches posts within topic", async function (assert) {
@ -264,10 +257,9 @@ acceptance("Search - Anonymous", function (needs) {
await click( await click(
".search-menu .results .search-menu-initial-options .search-menu-assistant-item:nth-child(2)" ".search-menu .results .search-menu-initial-options .search-menu-assistant-item:nth-child(2)"
); );
assert.ok( assert
exists(".search-result-post"), .dom(".search-result-post")
"search result is a list of posts" .exists("search result is a list of posts");
);
}); });
test("initial options - topic search scope - keep 'in this topic' filter in full page search", async function (assert) { test("initial options - topic search scope - keep 'in this topic' filter in full page search", async function (assert) {
@ -285,10 +277,9 @@ acceptance("Search - Anonymous", function (needs) {
"it goes to full search page and preserves search term + context" "it goes to full search page and preserves search term + context"
); );
assert.ok( assert
exists(".search-advanced-options"), .dom(".search-advanced-options")
"advanced search is expanded" .exists("advanced search is expanded");
);
}); });
test("initial options - topic search scope - special case when matching a single user", async function (assert) { test("initial options - topic search scope - special case when matching a single user", async function (assert) {
@ -341,15 +332,13 @@ acceptance("Search - Anonymous", function (needs) {
await triggerKeyEvent("#search-term", "keyup", "ArrowDown"); await triggerKeyEvent("#search-term", "keyup", "ArrowDown");
await click(document.activeElement); await click(document.activeElement);
assert.ok( assert
exists(".search-menu .search-result-topic ul li"), .dom(".search-menu .search-result-topic ul li")
"shows topic results" .exists("shows topic results");
);
assert.ok( assert
exists(".search-menu .results ul li .topic-title[data-topic-id]"), .dom(".search-menu .results ul li .topic-title[data-topic-id]")
"topic has data-topic-id" .exists("topic has data-topic-id");
);
}); });
test("topic results - topic search scope", async function (assert) { test("topic results - topic search scope", async function (assert) {
@ -360,10 +349,9 @@ acceptance("Search - Anonymous", function (needs) {
await triggerKeyEvent(document.activeElement, "keydown", "ArrowDown"); await triggerKeyEvent(document.activeElement, "keydown", "ArrowDown");
await click(document.activeElement); await click(document.activeElement);
assert.ok( assert
exists(".search-menu .search-result-post ul li"), .dom(".search-menu .search-result-post ul li")
"clicking second option scopes search to current topic" .exists("clicking second option scopes search to current topic");
);
assert.strictEqual( assert.strictEqual(
query("#post_7 span.highlighted").textContent.trim(), query("#post_7 span.highlighted").textContent.trim(),
@ -371,10 +359,9 @@ acceptance("Search - Anonymous", function (needs) {
"highlights the post correctly" "highlights the post correctly"
); );
assert.ok( assert
exists(".search-menu .search-context"), .dom(".search-menu .search-context")
"search context indicator is visible" .exists("search context indicator is visible");
);
await click(".clear-search"); await click(".clear-search");
assert.strictEqual( assert.strictEqual(
@ -384,10 +371,9 @@ acceptance("Search - Anonymous", function (needs) {
); );
await click(".search-context"); await click(".search-context");
assert.ok( assert
!exists(".search-menu .search-context"), .dom(".search-menu .search-context")
"search context indicator is no longer visible" .doesNotExist("search context indicator is no longer visible");
);
await fillIn("#search-term", "dev"); await fillIn("#search-term", "dev");
await query("#search-term").focus(); await query("#search-term").focus();
@ -395,19 +381,17 @@ acceptance("Search - Anonymous", function (needs) {
await triggerKeyEvent(document.activeElement, "keydown", "ArrowDown"); await triggerKeyEvent(document.activeElement, "keydown", "ArrowDown");
await click(document.activeElement); await click(document.activeElement);
assert.ok( assert
exists(".search-menu .search-context"), .dom(".search-menu .search-context")
"search context indicator is visible" .exists("search context indicator is visible");
);
await fillIn("#search-term", ""); await fillIn("#search-term", "");
await query("#search-term").focus(); await query("#search-term").focus();
await triggerKeyEvent("#search-term", "keyup", "Backspace"); await triggerKeyEvent("#search-term", "keyup", "Backspace");
assert.ok( assert
!exists(".search-menu .search-context"), .dom(".search-menu .search-context")
"backspace resets search context" .doesNotExist("backspace resets search context");
);
}); });
test("topic results - search result escapes html in topic title", async function (assert) { test("topic results - search result escapes html in topic title", async function (assert) {
@ -590,10 +574,9 @@ acceptance("Search - Authenticated", function (needs) {
assert.ok(exists(query(`${container} ul li`)), "has a list of items"); assert.ok(exists(query(`${container} ul li`)), "has a list of items");
await triggerKeyEvent("#search-term", "keyup", "Enter"); await triggerKeyEvent("#search-term", "keyup", "Enter");
assert.ok( assert
exists(query(`${container} .search-result-topic`)), .dom(query(`${container} .search-result-topic`))
"has topic results" .exists("has topic results");
);
await triggerKeyEvent("#search-term", "keyup", "ArrowDown"); await triggerKeyEvent("#search-term", "keyup", "ArrowDown");
assert.strictEqual( assert.strictEqual(
@ -638,20 +621,17 @@ acceptance("Search - Authenticated", function (needs) {
); );
await triggerKeyEvent("#search-term", "keyup", "Enter"); await triggerKeyEvent("#search-term", "keyup", "Enter");
assert.ok( assert
exists(query(`${container} .search-result-topic`)), .dom(query(`${container} .search-result-topic`))
"has topic results" .exists("has topic results");
);
await triggerKeyEvent("#search-term", "keyup", "Enter"); await triggerKeyEvent("#search-term", "keyup", "Enter");
assert.ok( assert
exists(query(`.search-container`)), .dom(query(`.search-container`))
"second Enter hit goes to full page search" .exists("second Enter hit goes to full page search");
); assert
assert.ok( .dom(query(`.search-menu`))
!exists(query(`.search-menu`)), .doesNotExist("search dropdown is collapsed after second Enter hit");
"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");
@ -1254,10 +1234,9 @@ acceptance("Search - assistant", function (needs) {
await clickOutside(); await clickOutside();
await click("#search-button"); await click("#search-button");
assert.ok( assert
exists(".btn.search-context"), .dom(".btn.search-context")
"it shows the button when reinvoking search" .exists("it shows the button when reinvoking search");
);
await fillIn("#search-term", "emoji"); await fillIn("#search-term", "emoji");
await query("input#search-term").focus(); await query("input#search-term").focus();

View File

@ -106,149 +106,140 @@ acceptance("Second Factor Auth Page", function (needs) {
test("default 2FA method", async function (assert) { test("default 2FA method", async function (assert) {
await visit("/session/2fa?nonce=ok111111"); await visit("/session/2fa?nonce=ok111111");
assert.ok( assert
exists("#security-key-authenticate-button"), .dom("#security-key-authenticate-button")
"security key is the default method" .exists("security key is the default method");
); assert
assert.ok( .dom("form.totp-token")
!exists("form.totp-token"), .doesNotExist(
"totp is not shown by default when security key is allowed" "totp is not shown by default when security key is allowed"
); );
assert.ok( assert
!exists("form.backup-code-token"), .dom("form.backup-code-token")
.doesNotExist(
"backup code form is not shown by default when security key is allowed" "backup code form is not shown by default when security key is allowed"
); );
await visit("/"); await visit("/");
await visit("/session/2fa?nonce=ok111110"); await visit("/session/2fa?nonce=ok111110");
assert.ok( assert
!exists("#security-key-authenticate-button"), .dom("#security-key-authenticate-button")
"security key method is not shown when it's not allowed" .doesNotExist("security key method is not shown when it's not allowed");
); assert
assert.ok( .dom("form.totp-token")
exists("form.totp-token"), .exists("totp is the default method when security key is not allowed");
"totp is the default method when security key is not allowed" assert
); .dom("form.backup-code-token")
assert.ok( .doesNotExist(
!exists("form.backup-code-token"),
"backup code form is not shown by default when TOTP is allowed" "backup code form is not shown by default when TOTP is allowed"
); );
await visit("/"); await visit("/");
await visit("/session/2fa?nonce=ok110111"); await visit("/session/2fa?nonce=ok110111");
assert.ok( assert
!exists("#security-key-authenticate-button"), .dom("#security-key-authenticate-button")
"security key method is not shown when it's not enabled" .doesNotExist("security key method is not shown when it's not enabled");
); assert
assert.ok( .dom("form.totp-token")
exists("form.totp-token"), .exists("totp is the default method when security key is not enabled");
"totp is the default method when security key is not enabled" assert
); .dom("form.backup-code-token")
assert.ok( .doesNotExist(
!exists("form.backup-code-token"),
"backup code form is not shown by default when TOTP is enabled" "backup code form is not shown by default when TOTP is enabled"
); );
}); });
test("alternative 2FA methods", async function (assert) { test("alternative 2FA methods", async function (assert) {
await visit("/session/2fa?nonce=ok111111"); await visit("/session/2fa?nonce=ok111111");
assert.ok( assert
exists(".toggle-second-factor-method.totp"), .dom(".toggle-second-factor-method.totp")
.exists(
"TOTP is shown as an alternative method if it's enabled and allowed" "TOTP is shown as an alternative method if it's enabled and allowed"
); );
assert.ok( assert
exists(".toggle-second-factor-method.backup-code"), .dom(".toggle-second-factor-method.backup-code")
.exists(
"backup code is shown as an alternative method if it's enabled and allowed" "backup code is shown as an alternative method if it's enabled and allowed"
); );
assert.ok( assert
!exists(".toggle-second-factor-method.security-key"), .dom(".toggle-second-factor-method.security-key")
.doesNotExist(
"security key is not shown as an alternative method when it's selected" "security key is not shown as an alternative method when it's selected"
); );
await visit("/"); await visit("/");
await visit("/session/2fa?nonce=ok100111"); await visit("/session/2fa?nonce=ok100111");
assert.ok( assert
!exists(".toggle-second-factor-method"), .dom(".toggle-second-factor-method")
.doesNotExist(
"no alternative methods are shown if only 1 method is enabled" "no alternative methods are shown if only 1 method is enabled"
); );
await visit("/"); await visit("/");
await visit("/session/2fa?nonce=ok111010"); await visit("/session/2fa?nonce=ok111010");
assert.ok( assert
!exists(".toggle-second-factor-method"), .dom(".toggle-second-factor-method")
.doesNotExist(
"no alternative methods are shown if only 1 method is allowed" "no alternative methods are shown if only 1 method is allowed"
); );
}); });
test("switching 2FA methods", async function (assert) { test("switching 2FA methods", async function (assert) {
await visit("/session/2fa?nonce=ok111111"); await visit("/session/2fa?nonce=ok111111");
assert.ok( assert
exists("#security-key-authenticate-button"), .dom("#security-key-authenticate-button")
"security key form is shown because it's the default" .exists("security key form is shown because it's the default");
); assert
assert.ok( .dom(".toggle-second-factor-method.totp")
exists(".toggle-second-factor-method.totp"), .exists("TOTP is shown as an alternative method");
"TOTP is shown as an alternative method" assert
); .dom(".toggle-second-factor-method.backup-code")
assert.ok( .exists("backup code is shown as an alternative method");
exists(".toggle-second-factor-method.backup-code"), assert
"backup code is shown as an alternative method" .dom(".toggle-second-factor-method.security-key")
); .doesNotExist(
assert.ok(
!exists(".toggle-second-factor-method.security-key"),
"security key is not shown as an alternative method because it's selected" "security key is not shown as an alternative method because it's selected"
); );
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.ok(exists("form.totp-token"), "TOTP form is now shown");
assert.ok( assert
exists(".toggle-second-factor-method.security-key"), .dom(".toggle-second-factor-method.security-key")
"security key is now shown as alternative method" .exists("security key is now shown as alternative method");
); assert
assert.ok( .dom(".toggle-second-factor-method.backup-code")
exists(".toggle-second-factor-method.backup-code"), .exists("backup code is still shown as an alternative method");
"backup code is still shown as an alternative method" assert
); .dom(".toggle-second-factor-method.totp")
assert.ok( .doesNotExist("TOTP is no longer shown as an alternative method");
!exists(".toggle-second-factor-method.totp"),
"TOTP is no longer shown as an alternative method"
);
await click(".toggle-second-factor-method.backup-code"); await click(".toggle-second-factor-method.backup-code");
assert.ok( assert
exists("form.backup-code-token"), .dom("form.backup-code-token")
"backup code form is now shown" .exists("backup code form is now shown");
); assert
assert.ok( .dom(".toggle-second-factor-method.security-key")
exists(".toggle-second-factor-method.security-key"), .exists("security key is still shown as alternative method");
"security key is still shown as alternative method" assert
); .dom(".toggle-second-factor-method.totp")
assert.ok( .exists("TOTP is now shown as an alternative method");
exists(".toggle-second-factor-method.totp"), assert
"TOTP is now shown as an alternative method" .dom(".toggle-second-factor-method.backup-code")
); .doesNotExist("backup code is no longer shown as an alternative method");
assert.ok(
!exists(".toggle-second-factor-method.backup-code"),
"backup code is no longer shown as an alternative method"
);
await click(".toggle-second-factor-method.security-key"); await click(".toggle-second-factor-method.security-key");
assert.ok( assert
exists("#security-key-authenticate-button"), .dom("#security-key-authenticate-button")
"security key form is back" .exists("security key form is back");
); assert
assert.ok( .dom(".toggle-second-factor-method.security-key")
!exists(".toggle-second-factor-method.security-key"), .doesNotExist("security key is no longer shown as alternative method");
"security key is no longer shown as alternative method" assert
); .dom(".toggle-second-factor-method.totp")
assert.ok( .exists("TOTP is now shown as an alternative method");
exists(".toggle-second-factor-method.totp"), assert
"TOTP is now shown as an alternative method" .dom(".toggle-second-factor-method.backup-code")
); .exists("backup code is now shown as an alternative method");
assert.ok(
exists(".toggle-second-factor-method.backup-code"),
"backup code is now shown as an alternative method"
);
}); });
test("2FA action description", async function (assert) { test("2FA action description", async function (assert) {

View File

@ -57,10 +57,9 @@ acceptance("Select-kit - Composer - Accessibility", function (needs) {
"Escape" "Escape"
); );
assert.notOk( assert
exists(".mini-tag-chooser .select-kit-body .select-kit-row"), .dom(".mini-tag-chooser .select-kit-body .select-kit-row")
"Hitting Escape dismisses the tag chooser" .doesNotExist("Hitting Escape dismisses the tag chooser");
);
assert.ok(exists(".composer-fields"), "Escape does not dismiss composer"); assert.ok(exists(".composer-fields"), "Escape does not dismiss composer");
}); });

View File

@ -29,19 +29,17 @@ acceptance("Share and Invite modal", function (needs) {
test("Topic footer button", async function (assert) { test("Topic footer button", async function (assert) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
assert.ok( assert
exists("#topic-footer-button-share-and-invite"), .dom("#topic-footer-button-share-and-invite")
"the button exists" .exists("the button exists");
);
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.ok(exists(".share-topic-modal"), "it shows the modal");
assert.notOk( assert
exists("#modal-alert.alert-warning"), .dom("#modal-alert.alert-warning")
"it does not show the alert with restricted groups" .doesNotExist("it does not show the alert with restricted groups");
);
assert.ok( assert.ok(
query("input.invite-link").value.includes( query("input.invite-link").value.includes(
@ -50,10 +48,9 @@ acceptance("Share and Invite modal", function (needs) {
"it shows the topic sharing url" "it shows the topic sharing url"
); );
assert.ok( assert
exists(".link-share-actions .invite"), .dom(".link-share-actions .invite")
"it shows the invite button" .exists("it shows the invite button");
);
await click(".link-share-actions .invite"); await click(".link-share-actions .invite");
@ -80,18 +77,16 @@ acceptance("Share and Invite modal", function (needs) {
test("Share topic in a restricted category", async function (assert) { test("Share topic in a restricted category", async function (assert) {
await visit("/t/topic-in-restricted-group/2481"); await visit("/t/topic-in-restricted-group/2481");
assert.ok( assert
exists("#topic-footer-button-share-and-invite"), .dom("#topic-footer-button-share-and-invite")
"the button exists" .exists("the button exists");
);
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.ok(exists(".share-topic-modal"), "it shows the modal");
assert.ok( assert
exists("#modal-alert.alert-warning"), .dom("#modal-alert.alert-warning")
"it shows restricted warning" .exists("it shows restricted warning");
);
assert.dom("#modal-alert.alert-warning").hasText( assert.dom("#modal-alert.alert-warning").hasText(
I18n.t("topic.share.restricted_groups", { I18n.t("topic.share.restricted_groups", {
count: 2, count: 2,
@ -109,10 +104,9 @@ acceptance("Share and Invite modal - mobile", function (needs) {
test("Topic footer mobile button", async function (assert) { test("Topic footer mobile button", async function (assert) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
assert.ok( assert
!exists("#topic-footer-button-share-and-invite"), .dom("#topic-footer-button-share-and-invite")
"the button doesnt exist" .doesNotExist("the button doesnt exist");
);
const subject = selectKit(".topic-footer-mobile-dropdown"); const subject = selectKit(".topic-footer-mobile-dropdown");
await subject.expand(); await subject.expand();

View File

@ -52,10 +52,9 @@ acceptance("Sidebar - Anonymous - Categories Section", function (needs) {
sidebarCategories[4].name sidebarCategories[4].name
); );
assert.ok( assert
exists("a.sidebar-section-link[data-link-name='all-categories']"), .dom("a.sidebar-section-link[data-link-name='all-categories']")
"all categories link is visible" .exists("all categories link is visible");
);
}); });
test("category section links ordered by default category's position when default_navigation_menu_categories has not been configured and site setting to fix categories positions is enabled", async function (assert) { test("category section links ordered by default category's position when default_navigation_menu_categories has not been configured and site setting to fix categories positions is enabled", async function (assert) {
@ -96,10 +95,9 @@ acceptance("Sidebar - Anonymous - Categories Section", function (needs) {
siteCategories[5].name siteCategories[5].name
); );
assert.ok( assert
exists("a.sidebar-section-link[data-link-name='all-categories']"), .dom("a.sidebar-section-link[data-link-name='all-categories']")
"all categories link is visible" .exists("all categories link is visible");
);
}); });
test("category section links in sidebar when default_navigation_menu_categories site setting has been configured and site setting to fix category position is enabled", async function (assert) { test("category section links in sidebar when default_navigation_menu_categories site setting has been configured and site setting to fix category position is enabled", async function (assert) {
@ -117,10 +115,9 @@ acceptance("Sidebar - Anonymous - Categories Section", function (needs) {
assert.strictEqual(categories[1].textContent.trim(), "blog"); assert.strictEqual(categories[1].textContent.trim(), "blog");
assert.strictEqual(categories[2].textContent.trim(), "bug"); assert.strictEqual(categories[2].textContent.trim(), "bug");
assert.ok( assert
exists("a.sidebar-section-link[data-link-name='all-categories']"), .dom("a.sidebar-section-link[data-link-name='all-categories']")
"all categories link is visible" .exists("all categories link is visible");
);
}); });
test("default uncategorized category section links is not shown when allow_uncategorized_topics is disabled", async function (assert) { test("default uncategorized category section links is not shown when allow_uncategorized_topics is disabled", async function (assert) {

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("Sidebar - Anonymous User", function (needs) { acceptance("Sidebar - Anonymous User", function (needs) {
needs.settings({ needs.settings({
@ -15,15 +15,13 @@ acceptance("Sidebar - Anonymous User", function (needs) {
"adds sidebar utility class to body" "adds sidebar utility class to body"
); );
assert.ok( assert
exists(".sidebar-container"), .dom(".sidebar-container")
"sidebar exists for anonymous user" .exists("sidebar exists for anonymous user");
);
assert.ok( assert
exists(".header-sidebar-toggle"), .dom(".header-sidebar-toggle")
"toggle button for anonymous user" .exists("toggle button for anonymous user");
);
}); });
test("sidebar hamburger panel dropdown when sidebar has been disabled", async function (assert) { test("sidebar hamburger panel dropdown when sidebar has been disabled", async function (assert) {
@ -32,8 +30,9 @@ acceptance("Sidebar - Anonymous User", function (needs) {
await visit("/"); await visit("/");
await click(".hamburger-dropdown button"); await click(".hamburger-dropdown button");
assert.ok( assert
exists(".sidebar-hamburger-dropdown .sidebar-sections-anonymous"), .dom(".sidebar-hamburger-dropdown .sidebar-sections-anonymous")
.exists(
"sidebar hamburger panel dropdown renders anonymous sidebar sections" "sidebar hamburger panel dropdown renders anonymous sidebar sections"
); );
}); });
@ -48,14 +47,12 @@ acceptance("Sidebar - Anonymous User - Login Required", function (needs) {
test("sidebar and toggle button is hidden", async function (assert) { test("sidebar and toggle button is hidden", async function (assert) {
await visit("/"); await visit("/");
assert.ok( assert
!exists(".sidebar-container"), .dom(".sidebar-container")
"sidebar is hidden for anonymous user" .doesNotExist("sidebar is hidden for anonymous user");
);
assert.ok( assert
!exists(".header-sidebar-toggle"), .dom(".header-sidebar-toggle")
"toggle button is hidden for anonymous user" .doesNotExist("toggle button is hidden for anonymous user");
);
}); });
}); });

View File

@ -33,17 +33,15 @@ acceptance("Sidebar - Narrow Desktop", function (needs) {
}); });
await click(".btn-sidebar-toggle"); await click(".btn-sidebar-toggle");
assert.ok( assert
exists(".sidebar-hamburger-dropdown"), .dom(".sidebar-hamburger-dropdown")
"cloak sidebar is displayed" .exists("cloak sidebar is displayed");
);
await triggerEvent(document.querySelector(".header-cloak"), "pointerdown"); await triggerEvent(document.querySelector(".header-cloak"), "pointerdown");
assert.ok( assert
!exists(".sidebar-hamburger-dropdown"), .dom(".sidebar-hamburger-dropdown")
"cloak sidebar is collapsed" .doesNotExist("cloak sidebar is collapsed");
);
document.body.style.width = "1200px"; document.body.style.width = "1200px";
await waitFor("#d-sidebar", { await waitFor("#d-sidebar", {

View File

@ -295,10 +295,9 @@ acceptance("Sidebar - Plugin API", function (needs) {
"displays first link with correct text" "displays first link with correct text"
); );
assert.ok( assert
exists(".sidebar-section-link.my-class-name"), .dom(".sidebar-section-link.my-class-name")
"sets the custom class name for the section link" .exists("sets the custom class name for the section link");
);
assert.strictEqual( assert.strictEqual(
links[0].title, links[0].title,
@ -453,10 +452,9 @@ acceptance("Sidebar - Plugin API", function (needs) {
"displays header with correct text" "displays header with correct text"
); );
assert.ok( assert
exists("button.sidebar-section-header-button"), .dom("button.sidebar-section-header-button")
"displays single header action button" .exists("displays single header action button");
);
assert.ok( assert.ok(
!exists( !exists(
@ -505,10 +503,9 @@ acceptance("Sidebar - Plugin API", function (needs) {
await visit("/"); await visit("/");
assert.notOk( assert
exists(".sidebar-section[data-section-name='test-chat-channels']"), .dom(".sidebar-section[data-section-name='test-chat-channels']")
"does not display the section" .doesNotExist("does not display the section");
);
}); });
test("Registering a custom countable for a section link in the user's sidebar categories section", async function (assert) { test("Registering a custom countable for a section link in the user's sidebar categories section", async function (assert) {

View File

@ -152,10 +152,9 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) {
await visit("/"); await visit("/");
assert.ok( assert
exists(".sidebar-section[data-section-name='categories']"), .dom(".sidebar-section[data-section-name='categories']")
"categories section is shown" .exists("categories section is shown");
);
const categorySectionLinks = queryAll( const categorySectionLinks = queryAll(
".sidebar-section[data-section-name='categories'] .sidebar-section-link-wrapper[data-category-id]" ".sidebar-section[data-section-name='categories'] .sidebar-section-link-wrapper[data-category-id]"

View File

@ -120,10 +120,9 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists(`.sidebar-section-link-wrapper[data-tag-name=tag1] a.active`), .dom(`.sidebar-section-link-wrapper[data-tag-name=tag1] a.active`)
"the tag1 section link is marked as active" .exists("the tag1 section link is marked as active");
);
await click(".sidebar-section-link-wrapper[data-tag-name=tag2] a"); await click(".sidebar-section-link-wrapper[data-tag-name=tag2] a");
@ -141,10 +140,9 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists(`.sidebar-section-link-wrapper[data-tag-name=tag2] a.active`), .dom(`.sidebar-section-link-wrapper[data-tag-name=tag2] a.active`)
"the tag2 section link is marked as active" .exists("the tag2 section link is marked as active");
);
}); });
test("clicking tag section links - sidebar_link_to_filtered_list set to true and no unread or new topics", async function (assert) { test("clicking tag section links - sidebar_link_to_filtered_list set to true and no unread or new topics", async function (assert) {
@ -171,10 +169,9 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists(`.sidebar-section-link-wrapper[data-tag-name=tag1] a.active`), .dom(`.sidebar-section-link-wrapper[data-tag-name=tag1] a.active`)
"the tag1 section link is marked as active" .exists("the tag1 section link is marked as active");
);
}); });
test("clicking tag section links - sidebar_link_to_filtered_list set to true with new topics", async function (assert) { test("clicking tag section links - sidebar_link_to_filtered_list set to true with new topics", async function (assert) {
@ -215,10 +212,9 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists(`.sidebar-section-link-wrapper[data-tag-name=tag1] a.active`), .dom(`.sidebar-section-link-wrapper[data-tag-name=tag1] a.active`)
"the tag1 section link is marked as active" .exists("the tag1 section link is marked as active");
);
}); });
test("clicking tag section links - sidebar_link_to_filtered_list set to true with unread topics", async function (assert) { test("clicking tag section links - sidebar_link_to_filtered_list set to true with unread topics", async function (assert) {
@ -259,10 +255,9 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists(`.sidebar-section-link-wrapper[data-tag-name=tag1] a.active`), .dom(`.sidebar-section-link-wrapper[data-tag-name=tag1] a.active`)
"the tag1 section link is marked as active" .exists("the tag1 section link is marked as active");
);
}); });
test("private message tag section links for user", async function (assert) { test("private message tag section links for user", async function (assert) {
@ -284,10 +279,9 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists(`.sidebar-section-link-wrapper[data-tag-name=tag4] a.active`), .dom(`.sidebar-section-link-wrapper[data-tag-name=tag4] a.active`)
"the tag4 section link is marked as active" .exists("the tag4 section link is marked as active");
);
}); });
test("visiting tag discovery top route", async function (assert) { test("visiting tag discovery top route", async function (assert) {
@ -301,10 +295,9 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists(".sidebar-section-link-wrapper[data-tag-name=tag1] a.active"), .dom(".sidebar-section-link-wrapper[data-tag-name=tag1] a.active")
"the tag1 section link is marked as active for the top route" .exists("the tag1 section link is marked as active for the top route");
);
}); });
test("visiting tag discovery new ", async function (assert) { test("visiting tag discovery new ", async function (assert) {
@ -318,10 +311,9 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists(".sidebar-section-link-wrapper[data-tag-name=tag1] a.active"), .dom(".sidebar-section-link-wrapper[data-tag-name=tag1] a.active")
"the tag1 section link is marked as active for the new route" .exists("the tag1 section link is marked as active for the new route");
);
}); });
test("visiting tag discovery unread route", async function (assert) { test("visiting tag discovery unread route", async function (assert) {
@ -335,10 +327,9 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
"only one link is marked as active" "only one link is marked as active"
); );
assert.ok( assert
exists(".sidebar-section-link-wrapper[data-tag-name=tag1] a.active"), .dom(".sidebar-section-link-wrapper[data-tag-name=tag1] a.active")
"the tag1 section link is marked as active for the unread route" .exists("the tag1 section link is marked as active for the unread route");
);
}); });
test("show suffix indicator for new content on tag section links", async function (assert) { test("show suffix indicator for new content on tag section links", async function (assert) {

View File

@ -13,29 +13,25 @@ acceptance("Signing In", function () {
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.ok(exists("#modal-alert:visible"), "it displays the login error");
assert.notOk( assert
exists(".d-modal__footer .btn-primary:disabled"), .dom(".d-modal__footer .btn-primary:disabled")
"enables the login button" .doesNotExist("enables the login button");
);
// Test password unmasking // Test password unmasking
assert.ok( assert
exists("#login-account-password[type='password']"), .dom("#login-account-password[type='password']")
"password is masked by default" .exists("password is masked by default");
);
await click(".toggle-password-mask"); await click(".toggle-password-mask");
assert.ok( assert
exists("#login-account-password[type='text']"), .dom("#login-account-password[type='text']")
"password is unmasked after toggle is clicked" .exists("password is unmasked after toggle is clicked");
);
// Use the correct password // Use the correct password
await fillIn("#login-account-password", "correct"); await fillIn("#login-account-password", "correct");
await click(".d-modal__footer .btn-primary"); await click(".d-modal__footer .btn-primary");
assert.ok( assert
exists(".d-modal__footer .btn-primary:disabled"), .dom(".d-modal__footer .btn-primary:disabled")
"disables the login button" .exists("disables the login button");
);
}); });
test("sign in - not activated", async function (assert) { test("sign in - not activated", async function (assert) {
@ -87,26 +83,20 @@ acceptance("Signing In", function () {
await fillIn("#login-account-password", "need-second-factor"); await fillIn("#login-account-password", "need-second-factor");
await click(".d-modal__footer .btn-primary"); await click(".d-modal__footer .btn-primary");
assert.notOk( assert
exists("#credentials:visible"), .dom("#credentials")
"it hides the username and password prompt" .isNotVisible("hides the username and password prompt");
); assert.dom("#second-factor").isVisible("displays the second factor prompt");
assert.ok( assert
exists("#second-factor:visible"), .dom(".d-modal__footer .btn-primary:disabled")
"it displays the second factor prompt" .doesNotExist("enables the login button");
);
assert.notOk(
exists(".d-modal__footer .btn-primary:disabled"),
"enables the login button"
);
await fillIn("#login-second-factor", "123456"); await fillIn("#login-second-factor", "123456");
await click(".d-modal__footer .btn-primary"); await click(".d-modal__footer .btn-primary");
assert.ok( assert
exists(".d-modal__footer .btn-primary:disabled"), .dom(".d-modal__footer .btn-primary:disabled")
"disables the login button" .exists("disables the login button");
);
}); });
test("security key", async function (assert) { test("security key", async function (assert) {
@ -119,19 +109,14 @@ acceptance("Signing In", function () {
await fillIn("#login-account-password", "need-security-key"); await fillIn("#login-account-password", "need-security-key");
await click(".d-modal__footer .btn-primary"); await click(".d-modal__footer .btn-primary");
assert.notOk( assert
exists("#credentials:visible"), .dom("#credentials")
"it hides the username and password prompt" .isNotVisible("hides the username and password prompt");
); assert
assert.notOk( .dom("#login-second-factor")
exists("#login-second-factor:visible"), .isNotVisible("does not display the second factor prompt");
"it does not display the second factor prompt" assert.dom("#security-key").isVisible("shows the security key prompt");
); assert.dom("#login-button").isNotVisible("hides the login button");
assert.ok(
exists("#security-key:visible"),
"it shows the security key prompt"
);
assert.notOk(exists("#login-button:visible"), "hides the login button");
}); });
test("second factor backup - valid token", async function (assert) { test("second factor backup - valid token", async function (assert) {
@ -144,10 +129,9 @@ acceptance("Signing In", function () {
await fillIn("#login-second-factor", "123456"); await fillIn("#login-second-factor", "123456");
await click(".d-modal__footer .btn-primary"); await click(".d-modal__footer .btn-primary");
assert.ok( assert
exists(".d-modal__footer .btn-primary:disabled"), .dom(".d-modal__footer .btn-primary:disabled")
"it closes the modal when the code is valid" .exists("it 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) {
@ -160,9 +144,8 @@ acceptance("Signing In", function () {
await fillIn("#login-second-factor", "something"); await fillIn("#login-second-factor", "something");
await click(".d-modal__footer .btn-primary"); await click(".d-modal__footer .btn-primary");
assert.ok( assert
exists("#modal-alert:visible"), .dom("#modal-alert")
"it shows an error when the code is invalid" .exists("shows an error when the code is invalid");
);
}); });
}); });

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 selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
import { setPrefix } from "discourse-common/lib/get-url"; import { setPrefix } from "discourse-common/lib/get-url";
@ -82,10 +78,9 @@ acceptance("Tag Groups", function (needs) {
await click(".tag-group-content .btn.btn-primary"); await click(".tag-group-content .btn.btn-primary");
await click(".tag-groups-sidebar li:first-child a"); await click(".tag-groups-sidebar li:first-child a");
assert.ok( assert
exists("#visible-permission:checked"), .dom("#visible-permission:checked")
"selected permission does not change after saving" .exists("selected permission does not change after saving");
);
}); });
test("going back to tags supports subfolder", async function (assert) { test("going back to tags supports subfolder", async function (assert) {

View File

@ -206,10 +206,7 @@ acceptance("Theme", function (needs) {
await click(".admin-install-theme-modal .d-modal__footer .btn-danger"); await click(".admin-install-theme-modal .d-modal__footer .btn-danger");
assert.notOk( assert.dom(".admin-install-theme-modal").doesNotExist("modal is closed");
exists(".admin-install-theme-modal:visible"),
"modal is closed"
);
}); });
test("can continue installation", async function (assert) { test("can continue installation", async function (assert) {

View File

@ -12,10 +12,9 @@ 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.ok(exists("#topic"), "The topic was rendered");
assert.ok( assert
!exists(".toggle-admin-menu"), .dom(".toggle-admin-menu")
"The admin menu button was not rendered" .doesNotExist("The admin menu button was not rendered");
);
}); });
}); });
@ -26,10 +25,9 @@ acceptance("Topic - Admin Menu", function (needs) {
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.ok(exists("#topic"), "The topic was rendered");
assert.ok( assert
exists(".toggle-admin-menu"), .dom(".toggle-admin-menu")
"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.ok(exists(".topic-admin-delete"), "The delete item was rendered");
@ -40,10 +38,9 @@ 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.ok(exists("#topic"), "The topic was rendered");
assert.ok( assert
exists(".toggle-admin-menu"), .dom(".toggle-admin-menu")
"The admin menu button was rendered" .exists("The admin menu button was rendered");
);
}); });
test("Button added using addTopicAdminMenuButton", async function (assert) { test("Button added using addTopicAdminMenuButton", async function (assert) {
@ -66,10 +63,9 @@ 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.ok(exists("#topic"), "The topic was rendered");
await click(".toggle-admin-menu"); await click(".toggle-admin-menu");
assert.ok( assert
exists(".extra-button svg.d-icon-heart"), .dom(".extra-button svg.d-icon-heart")
"The icon was rendered" .exists("The icon was rendered");
);
assert assert
.dom(".extra-button .d-button-label") .dom(".extra-button .d-button-label")
.hasText(I18n.t("yes_value"), "The label was rendered"); .hasText(I18n.t("yes_value"), "The label was rendered");

View File

@ -7,10 +7,9 @@ acceptance("Topic - Anonymous", function () {
await visit("/t/internationalization-localization/280/1"); await visit("/t/internationalization-localization/280/1");
assert.ok(exists("#topic"), "The topic was rendered"); assert.ok(exists("#topic"), "The topic was rendered");
assert.ok(exists("#topic .cooked"), "The topic has cooked posts"); assert.ok(exists("#topic .cooked"), "The topic has cooked posts");
assert.ok( assert
!exists(".shared-draft-notice"), .dom(".shared-draft-notice")
"no shared draft unless there's a dest category id" .doesNotExist("no shared draft unless there's a dest category id");
);
}); });
test("Enter without an id", async function (assert) { test("Enter without an id", async function (assert) {

View File

@ -78,42 +78,38 @@ acceptance("Topic Discovery", function (needs) {
await visit("/c/feature"); await visit("/c/feature");
assert.ok(exists(".topic-list"), "The list of topics was rendered"); assert.ok(exists(".topic-list"), "The list of topics was rendered");
assert.ok( assert
exists(".category-boxes"), .dom(".category-boxes")
"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.ok(exists(".topic-list"), "The list of topics was rendered");
assert.ok( assert
exists(".category-boxes-with-topics"), .dom(".category-boxes-with-topics")
.exists(
"The list of subcategories were rendered with box-with-featured-topics style" "The list of subcategories were rendered with box-with-featured-topics style"
); );
assert.ok( assert
exists(".category-boxes-with-topics .featured-topics"), .dom(".category-boxes-with-topics .featured-topics")
"The featured topics are there too" .exists("The featured topics are there too");
);
}); });
test("Clearing state after leaving a category", async function (assert) { test("Clearing state after leaving a category", async function (assert) {
await visit("/c/dev"); await visit("/c/dev");
assert.ok( assert
exists('.topic-list-item[data-topic-id="11994"] .topic-excerpt'), .dom('.topic-list-item[data-topic-id="11994"] .topic-excerpt')
"it expands pinned topics in a subcategory" .exists("it expands pinned topics in a subcategory");
);
await visit("/"); await visit("/");
assert.ok( assert
!exists('.topic-list-item[data-topic-id="11557"] .topic-excerpt'), .dom('.topic-list-item[data-topic-id="11557"] .topic-excerpt')
"it doesn't expand all pinned in the latest category" .doesNotExist("it doesn't expand all pinned in the latest category");
);
}); });
test("Live update unread state", async function (assert) { test("Live update unread state", async function (assert) {
await visit("/"); await visit("/");
assert.ok( assert
exists(".topic-list-item:not(.visited) a[data-topic-id='11995']"), .dom(".topic-list-item:not(.visited) a[data-topic-id='11995']")
"shows the topic unread" .exists("shows the topic unread");
);
await publishToMessageBus("/latest", { await publishToMessageBus("/latest", {
message_type: "read", message_type: "read",
@ -126,10 +122,9 @@ acceptance("Topic Discovery", function (needs) {
}, },
}); });
assert.ok( assert
exists(".topic-list-item.visited a[data-topic-id='11995']"), .dom(".topic-list-item.visited a[data-topic-id='11995']")
"shows the topic read" .exists("shows the topic read");
);
}); });
test("Using period chooser when query params are present", async function (assert) { test("Using period chooser when query params are present", async function (assert) {

View File

@ -5,7 +5,6 @@ import Site from "discourse/models/site";
import topicFixtures from "discourse/tests/fixtures/discovery-fixtures"; import topicFixtures from "discourse/tests/fixtures/discovery-fixtures";
import { import {
acceptance, acceptance,
exists,
publishToMessageBus, publishToMessageBus,
query, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -64,22 +63,25 @@ acceptance("Topic Discovery Tracked", function (needs) {
await visit("/"); await visit("/");
assert.ok( assert
exists("#navigation-bar li.categories"), .dom("#navigation-bar li.categories")
.exists(
"the categories nav item is displayed when tracked filter is not present" "the categories nav item is displayed when tracked filter is not present"
); );
await visit("/categories"); await visit("/categories");
assert.ok( assert
exists("#navigation-bar li.categories"), .dom("#navigation-bar li.categories")
.exists(
"the categories nav item is displayed on categories route when tracked filter is not present" "the categories nav item is displayed on categories route when tracked filter is not present"
); );
await visit("/?f=tracked"); await visit("/?f=tracked");
assert.ok( assert
!exists("#navigation-bar li.categories"), .dom("#navigation-bar li.categories")
.doesNotExist(
"the categories nav item is not displayed when tracked filter is present" "the categories nav item is not displayed when tracked filter is present"
); );

View File

@ -8,7 +8,7 @@ import {
} from "discourse/lib/topic-list-tracker"; } from "discourse/lib/topic-list-tracker";
import discoveryFixtures from "discourse/tests/fixtures/discovery-fixtures"; import discoveryFixtures from "discourse/tests/fixtures/discovery-fixtures";
import topicFixtures from "discourse/tests/fixtures/topic"; import topicFixtures from "discourse/tests/fixtures/topic";
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object"; import { cloneJSON } from "discourse-common/lib/object";
acceptance("Topic list tracking", function (needs) { acceptance("Topic list tracking", function (needs) {
@ -65,10 +65,9 @@ acceptance("Topic list tracking", function (needs) {
await visit("/"); await visit("/");
assert.ok( assert
exists("tr[data-topic-id='11557'] .unread-posts"), .dom("tr[data-topic-id='11557'] .unread-posts")
"unread count for topic is shown" .exists("unread count for topic is shown");
);
}); });
test("unread count is not set on topic that user is not tracking", async function (assert) { test("unread count is not set on topic that user is not tracking", async function (assert) {
@ -80,9 +79,8 @@ acceptance("Topic list tracking", function (needs) {
await visit("/"); await visit("/");
assert.notOk( assert
exists("tr[data-topic-id='11557'] .unread-posts"), .dom("tr[data-topic-id='11557'] .unread-posts")
"unread count for topic is not shown" .doesNotExist("unread count for topic is not shown");
);
}); });
}); });

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("Topic move posts", function (needs) { acceptance("Topic move posts", function (needs) {
@ -127,8 +123,9 @@ acceptance("Topic move posts", function (needs) {
await fillIn(".choose-topic-modal #choose-topic-title", "Topic"); await fillIn(".choose-topic-modal #choose-topic-title", "Topic");
assert.notOk( assert
exists(".choose-topic-modal .checkbox-label"), .dom(".choose-topic-modal .checkbox-label")
.doesNotExist(
"there is no chronological order checkbox when no topic is selected" "there is no chronological order checkbox when no topic is selected"
); );
@ -221,8 +218,9 @@ acceptance("Topic move posts", function (needs) {
await fillIn(".choose-topic-modal #choose-message-title", "Topic"); await fillIn(".choose-topic-modal #choose-message-title", "Topic");
assert.notOk( assert
exists(".choose-topic-modal .checkbox-label"), .dom(".choose-topic-modal .checkbox-label")
.doesNotExist(
"there is no chronological order checkbox when no message is selected" "there is no chronological order checkbox when no message is selected"
); );

View File

@ -45,14 +45,12 @@ acceptance("Topic - Quote button - logged in", function (needs) {
await selectText("#post_5 blockquote"); await selectText("#post_5 blockquote");
assert.ok(exists(".quote-sharing"), "it shows the quote sharing options"); assert.ok(exists(".quote-sharing"), "it shows the quote sharing options");
assert.ok( assert
exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`), .dom(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`)
"it includes the twitter share button" .exists("it includes the twitter share button");
); assert
assert.ok( .dom(`.quote-sharing .btn[title='${I18n.t("share.email")}']`)
exists(`.quote-sharing .btn[title='${I18n.t("share.email")}']`), .exists("it includes the email share button");
"it includes the email share button"
);
}); });
test("Quoting a Onebox should not copy the formatting of the rendered Onebox", async function (assert) { test("Quoting a Onebox should not copy the formatting of the rendered Onebox", async function (assert) {
@ -105,14 +103,12 @@ acceptance("Topic - Quote button - anonymous", function (needs) {
await selectText("#post_5 blockquote"); await selectText("#post_5 blockquote");
assert.ok(queryAll(".quote-sharing"), "it shows the quote sharing options"); assert.ok(queryAll(".quote-sharing"), "it shows the quote sharing options");
assert.ok( assert
exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`), .dom(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`)
"it includes the twitter share button" .exists("it includes the twitter share button");
); assert
assert.ok( .dom(`.quote-sharing .btn[title='${I18n.t("share.email")}']`)
exists(`.quote-sharing .btn[title='${I18n.t("share.email")}']`), .exists("it includes the email share button");
"it includes the email share button"
);
assert.ok(!exists(".insert-quote"), "it does not show the quote button"); assert.ok(!exists(".insert-quote"), "it does not show the quote button");
}); });
@ -123,14 +119,12 @@ acceptance("Topic - Quote button - anonymous", function (needs) {
await selectText("#post_5 blockquote"); await selectText("#post_5 blockquote");
assert.ok(exists(".quote-sharing"), "it shows the quote sharing options"); assert.ok(exists(".quote-sharing"), "it shows the quote sharing options");
assert.ok( assert
exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`), .dom(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`)
"it includes the twitter share button" .exists("it includes the twitter share button");
); assert
assert.ok( .dom(".quote-share-label")
!exists(".quote-share-label"), .doesNotExist("it does not show the Share label");
"it does not show the Share label"
);
}); });
test("Shows nothing when visibility is disabled", async function (assert) { test("Shows nothing when visibility is disabled", async function (assert) {

View File

@ -95,10 +95,9 @@ acceptance("Topic", function (needs) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
await click(".topic-post:first-child button.post-action-menu__copy-link"); await click(".topic-post:first-child button.post-action-menu__copy-link");
assert.ok( assert
exists(".post-action-menu__copy-link-checkmark"), .dom(".post-action-menu__copy-link-checkmark")
"it shows the Link Copied! message" .exists("it shows the Link Copied! message");
);
}); });
test("Showing and hiding the edit controls", async function (assert) { test("Showing and hiding the edit controls", async function (assert) {
@ -107,10 +106,9 @@ 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.ok(exists("#edit-title"), "it shows the editing controls");
assert.ok( assert
!exists(".title-wrapper .remove-featured-link"), .dom(".title-wrapper .remove-featured-link")
"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");
@ -258,10 +256,9 @@ acceptance("Topic", function (needs) {
test("Suspended user posts", async function (assert) { test("Suspended user posts", async function (assert) {
await visit("/t/topic-from-suspended-user/54077"); await visit("/t/topic-from-suspended-user/54077");
assert.ok( assert
exists(".topic-post.user-suspended > #post_1"), .dom(".topic-post.user-suspended > #post_1")
"it has a class applied" .exists("it has a class applied");
);
}); });
}); });
@ -285,16 +282,14 @@ acceptance("Topic featured links", function (needs) {
test("remove featured link", async function (assert) { test("remove featured link", async function (assert) {
await visit("/t/-/299/1"); await visit("/t/-/299/1");
assert.ok( assert
exists(".title-wrapper .topic-featured-link"), .dom(".title-wrapper .topic-featured-link")
"link is shown with topic title" .exists("link is shown with topic title");
);
await click(".title-wrapper .edit-topic"); await click(".title-wrapper .edit-topic");
assert.ok( assert
exists(".title-wrapper .remove-featured-link"), .dom(".title-wrapper .remove-featured-link")
"link to remove featured link" .exists("link to remove featured link");
);
// TODO: decide if we want to test this, test is flaky so it // TODO: decide if we want to test this, test is flaky so it
// was commented out. // was commented out.
@ -332,10 +327,9 @@ acceptance("Topic featured links", function (needs) {
await click(".topic-admin-visible .btn"); await click(".topic-admin-visible .btn");
await click(".toggle-admin-menu"); await click(".toggle-admin-menu");
assert.ok( assert
exists(".topic-admin-pin"), .dom(".topic-admin-pin")
"it should show the multi select menu" .exists("it should show the multi select menu");
);
}); });
test("selecting posts", async function (assert) { test("selecting posts", async function (assert) {
@ -343,15 +337,13 @@ acceptance("Topic featured links", function (needs) {
await click(".toggle-admin-menu"); await click(".toggle-admin-menu");
await click(".topic-admin-multi-select .btn"); await click(".topic-admin-multi-select .btn");
assert.ok( assert
exists(".selected-posts:not(.hidden)"), .dom(".selected-posts:not(.hidden)")
"it should show the multi select menu" .exists("it should show the multi select menu");
);
assert.ok( assert
exists(".select-all"), .dom(".select-all")
"it should allow users to select all the posts" .exists("it should allow users to select all the posts");
);
}); });
test("select below", async function (assert) { test("select below", async function (assert) {
@ -459,16 +451,14 @@ acceptance("Topic featured links", function (needs) {
test("remove featured link", async function (assert) { test("remove featured link", async function (assert) {
await visit("/t/-/299/1"); await visit("/t/-/299/1");
assert.ok( assert
exists(".title-wrapper .topic-featured-link"), .dom(".title-wrapper .topic-featured-link")
"link is shown with topic title" .exists("link is shown with topic title");
);
await click(".title-wrapper .edit-topic"); await click(".title-wrapper .edit-topic");
assert.ok( assert
exists(".title-wrapper .remove-featured-link"), .dom(".title-wrapper .remove-featured-link")
"link to remove featured link" .exists("link to remove featured link");
);
}); });
}); });
@ -510,15 +500,13 @@ acceptance("Topic pinning/unpinning as an admin", function (needs) {
await click(".toggle-admin-menu"); await click(".toggle-admin-menu");
await click(".topic-admin-pin .btn"); await click(".topic-admin-pin .btn");
assert.ok( assert
exists(".feature-topic .btn-primary"), .dom(".feature-topic .btn-primary")
"it should show the 'Pin Topic' button" .exists("it should show the 'Pin Topic' button");
);
assert.ok( assert
exists(".make-banner"), .dom(".make-banner")
"it should show the 'Banner Topic' button" .exists("it should show the 'Banner Topic' button");
);
}); });
}); });
@ -531,15 +519,13 @@ acceptance("Topic pinning/unpinning as a staff member", function (needs) {
await click(".toggle-admin-menu"); await click(".toggle-admin-menu");
await click(".topic-admin-pin .btn"); await click(".topic-admin-pin .btn");
assert.ok( assert
exists(".feature-topic .btn-primary"), .dom(".feature-topic .btn-primary")
"it should show the 'Pin Topic' button" .exists("it should show the 'Pin Topic' button");
);
assert.ok( assert
exists(".make-banner"), .dom(".make-banner")
"it should show the 'Banner Topic' button" .exists("it should show the 'Banner Topic' button");
);
}); });
}); });
@ -552,15 +538,13 @@ acceptance("Topic pinning/unpinning as a group moderator", function (needs) {
await click(".toggle-admin-menu"); await click(".toggle-admin-menu");
await click(".topic-admin-pin .btn"); await click(".topic-admin-pin .btn");
assert.ok( assert
exists(".feature-topic .btn-primary"), .dom(".feature-topic .btn-primary")
"it should show the 'Pin Topic' button" .exists("it should show the 'Pin Topic' button");
);
assert.ok( assert
!exists(".make-banner"), .dom(".make-banner")
"it should not show the 'Banner Topic' button" .doesNotExist("it should not show the 'Banner Topic' button");
);
}); });
}); });
@ -570,17 +554,15 @@ acceptance("Topic last visit line", function (needs) {
test("visit topic", async function (assert) { test("visit topic", async function (assert) {
await visit("/t/-/280"); await visit("/t/-/280");
assert.ok( assert
exists(".topic-post-visited-line.post-10"), .dom(".topic-post-visited-line.post-10")
"shows the last visited line on the right post" .exists("shows the last visited line on the right post");
);
await visit("/t/-/9"); await visit("/t/-/9");
assert.ok( assert
!exists(".topic-post-visited-line"), .dom(".topic-post-visited-line")
"does not show last visited line if post is the last post" .doesNotExist("does not show last visited line if post is the last post");
);
}); });
}); });

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("Glimmer Topic Timeline", function (needs) { acceptance("Glimmer Topic Timeline", function (needs) {
needs.user({ needs.user({
@ -334,26 +334,23 @@ acceptance("Glimmer Topic Timeline", function (needs) {
test("it has a topic admin menu", async function (assert) { test("it has a topic admin menu", async function (assert) {
await visit("/t/internationalization-localization"); await visit("/t/internationalization-localization");
assert.ok( assert
exists(".timeline-controls .topic-admin-menu-button"), .dom(".timeline-controls .topic-admin-menu-button")
"admin menu is present" .exists("admin menu is present");
);
}); });
test("it has a reply-to-post button", async function (assert) { test("it has a reply-to-post button", async function (assert) {
await visit("/t/internationalization-localization"); await visit("/t/internationalization-localization");
assert.ok( assert
exists(".timeline-footer-controls .reply-to-post"), .dom(".timeline-footer-controls .reply-to-post")
"reply to post button is present" .exists("reply to post button is present");
);
}); });
test("it has a topic notification button", async function (assert) { test("it has a topic notification button", async function (assert) {
await visit("/t/internationalization-localization"); await visit("/t/internationalization-localization");
assert.ok( assert
exists(".timeline-footer-controls .topic-notifications-button"), .dom(".timeline-footer-controls .topic-notifications-button")
"topic notifications button is present" .exists("topic notifications button is present");
);
}); });
test("Shows dates of first and last posts", async function (assert) { test("Shows dates of first and last posts", async function (assert) {

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,
publishToMessageBus, publishToMessageBus,
query, query,
queryAll, queryAll,
@ -121,10 +120,9 @@ acceptance("Topic - User Status - live updates", function (needs) {
await publishToMessageBus(`/user-status`, { [userId]: null }); await publishToMessageBus(`/user-status`, { [userId]: null });
assert.notOk( assert
exists(".topic-post .user-status-message"), .dom(".topic-post .user-status-message")
"status on all posts has disappeared" .doesNotExist("status on all posts has disappeared");
);
const newStatus = { emoji: "surfing_man", description: "surfing" }; const newStatus = { emoji: "surfing_man", description: "surfing" };
await publishToMessageBus(`/user-status`, { [userId]: newStatus }); await publishToMessageBus(`/user-status`, { [userId]: newStatus });

View File

@ -2,7 +2,7 @@ import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
import userFixtures from "../fixtures/user-fixtures"; import userFixtures from "../fixtures/user-fixtures";
import { acceptance, exists, query, queryAll } from "../helpers/qunit-helpers"; import { acceptance, query, queryAll } from "../helpers/qunit-helpers";
acceptance("User Activity / Topics - bulk actions", function (needs) { acceptance("User Activity / Topics - bulk actions", function (needs) {
const currentUser = "eviltrout"; const currentUser = "eviltrout";
@ -29,10 +29,9 @@ acceptance("User Activity / Topics - bulk actions", function (needs) {
await click(".bulk-select-topics-dropdown-trigger"); await click(".bulk-select-topics-dropdown-trigger");
await click(".dropdown-menu__item .close-topics"); await click(".dropdown-menu__item .close-topics");
assert.notOk( assert
exists("div.bulk-buttons"), .dom("div.bulk-buttons")
"The bulk actions modal was closed" .doesNotExist("The bulk actions modal was closed");
);
}); });
}); });

View File

@ -29,10 +29,9 @@ acceptance("User Drafts", function (needs) {
await visit("/"); await visit("/");
assert.ok(visible("#create-topic")); assert.ok(visible("#create-topic"));
assert.ok( assert
!exists("#create-topic.open-draft"), .dom("#create-topic.open-draft")
"Open Draft button is not present" .doesNotExist("Open Draft button is not present");
);
}); });
test("Stream - resume draft", async function (assert) { test("Stream - resume draft", async function (assert) {

View File

@ -148,10 +148,9 @@ acceptance("User menu", function (needs) {
"/review/17", "/review/17",
"clicking on an item results in navigation to the item's page" "clicking on an item results in navigation to the item's page"
); );
assert.notOk( assert
exists(".user-menu"), .dom(".user-menu")
"clicking on an item closes the menu after navigating" .doesNotExist("clicking on an item closes the menu after navigating");
);
await click(".d-header-icons .current-user button"); await click(".d-header-icons .current-user button");
await click("#user-menu-button-review-queue"); await click("#user-menu-button-review-queue");
@ -162,10 +161,9 @@ acceptance("User menu", function (needs) {
"/review/17", "/review/17",
"clicking on the same item again keeps on the same page" "clicking on the same item again keeps on the same page"
); );
assert.notOk( assert
exists(".user-menu"), .dom(".user-menu")
"clicking on the same item again closes the menu" .doesNotExist("clicking on the same item again closes the menu");
);
}); });
test("tabs have title attributes", async function (assert) { test("tabs have title attributes", async function (assert) {
@ -294,14 +292,12 @@ acceptance("User menu", function (needs) {
await visit("/"); await visit("/");
await click(".d-header-icons .current-user button"); await click(".d-header-icons .current-user button");
assert.ok( assert
exists("#user-menu-button-custom-tab-1"), .dom("#user-menu-button-custom-tab-1")
"first custom tab is rendered" .exists("first custom tab is rendered");
); assert
assert.ok( .dom("#user-menu-button-custom-tab-2")
exists("#user-menu-button-custom-tab-2"), .exists("second custom tab is rendered");
"second custom tab is rendered"
);
const tabs = [...queryAll(".tabs-list.top-tabs .btn")]; const tabs = [...queryAll(".tabs-list.top-tabs .btn")];
@ -355,15 +351,13 @@ acceptance("User menu", function (needs) {
await click("#user-menu-button-custom-tab-1"); await click("#user-menu-button-custom-tab-1");
assert.ok( assert
exists("#user-menu-button-custom-tab-1.active"), .dom("#user-menu-button-custom-tab-1.active")
"custom tabs can be clicked on and become active" .exists("custom tabs can be clicked on and become active");
);
assert.ok( assert
exists("#quick-access-custom-tab-1 button.btn"), .dom("#quick-access-custom-tab-1 button.btn")
"the tab's content is now displayed in the panel" .exists("the tab's content is now displayed in the panel");
);
}); });
test("notifications tab applies model transformations registered by plugins", async function (assert) { test("notifications tab applies model transformations registered by plugins", async function (assert) {
@ -502,10 +496,9 @@ acceptance("User menu", function (needs) {
await click("#user-menu-button-profile"); await click("#user-menu-button-profile");
assert.notOk( assert
exists("#quick-access-profile ul li.invites"), .dom("#quick-access-profile ul li.invites")
"invites link not shown when the user can't invite" .doesNotExist("invites link not shown when the user can't invite");
);
const draftsLink = query("#quick-access-profile ul li.drafts a"); const draftsLink = query("#quick-access-profile ul li.drafts a");
assert.ok( assert.ok(
@ -576,10 +569,9 @@ acceptance("User menu", function (needs) {
"Do Not Disturb button has the right icon when Do Not Disturb is enabled" "Do Not Disturb button has the right icon when Do Not Disturb is enabled"
); );
assert.ok( assert
exists("#quick-access-profile ul li.enable-anonymous .btn"), .dom("#quick-access-profile ul li.enable-anonymous .btn")
"toggle anon button is shown" .exists("toggle anon button is shown");
);
let toggleAnonButton = query( let toggleAnonButton = query(
"#quick-access-profile ul li.enable-anonymous .btn" "#quick-access-profile ul li.enable-anonymous .btn"
); );
@ -631,12 +623,14 @@ acceptance("User menu", function (needs) {
await click(".d-header-icons .current-user button"); await click(".d-header-icons .current-user button");
await click("#user-menu-button-profile"); await click("#user-menu-button-profile");
assert.notOk( assert
exists("#quick-access-profile ul li.enable-anonymous"), .dom("#quick-access-profile ul li.enable-anonymous")
.doesNotExist(
"toggle anon button isn't shown when the user can't use it" "toggle anon button isn't shown when the user can't use it"
); );
assert.notOk( assert
exists("#quick-access-profile ul li.disable-anonymous"), .dom("#quick-access-profile ul li.disable-anonymous")
.doesNotExist(
"toggle anon button isn't shown when the user can't use it" "toggle anon button isn't shown when the user can't use it"
); );
@ -654,10 +648,9 @@ acceptance("User menu", function (needs) {
await click(".d-header-icons .current-user button"); await click(".d-header-icons .current-user button");
await click("#user-menu-button-profile"); await click("#user-menu-button-profile");
assert.ok( assert
exists("#quick-access-profile ul li.disable-anonymous"), .dom("#quick-access-profile ul li.disable-anonymous")
"toggle anon button is always shown if the user is anonymous" .exists("toggle anon button is always shown if the user is anonymous");
);
await clickOutside(); await clickOutside();
updateCurrentUser({ updateCurrentUser({
@ -675,8 +668,9 @@ acceptance("User menu", function (needs) {
await click(".d-header-icons .current-user button"); await click(".d-header-icons .current-user button");
await click("#user-menu-button-profile"); await click("#user-menu-button-profile");
assert.notOk( assert
exists("#quick-access-profile ul li.enable-anonymous"), .dom("#quick-access-profile ul li.enable-anonymous")
.doesNotExist(
"toggle anon button is not shown if the allow_anonymous_posting setting is false" "toggle anon button is not shown if the allow_anonymous_posting setting is false"
); );
@ -694,8 +688,9 @@ acceptance("User menu", function (needs) {
await click(".d-header-icons .current-user button"); await click(".d-header-icons .current-user button");
await click("#user-menu-button-profile"); await click("#user-menu-button-profile");
assert.notOk( assert
exists("#quick-access-profile ul li.enable-anonymous"), .dom("#quick-access-profile ul li.enable-anonymous")
.doesNotExist(
"toggle anon button is not shown if the user is not allowed to post anonymously" "toggle anon button is not shown if the user is not allowed to post anonymously"
); );
@ -878,8 +873,9 @@ acceptance("User menu", function (needs) {
"Enter" "Enter"
); );
assert.ok( assert
exists("#quick-access-other-notifications"), .dom("#quick-access-other-notifications")
.exists(
"the other notifications panel can display using keyboard navigation" "the other notifications panel can display using keyboard navigation"
); );
}); });
@ -982,14 +978,12 @@ acceptance("User menu - Dismiss button", function (needs) {
); );
await click("#user-menu-button-bookmarks"); await click("#user-menu-button-bookmarks");
assert.ok( assert
exists("#quick-access-bookmarks ul li.notification"), .dom("#quick-access-bookmarks ul li.notification")
"bookmark reminder notifications are visible" .exists("bookmark reminder notifications are visible");
); assert
assert.ok( .dom("#quick-access-bookmarks ul li.bookmark")
exists("#quick-access-bookmarks ul li.bookmark"), .exists("bookmarks are visible");
"bookmarks are visible"
);
await click(".user-menu .notifications-dismiss"); await click(".user-menu .notifications-dismiss");
@ -1006,18 +1000,15 @@ acceptance("User menu - Dismiss button", function (needs) {
await click(".d-modal__footer .btn-primary"); // confirm dismiss on the dismiss modal await click(".d-modal__footer .btn-primary"); // confirm dismiss on the dismiss modal
assert.notOk( assert
exists("#quick-access-bookmarks ul li.notification"), .dom("#quick-access-bookmarks ul li.notification")
"bookmark reminder notifications are gone" .doesNotExist("bookmark reminder notifications are gone");
); assert
assert.ok( .dom("#quick-access-bookmarks ul li.bookmark")
exists("#quick-access-bookmarks ul li.bookmark"), .exists("bookmarks are still visible");
"bookmarks are still visible" assert
); .dom("#user-menu-button-bookmarks .badge-notification")
assert.notOk( .doesNotExist("bookmarks tab no longer has bubble");
exists("#user-menu-button-bookmarks .badge-notification"),
"bookmarks tab no longer has bubble"
);
assert.ok(markRead, "mark-read request is sent"); assert.ok(markRead, "mark-read request is sent");
assert.strictEqual( assert.strictEqual(
markReadRequestBody, markReadRequestBody,
@ -1038,14 +1029,12 @@ acceptance("User menu - Dismiss button", function (needs) {
); );
await click("#user-menu-button-messages"); await click("#user-menu-button-messages");
assert.ok( assert
exists("#quick-access-messages ul li.notification"), .dom("#quick-access-messages ul li.notification")
"messages notifications are visible" .exists("messages notifications are visible");
); assert
assert.ok( .dom("#quick-access-messages ul li.message")
exists("#quick-access-messages ul li.message"), .exists("messages are visible");
"messages are visible"
);
await click(".user-menu .notifications-dismiss"); await click(".user-menu .notifications-dismiss");
@ -1062,18 +1051,15 @@ acceptance("User menu - Dismiss button", function (needs) {
await click(".d-modal__footer .btn-primary"); // confirm dismiss on the dismiss modal await click(".d-modal__footer .btn-primary"); // confirm dismiss on the dismiss modal
assert.notOk( assert
exists("#quick-access-messages ul li.notification"), .dom("#quick-access-messages ul li.notification")
"messages notifications are gone" .doesNotExist("messages notifications are gone");
); assert
assert.ok( .dom("#quick-access-messages ul li.message")
exists("#quick-access-messages ul li.message"), .exists("messages are still visible");
"messages are still visible" assert
); .dom("#user-menu-button-messages .badge-notification")
assert.notOk( .doesNotExist("messages tab no longer has bubble");
exists("#user-menu-button-messages .badge-notification"),
"messages tab no longer has bubble"
);
assert.ok(markRead, "mark-read request is sent"); assert.ok(markRead, "mark-read request is sent");
assert.strictEqual( assert.strictEqual(
markReadRequestBody, markReadRequestBody,

View File

@ -121,10 +121,9 @@ acceptance("User Preferences - Account", function (needs) {
test("connected accounts", async function (assert) { test("connected accounts", async function (assert) {
await visit("/u/eviltrout/preferences/account"); await visit("/u/eviltrout/preferences/account");
assert.ok( assert
exists(".pref-associated-accounts"), .dom(".pref-associated-accounts")
"it has the connected accounts section" .exists("it has the connected accounts section");
);
assert.ok( assert.ok(
query( query(
@ -155,15 +154,13 @@ 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( assert
exists(".selectable-avatars"), .dom(".selectable-avatars")
"opens the avatar selection modal" .exists("opens the avatar selection modal");
);
assert.ok( assert
exists("#uploaded-avatar"), .dom("#uploaded-avatar")
"avatar selection modal includes option to upload" .exists("avatar selection modal includes option to upload");
);
}); });
test("avatars are not selectable for non-staff user when `selectable_avatars_mode` site setting is set to `staff`", async function (assert) { test("avatars are not selectable for non-staff user when `selectable_avatars_mode` site setting is set to `staff`", async function (assert) {
@ -177,15 +174,13 @@ 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( assert
exists(".selectable-avatars"), .dom(".selectable-avatars")
"opens the avatar selection modal" .exists("opens the avatar selection modal");
);
assert.notOk( assert
exists("#uploaded-avatar"), .dom("#uploaded-avatar")
"avatar selection modal does not include option to upload" .doesNotExist("avatar selection modal does not include option to upload");
);
}); });
test("avatars not selectable when `selectable_avatars_mode` site setting is set to `no_one`", async function (assert) { test("avatars not selectable when `selectable_avatars_mode` site setting is set to `no_one`", async function (assert) {
@ -198,15 +193,13 @@ 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( assert
exists(".selectable-avatars"), .dom(".selectable-avatars")
"opens the avatar selection modal" .exists("opens the avatar selection modal");
);
assert.notOk( assert
exists("#uploaded-avatar"), .dom("#uploaded-avatar")
"avatar selection modal does not include option to upload" .doesNotExist("avatar selection modal does not include option to upload");
);
}); });
test("avatars are selectable for user with required trust level when `selectable_avatars_mode` site setting is set to `tl3`", async function (assert) { test("avatars are selectable for user with required trust level when `selectable_avatars_mode` site setting is set to `tl3`", async function (assert) {
@ -221,15 +214,13 @@ 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( assert
exists(".selectable-avatars"), .dom(".selectable-avatars")
"opens the avatar selection modal" .exists("opens the avatar selection modal");
);
assert.ok( assert
exists("#uploaded-avatar"), .dom("#uploaded-avatar")
"avatar selection modal includes option to upload" .exists("avatar selection modal includes option to upload");
);
}); });
test("avatars are not selectable for user without required trust level when `selectable_avatars_mode` site setting is set to `tl3`", async function (assert) { test("avatars are not selectable for user without required trust level when `selectable_avatars_mode` site setting is set to `tl3`", async function (assert) {
@ -244,15 +235,13 @@ 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( assert
exists(".selectable-avatars"), .dom(".selectable-avatars")
"opens the avatar selection modal" .exists("opens the avatar selection modal");
);
assert.notOk( assert
exists("#uploaded-avatar"), .dom("#uploaded-avatar")
"avatar selection modal does not include option to upload" .doesNotExist("avatar selection modal does not include option to upload");
);
}); });
test("avatars are selectable for staff user when `selectable_avatars_mode` site setting is set to `tl3`", async function (assert) { test("avatars are selectable for staff user when `selectable_avatars_mode` site setting is set to `tl3`", async function (assert) {
@ -267,15 +256,13 @@ 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( assert
exists(".selectable-avatars"), .dom(".selectable-avatars")
"opens the avatar selection modal" .exists("opens the avatar selection modal");
);
assert.ok( assert
exists("#uploaded-avatar"), .dom("#uploaded-avatar")
"avatar selection modal includes option to upload" .exists("avatar selection modal includes option to upload");
);
}); });
test("default avatar selector", async function (assert) { test("default avatar selector", async function (assert) {
@ -286,10 +273,9 @@ acceptance("User Preferences - Account", function (needs) {
await click(".avatar-selector-refresh-gravatar"); await click(".avatar-selector-refresh-gravatar");
assert.ok( assert
exists(".avatar[src='/images/gravatar_is_not_avatar.png']"), .dom(".avatar[src='/images/gravatar_is_not_avatar.png']")
"displays the new gravatar image" .exists("displays the new gravatar image");
);
await click("#gravatar"); await click("#gravatar");
await click(".d-modal__footer .btn"); await click(".d-modal__footer .btn");

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,
query, query,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -44,14 +43,12 @@ acceptance("User Profile - Account - User Status", function (needs) {
await visit(`/u/${username}/preferences/account`); await visit(`/u/${username}/preferences/account`);
assert.ok( assert
exists(".pref-user-status .user-status-message"), .dom(".pref-user-status .user-status-message")
"status is shown" .exists("status is shown");
); assert
assert.ok( .dom(`.pref-user-status .emoji[alt='${status.emoji}']`)
exists(`.pref-user-status .emoji[alt='${status.emoji}']`), .exists("status emoji is correct");
"status emoji is correct"
);
assert.equal( assert.equal(
query( query(
`.pref-user-status .user-status-message-description` `.pref-user-status .user-status-message-description`
@ -75,21 +72,18 @@ acceptance("User Profile - Account - User Status", function (needs) {
updateCurrentUser({ status: null }); updateCurrentUser({ status: null });
await visit(`/u/${username}/preferences/account`); await visit(`/u/${username}/preferences/account`);
assert.notOk( assert
exists(".pref-user-status .user-status-message"), .dom(".pref-user-status .user-status-message")
"status isn't shown" .doesNotExist("status isn't shown");
);
await setStatus(status); await setStatus(status);
assert.ok( assert
exists(".pref-user-status .user-status-message"), .dom(".pref-user-status .user-status-message")
"status is shown" .exists("status is shown");
); assert
assert.ok( .dom(`.pref-user-status .emoji[alt='${status.emoji}']`)
exists(`.pref-user-status .emoji[alt='${status.emoji}']`), .exists("status emoji is correct");
"status emoji is correct"
);
assert.equal( assert.equal(
query( query(
`.pref-user-status .user-status-message-description` `.pref-user-status .user-status-message-description`
@ -106,14 +100,12 @@ acceptance("User Profile - Account - User Status", function (needs) {
const newStatus = { emoji: "surfing_man", description: "surfing" }; const newStatus = { emoji: "surfing_man", description: "surfing" };
await setStatus(newStatus); await setStatus(newStatus);
assert.ok( assert
exists(".pref-user-status .user-status-message"), .dom(".pref-user-status .user-status-message")
"status is shown" .exists("status is shown");
); assert
assert.ok( .dom(`.pref-user-status .emoji[alt='${newStatus.emoji}']`)
exists(`.pref-user-status .emoji[alt='${newStatus.emoji}']`), .exists("status emoji is correct");
"status emoji is correct"
);
assert.equal( assert.equal(
query( query(
`.pref-user-status .user-status-message-description` `.pref-user-status .user-status-message-description`
@ -130,9 +122,8 @@ acceptance("User Profile - Account - User Status", function (needs) {
await openUserStatusModal(); await openUserStatusModal();
await click(".btn.delete-status"); await click(".btn.delete-status");
assert.notOk( assert
exists(".pref-user-status .user-status-message"), .dom(".pref-user-status .user-status-message")
"status isn't shown" .doesNotExist("status isn't shown");
);
}); });
}); });

View File

@ -17,9 +17,8 @@ acceptance("User Preferences Admin - Mobile", function (needs) {
test("Mobile user admin button", async function (assert) { test("Mobile user admin button", async function (assert) {
await visit("/u/eviltrout"); await visit("/u/eviltrout");
assert.ok( assert
exists(".user-nav__admin"), .dom(".user-nav__admin")
"mobile user admin nav button exists" .exists("mobile user admin nav button exists");
);
}); });
}); });

View File

@ -150,10 +150,9 @@ acceptance("User Preferences - Interface", function (needs) {
await visit("/u/eviltrout/preferences/interface"); await visit("/u/eviltrout/preferences/interface");
assert.ok( assert
exists(".pref-reset-seen-user-tips"), .dom(".pref-reset-seen-user-tips")
"has reset seen user tips button" .exists("has reset seen user tips button");
);
await click(".pref-reset-seen-user-tips"); await click(".pref-reset-seen-user-tips");

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { import {
acceptance, acceptance,
count, count,
exists,
fakeTime, fakeTime,
loggedInUser, loggedInUser,
queryAll, queryAll,
@ -17,15 +16,13 @@ acceptance("User notification schedule", function (needs) {
test("the schedule interface is hidden until enabled", async function (assert) { test("the schedule interface is hidden until enabled", async function (assert) {
await visit("/u/eviltrout/preferences/notifications"); await visit("/u/eviltrout/preferences/notifications");
assert.ok( assert
!exists(".notification-schedule-table"), .dom(".notification-schedule-table")
"notification schedule is hidden" .doesNotExist("notification schedule is hidden");
);
await click(".control-group.notification-schedule input"); await click(".control-group.notification-schedule input");
assert.ok( assert
exists(".notification-schedule-table"), .dom(".notification-schedule-table")
"notification schedule is visible" .exists("notification schedule is visible");
);
}); });
test("By default every day is selected 8:00am - 5:00pm", async function (assert) { test("By default every day is selected 8:00am - 5:00pm", async function (assert) {

View File

@ -33,10 +33,9 @@ acceptance("User Preferences - Second Factor Backup", function (needs) {
await visit("/u/eviltrout/preferences/second-factor"); await visit("/u/eviltrout/preferences/second-factor");
await click(".new-second-factor-backup"); await click(".new-second-factor-backup");
assert.ok( assert
exists(".second-factor-backup-edit-modal"), .dom(".second-factor-backup-edit-modal")
"shows the 2fa backup panel" .exists("shows the 2fa backup panel");
);
await click(".second-factor-backup-edit-modal .btn-primary"); await click(".second-factor-backup-edit-modal .btn-primary");

View File

@ -70,10 +70,9 @@ acceptance("User Preferences - Second Factor", function (needs) {
assert.ok(exists(".qr-code img"), "shows qr code image"); assert.ok(exists(".qr-code img"), "shows qr code image");
await click(".modal a.show-second-factor-key"); await click(".modal a.show-second-factor-key");
assert.ok( assert
exists(".modal .second-factor-key"), .dom(".modal .second-factor-key")
"displays second factor key" .exists("displays second factor key");
);
await click(".add-totp"); await click(".add-totp");
assert.ok( assert.ok(
@ -112,20 +111,18 @@ acceptance("User Preferences - Second Factor", function (needs) {
assert.dom("#dialog-title").hasText("Deleting an authenticator"); assert.dom("#dialog-title").hasText("Deleting an authenticator");
await click(".dialog-close"); await click(".dialog-close");
assert.ok( assert
exists(".security-key .second-factor-item"), .dom(".security-key .second-factor-item")
"User has a physical security key" .exists("User has a physical security key");
);
await click(".security-key-dropdown .select-kit-header"); await click(".security-key-dropdown .select-kit-header");
await click("li[data-name='Disable']"); await click("li[data-name='Disable']");
assert.dom("#dialog-title").hasText("Deleting an authenticator"); assert.dom("#dialog-title").hasText("Deleting an authenticator");
await click(".dialog-footer .btn-danger"); await click(".dialog-footer .btn-danger");
assert.notOk( assert
exists(".security-key .second-factor-item"), .dom(".security-key .second-factor-item")
"security key row is removed after a successful delete" .doesNotExist("security key row is removed after a successful delete");
);
await click(".pref-second-factor-disable-all .btn-danger"); await click(".pref-second-factor-disable-all .btn-danger");
assert assert

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { import {
acceptance, acceptance,
count, count,
exists,
query, query,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -94,15 +93,13 @@ acceptance("User Preferences - Security", function (needs) {
"displays the scope for the API key" "displays the scope for the API key"
); );
assert.ok( assert
exists(".pref-user-api-keys__created-at"), .dom(".pref-user-api-keys__created-at")
"displays the created at date for the API key" .exists("displays the created at date for the API key");
);
assert.ok( assert
exists(".pref-user-api-keys__last-used-at"), .dom(".pref-user-api-keys__last-used-at")
"displays the last used at date for the API key" .exists("displays the last used at date for the API key");
);
}); });
test("Viewing Passkeys - user has a key", async function (assert) { test("Viewing Passkeys - user has a key", async function (assert) {

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("User Preferences - Tracking", function (needs) { acceptance("User Preferences - Tracking", function (needs) {
@ -24,10 +24,9 @@ acceptance("User Preferences - Tracking", function (needs) {
await visit("/u/eviltrout/preferences/tracking"); await visit("/u/eviltrout/preferences/tracking");
assert.notOk( assert
exists(".tag-notifications"), .dom(".tag-notifications")
"tag notification levels section is not displayed" .doesNotExist("tag notification levels section is not displayed");
);
}); });
test("updating notification levels of tags when tagging is enabled", async function (assert) { test("updating notification levels of tags when tagging is enabled", async function (assert) {

View File

@ -24,10 +24,9 @@ acceptance("User Profile - Summary", function (needs) {
assert.ok(exists(".liked-by-section .user-info"), "liked by"); assert.ok(exists(".liked-by-section .user-info"), "liked by");
assert.ok(exists(".liked-section .user-info"), "liked"); assert.ok(exists(".liked-section .user-info"), "liked");
assert.ok(exists(".badges-section .badge-card"), "badges"); assert.ok(exists(".badges-section .badge-card"), "badges");
assert.ok( assert
exists(".top-categories-section .category-link"), .dom(".top-categories-section .category-link")
"top categories" .exists("top categories");
);
}); });
test("Top Categories Search", async function (assert) { test("Top Categories Search", async function (assert) {

View File

@ -129,10 +129,9 @@ acceptance("User Status", function (needs) {
await fillIn(".emoji-picker-content .filter", userStatusEmoji); await fillIn(".emoji-picker-content .filter", userStatusEmoji);
await click(".results .emoji"); await click(".results .emoji");
assert.ok( assert
exists(`.btn-emoji img.emoji[title=${userStatusEmoji}]`), .dom(`.btn-emoji img.emoji[title=${userStatusEmoji}]`)
"chosen status emoji is shown" .exists("chosen status emoji is shown");
);
}); });
test("setting user status", async function (assert) { test("setting user status", async function (assert) {
@ -143,10 +142,9 @@ acceptance("User Status", function (needs) {
await fillIn(".user-status-description", userStatus); await fillIn(".user-status-description", userStatus);
await pickEmoji(userStatusEmoji); await pickEmoji(userStatusEmoji);
assert.ok( assert
exists(`.btn-emoji img.emoji[title=${userStatusEmoji}]`), .dom(`.btn-emoji img.emoji[title=${userStatusEmoji}]`)
"chosen status emoji is shown" .exists("chosen status emoji is shown");
);
await click(".btn-primary"); // save await click(".btn-primary"); // save
assert.equal( assert.equal(
@ -262,10 +260,9 @@ acceptance("User Status", function (needs) {
await openUserStatusModal(); await openUserStatusModal();
await fillIn(".user-status-description", "some status"); await fillIn(".user-status-description", "some status");
assert.ok( assert
exists(`.btn-emoji img.emoji[title=${defaultStatusEmoji}]`), .dom(`.btn-emoji img.emoji[title=${defaultStatusEmoji}]`)
"default status emoji is shown" .exists("default status emoji is shown");
);
}); });
test("shows actual status on the modal after canceling the modal and opening it again", async function (assert) { test("shows actual status on the modal after canceling the modal and opening it again", async function (assert) {
@ -500,10 +497,9 @@ acceptance("User Status - user menu", function (needs) {
await click("#user-menu-button-profile"); await click("#user-menu-button-profile");
assert.ok(exists("li.set-user-status .btn"), "shows the button"); assert.ok(exists("li.set-user-status .btn"), "shows the button");
assert.ok( assert
exists("li.set-user-status svg.d-icon-circle-plus"), .dom("li.set-user-status svg.d-icon-circle-plus")
"shows the icon on the button" .exists("shows the icon on the button");
);
}); });
test("shows user status on the button", async function (assert) { test("shows user status on the button", async function (assert) {

View File

@ -88,19 +88,17 @@ acceptance("User Routes", function (needs) {
await visit("/u/charlie/summary"); await visit("/u/charlie/summary");
assert.notOk( assert
exists(".user-nav > .user-nav__notifications"), .dom(".user-nav > .user-nav__notifications")
"does not have the notifications tab" .doesNotExist("does not have the notifications tab");
);
updateCurrentUser({ moderator: false, admin: true }); updateCurrentUser({ moderator: false, admin: true });
await visit("/u/charlie/summary"); await visit("/u/charlie/summary");
assert.ok( assert
exists(".user-nav > .user-nav__notifications"), .dom(".user-nav > .user-nav__notifications")
"has the notifications tab" .exists("has the notifications tab");
);
}); });
test("Root URL - Viewing Self", async function (assert) { test("Root URL - Viewing Self", async function (assert) {
@ -120,16 +118,14 @@ acceptance("User Routes", function (needs) {
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.ok(exists(".user-stream"), "has drafts stream");
assert.ok( assert
exists(".user-stream .user-stream-item-draft-actions"), .dom(".user-stream .user-stream-item-draft-actions")
"has draft action buttons" .exists("has draft action buttons");
);
await click(".user-stream button.resume-draft:nth-of-type(1)"); await click(".user-stream button.resume-draft:nth-of-type(1)");
assert.ok( assert
exists(".d-editor-input"), .dom(".d-editor-input")
"composer is visible after resuming a draft" .exists("composer is visible after resuming a draft");
);
}); });
}); });
@ -392,10 +388,9 @@ acceptance("User - Logout", function (needs) {
await publishToMessageBus("/logout/19"); await publishToMessageBus("/logout/19");
assert.dom(".dialog-body").exists(); assert.dom(".dialog-body").exists();
assert.ok( assert
!exists(".dialog-footer .btn-default"), .dom(".dialog-footer .btn-default")
"no cancel button present" .doesNotExist("no cancel button present");
);
assert assert
.dom(".dialog-footer .btn-primary") .dom(".dialog-footer .btn-primary")
.hasText(I18n.t("house"), "primary dialog button is present"); .hasText(I18n.t("house"), "primary dialog button is present");

View File

@ -18,10 +18,9 @@ acceptance("User Directory", function () {
document.body.classList.contains("users-page"), document.body.classList.contains("users-page"),
"has the body class" "has the body class"
); );
assert.ok( assert
exists(".directory .directory-table .directory-table__row"), .dom(".directory .directory-table .directory-table__row")
"has a list of users" .exists("has a list of users");
);
}); });
test("Visit All Time", async function (assert) { test("Visit All Time", async function (assert) {
@ -35,10 +34,9 @@ acceptance("User Directory", function () {
document.body.classList.contains("users-page"), document.body.classList.contains("users-page"),
"has the body class" "has the body class"
); );
assert.ok( assert
exists(".directory .directory-table .directory-table__row"), .dom(".directory .directory-table .directory-table__row")
"has a list of users" .exists("has a list of users");
);
}); });
test("Visit With Group Exclusion", async function (assert) { test("Visit With Group Exclusion", async function (assert) {
@ -65,10 +63,9 @@ acceptance("User Directory", function () {
document.body.classList.contains("users-page"), document.body.classList.contains("users-page"),
"has the body class" "has the body class"
); );
assert.ok( assert
exists(".directory .directory-table .directory-table__row"), .dom(".directory .directory-table .directory-table__row")
"has a list of users" .exists("has a list of users");
);
}); });
test("Custom user fields are present", async function (assert) { test("Custom user fields are present", async function (assert) {

View File

@ -54,38 +54,32 @@ module("Integration | Component | d-button", function (hooks) {
await render(hbs`<DButton @isLoading={{this.isLoading}} />`); await render(hbs`<DButton @isLoading={{this.isLoading}} />`);
assert.ok( assert
exists("button.is-loading .loading-icon"), .dom("button.is-loading .loading-icon")
"it has a spinner showing" .exists("it has a spinner showing");
); assert
assert.ok( .dom("button[disabled]")
exists("button[disabled]"), .exists("while loading the button is disabled");
"while loading the button is disabled"
);
this.set("isLoading", false); this.set("isLoading", false);
assert.notOk( assert
exists("button .loading-icon"), .dom("button .loading-icon")
"it doesn't have a spinner showing" .doesNotExist("it doesn't have a spinner showing");
); assert
assert.ok( .dom("button:not([disabled])")
exists("button:not([disabled])"), .exists("while not loading the button is enabled");
"while not loading the button is enabled"
);
}); });
test("button without isLoading attribute", async function (assert) { test("button without isLoading attribute", async function (assert) {
await render(hbs`<DButton />`); await render(hbs`<DButton />`);
assert.notOk( assert
exists("button.is-loading"), .dom("button.is-loading")
"it doesn't have class is-loading" .doesNotExist("it doesn't have class is-loading");
); assert
assert.notOk( .dom("button .loading-icon")
exists("button .loading-icon"), .doesNotExist("it doesn't have a spinner showing");
"it doesn't have a spinner showing"
);
assert.notOk(exists("button[disabled]"), "it isn't disabled"); assert.notOk(exists("button[disabled]"), "it isn't disabled");
}); });
@ -94,14 +88,12 @@ module("Integration | Component | d-button", function (hooks) {
await render(hbs`<DButton @isLoading={{this.isLoading}} />`); await render(hbs`<DButton @isLoading={{this.isLoading}} />`);
assert.notOk( assert
exists("button.is-loading"), .dom("button.is-loading")
"it doesn't have class is-loading" .doesNotExist("it doesn't have class is-loading");
); assert
assert.notOk( .dom("button .loading-icon")
exists("button .loading-icon"), .doesNotExist("it doesn't have a spinner showing");
"it doesn't have a spinner showing"
);
assert.notOk(exists("button[disabled]"), "it isn't disabled"); assert.notOk(exists("button[disabled]"), "it isn't disabled");
}); });

View File

@ -12,16 +12,14 @@ module("Integration | Component | group-membership-button", function (hooks) {
await render(hbs`<GroupMembershipButton @model={{this.model}} />`); await render(hbs`<GroupMembershipButton @model={{this.model}} />`);
assert.ok( assert
!exists(".group-index-join"), .dom(".group-index-join")
"can't join group if public_admission is false" .doesNotExist("can't join group if public_admission is false");
);
this.set("model.public_admission", true); this.set("model.public_admission", true);
assert.ok( assert
!exists(".group-index-join"), .dom(".group-index-join")
"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.ok(exists(".group-index-join"), "allowed to join group");
@ -32,16 +30,14 @@ module("Integration | Component | group-membership-button", function (hooks) {
await render(hbs`<GroupMembershipButton @model={{this.model}} />`); await render(hbs`<GroupMembershipButton @model={{this.model}} />`);
assert.ok( assert
!exists(".group-index-leave"), .dom(".group-index-leave")
"can't leave group if public_exit is false" .doesNotExist("can't leave group if public_exit is false");
);
this.set("model.public_exit", true); this.set("model.public_exit", true);
assert.ok( assert
!exists(".group-index-leave"), .dom(".group-index-leave")
"can't leave group if user is not in the group" .doesNotExist("can't leave group if user is not in the group");
);
this.set("model.is_group_user", true); this.set("model.is_group_user", true);
assert.strictEqual( assert.strictEqual(
@ -59,14 +55,14 @@ module("Integration | Component | group-membership-button", function (hooks) {
await render(hbs`<GroupMembershipButton @model={{this.model}} />`); await render(hbs`<GroupMembershipButton @model={{this.model}} />`);
assert.ok( assert
!exists(".group-index-request"), .dom(".group-index-request")
.doesNotExist(
"can't request for membership if user is already in the group" "can't request for membership if user is already in the group"
); );
this.set("model.is_group_user", false); this.set("model.is_group_user", false);
assert.ok( assert
exists(".group-index-request"), .dom(".group-index-request")
"allowed to request for group membership" .exists("allowed to request for group membership");
);
}); });
}); });

View File

@ -32,19 +32,17 @@ module("Integration | Component | search-menu", function (hooks) {
await render(<template><SearchMenu /></template>); await render(<template><SearchMenu /></template>);
assert.ok( assert
exists(".show-advanced-search"), .dom(".show-advanced-search")
"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.notOk(exists(".menu-panel"), "Menu panel is not rendered yet");
await click("#search-term"); await click("#search-term");
assert.ok( assert
exists(".menu-panel .search-menu-initial-options"), .dom(".menu-panel .search-menu-initial-options")
"Menu panel is rendered with initial options" .exists("Menu panel is rendered with initial options");
);
await fillIn("#search-term", "test"); await fillIn("#search-term", "test");
@ -56,10 +54,9 @@ module("Integration | Component | search-menu", function (hooks) {
await triggerKeyEvent("#search-term", "keyup", "Enter"); await triggerKeyEvent("#search-term", "keyup", "Enter");
assert.ok( assert
exists(".search-result-topic"), .dom(".search-result-topic")
"search result is a list of topics" .exists("search result is a list of topics");
);
await triggerKeyEvent("#search-term", "keydown", "Escape"); await triggerKeyEvent("#search-term", "keydown", "Escape");
@ -68,10 +65,9 @@ module("Integration | Component | search-menu", function (hooks) {
await click("#search-term"); await click("#search-term");
await click("#search-term"); await click("#search-term");
assert.ok( assert
exists(".search-result-topic"), .dom(".search-result-topic")
"Clicking the term brought back search results" .exists("Clicking the term brought back search results");
);
}); });
test("clicking outside results hides and blurs input", async function (assert) { test("clicking outside results hides and blurs input", async function (assert) {
@ -91,9 +87,8 @@ module("Integration | Component | search-menu", function (hooks) {
document.body, document.body,
"Clicking outside blurs focus and closes panel" "Clicking outside blurs focus and closes panel"
); );
assert.notOk( assert
exists(".menu-panel .search-menu-initial-options"), .dom(".menu-panel .search-menu-initial-options")
"Menu panel is hidden" .doesNotExist("Menu panel is hidden");
);
}); });
}); });

View File

@ -2,7 +2,7 @@ import { blur, click, 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 { count, exists, query } from "discourse/tests/helpers/qunit-helpers"; import { count, query } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
module("Integration | Component | secret-value-list", function (hooks) { module("Integration | Component | secret-value-list", function (hooks) {
@ -73,10 +73,9 @@ module("Integration | Component | secret-value-list", function (hooks) {
await fillIn(".new-value-input.secret", "keyWithAPipe|Hidden"); await fillIn(".new-value-input.secret", "keyWithAPipe|Hidden");
await click(".add-value-btn"); await click(".add-value-btn");
assert.ok( assert
!exists(".values .value"), .dom(".values .value")
"it doesn't add the value to the list of values" .doesNotExist("it doesn't add the value to the list of values");
);
assert.deepEqual( assert.deepEqual(
this.values, this.values,

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, 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";
const DEFAULT_CONTENT = [ const DEFAULT_CONTENT = [
@ -127,9 +127,8 @@ module("Integration | Component | select-kit/multi-select", function (hooks) {
`); `);
await this.subject.expand(); await this.subject.expand();
assert.notOk( assert
exists(".selected-content"), .dom(".selected-content")
"it doesnt render an empty content div" .doesNotExist("it doesnt render an empty content div");
);
}); });
}); });

View File

@ -19,10 +19,9 @@ module("Integration | Component | sidebar | section", function (hooks) {
this.headerActions = []; this.headerActions = [];
await render(template); await render(template);
assert.ok( assert
exists(".sidebar-section-wrapper"), .dom(".sidebar-section-wrapper")
"section is displayed by default if no display arg is provided" .exists("section is displayed by default if no display arg is provided");
);
}); });
test("displaySection is dynamic based on argument", async function (assert) { test("displaySection is dynamic based on argument", async function (assert) {
@ -39,10 +38,9 @@ module("Integration | Component | sidebar | section", function (hooks) {
this.headerActions = []; this.headerActions = [];
await render(template); await render(template);
assert.notOk( assert
exists(".sidebar-section-wrapper"), .dom(".sidebar-section-wrapper")
"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.ok(exists(".sidebar-section-wrapper"), "section is displayed");
@ -65,9 +63,8 @@ module("Integration | Component | sidebar | section", function (hooks) {
await click(".sidebar-section-header-caret"); await click(".sidebar-section-header-caret");
assert.notOk( assert
exists(".sidebar-section-content"), .dom(".sidebar-section-content")
"does not show content after collapsing" .doesNotExist("does not show content after collapsing");
);
}); });
}); });

View File

@ -8,7 +8,7 @@ import {
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, query } from "discourse/tests/helpers/qunit-helpers"; import { count, query } from "discourse/tests/helpers/qunit-helpers";
module("Integration | Component | simple-list", function (hooks) { module("Integration | Component | simple-list", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -18,10 +18,9 @@ module("Integration | Component | simple-list", function (hooks) {
await render(hbs`<SimpleList @values={{this.values}} />`); await render(hbs`<SimpleList @values={{this.values}} />`);
assert.ok( assert
exists(".add-value-btn[disabled]"), .dom(".add-value-btn[disabled]")
"while loading the + button is disabled" .exists("while loading the + button is disabled");
);
await fillIn(".add-value-input", "penar"); await fillIn(".add-value-input", "penar");
await click(".add-value-btn"); await click(".add-value-btn");

View File

@ -54,9 +54,8 @@ module("Integration | Component | slow-mode-info", function (hooks) {
hbs`<SlowModeInfo @topic={{this.topic}} @user={{this.user}} />` hbs`<SlowModeInfo @topic={{this.topic}} @user={{this.user}} />`
); );
assert.ok( assert
!exists(".slow-mode-remove"), .dom(".slow-mode-remove")
"it doesn't let you disable slow mode" .doesNotExist("it doesn't let you disable slow mode");
);
}); });
}); });

View File

@ -4,7 +4,6 @@ import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { import {
count, count,
exists,
publishToMessageBus, publishToMessageBus,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -14,10 +13,9 @@ module("Integration | Component | software-update-prompt", function (hooks) {
test("software-update-prompt gets correct CSS class after messageBus message", async function (assert) { test("software-update-prompt gets correct CSS class after messageBus message", async function (assert) {
await render(hbs`{{software-update-prompt}}`); await render(hbs`{{software-update-prompt}}`);
assert.ok( assert
!exists("div.software-update-prompt"), .dom("div.software-update-prompt")
"it does not have the class to show the prompt" .doesNotExist("it does not have the class to show the prompt");
);
await publishToMessageBus("/global/asset-version", "somenewversion"); await publishToMessageBus("/global/asset-version", "somenewversion");

View File

@ -56,8 +56,9 @@ module("Integration | Component | themes-list", function (hooks) {
"components tab is not active" "components tab is not active"
); );
assert.notOk( assert
exists(".inactive-indicator"), .dom(".inactive-indicator")
.doesNotExist(
"there is no inactive themes separator when all themes are inactive" "there is no inactive themes separator when all themes are inactive"
); );
assert.strictEqual( assert.strictEqual(
@ -85,8 +86,9 @@ module("Integration | Component | themes-list", function (hooks) {
this.themes.forEach((theme) => theme.set("user_selectable", true)); this.themes.forEach((theme) => theme.set("user_selectable", true));
this.set("themes", this.themes); this.set("themes", this.themes);
assert.notOk( assert
exists(".inactive-indicator"), .dom(".inactive-indicator")
.doesNotExist(
"there is no inactive themes separator when all themes are user-selectable" "there is no inactive themes separator when all themes are user-selectable"
); );
@ -167,10 +169,9 @@ module("Integration | Component | themes-list", function (hooks) {
hbs`<ThemesList @themes={{this.themes}} @components={{(array)}} @currentTab={{this.currentTab}} />` hbs`<ThemesList @themes={{this.themes}} @components={{(array)}} @currentTab={{this.currentTab}} />`
); );
assert.ok( assert
!exists(".themes-list-search"), .dom(".themes-list-search")
"search input not shown when we have fewer than 10 themes" .doesNotExist("search input not shown when we have fewer than 10 themes");
);
}); });
test("themes search keeps themes whose names include the search term", async function (assert) { test("themes search keeps themes whose names include the search term", async function (assert) {

View File

@ -72,10 +72,9 @@ module("Integration | Component | time-shortcut-picker", function (hooks) {
await render(hbs`<TimeShortcutPicker @_itsatrap={{this.itsatrap}} />`); await render(hbs`<TimeShortcutPicker @_itsatrap={{this.itsatrap}} />`);
assert.notOk( assert
exists("#tap_tile_later_this_week"), .dom("#tap_tile_later_this_week")
"it does not have later this week" .doesNotExist("it does not have later this week");
);
}); });
test("does not show 'Later Today' if 'Later Today' is tomorrow", async function (assert) { test("does not show 'Later Today' if 'Later Today' is tomorrow", async function (assert) {
@ -87,10 +86,9 @@ module("Integration | Component | time-shortcut-picker", function (hooks) {
await render(hbs`<TimeShortcutPicker @_itsatrap={{this.itsatrap}} />`); await render(hbs`<TimeShortcutPicker @_itsatrap={{this.itsatrap}} />`);
assert.notOk( assert
exists("#tap_tile_later_today"), .dom("#tap_tile_later_today")
"it does not have later today" .doesNotExist("it does not have later today");
);
}); });
test("shows 'Later Today' if it is before 5pm", async function (assert) { test("shows 'Later Today' if it is before 5pm", async function (assert) {
@ -114,10 +112,9 @@ module("Integration | Component | time-shortcut-picker", function (hooks) {
await render(hbs`<TimeShortcutPicker @_itsatrap={{this.itsatrap}} />`); await render(hbs`<TimeShortcutPicker @_itsatrap={{this.itsatrap}} />`);
assert.notOk( assert
exists("#tap_tile_later_today"), .dom("#tap_tile_later_today")
"it does not have later today" .doesNotExist("it does not have later today");
);
}); });
test("default custom date time is in one hour from now", async function (assert) { test("default custom date time is in one hour from now", async function (assert) {

View File

@ -24,10 +24,9 @@ module("Integration | Component | uppy-image-uploader", function (hooks) {
"it displays the trash icon" "it displays the trash icon"
); );
assert.ok( assert
!exists(".placeholder-overlay"), .dom(".placeholder-overlay")
"it does not display the placeholder image" .doesNotExist("it does not display the placeholder image");
);
await click(".image-uploader-lightbox-btn"); await click(".image-uploader-lightbox-btn");
@ -49,10 +48,9 @@ module("Integration | Component | uppy-image-uploader", function (hooks) {
assert.ok(!exists(".d-icon-trash-can"), "it does not display trash icon"); assert.ok(!exists(".d-icon-trash-can"), "it does not display trash icon");
assert.ok( assert
!exists(".image-uploader-lightbox-btn"), .dom(".image-uploader-lightbox-btn")
"it does not display the button to open image lightbox" .doesNotExist("it does not display the button to open image lightbox");
);
}); });
test("with placeholder", async function (assert) { test("with placeholder", async function (assert) {
@ -68,10 +66,9 @@ module("Integration | Component | uppy-image-uploader", function (hooks) {
assert.ok(!exists(".d-icon-trash-can"), "it does not display trash icon"); assert.ok(!exists(".d-icon-trash-can"), "it does not display trash icon");
assert.ok( assert
!exists(".image-uploader-lightbox-btn"), .dom(".image-uploader-lightbox-btn")
"it does not display the button to open image lightbox" .doesNotExist("it does not display the button to open image lightbox");
);
assert.strictEqual( assert.strictEqual(
count(".placeholder-overlay"), count(".placeholder-overlay"),

View File

@ -5,7 +5,7 @@ import { NOTIFICATION_TYPES } from "discourse/tests/fixtures/concerns/notificati
import UserMenuFixtures from "discourse/tests/fixtures/user-menu"; import UserMenuFixtures from "discourse/tests/fixtures/user-menu";
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, deepMerge } from "discourse-common/lib/object"; import { cloneJSON, deepMerge } from "discourse-common/lib/object";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -282,8 +282,9 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
this.currentUser.set("grouped_unread_notifications", {}); this.currentUser.set("grouped_unread_notifications", {});
await settled(); await settled();
assert.notOk( assert
exists(".panel-body-bottom .notifications-dismiss"), .dom(".panel-body-bottom .notifications-dismiss")
.doesNotExist(
"dismiss button is not shown if the user no unread private_message notifications" "dismiss button is not shown if the user no unread private_message notifications"
); );
}); });
@ -302,10 +303,9 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
I18n.t("user.no_messages_title"), I18n.t("user.no_messages_title"),
"empty state title is shown" "empty state title is shown"
); );
assert.ok( assert
exists(".empty-state-body svg.d-icon-envelope"), .dom(".empty-state-body svg.d-icon-envelope")
"icon is correctly rendered in the empty state body" .exists("icon is correctly rendered in the empty state body");
);
const emptyStateBodyLink = query(".empty-state-body a"); const emptyStateBodyLink = query(".empty-state-body a");
assert.ok( assert.ok(
emptyStateBodyLink.href.endsWith("/about"), emptyStateBodyLink.href.endsWith("/about"),

View File

@ -13,10 +13,9 @@ module("Integration | Component | Widget | button", function (hooks) {
await render(hbs`<MountWidget @widget="button" @args={{this.args}} />`); await render(hbs`<MountWidget @widget="button" @args={{this.args}} />`);
assert.ok(exists("button.btn.btn-icon.no-text"), "it has all the classes"); assert.ok(exists("button.btn.btn-icon.no-text"), "it has all the classes");
assert.ok( assert
exists("button .d-icon.d-icon-far-face-smile"), .dom("button .d-icon.d-icon-far-face-smile")
"it has the icon" .exists("it has the icon");
);
}); });
test("icon and text button", async function (assert) { test("icon and text button", async function (assert) {

View File

@ -173,10 +173,9 @@ module("Integration | Component | Widget | post-menu", function (hooks) {
await render(hbs`<MountWidget @widget="post-menu" @args={{this.args}} />`); await render(hbs`<MountWidget @widget="post-menu" @args={{this.args}} />`);
assert.ok( assert
!exists("h1.post-menu-replacement"), .dom("h1.post-menu-replacement")
"replacement is not rendered" .doesNotExist("replacement is not rendered");
);
assert.ok(exists(".actions .reply"), "reply button is present"); assert.ok(exists(".actions .reply"), "reply button is present");
}); });
}); });

View File

@ -222,10 +222,9 @@ module("Integration | Component | Widget | post", function (hooks) {
await render(hbs`<MountWidget @widget="post" @args={{this.args}} />`); await render(hbs`<MountWidget @widget="post" @args={{this.args}} />`);
assert.ok( assert
exists(".actions button.post-action-menu__copy-link"), .dom(".actions button.post-action-menu__copy-link")
"it renders a copy link button" .exists("it renders a copy link button");
);
}); });
test("liking", async function (assert) { test("liking", async function (assert) {

View File

@ -55,10 +55,9 @@ module("Integration | Component | Widget | topic-status", function (hooks) {
); );
assert.ok(exists(".topic-statuses .pinned"), "pinned icon is shown"); assert.ok(exists(".topic-statuses .pinned"), "pinned icon is shown");
assert.ok( assert
!exists(".topic-statuses .unpinned"), .dom(".topic-statuses .unpinned")
"unpinned icon is not shown" .doesNotExist("unpinned icon is not shown");
);
await click(".topic-statuses .pin-toggle-button"); await click(".topic-statuses .pin-toggle-button");
@ -68,9 +67,8 @@ module("Integration | Component | Widget | topic-status", function (hooks) {
await click(".topic-statuses .pin-toggle-button"); await click(".topic-statuses .pin-toggle-button");
assert.ok(exists(".topic-statuses .pinned"), "pinned icon is shown"); assert.ok(exists(".topic-statuses .pinned"), "pinned icon is shown");
assert.ok( assert
!exists(".topic-statuses .unpinned"), .dom(".topic-statuses .unpinned")
"unpinned icon is not shown" .doesNotExist("unpinned icon is not shown");
);
}); });
}); });

View File

@ -2,7 +2,6 @@ import { click, fillIn, settled, visit } from "@ember/test-helpers";
import { skip } from "qunit"; import { skip } from "qunit";
import { import {
acceptance, acceptance,
exists,
publishToMessageBus, publishToMessageBus,
query, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -100,10 +99,9 @@ acceptance("Discourse Chat - Composer - unreliable network", function (needs) {
await fillIn(".chat-composer__input", "network-error-message"); await fillIn(".chat-composer__input", "network-error-message");
await click(".chat-composer-button.-send"); await click(".chat-composer-button.-send");
assert.ok( assert
exists(".chat-message-container[data-id='1'] .retry-staged-message-btn"), .dom(".chat-message-container[data-id='1'] .retry-staged-message-btn")
"it adds a retry button" .exists("it adds a retry button");
);
await fillIn(".chat-composer__input", "network-error-message"); await fillIn(".chat-composer__input", "network-error-message");
await click(".chat-composer-button.-send"); await click(".chat-composer-button.-send");
@ -117,14 +115,12 @@ acceptance("Discourse Chat - Composer - unreliable network", function (needs) {
}, },
}); });
assert.notOk( assert
exists(".chat-message-container[data-id='1'] .retry-staged-message-btn"), .dom(".chat-message-container[data-id='1'] .retry-staged-message-btn")
"it removes the staged message" .doesNotExist("it removes the staged message");
); assert
assert.ok( .dom(".chat-message-container[data-id='175']")
exists(".chat-message-container[data-id='175']"), .exists("it sends the message");
"it sends the message"
);
assert.strictEqual( assert.strictEqual(
query(".chat-composer__input").value, query(".chat-composer__input").value,
"", "",
@ -137,9 +133,8 @@ acceptance("Discourse Chat - Composer - unreliable network", function (needs) {
this.chatService.set("isNetworkUnreliable", true); this.chatService.set("isNetworkUnreliable", true);
await settled(); await settled();
assert.ok( assert
exists(".chat-composer__unreliable-network"), .dom(".chat-composer__unreliable-network")
"it displays a network error icon" .exists("it displays a network error icon");
);
}); });
}); });

View File

@ -134,7 +134,6 @@ acceptance("Discourse Chat - Chat live pane collapse", function (needs) {
}); });
skip("lightbox shows up before and after expand and collapse", async function (assert) { skip("lightbox shows up before and after expand and collapse", async function (assert) {
const lightboxImage = ".mfp-img";
const image = ".chat-message-container[data-id='2'] .chat-img-upload"; const image = ".chat-message-container[data-id='2'] .chat-img-upload";
const expandImage = const expandImage =
".chat-message-container[data-id='2'] .chat-message-collapser-closed"; ".chat-message-container[data-id='2'] .chat-message-collapser-closed";
@ -145,20 +144,14 @@ acceptance("Discourse Chat - Chat live pane collapse", function (needs) {
await click(image); await click(image);
assert.ok( assert.dom(".mfp-img").exists("can see lightbox");
exists(document.querySelector(lightboxImage)), await click(".mfp-container");
"can see lightbox"
);
await click(document.querySelector(".mfp-container"));
await click(collapseImage); await click(collapseImage);
await click(expandImage); await click(expandImage);
await click(image); await click(image);
assert.ok( assert.dom(".mfp-img").exists("can see lightbox after collapse expand");
exists(document.querySelector(lightboxImage)), await click(".mfp-container");
"can see lightbox after collapse expand"
);
await click(document.querySelector(".mfp-container"));
}); });
}); });

View File

@ -155,10 +155,9 @@ acceptance("Discourse Presence Plugin", function (needs) {
const avatarSelector = const avatarSelector =
".topic-above-footer-buttons-outlet.presence .presence-avatars .avatar"; ".topic-above-footer-buttons-outlet.presence .presence-avatars .avatar";
assert.ok( assert
exists(".topic-above-footer-buttons-outlet.presence"), .dom(".topic-above-footer-buttons-outlet.presence")
"includes the presence component" .exists("includes the presence component");
);
assert.strictEqual(count(avatarSelector), 0, "no avatars displayed"); assert.strictEqual(count(avatarSelector), 0, "no avatars displayed");
await joinChannel("/discourse-presence/reply/280", { await joinChannel("/discourse-presence/reply/280", {

View File

@ -2,7 +2,6 @@ import { test } from "qunit";
import { AUTO_GROUPS } from "discourse/lib/constants"; import { AUTO_GROUPS } from "discourse/lib/constants";
import { import {
acceptance, acceptance,
exists,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { displayPollBuilderButton } from "discourse/plugins/poll/helpers/display-poll-builder-button"; import { displayPollBuilderButton } from "discourse/plugins/poll/helpers/display-poll-builder-button";
@ -24,10 +23,9 @@ acceptance("Poll Builder - polls are disabled", function (needs) {
await displayPollBuilderButton(); await displayPollBuilderButton();
assert.ok( assert
!exists(".select-kit-row[data-value='showPollBuilder']"), .dom(".select-kit-row[data-value='showPollBuilder']")
"it hides the builder button" .doesNotExist("it hides the builder button");
);
}); });
test("regular user - insufficient permissions", async function (assert) { test("regular user - insufficient permissions", async function (assert) {
@ -40,10 +38,9 @@ acceptance("Poll Builder - polls are disabled", function (needs) {
await displayPollBuilderButton(); await displayPollBuilderButton();
assert.ok( assert
!exists(".select-kit-row[data-value='showPollBuilder']"), .dom(".select-kit-row[data-value='showPollBuilder']")
"it hides the builder button" .doesNotExist("it hides the builder button");
);
}); });
test("staff", async function (assert) { test("staff", async function (assert) {
@ -51,9 +48,8 @@ acceptance("Poll Builder - polls are disabled", function (needs) {
await displayPollBuilderButton(); await displayPollBuilderButton();
assert.ok( assert
!exists(".select-kit-row[data-value='showPollBuilder']"), .dom(".select-kit-row[data-value='showPollBuilder']")
"it hides the builder button" .doesNotExist("it hides the builder button");
);
}); });
}); });

View File

@ -64,10 +64,9 @@ acceptance("Poll Builder - polls are enabled", function (needs) {
await displayPollBuilderButton(); await displayPollBuilderButton();
assert.ok( assert
!exists(".select-kit-row[data-value='showPollBuilder]"), .dom(".select-kit-row[data-value='showPollBuilder']")
"it hides the builder button" .doesNotExist("hides the builder button");
);
}); });
test("staff - with insufficient trust level", async function (assert) { test("staff - with insufficient trust level", async function (assert) {