1
0
mirror of https://github.com/discourse/discourse.git synced 2025-03-15 11:01:14 +00:00

DEV: Fix no-loose-assertions lint ()

and enable some of qunit lints
This commit is contained in:
Jarek Radosz
2024-11-28 11:22:27 +01:00
committed by GitHub
parent 1f538a81a8
commit ef7518d4ad
112 changed files with 1140 additions and 1264 deletions
app/assets/javascripts/discourse/tests
acceptance
integration/components
unit
eslint.config.mjs
plugins

@ -1,7 +1,7 @@
import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
const EMAIL = `
From: "somebody" <somebody@example.com>
@ -48,11 +48,10 @@ acceptance("Admin - Emails", function (needs) {
await fillIn(".admin-controls input", "test@example.com");
await click(".btn-primary");
assert.ok(query("#dialog-holder").innerText.includes("some error"));
assert.ok(
query("#dialog-holder .dialog-body b"),
"Error message can contain html"
);
assert.dom("#dialog-holder").includesText("some error");
assert
.dom("#dialog-holder .dialog-body b")
.exists("Error message can contain html");
await click(".dialog-overlay");
});
});

@ -5,6 +5,7 @@ import { i18n } from "discourse-i18n";
acceptance("Admin - Themes - Install modal", function (needs) {
needs.user();
test("closing the modal resets the modal inputs", async function (assert) {
const urlInput = ".install-theme-content .repo input";
const branchInput = ".install-theme-content .branch input";
@ -24,7 +25,7 @@ acceptance("Admin - Themes - Install modal", function (needs) {
"tests-passed",
"branch input is filled"
);
assert.ok(query(publicKey), "shows public key");
assert.dom(publicKey).exists("shows public key");
await click(".d-modal__footer .d-modal-cancel");
@ -33,7 +34,7 @@ acceptance("Admin - Themes - Install modal", function (needs) {
await click(".install-theme-content .inputs .advanced-repo");
assert.dom(urlInput).hasValue("", "url input is reset");
assert.dom(branchInput).hasValue("", "branch input is reset");
assert.notOk(query(publicKey), "hide public key");
assert.dom(publicKey).doesNotExist("hide public key");
});
test("show public key for valid ssh theme urls", async function (assert) {
@ -50,34 +51,35 @@ acceptance("Admin - Themes - Install modal", function (needs) {
await fillIn(urlInput, themeUrl);
await click(".install-theme-content .inputs .advanced-repo");
assert.dom(urlInput).hasValue(themeUrl, "url input is filled");
assert.ok(query(publicKey), "shows public key");
assert.dom(publicKey).exists("shows public key");
// Supports AWS CodeCommit style repo URLs
await fillIn(
urlInput,
"ssh://someID@git-codecommit.us-west-2.amazonaws.com/v1/repos/test-repo.git"
);
assert.ok(query(publicKey), "shows public key");
assert.dom(publicKey).exists("shows public key");
await fillIn(urlInput, "https://github.com/discourse/discourse.git");
assert.notOk(query(publicKey), "does not show public key for https urls");
assert
.dom(publicKey)
.doesNotExist("does not show public key for https urls");
await fillIn(urlInput, "git@github.com:discourse/discourse.git");
assert.ok(query(publicKey), "shows public key for valid github repo url");
assert.dom(publicKey).exists("shows public key for valid github repo url");
await fillIn(urlInput, "git@github.com:discourse/discourse");
assert.ok(query(publicKey), "shows public key for valid github repo url");
assert.dom(publicKey).exists("shows public key for valid github repo url");
await fillIn(urlInput, "git@github.com/discourse/discourse");
assert.notOk(
query(publicKey),
"does not shows public key for valid github repo url"
);
assert
.dom(publicKey)
.doesNotExist("does not shows public key for valid github repo url");
});
test("modal can be auto-opened with the right query params", async function (assert) {
await visit("/admin/customize/themes?repoUrl=testUrl&repoName=testName");
assert.ok(query(".admin-install-theme-modal"), "modal is visible");
assert.dom(".admin-install-theme-modal").exists("modal is visible");
assert.strictEqual(
query(".install-theme code").textContent.trim(),
"testUrl",
@ -96,12 +98,11 @@ acceptance("Admin - Themes - Install modal", function (needs) {
await visit("/admin/customize/themes");
await click(".create-actions .btn-primary");
assert.notOk(
query(
assert
.dom(
'.popular-theme-item[data-name="Graceful"] .popular-theme-buttons button'
),
"no install button is shown for installed themes"
);
)
.doesNotExist("no install button is shown for installed themes");
assert.strictEqual(
query(
'.popular-theme-item[data-name="Graceful"] .popular-theme-buttons'
@ -109,11 +110,10 @@ acceptance("Admin - Themes - Install modal", function (needs) {
i18n("admin.customize.theme.installed")
);
assert.ok(
query(
assert
.dom(
'.popular-theme-item[data-name="Mint"] .popular-theme-buttons button'
),
"install button is shown for not installed themes"
);
)
.exists("install button is shown for not installed themes");
});
});

@ -6,7 +6,7 @@ import selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from "discourse-i18n";
const { TOTP, BACKUP_CODE, SECURITY_KEY } = SECOND_FACTOR_METHODS;
let deleteAndBlock = null;
let deleteAndBlock;
acceptance("Admin - User Index", function (needs) {
needs.user();
@ -129,11 +129,7 @@ acceptance("Admin - User Index", function (needs) {
server.delete("/admin/users/5.json", (request) => {
const data = helper.parsePostData(request.requestBody);
if (data.block_email || data.block_ip || data.block_urls) {
deleteAndBlock = true;
} else {
deleteAndBlock = false;
}
deleteAndBlock = !!(data.block_email || data.block_ip || data.block_urls);
return helper.response({});
});
@ -307,6 +303,6 @@ acceptance("Admin - User Index", function (needs) {
await click(".btn-user-delete");
await click(".dialog-footer .btn-danger");
assert.ok(deleteAndBlock, "user does not get blocked");
assert.true(deleteAndBlock, "user does not get blocked");
});
});

@ -32,23 +32,17 @@ acceptance("Admin - Users List", function (needs) {
".users-list .directory-table__column-header--username.sortable"
);
assert.ok(
query(".users-list .user:nth-child(1) .username").innerText.includes(
"eviltrout"
),
"list should be sorted by username"
);
assert
.dom(".users-list .user:nth-child(1) .username")
.includesText("eviltrout", "list should be sorted by username");
await click(
".users-list .directory-table__column-header--username.sortable"
);
assert.ok(
query(".users-list .user:nth-child(1) .username").innerText.includes(
"discobot"
),
"list should be sorted ascending by username"
);
assert
.dom(".users-list .user:nth-child(1) .username")
.includesText("discobot", "list should be sorted ascending by username");
});
test("toggles email visibility", async function (assert) {
@ -81,37 +75,29 @@ acceptance("Admin - Users List", function (needs) {
await visit("/admin/users/list/active");
assert.dom(".admin-title h2").hasText(activeTitle);
assert.ok(
query(".users-list .user:nth-child(1) .username").innerText.includes(
activeUser
)
);
assert
.dom(".users-list .user:nth-child(1) .username")
.includesText(activeUser);
await click('a[href="/admin/users/list/new"]');
assert.dom(".admin-title h2").hasText(suspectTitle);
assert.ok(
query(".users-list .user:nth-child(1) .username").innerText.includes(
suspectUser
)
);
assert
.dom(".users-list .user:nth-child(1) .username")
.includesText(suspectUser);
await click(".users-list .sortable:nth-child(4)");
assert.dom(".admin-title h2").hasText(suspectTitle);
assert.ok(
query(".users-list .user:nth-child(1) .username").innerText.includes(
suspectUser
)
);
assert
.dom(".users-list .user:nth-child(1) .username")
.includesText(suspectUser);
await click('a[href="/admin/users/list/active"]');
assert.dom(".admin-title h2").hasText(activeTitle);
assert.ok(
query(".users-list .user:nth-child(1) .username").innerText.includes(
activeUser
)
);
assert
.dom(".users-list .user:nth-child(1) .username")
.includesText(activeUser);
});
});

@ -35,7 +35,7 @@ acceptance("Category Edit - Security", function (needs) {
await click(".row-body .remove-permission");
await availableGroups.expand();
assert.ok(
assert.true(
availableGroups.rowByValue("everyone").exists(),
"everyone has been removed and appears in the available groups"
);

@ -18,7 +18,7 @@ acceptance("Category Edit", function (needs) {
assert.strictEqual(
currentURL(),
"/c/bug/edit/general",
"it jumps to the correct screen"
"jumps to the correct screen"
);
assert.dom(".category-breadcrumb .badge-category").hasText("bug");
@ -35,7 +35,7 @@ acceptance("Category Edit", function (needs) {
assert.strictEqual(
currentURL(),
"/c/bug/edit/general",
"it stays on the edit screen"
"stays on the edit screen"
);
await visit("/c/bug/edit/settings");
@ -47,13 +47,13 @@ acceptance("Category Edit", function (needs) {
assert.strictEqual(
currentURL(),
"/c/bug/edit/settings",
"it stays on the edit screen"
"stays on the edit screen"
);
sinon.stub(DiscourseURL, "routeTo");
await click(".edit-category-security a");
assert.ok(
assert.true(
DiscourseURL.routeTo.calledWith("/c/bug/edit/security"),
"tab routing works"
);
@ -141,8 +141,8 @@ acceptance("Category Edit", function (needs) {
await categoryChooser.expand();
const names = [...categoryChooser.rows()].map((row) => row.dataset.name);
assert.ok(names.includes("(no category)"));
assert.notOk(names.includes("Uncategorized"));
assert.true(names.includes("(no category)"));
assert.false(names.includes("Uncategorized"));
});
test("Editing parent category (enabled Uncategorized)", async function (assert) {
@ -156,8 +156,8 @@ acceptance("Category Edit", function (needs) {
await categoryChooser.expand();
const names = [...categoryChooser.rows()].map((row) => row.dataset.name);
assert.ok(names.includes("(no category)"));
assert.notOk(names.includes("Uncategorized"));
assert.true(names.includes("(no category)"));
assert.false(names.includes("Uncategorized"));
});
test("Index Route", async function (assert) {
@ -165,7 +165,7 @@ acceptance("Category Edit", function (needs) {
assert.strictEqual(
currentURL(),
"/c/bug/edit/general",
"it redirects to the general tab"
"redirects to the general tab"
);
});
@ -174,7 +174,7 @@ acceptance("Category Edit", function (needs) {
assert.strictEqual(
currentURL(),
"/c/1-category/edit/general",
"it goes to the general tab"
"goes to the general tab"
);
assert.dom("input.category-name").hasValue("bug");
});

@ -92,7 +92,7 @@ acceptance("Category New", function (needs) {
sinon.stub(DiscourseURL, "routeTo");
await click(".category-back");
assert.ok(
assert.true(
DiscourseURL.routeTo.calledWith("/c/testing/11"),
"back routing works"
);

@ -128,7 +128,7 @@ acceptance("Composer Actions", function (needs) {
assert.strictEqual(categoryChooserReplyArea.header().name(), "faq");
assert.dom(".action-title").hasText(i18n("topic.create_long"));
assert.ok(query(".d-editor-input").value.includes(quote));
assert.true(query(".d-editor-input").value.includes(quote));
});
test("reply_as_new_topic without a new_topic draft", async function (assert) {
@ -211,7 +211,7 @@ acceptance("Composer Actions", function (needs) {
await composerActions.expand();
assert.dom(".action-title").hasText(i18n("topic.create_long"));
assert.ok(query(".d-editor-input").value.includes(quote));
assert.true(query(".d-editor-input").value.includes(quote));
assert.strictEqual(composerActions.rowByIndex(0).value(), "reply_to_post");
assert.strictEqual(composerActions.rowByIndex(1).value(), "reply_to_topic");
assert.strictEqual(composerActions.rowByIndex(2).value(), "shared_draft");
@ -437,7 +437,7 @@ acceptance("Composer Actions With New Topic Draft", function (needs) {
.hasText(i18n("composer.composer_actions.reply_as_new_topic.confirm"));
await click(".dialog-footer .btn-primary");
assert.ok(
assert.true(
query(".d-editor-input").value.startsWith(
"Continuing the discussion from"
)

@ -73,12 +73,13 @@ and a second group of images
);
// Second group of images is in paragraph 2
assert.ok(
query(
".d-editor-preview p:nth-child(2) .wrap-image-grid-button[data-image-count='3']"
),
"Grid button has correct image count"
);
assert
.dom(".d-editor-preview p:nth-child(2) .wrap-image-grid-button")
.hasAttribute(
"data-image-count",
"3",
"Grid button has correct image count"
);
await click(".d-editor-preview p:nth-child(2) .wrap-image-grid-button");
@ -107,12 +108,13 @@ and a second group of images
await click("#create-topic");
await fillIn(".d-editor-input", uploads.join("\n"));
assert.ok(
query(
".image-wrapper:first-child .wrap-image-grid-button[data-image-count='2']"
),
"Grid button has correct image count"
);
assert
.dom(".image-wrapper:first-child .wrap-image-grid-button")
.hasAttribute(
"data-image-count",
"2",
"Grid button has correct image count"
);
await click(
".button-wrapper[data-image-index='0'] .wrap-image-grid-button"
@ -127,10 +129,13 @@ and a second group of images
await fillIn(".d-editor-input", `[grid]\n${uploads[0]}\n[/grid]`);
assert.ok(
query(".d-editor-preview .d-image-grid[data-disabled]"),
"Grid is disabled when there is only one image"
);
assert
.dom(".d-editor-preview .d-image-grid")
.hasAttribute(
"data-disabled",
"true",
"Grid is disabled when there is only one image"
);
await fillIn(
".d-editor-input",

@ -175,10 +175,10 @@ acceptance("Composer", function (needs) {
await click("#reply-control button.create");
assert
.dom(".title-input .popup-tip.bad")
.exists("it shows the empty title error");
.exists("shows the empty title error");
assert
.dom(".d-editor-textarea-wrapper .popup-tip.bad")
.exists("it shows the empty body error");
.exists("shows the empty body error");
await fillIn("#reply-title", "this is my new topic title");
assert
@ -215,7 +215,7 @@ acceptance("Composer", function (needs) {
assert.strictEqual(
query("#reply-control .d-editor-input").value.trim(),
`this is the *content* of a post**${example}**`,
"it supports keyboard shortcuts"
"supports keyboard shortcuts"
);
await click("#reply-control a.cancel");
@ -256,7 +256,7 @@ acceptance("Composer", function (needs) {
assert.strictEqual(
currentURL(),
"/t/internationalization-localization/280",
"it transitions to the newly created topic URL"
"transitions to the newly created topic URL"
);
});
@ -278,7 +278,7 @@ acceptance("Composer", function (needs) {
await fillIn(".d-editor-input", "enqueue this content please");
await click("#reply-control button.create");
assert.dom(".d-modal").exists("pops up a modal");
assert.strictEqual(currentURL(), "/", "it doesn't change routes");
assert.strictEqual(currentURL(), "/", "doesn't change routes");
await click(".d-modal__footer button");
assert.dom(".d-modal").doesNotExist("the modal can be dismissed");
@ -294,7 +294,7 @@ acceptance("Composer", function (needs) {
assert
.dom("#dialog-holder .dialog-body")
.hasText("This is a custom response");
assert.strictEqual(currentURL(), "/", "it doesn't change routes");
assert.strictEqual(currentURL(), "/", "doesn't change routes");
await click(".dialog-footer .btn-primary");
assert.strictEqual(
@ -417,22 +417,20 @@ acceptance("Composer", function (needs) {
await fillIn(".d-editor-input", "this is the content of the first reply");
await visit("/t/this-is-a-test-topic/9");
assert.ok(
assert.true(
currentURL().startsWith("/t/this-is-a-test-topic/9"),
"moves to second topic"
);
await click("#topic-footer-buttons .btn.create");
assert
.dom(".discard-draft-modal.modal")
.exists("it pops up the discard drafts modal");
.exists("pops up the discard drafts modal");
await click(".d-modal__footer button.keep-editing");
assert.dom(".discard-draft-modal.modal").doesNotExist("hides modal");
await click("#topic-footer-buttons .btn.create");
assert
.dom(".discard-draft-modal.modal")
.exists("it pops up the modal again");
assert.dom(".discard-draft-modal.modal").exists("pops up the modal again");
await click(".d-modal__footer button.discard-draft");
@ -484,13 +482,13 @@ acceptance("Composer", function (needs) {
assert
.dom(".topic-post:nth-of-type(1) .post-info.edits")
.doesNotExist("it has no edits icon at first");
.doesNotExist("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.edit");
assert.ok(
assert.true(
query(".d-editor-input").value.startsWith("Any plans to support"),
"it populates the input with the post text"
"populates the input with the post text"
);
await fillIn(".d-editor-input", "This is the new text for the post");
@ -499,19 +497,16 @@ acceptance("Composer", function (needs) {
assert.dom(".d-editor-input").doesNotExist("closes the composer");
assert
.dom(".topic-post:nth-of-type(1) .post-info.edits")
.exists("it has the edits icon");
assert.ok(
query("#topic-title h1").innerText.includes(
"This is the new text for the title"
),
"it shows the new title"
);
assert.ok(
query(".topic-post:nth-of-type(1) .cooked").innerText.includes(
"This is the new text for the post"
),
"it updates the post"
);
.exists("has the edits icon");
assert
.dom("#topic-title h1")
.includesText(
"This is the new text for the title",
"shows the new title"
);
assert
.dom(".topic-post:nth-of-type(1) .cooked")
.includesText("This is the new text for the post", "updates the post");
});
test("Editing a post stages new content", async function (assert) {
@ -544,14 +539,14 @@ acceptance("Composer", function (needs) {
await visit("/t/this-is-a-test-topic/9");
await click(".topic-post:nth-of-type(1) button.edit");
assert.ok(
assert.true(
query(".d-editor-input").value.startsWith("This is the first post."),
"it populates the input with the post text"
"populates the input with the post text"
);
await click(".topic-post:nth-of-type(2) button.edit");
assert.ok(
assert.true(
query(".d-editor-input").value.startsWith("This is the second post."),
"it populates the input with the post text"
"populates the input with the post text"
);
});
@ -563,12 +558,12 @@ acceptance("Composer", function (needs) {
await click(".topic-post:nth-of-type(2) button.edit");
assert
.dom(".discard-draft-modal.modal")
.exists("it pops up a confirmation dialog");
.exists("pops up a confirmation dialog");
await click(".d-modal__footer button.discard-draft");
assert.ok(
assert.true(
query(".d-editor-input").value.startsWith("This is the second post."),
"it populates the input with the post text"
"populates the input with the post text"
);
});
@ -576,20 +571,16 @@ acceptance("Composer", function (needs) {
await visit("/t/this-is-a-test-topic/9");
await click(".topic-post:nth-of-type(1) button.edit");
assert.ok(
assert.true(
query(".d-editor-input").value.startsWith("This is the first post."),
"it populates the input with the post text"
"populates the input with the post text"
);
await click(".topic-post:nth-of-type(1) button.reply");
assert.strictEqual(
query(".d-editor-input").value,
"",
"it clears the input"
);
assert.strictEqual(query(".d-editor-input").value, "", "clears the input");
await click(".topic-post:nth-of-type(1) button.edit");
assert.ok(
assert.true(
query(".d-editor-input").value.startsWith("This is the first post."),
"it populates the input with the post text"
"populates the input with the post text"
);
});
@ -611,7 +602,7 @@ acceptance("Composer", function (needs) {
assert
.dom(".composer-actions svg.d-icon-far-eye-slash")
.doesNotExist("it removes the whisper mode");
.doesNotExist("removes the whisper mode");
await menu.expand();
await menu.selectRowByName("toggle-whisper");
@ -620,7 +611,7 @@ acceptance("Composer", function (needs) {
await menu.expand();
assert.ok(
assert.true(
menu.rowByName("toggle-whisper").exists(),
"whisper toggling is still present when going fullscreen"
);
@ -702,26 +693,23 @@ acceptance("Composer", function (needs) {
await click("#create-topic");
assert
.dom(".reply-details .whisper .d-icon-far-eye-slash")
.doesNotExist("it should reset the state of the composer's model");
.doesNotExist("should reset the state of the composer's model");
await selectKit(".toolbar-popup-menu-options").expand();
await selectKit(".toolbar-popup-menu-options").selectRowByName(
"toggle-invisible"
);
assert.ok(
query(".reply-details .unlist").innerText.includes(
i18n("composer.unlist")
),
"it sets the topic to unlisted"
);
assert
.dom(".reply-details .unlist")
.includesText(i18n("composer.unlist"), "sets the topic to unlisted");
await visit("/t/this-is-a-test-topic/9");
await click(".topic-post:nth-of-type(1) button.reply");
assert
.dom(".reply-details .whisper")
.doesNotExist("it should reset the state of the composer's model");
.doesNotExist("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) {
@ -760,7 +748,7 @@ acceptance("Composer", function (needs) {
await click(".topic-post:nth-of-type(2) button.edit");
assert
.dom(".discard-draft-modal.modal")
.exists("it pops up a confirmation dialog");
.exists("pops up a confirmation dialog");
assert.dom(".d-modal__footer button.save-draft").doesNotExist();
assert
.dom(".d-modal__footer button.keep-editing")
@ -769,9 +757,9 @@ acceptance("Composer", function (needs) {
"has keep editing button"
);
await click(".d-modal__footer button.discard-draft");
assert.ok(
assert.true(
query(".d-editor-input").value.startsWith("This is the second post."),
"it populates the input with the post text"
"populates the input with the post text"
);
});
@ -786,7 +774,7 @@ acceptance("Composer", function (needs) {
assert
.dom(".discard-draft-modal.modal")
.exists("it pops up a confirmation dialog");
.exists("pops up a confirmation dialog");
assert
.dom(".d-modal__footer button.save-draft")
.hasText(
@ -803,7 +791,7 @@ acceptance("Composer", function (needs) {
assert.strictEqual(
query(".d-editor-input").value,
"",
"it clears the composer input"
"clears the composer input"
);
});
@ -848,7 +836,7 @@ acceptance("Composer", function (needs) {
assert.dom(".d-modal__body").doesNotExist("abandon popup shouldn't come");
assert.ok(
assert.true(
query(".d-editor-input").value.includes(longText),
"entered text should still be there"
);
@ -908,7 +896,7 @@ acceptance("Composer", function (needs) {
.hasAttribute(
"placeholder",
i18n("composer.reply_placeholder"),
"it should not block because of missing category"
"should not block because of missing category"
);
});
@ -1107,10 +1095,9 @@ acceptance("Composer - Error Extensibility", function (needs) {
await fillIn(".d-editor-input", "this is the *content* of a post");
await click("#reply-control button.create");
assert.dom(".dialog-body").exists("pops up an error message");
assert.ok(
query(".dialog-body").innerText.match(/PLUGIN_ABC ERROR/),
"it contains the server side error text"
);
assert
.dom(".dialog-body")
.hasText(/PLUGIN_ABC ERROR/, "contains the server side error text");
await click(".dialog-footer .btn-primary");
assert.dom(".dialog-body").doesNotExist("dismisses the error");
assert.dom(".d-editor-input").exists("the composer input is visible");
@ -1317,11 +1304,11 @@ acceptance("Composer - current time", function (needs) {
shiftKey: true,
});
const inputValue = query("#reply-control .d-editor-input").value.trim();
assert.ok(
inputValue.startsWith(`and the time now is: [date=${date}`),
"it adds the current date"
assert.true(
query("#reply-control .d-editor-input")
.value.trim()
.startsWith(`and the time now is: [date=${date}`),
"adds the current date"
);
});
});
@ -1364,7 +1351,7 @@ acceptance("composer buttons API", function (needs) {
Object.assign({ altKey: true }, metaModifier)
);
assert.strictEqual(editor.value, "hello **the** world", "it adds the bold");
assert.strictEqual(editor.value, "hello **the** world", "adds the bold");
const dropdown = selectKit(".toolbar-popup-menu-options");
await dropdown.expand();
@ -1376,14 +1363,14 @@ acceptance("composer buttons API", function (needs) {
"title",
i18n("some_title") +
` (${translateModKey(PLATFORM_KEY_MODIFIER + "+alt+b")})`,
"it shows the title with shortcut"
"shows the title with shortcut"
);
assert
.dom(row)
.hasText(
i18n("some_label") +
` ${translateModKey(PLATFORM_KEY_MODIFIER + "+alt+b")}`,
"it shows the label with shortcut"
"shows the label with shortcut"
);
});

@ -65,7 +65,7 @@ acceptance("Experimental Lightbox - site setting", function (needs) {
setupPretender(server, helper, singleLargeImageMarkup)
);
test("it does not interfere with Magnific when enable_experimental_lightbox is disabled", async function (assert) {
test("does not interfere with Magnific when enable_experimental_lightbox is disabled", async function (assert) {
await visit("/t/internationalization-localization/280");
await click(SELECTORS.DEFAULT_ITEM_SELECTOR);
@ -82,7 +82,7 @@ acceptance("Experimental Lightbox - layout single image", function (needs) {
setupPretender(server, helper, singleLargeImageMarkup)
);
test("it shows the correct elements for a single-image lightbox", async function (assert) {
test("shows the correct elements for a single-image lightbox", async function (assert) {
await visit("/t/internationalization-localization/280");
await click(SELECTORS.DEFAULT_ITEM_SELECTOR);
@ -137,7 +137,7 @@ acceptance("Experimental Lightbox - layout multiple images", function (needs) {
setupPretender(server, helper, multipleLargeImagesMarkup)
);
test("it shows multiple image controls when there's more than one item", async function (assert) {
test("shows multiple image controls when there's more than one item", async function (assert) {
await visit("/t/internationalization-localization/280");
await click(SELECTORS.DEFAULT_ITEM_SELECTOR);
@ -354,7 +354,7 @@ acceptance("Experimental Lightbox - interaction", function (needs) {
assert.dom(SELECTORS.LIGHTBOX_CONTENT).exists();
assert.ok(
assert.true(
classListAddStub.calledWith("has-lightbox"),
"adds has-lightbox class to document element"
);
@ -363,7 +363,7 @@ acceptance("Experimental Lightbox - interaction", function (needs) {
assert.dom(SELECTORS.LIGHTBOX_CONTENT).doesNotExist();
assert.ok(
assert.true(
classListRemoveStub.calledWith("has-lightbox"),
"removes has-lightbox class from document element"
);
@ -390,13 +390,13 @@ acceptance("Experimental Lightbox - interaction", function (needs) {
await click(SELECTORS.FULL_SCREEN_BUTTON);
assert.dom(SELECTORS.LIGHTBOX_CONTAINER).hasClass("is-fullscreen");
assert.ok(requestFullscreenStub.calledOnce, "it calls requestFullscreen");
assert.true(requestFullscreenStub.calledOnce, "calls requestFullscreen");
await click(SELECTORS.FULL_SCREEN_BUTTON);
assert.dom(SELECTORS.LIGHTBOX_CONTENT).doesNotHaveClass("is-fullscreen");
assert.ok(exitFullscreenStub.calledOnce, "it calls exitFullscreen");
assert.true(exitFullscreenStub.calledOnce, "calls exitFullscreen");
await click(SELECTORS.CLOSE_BUTTON);
@ -418,7 +418,7 @@ acceptance("Experimental Lightbox - interaction", function (needs) {
// appends and clicks <a download="..." href="..."></a>
await click(SELECTORS.DOWNLOAD_BUTTON);
assert.ok(clickStub.called, "The click method was called");
assert.true(clickStub.called, "The click method was called");
await click(SELECTORS.CLOSE_BUTTON);
assert.dom(SELECTORS.LIGHTBOX_CONTENT).doesNotExist();
@ -437,7 +437,7 @@ acceptance("Experimental Lightbox - interaction", function (needs) {
await click(SELECTORS.TAB_BUTTON);
assert.ok(openStub.called, "The open method was called");
assert.true(openStub.called, "The open method was called");
await click(SELECTORS.CLOSE_BUTTON);
@ -899,7 +899,7 @@ acceptance("Experimental Lightbox - conditional buttons", function (needs) {
setupPretender(server, helper, singleSmallImageMarkup)
);
test("it doesn't show the newtab and download buttons to anons if prevent_anons_from_downloading_files is enabled", async function (assert) {
test("doesn't show the newtab and download buttons to anons if prevent_anons_from_downloading_files is enabled", async function (assert) {
this.siteSettings.prevent_anons_from_downloading_files = true;
await visit("/t/internationalization-localization/280");
await click(SELECTORS.DEFAULT_ITEM_SELECTOR);
@ -909,7 +909,7 @@ acceptance("Experimental Lightbox - conditional buttons", function (needs) {
assert.dom(SELECTORS.DOWNLOAD_BUTTON).doesNotExist();
});
test("it doesn't show the zoom button if the image is smaller than the viewport", async function (assert) {
test("doesn't show the zoom button if the image is smaller than the viewport", async function (assert) {
await visit("/t/internationalization-localization/280");
await click(SELECTORS.DEFAULT_ITEM_SELECTOR);

@ -10,7 +10,11 @@ acceptance("Acceptance | Globals", function () {
test("Globals function as expected", async function (assert) {
await visit("/");
assert.ok(window.Discourse, "window.Discourse is present");
assert.notStrictEqual(
window.Discourse,
undefined,
"window.Discourse is present"
);
assert.strictEqual(
window.Discourse,

@ -11,10 +11,9 @@ acceptance("Managing Group Email Settings - SMTP Disabled", function (needs) {
test("When SiteSetting.enable_smtp is false", async function (assert) {
await visit("/g/discourse/manage/email");
assert.notOk(
query(".user-secondary-navigation").innerText.includes("Email"),
"email link is not shown in the sidebar"
);
assert
.dom(".user-secondary-navigation")
.doesNotIncludeText("Email", "email link is not shown in the sidebar");
assert.strictEqual(
currentRouteName(),
"group.manage.profile",
@ -31,10 +30,9 @@ acceptance(
test("When SiteSetting.enable_smtp is true but SiteSetting.enable_imap is false", async function (assert) {
await visit("/g/discourse/manage/email");
assert.ok(
query(".user-secondary-navigation").innerText.includes("Email"),
"email link is shown in the sidebar"
);
assert
.dom(".user-secondary-navigation")
.includesText("Email", "email link is shown in the sidebar");
assert.strictEqual(
currentRouteName(),
"group.manage.email",
@ -68,10 +66,9 @@ acceptance(
test("enabling SMTP, testing, and saving", async function (assert) {
await visit("/g/discourse/manage/email");
assert.ok(
query(".user-secondary-navigation").innerText.includes("Email"),
"email link is shown in the sidebar"
);
assert
.dom(".user-secondary-navigation")
.includesText("Email", "email link is shown in the sidebar");
assert
.dom("#enable_imap")
.isDisabled("IMAP is disabled until SMTP settings are valid");
@ -315,14 +312,13 @@ acceptance(
"imap mailbox is prefilled"
);
const regex = /updated: (.*?) by eviltrout/;
assert.dom(".group-email-last-updated-details.for-imap").exists();
assert.ok(
regex.test(
query(".group-email-last-updated-details.for-imap").innerText.trim()
),
"shows last updated imap details"
);
assert
.dom(".group-email-last-updated-details.for-imap")
.hasText(
"Last updated: Jun 16, 2021 by eviltrout",
"shows last updated imap details"
);
});
}
);

@ -1,6 +1,6 @@
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Group Requests", function (needs) {
let requests;
@ -86,50 +86,37 @@ acceptance("Group Requests", function (needs) {
await visit("/g/Macdonald/requests");
assert.dom(".group-members .group-member").exists({ count: 2 });
assert.strictEqual(
query(".group-members .directory-table__row:first-child .user-detail")
.innerText.trim()
.replace(/\s+/g, " "),
"eviltrout Robin Ward"
);
assert.strictEqual(
query(
assert
.dom(".group-members .directory-table__row:first-child .user-detail")
.hasText("eviltrout Robin Ward");
assert
.dom(
".group-members .directory-table__row:first-child .directory-table__cell:nth-child(3)"
).innerText.trim(),
"Please accept my membership request."
);
assert.strictEqual(
query(
".group-members .directory-table__row:first-child .btn-primary"
).innerText.trim(),
"Accept"
);
assert.strictEqual(
query(
".group-members .directory-table__row:first-child .btn-danger"
).innerText.trim(),
"Deny"
);
)
.includesText("Please accept my membership request.");
assert
.dom(".group-members .directory-table__row:first-child .btn-primary")
.hasText("Accept");
assert
.dom(".group-members .directory-table__row:first-child .btn-danger")
.hasText("Deny");
await click(
".group-members .directory-table__row:first-child .btn-primary"
);
assert.ok(
query(
assert
.dom(
".group-members .directory-table__row:first-child .directory-table__cell:nth-child(4)"
)
.innerText.trim()
.startsWith("accepted")
);
.includesText("accepted");
assert.deepEqual(requests, [["19", "true"]]);
await click(".group-members .directory-table__row:last-child .btn-danger");
assert.strictEqual(
query(
assert
.dom(
".group-members .directory-table__row:last-child .directory-table__cell:nth-child(4)"
).innerText.trim(),
"denied"
);
)
.hasText("denied");
assert.deepEqual(requests, [
["19", "true"],
["20", undefined],

@ -25,7 +25,7 @@ acceptance("Group - Anonymous", function (needs) {
assert
.dom(".nav-pills li a[title='Messages']")
.doesNotExist("it does not show group messages navigation link");
.doesNotExist("does not show group messages navigation link");
await click(".nav-pills li a[title='Activity']");
@ -33,7 +33,7 @@ acceptance("Group - Anonymous", function (needs) {
await click(".activity-nav li a[href='/g/discourse/activity/topics']");
assert.ok(query(".topic-list"), "it shows the topic list");
assert.dom(".topic-list").exists("shows the topic list");
assert.dom(".topic-list-item").exists({ count: 2 }, "lists stream items");
await click(".activity-nav li a[href='/g/discourse/activity/mentions']");
@ -41,10 +41,10 @@ acceptance("Group - Anonymous", function (needs) {
assert.dom(".user-stream-item").exists("lists stream items");
assert
.dom(".nav-pills li a[title='Edit Group']")
.doesNotExist("it should not show messages tab if user is not admin");
.doesNotExist("does not show messages tab if user is not admin");
assert
.dom(".nav-pills li a[title='Logs']")
.doesNotExist("it should not show Logs tab if user is not admin");
.doesNotExist("does not show Logs tab if user is not admin");
assert.dom(".user-stream-item").exists("lists stream items");
const groupDropdown = selectKit(".group-dropdown");
@ -66,7 +66,7 @@ acceptance("Group - Anonymous", function (needs) {
assert
.dom(".group-dropdown-filter")
.doesNotExist("it should not display the default header");
.doesNotExist("does not display the default header");
});
test("Anonymous Viewing Automatic Group", async function (assert) {
@ -74,7 +74,7 @@ acceptance("Group - Anonymous", function (needs) {
assert
.dom(".nav-pills li a[title='Manage']")
.doesNotExist("it does not show group messages navigation link");
.doesNotExist("does not show group messages navigation link");
});
});
@ -204,7 +204,7 @@ acceptance("Group - Authenticated", function (needs) {
assert.strictEqual(
privateMessageUsers.header().value(),
"discourse",
"it prefills the group name"
"prefills the group name"
);
assert.dom(".add-warning").doesNotExist("groups can't receive warnings");
@ -218,7 +218,7 @@ acceptance("Group - Authenticated", function (needs) {
.dom("span.empty-state-title")
.hasText(
i18n("no_group_messages_title"),
"it should display the right text"
"should display the right text"
);
});
@ -230,16 +230,15 @@ acceptance("Group - Authenticated", function (needs) {
.dom(".topic-list-item .link-top-line")
.hasText(
"This is a private message 1",
"it should display the list of group topics"
"should display the list of group topics"
);
await click("#search-button");
await fillIn("#search-term", "something");
assert.ok(
query(".search-menu .btn.search-context"),
"'in messages' toggle is active by default"
);
assert
.dom(".search-menu .btn.search-context")
.exists("'in messages' toggle is active by default");
});
test("Admin Viewing Group", async function (assert) {
@ -254,7 +253,7 @@ acceptance("Group - Authenticated", function (needs) {
.exists("displays show group message button");
assert
.dom(".group-info-name")
.hasText("Awesome Team", "it should display the group name");
.hasText("Awesome Team", "should display the group name");
await click(".group-details-button button.btn-danger");
@ -263,17 +262,20 @@ acceptance("Group - Authenticated", function (needs) {
i18n("admin.groups.delete_with_messages_confirm", {
count: 2,
}),
"it should warn about orphan messages"
"should warn about orphan messages"
);
await click(".dialog-footer .btn-default");
await visit("/g/discourse/activity/posts");
assert.ok(
".user-stream-item a.avatar-link[href='/u/awesomerobot']",
"avatar link contains href (is tabbable)"
);
assert
.dom(".user-stream-item a.avatar-link")
.hasAttribute(
"href",
"/u/awesomerobot",
"avatar link contains href (is tabbable)"
);
});
test("Moderator Viewing Group", async function (assert) {
@ -287,7 +289,7 @@ acceptance("Group - Authenticated", function (needs) {
assert
.dom(".group-add-members-modal #set-owner")
.exists("it allows moderators to set group owners");
.exists("allows moderators to set group owners");
await click(".group-add-members-modal .modal-close");

@ -1,12 +1,13 @@
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Login with email - no social logins", function (needs) {
needs.settings({ enable_local_logins_via_email: true });
needs.pretender((server, helper) => {
server.post("/u/email-login", () => helper.response({ success: "OK" }));
});
test("with login with email enabled", async function (assert) {
await visit("/");
await click("header .login-button");
@ -18,6 +19,6 @@ acceptance("Login with email - no social logins", function (needs) {
await visit("/");
await click("header .login-button");
assert.notOk(queryAll(".login-buttons").is(":visible"));
assert.dom(".login-buttons").doesNotExist();
});
});

@ -100,7 +100,7 @@ acceptance("Password Reset", function (needs) {
await fillIn(".password-reset input", "perf3ctly5ecur3");
sinon.stub(DiscourseURL, "redirectTo");
await click(".password-reset form button[type='submit']");
assert.ok(DiscourseURL.redirectTo.calledWith("/"), "form is gone");
assert.true(DiscourseURL.redirectTo.calledWith("/"), "form is gone");
});
test("Password Reset Page With Second Factor", async function (assert) {
@ -133,7 +133,7 @@ acceptance("Password Reset", function (needs) {
sinon.stub(DiscourseURL, "redirectTo");
await click(".password-reset form button[type='submit']");
assert.ok(
assert.true(
DiscourseURL.redirectTo.calledWith("/"),
"it redirects after submitting form"
);

@ -33,7 +33,11 @@ acceptance("Personal Message", function (needs) {
await click(".archive-topic");
assert.strictEqual(currentURL(), "/u/eviltrout/messages");
assert.notOk(getCachedTopicList(session), "topic list cached is cleared");
assert.strictEqual(
getCachedTopicList(session),
undefined,
"topic list cached is cleared"
);
});
});

@ -20,10 +20,9 @@ acceptance("Plugin Keyboard Shortcuts - Logged In", function (needs) {
await visit("/t/this-is-a-test-topic/9");
await triggerKeyEvent(document, "keypress", "]".charCodeAt(0));
assert.ok(
document.querySelector("#added-element"),
"the keyboard shortcut callback fires successfully"
);
assert
.dom("#added-element", document.body)
.exists("the keyboard shortcut callback fires successfully");
});
});
@ -37,7 +36,7 @@ acceptance("Plugin Keyboard Shortcuts - Anonymous", function () {
});
});
assert.ok(
assert.true(
spy.calledWith("test-path", "]"),
"bindToPath is called due to options provided"
);

@ -55,7 +55,7 @@ acceptance("Post inline mentions", function (needs) {
const statusElement = query(
".topic-post .cooked .mention .user-status-message img"
);
assert.ok(
assert.true(
statusElement.src.includes(status.emoji),
"status emoji is correct"
);
@ -84,7 +84,7 @@ acceptance("Post inline mentions", function (needs) {
const statusElement = query(
".topic-post .cooked .mention .user-status-message img"
);
assert.ok(
assert.true(
statusElement.src.includes(status.emoji),
"status emoji is correct"
);
@ -117,7 +117,7 @@ acceptance("Post inline mentions", function (needs) {
const statusElement = query(
".topic-post .cooked .mention .user-status-message img"
);
assert.ok(
assert.true(
statusElement.src.includes(newStatus.emoji),
"updated status emoji is correct"
);
@ -169,16 +169,18 @@ acceptance("Post inline mentions user status tooltip", function (needs) {
.exists("user status is shown");
await mouseMove(".user-status-message");
const statusTooltip = document.querySelector(
".user-status-message-tooltip"
);
assert.ok(statusTooltip, "status tooltip is shown");
assert.ok(
statusTooltip.querySelector("img").src.includes(status.emoji),
assert
.dom(".user-status-message-tooltip")
.exists("status tooltip is shown");
assert.true(
document
.querySelector(".user-status-message-tooltip img")
.src.includes(status.emoji),
"emoji is correct"
);
assert
.dom(".user-status-tooltip-description", statusTooltip)
.dom(".user-status-tooltip-description")
.hasText(status.description, "status description is correct");
});
});

@ -219,8 +219,9 @@ acceptance("Review", function (needs) {
test("Reviewables can become stale", async function (assert) {
await visit("/review");
const reviewable = query(`[data-reviewable-id="1234"]`);
assert.notOk(reviewable.className.includes("reviewable-stale"));
assert
.dom("[data-reviewable-id='1234']")
.doesNotHaveClass("reviewable-stale");
assert.dom("[data-reviewable-id='1234'] .status .pending").exists();
assert.dom(".stale-help").doesNotExist();
@ -231,10 +232,10 @@ acceptance("Review", function (needs) {
},
});
assert.ok(reviewable.className.includes("reviewable-stale"));
assert.dom("[data-reviewable-id='1234']").hasClass("reviewable-stale");
assert.dom("[data-reviewable-id='1234'] .status .approved").exists();
assert.dom(".stale-help").exists();
assert.ok(query(".stale-help").innerText.includes("foo"));
assert.dom(".stale-help").includesText("foo");
await visit("/");
await visit("/review"); // reload review

@ -62,9 +62,7 @@ acceptance("Search - Anonymous", function (needs) {
await click("#search-button");
assert.dom("#search-term").exists("shows the search input");
assert
.dom(".show-advanced-search")
.exists("it shows full page search button");
assert.dom(".show-advanced-search").exists("shows full page search button");
});
test("random quick tips", async function (assert) {
@ -88,7 +86,7 @@ acceptance("Search - Anonymous", function (needs) {
assert.strictEqual(
query(".full-page-search").value,
"dev",
"it goes to full search page and preserves the search term"
"goes to full search page and preserves the search term"
);
assert
@ -273,7 +271,7 @@ acceptance("Search - Anonymous", function (needs) {
assert.strictEqual(
query(".full-page-search").value,
"proper topic:280",
"it goes to full search page and preserves search term + context"
"goes to full search page and preserves search term + context"
);
assert
@ -499,16 +497,16 @@ acceptance("Search - Authenticated", function (needs) {
await visit("/search?expanded=true");
await inSelector.expand();
assert.ok(inSelector.rowByValue("first").exists());
assert.ok(inSelector.rowByValue("pinned").exists());
assert.ok(inSelector.rowByValue("wiki").exists());
assert.ok(inSelector.rowByValue("images").exists());
assert.true(inSelector.rowByValue("first").exists());
assert.true(inSelector.rowByValue("pinned").exists());
assert.true(inSelector.rowByValue("wiki").exists());
assert.true(inSelector.rowByValue("images").exists());
assert.ok(inSelector.rowByValue("unseen").exists());
assert.ok(inSelector.rowByValue("posted").exists());
assert.ok(inSelector.rowByValue("watching").exists());
assert.ok(inSelector.rowByValue("tracking").exists());
assert.ok(inSelector.rowByValue("bookmarks").exists());
assert.true(inSelector.rowByValue("unseen").exists());
assert.true(inSelector.rowByValue("posted").exists());
assert.true(inSelector.rowByValue("watching").exists());
assert.true(inSelector.rowByValue("tracking").exists());
assert.true(inSelector.rowByValue("bookmarks").exists());
assert.dom(".search-advanced-options .in-likes").exists();
assert.dom(".search-advanced-options .in-private").exists();
@ -649,12 +647,12 @@ acceptance("Search - Authenticated", function (needs) {
await triggerKeyEvent(document.activeElement, "keyup", "ArrowDown");
await triggerKeyEvent(document.activeElement, "keydown", 65); // maps to lowercase a
assert.ok(
assert.true(
query(".d-editor-input").value.includes("a link"),
"still has the original composer content"
);
assert.ok(
assert.true(
query(".d-editor-input").value.includes(
searchFixtures["search/query"].topics[0].slug
),
@ -1235,7 +1233,7 @@ acceptance("Search - assistant", function (needs) {
await click("#search-button");
assert
.dom(".btn.search-context")
.exists("it shows the button when reinvoking search");
.exists("shows the button when reinvoking search");
await fillIn("#search-term", "emoji");
await query("input#search-term").focus();

@ -37,7 +37,7 @@ acceptance("Share and Invite modal", function (needs) {
.dom("#modal-alert.alert-warning")
.doesNotExist("it does not show the alert with restricted groups");
assert.ok(
assert.true(
query("input.invite-link").value.includes(
"/t/internationalization-localization/280?u=eviltrout"
),
@ -127,7 +127,7 @@ acceptance("Share url with badges disabled - desktop", function (needs) {
await visit("/t/internationalization-localization/280");
await click("#topic-footer-button-share-and-invite");
assert.notOk(
assert.false(
query("input.invite-link").value.includes("?u=eviltrout"),
"it doesn't add the username param when badges are disabled"
);
@ -148,7 +148,7 @@ acceptance("With username in share links disabled - desktop", function (needs) {
await visit("/t/internationalization-localization/280");
await click("#topic-footer-button-share-and-invite");
assert.notOk(
assert.false(
query("input.invite-link").value.includes("?u=eviltrout"),
"it doesn't add the username param when username in share links are disabled"
);

@ -973,7 +973,7 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) {
await click(".btn-sidebar-toggle");
assert.ok(
assert.true(
Object.keys(topicTrackingState.stateChangeCallbacks).length <
initialCallbackCount
);

@ -1123,7 +1123,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
await click(".btn-sidebar-toggle");
assert.ok(teardownCalled, "section link teardown callback was called");
assert.true(teardownCalled, "section link teardown callback was called");
});
});

@ -530,7 +530,7 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
await click(".btn-sidebar-toggle");
assert.ok(
assert.true(
Object.keys(topicTrackingState.stateChangeCallbacks).length <
initialCallbackCount
);

@ -430,10 +430,9 @@ acceptance("Tag info", function (needs) {
await click("#show-tag-info");
assert.dom(".tag-info .tag-name").exists("show tag");
assert.ok(
query(".tag-info .tag-associations").innerText.includes("Gardening"),
"show tag group names"
);
assert
.dom(".tag-info .tag-associations")
.includesText("Gardening", "show tag group names");
assert
.dom(".tag-info .synonyms-list .tag-box")
.exists({ count: 2 }, "shows the synonyms");
@ -478,21 +477,17 @@ acceptance("Tag info", function (needs) {
assert.strictEqual(
query("#edit-name").value,
"happy-monkey",
"it displays original tag name"
"displays original tag name"
);
assert.strictEqual(
query("#edit-description").value,
"happy monkey description",
"it displays original tag description"
"displays original tag description"
);
await fillIn("#edit-description", "new description");
await click(".submit-edit");
assert.strictEqual(
currentURL(),
"/tag/happy-monkey",
"it doesn't change URL"
);
assert.strictEqual(currentURL(), "/tag/happy-monkey", "doesn't change URL");
await click(".edit-tag");
await fillIn("#edit-name", "happy-monkey2");
@ -500,7 +495,7 @@ acceptance("Tag info", function (needs) {
assert.strictEqual(
currentURL(),
"/tag/happy-monkey2",
"it changes URL to new tag path"
"changes URL to new tag path"
);
});

@ -1,6 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { i18n } from "discourse-i18n";
acceptance("Theme", function (needs) {
@ -203,29 +203,28 @@ acceptance("Theme", function (needs) {
await visit("/admin/customize/themes");
await click(".themes-list-container__item .info");
assert.ok(
query(".control-unit .status-message").innerText.includes(
i18n("admin.customize.theme.last_attempt")
),
"it says that theme is not completely installed"
);
assert
.dom(".control-unit .status-message")
.includesText(
i18n("admin.customize.theme.last_attempt"),
"says that theme is not completely installed"
);
await click(".control-unit .btn-primary.finish-install");
assert
.dom(".show-current-style .title span")
.hasText("discourse-complete-theme", "it updates theme title");
.hasText("discourse-complete-theme", "updates theme title");
assert.notOk(
query(".metadata.control-unit").innerText.includes(
i18n("admin.customize.theme.last_attempt")
),
"it does not say that theme is not completely installed"
);
assert
.dom(".metadata.control-unit")
.doesNotIncludeText(
i18n("admin.customize.theme.last_attempt"),
"does not say that theme is not completely installed"
);
assert.notOk(
query(".control-unit .btn-primary.finish-install"),
"it does not show finish install button"
);
assert
.dom(".control-unit .btn-primary.finish-install")
.doesNotExist("does not show finish install button");
});
});

@ -69,6 +69,6 @@ acceptance("Topic - Admin Menu", function (needs) {
.dom(".extra-button .d-button-label")
.hasText(i18n("yes_value"), "The label was rendered");
await click(".extra-button");
assert.ok(this.actionCalled, "The action was called");
assert.true(this.actionCalled, "The action was called");
});
});

@ -4,7 +4,6 @@ import topicFixtures from "discourse/tests/fixtures/topic";
import {
acceptance,
query,
queryAll,
selectText,
} from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object";
@ -46,10 +45,10 @@ acceptance("Topic - Quote button - logged in", function (needs) {
assert.dom(".quote-sharing").exists("shows the quote sharing options");
assert
.dom(`.quote-sharing .btn[title='${i18n("share.twitter")}']`)
.exists("it includes the twitter share button");
.exists("includes the twitter share button");
assert
.dom(`.quote-sharing .btn[title='${i18n("share.email")}']`)
.exists("it includes the email share button");
.exists("includes the email share button");
});
test("Quoting a Onebox should not copy the formatting of the rendered Onebox", async function (assert) {
@ -82,7 +81,7 @@ acceptance("Closed Topic - Quote button - logged in", function (needs) {
assert.dom(".insert-quote").exists("shows the quote button");
await click(".insert-quote");
assert.ok(
assert.true(
query(".d-editor-input")
.value.trim()
.startsWith("Continuing the discussion from"),
@ -101,16 +100,14 @@ acceptance("Topic - Quote button - anonymous", function (needs) {
await visit("/t/internationalization-localization/280");
await selectText("#post_5 blockquote");
assert.ok(queryAll(".quote-sharing"), "it shows the quote sharing options");
assert.dom(".quote-sharing").exists("shows the quote sharing options");
assert
.dom(`.quote-sharing .btn[title='${i18n("share.twitter")}']`)
.exists("it includes the twitter share button");
.exists("includes the twitter share button");
assert
.dom(`.quote-sharing .btn[title='${i18n("share.email")}']`)
.exists("it includes the email share button");
assert
.dom(".insert-quote")
.doesNotExist("it does not show the quote button");
.exists("includes the email share button");
assert.dom(".insert-quote").doesNotExist("does not show the quote button");
});
test("Shows single share button when site setting only has one item", async function (assert) {
@ -122,10 +119,10 @@ acceptance("Topic - Quote button - anonymous", function (needs) {
assert.dom(".quote-sharing").exists("shows the quote sharing options");
assert
.dom(`.quote-sharing .btn[title='${i18n("share.twitter")}']`)
.exists("it includes the twitter share button");
.exists("includes the twitter share button");
assert
.dom(".quote-share-label")
.doesNotExist("it does not show the Share label");
.doesNotExist("does not show the Share label");
});
test("Shows nothing when visibility is disabled", async function (assert) {
@ -148,7 +145,7 @@ acceptance("Topic - Quote button - keyboard shortcut", function (needs) {
await triggerKeyEvent(document, "keypress", "Q");
assert.dom(".d-editor-input").exists("the editor is open");
assert.ok(
assert.true(
query(".d-editor-input").value.includes("Any plans to support"),
"editor includes selected text"
);

@ -51,12 +51,12 @@ acceptance("Topic", function (needs) {
assert.strictEqual(
query(".d-editor-input").value.trim(),
`Continuing the discussion from [Internationalization / localization](${window.location.origin}/t/internationalization-localization/280):`,
"it fills composer with the ring string"
"fills composer with the ring string"
);
assert.strictEqual(
selectKit(".category-chooser").header().value(),
"2",
"it fills category selector with the right category"
"fills category selector with the right category"
);
});
@ -70,14 +70,14 @@ acceptance("Topic", function (needs) {
assert.strictEqual(
query(".d-editor-input").value.trim(),
`Continuing the discussion from [PM for testing](${window.location.origin}/t/pm-for-testing/12):`,
"it fills composer with the ring string"
"fills composer with the ring string"
);
const privateMessageUsers = selectKit("#private-message-users");
assert.strictEqual(
privateMessageUsers.header().value(),
"someguy,test,Group",
"it fills up the composer correctly"
"fills up the composer correctly"
);
});
@ -94,7 +94,7 @@ acceptance("Topic", function (needs) {
assert
.dom(".post-action-menu__copy-link-checkmark")
.exists("it shows the Link Copied! message");
.exists("shows the Link Copied! message");
});
test("Showing and hiding the edit controls", async function (assert) {
@ -125,10 +125,10 @@ acceptance("Topic", function (needs) {
assert
.dom("#topic-title .badge-category")
.hasText("faq", "it displays the new category");
.hasText("faq", "displays the new category");
assert
.dom(".fancy-title")
.hasText("this is the new title", "it displays the new title");
.hasText("this is the new title", "displays the new title");
});
test("Marking a topic as wiki", async function (assert) {
@ -148,7 +148,7 @@ acceptance("Topic", function (needs) {
assert
.dom(".fancy-title")
.hasText("PM for testing", "it routes to the right topic");
.hasText("PM for testing", "routes to the right topic");
await visit("/t/280/20");
@ -156,7 +156,7 @@ acceptance("Topic", function (needs) {
.dom(".fancy-title")
.hasText(
"Internationalization / localization",
"it routes to the right topic"
"routes to the right topic"
);
});
@ -251,7 +251,7 @@ acceptance("Topic", function (needs) {
assert
.dom(".topic-post.user-suspended > #post_1")
.exists("it has a class applied");
.exists("has a class applied");
});
});
@ -319,9 +319,7 @@ acceptance("Topic featured links", function (needs) {
await click(".topic-admin-visible .btn");
await click(".toggle-admin-menu");
assert
.dom(".topic-admin-pin")
.exists("it should show the multi select menu");
assert.dom(".topic-admin-pin").exists("should show the multi select menu");
});
test("selecting posts", async function (assert) {
@ -331,11 +329,11 @@ acceptance("Topic featured links", function (needs) {
assert
.dom(".selected-posts:not(.hidden)")
.exists("it should show the multi select menu");
.exists("should show the multi select menu");
assert
.dom(".select-all")
.exists("it should allow users to select all the posts");
.exists("should allow users to select all the posts");
});
test("select below", async function (assert) {
@ -373,7 +371,7 @@ acceptance("Topic featured links", function (needs) {
await selectText("#post_5 blockquote");
await click(".quote-button .insert-quote");
assert.ok(
assert.true(
query(".d-editor-input").value.includes(
'quote="codinghorror said, post:3, topic:280"'
)
@ -385,7 +383,7 @@ acceptance("Topic featured links", function (needs) {
await selectText("#post_9 blockquote");
await click(".quote-button .insert-quote");
assert.ok(
assert.true(
query(".d-editor-input").value.includes(
'quote="A new topic with a link to another topic, post:3, topic:62"'
)
@ -397,7 +395,7 @@ acceptance("Topic featured links", function (needs) {
await selectText("#post_5 blockquote");
await click(".reply");
assert.ok(
assert.true(
query(".d-editor-input").value.includes(
'quote="codinghorror said, post:3, topic:280"'
)
@ -413,7 +411,7 @@ acceptance("Topic featured links", function (needs) {
await triggerKeyEvent(document, "keypress", "J");
await triggerKeyEvent(document, "keypress", "T");
assert.ok(
assert.true(
query(".d-editor-input").value.includes(
'quote="codinghorror said, post:3, topic:280"'
)
@ -425,7 +423,7 @@ acceptance("Topic featured links", function (needs) {
await visit("/t/internationalization-localization/280");
await selectText("#post_5 .cooked");
await click(".quote-button .insert-quote");
assert.ok(
assert.true(
query(".d-editor-input").value.includes(
'quote="pekka, post:5, topic:280, full:true"'
)
@ -468,17 +466,16 @@ acceptance("Topic with title decorated", function (needs) {
test("Decorate topic title", async function (assert) {
await visit("/t/internationalization-localization/280");
assert.ok(
query(".fancy-title").innerText.endsWith("-280-topic-title"),
"it decorates topic title"
);
assert
.dom(".fancy-title")
.hasText(/-280-topic-title$/, "decorates topic title");
assert.ok(
query(".raw-topic-link:nth-child(1)").innerText.endsWith(
"-27331-topic-list-item-title"
),
"it decorates topic list item title"
);
assert
.dom(".raw-topic-link:nth-child(1)")
.hasText(
/-27331-topic-list-item-title$/,
"decorates topic list item title"
);
});
});
@ -493,11 +490,9 @@ acceptance("Topic pinning/unpinning as an admin", function (needs) {
assert
.dom(".feature-topic .btn-primary")
.exists("it should show the 'Pin Topic' button");
.exists("should show the 'Pin Topic' button");
assert
.dom(".make-banner")
.exists("it should show the 'Banner Topic' button");
assert.dom(".make-banner").exists("should show the 'Banner Topic' button");
});
});
@ -512,11 +507,9 @@ acceptance("Topic pinning/unpinning as a staff member", function (needs) {
assert
.dom(".feature-topic .btn-primary")
.exists("it should show the 'Pin Topic' button");
.exists("should show the 'Pin Topic' button");
assert
.dom(".make-banner")
.exists("it should show the 'Banner Topic' button");
assert.dom(".make-banner").exists("should show the 'Banner Topic' button");
});
});
@ -531,11 +524,11 @@ acceptance("Topic pinning/unpinning as a group moderator", function (needs) {
assert
.dom(".feature-topic .btn-primary")
.exists("it should show the 'Pin Topic' button");
.exists("should show the 'Pin Topic' button");
assert
.dom(".make-banner")
.doesNotExist("it should not show the 'Banner Topic' button");
.doesNotExist("should not show the 'Banner Topic' button");
});
});
@ -605,26 +598,26 @@ acceptance("Navigating between topics", function (needs) {
test("clicking slug-less URLs within the same topic", async function (assert) {
await visit("/t/-/280");
await click("a.same-topic-slugless");
assert.ok(currentURL().includes("/280"));
assert.true(currentURL().includes("/280"));
await click("a.same-topic-slugless-post");
assert.ok(currentURL().includes("/280"));
assert.true(currentURL().includes("/280"));
});
test("clicking slug-less URLs to a different topic", async function (assert) {
await visit("/t/-/280");
await click("a.diff-topic-slugless");
assert.ok(currentURL().includes("/28830"));
assert.true(currentURL().includes("/28830"));
await visit("/t/-/280");
await click("a.diff-topic-slugless-post");
assert.ok(currentURL().includes("/28830"));
assert.true(currentURL().includes("/28830"));
});
test("clicking post URLs", async function (assert) {
await visit("/t/-/280");
await click("a.by-post-id");
assert.ok(currentURL().includes("/280"));
assert.true(currentURL().includes("/280"));
});
});
@ -646,10 +639,10 @@ acceptance("Topic stats update automatically", function () {
await publishToMessageBus("/topic/280", likesChangedFixture);
assert.dom(likesCountSelectors).hasText(expectedLikesCount);
assert.notEqual(
assert.notStrictEqual(
oldLikesCount,
expectedLikesCount,
"it updates the likes count on the topic stats"
"updates the likes count on the topic stats"
);
});
});

@ -332,21 +332,21 @@ acceptance("Glimmer Topic Timeline", function (needs) {
});
});
test("it has a topic admin menu", async function (assert) {
test("has a topic admin menu", async function (assert) {
await visit("/t/internationalization-localization");
assert
.dom(".timeline-controls .topic-admin-menu-button")
.exists("admin menu is present");
});
test("it has a reply-to-post button", async function (assert) {
test("has a reply-to-post button", async function (assert) {
await visit("/t/internationalization-localization");
assert
.dom(".timeline-footer-controls .reply-to-post")
.exists("reply to post button is present");
});
test("it has a topic notification button", async function (assert) {
test("has a topic notification button", async function (assert) {
await visit("/t/internationalization-localization");
assert
.dom(".timeline-footer-controls .topic-notifications-button")
@ -381,7 +381,7 @@ acceptance("Glimmer Topic Timeline", function (needs) {
test("clicking the timeline padding updates the position", async function (assert) {
await visit("/t/internationalization-localization/280/2");
await click(".timeline-scrollarea .timeline-padding");
assert.notOk(
assert.false(
currentURL().includes("/280/2"),
"The position of the currently viewed post has been updated from it's initial position"
);

@ -72,7 +72,7 @@ acceptance("Topic - User Status - live updates", function (needs) {
assert
.dom(".topic-post .user-status-message")
.exists({ count: 3 }, "all posts has user status");
assert.ok(
assert.true(
query(".topic-post .user-status-message .emoji").src.includes(
status.emoji
),
@ -85,7 +85,7 @@ acceptance("Topic - User Status - live updates", function (needs) {
assert
.dom(".topic-post .user-status-message")
.exists({ count: 3 }, "all posts has user status");
assert.ok(
assert.true(
query(".topic-post .user-status-message .emoji").src.includes(
newStatus.emoji
),
@ -100,7 +100,7 @@ acceptance("Topic - User Status - live updates", function (needs) {
assert
.dom(".topic-post .user-status-message")
.exists({ count: 3 }, "all posts has user status");
assert.ok(
assert.true(
query(".topic-post .user-status-message .emoji").src.includes(
status.emoji
),
@ -119,7 +119,7 @@ acceptance("Topic - User Status - live updates", function (needs) {
assert
.dom(".topic-post .user-status-message")
.exists({ count: 3 }, "all posts have user status");
assert.ok(
assert.true(
query(".topic-post .user-status-message .emoji").src.includes(
newStatus.emoji
),

@ -444,7 +444,7 @@ acceptance("User menu", function (needs) {
await click("#user-menu-button-profile");
const summaryLink = query("#quick-access-profile ul li.summary a");
assert.ok(
assert.true(
summaryLink.href.endsWith("/u/eviltrout/summary"),
"has a link to the summary page of the user"
);
@ -453,13 +453,12 @@ acceptance("User menu", function (needs) {
i18n("user.summary.title"),
"summary link has the right label"
);
assert.ok(
summaryLink.querySelector(".d-icon-user"),
"summary link has the right icon"
);
assert
.dom(".d-icon-user", summaryLink)
.exists("summary link has the right icon");
const activityLink = query("#quick-access-profile ul li.activity a");
assert.ok(
assert.true(
activityLink.href.endsWith("/u/eviltrout/activity"),
"has a link to the activity page of the user"
);
@ -468,13 +467,12 @@ acceptance("User menu", function (needs) {
i18n("user.activity_stream"),
"activity link has the right label"
);
assert.ok(
activityLink.querySelector(".d-icon-bars-staggered"),
"activity link has the right icon"
);
assert
.dom(".d-icon-bars-staggered", activityLink)
.exists("activity link has the right icon");
const invitesLink = query("#quick-access-profile ul li.invites a");
assert.ok(
assert.true(
invitesLink.href.endsWith("/u/eviltrout/invited"),
"has a link to the invites page of the user"
);
@ -483,10 +481,9 @@ acceptance("User menu", function (needs) {
i18n("user.invited.title"),
"invites link has the right label"
);
assert.ok(
invitesLink.querySelector(".d-icon-user-plus"),
"invites link has the right icon"
);
assert
.dom(".d-icon-user-plus", invitesLink)
.exists("invites link has the right icon");
await clickOutside();
updateCurrentUser({ can_invite_to_forum: false });
@ -499,7 +496,7 @@ acceptance("User menu", function (needs) {
.doesNotExist("invites link not shown when the user can't invite");
const draftsLink = query("#quick-access-profile ul li.drafts a");
assert.ok(
assert.true(
draftsLink.href.endsWith("/u/eviltrout/activity/drafts"),
"has a link to the drafts page of the user"
);
@ -508,13 +505,12 @@ acceptance("User menu", function (needs) {
i18n("drafts.label_with_count", { count: 13 }),
"drafts link has the right label with count of the user's drafts"
);
assert.ok(
draftsLink.querySelector(".d-icon-user_menu\\.drafts"),
"drafts link has the right icon"
);
assert
.dom(".d-icon-user_menu\\.drafts", draftsLink)
.exists("drafts link has the right icon");
const preferencesLink = query("#quick-access-profile ul li.preferences a");
assert.ok(
assert.true(
preferencesLink.href.endsWith("/u/eviltrout/preferences"),
"has a link to the preferences page of the user"
);
@ -523,10 +519,9 @@ acceptance("User menu", function (needs) {
i18n("user.preferences.title"),
"preferences link has the right label"
);
assert.ok(
preferencesLink.querySelector(".d-icon-gear"),
"preferences link has the right icon"
);
assert
.dom(".d-icon-gear", preferencesLink)
.exists("preferences link has the right icon");
let doNotDisturbButton = query(
"#quick-access-profile ul li.do-not-disturb .btn"
@ -539,10 +534,9 @@ acceptance("User menu", function (needs) {
i18n("pause_notifications.label"),
"Do Not Disturb button has the right label"
);
assert.ok(
doNotDisturbButton.querySelector(".d-icon-toggle-off"),
"Do Not Disturb button has the right icon"
);
assert
.dom(".d-icon-toggle-off", doNotDisturbButton)
.exists("Do Not Disturb button has the right icon");
await clickOutside();
const date = new Date();
@ -562,10 +556,11 @@ acceptance("User menu", function (needs) {
`${i18n("pause_notifications.label")} 2h`,
"Do Not Disturb button has the right label when Do Not Disturb is enabled"
);
assert.ok(
doNotDisturbButton.querySelector(".d-icon-toggle-on"),
"Do Not Disturb button has the right icon when Do Not Disturb is enabled"
);
assert
.dom(".d-icon-toggle-on", doNotDisturbButton)
.exists(
"Do Not Disturb button has the right icon when Do Not Disturb is enabled"
);
assert
.dom("#quick-access-profile ul li.enable-anonymous .btn")
@ -581,10 +576,11 @@ acceptance("User menu", function (needs) {
i18n("switch_to_anon"),
"toggle anonymous button has the right label when the user isn't anonymous"
);
assert.ok(
toggleAnonButton.querySelector(".d-icon-user-secret"),
"toggle anonymous button has the right icon when the user isn't anonymous"
);
assert
.dom(".d-icon-user-secret", toggleAnonButton)
.exists(
"toggle anonymous button has the right icon when the user isn't anonymous"
);
await clickOutside();
updateCurrentUser({ is_anonymous: true });
@ -602,10 +598,11 @@ acceptance("User menu", function (needs) {
i18n("switch_from_anon"),
"toggle anonymous button has the right label when the user is anonymous"
);
assert.ok(
toggleAnonButton.querySelector(".d-icon-ban"),
"toggle anonymous button has the right icon when the user is anonymous"
);
assert
.dom(".d-icon-ban", toggleAnonButton)
.exists(
"toggle anonymous button has the right icon when the user is anonymous"
);
await clickOutside();
updateCurrentUser({
@ -701,10 +698,9 @@ acceptance("User menu", function (needs) {
i18n("user.log_out"),
"logout button has the right label"
);
assert.ok(
logoutButton.querySelector(".d-icon-right-from-bracket"),
"logout button has the right icon"
);
assert
.dom(".d-icon-right-from-bracket", logoutButton)
.exists("logout button has the right icon");
});
test("Extra items added to profile tab via plugin API are rendered properly", async function (assert) {
@ -729,22 +725,20 @@ acceptance("User menu", function (needs) {
const item1 = query("#quick-access-profile ul li.test-1-item");
assert.ok(
item1.querySelector(".d-icon-wrench"),
"The first item's icon is rendered"
);
assert.ok(
assert
.dom(".d-icon-wrench", item1)
.exists("The first item's icon is rendered");
assert.true(
item1.querySelector("a").href.endsWith("/test_1_path"),
"The first item's link is present with correct href"
);
const item2 = query("#quick-access-profile ul li.test-2-item");
assert.notOk(
item2.querySelector(".d-icon"),
"The second item doesn't have an icon"
);
assert.ok(
assert
.dom(".d-icon", item2)
.doesNotExist("The second item doesn't have an icon");
assert.true(
item2.querySelector("a").href.endsWith("/test_2_path"),
"The second item's link is present with correct href"
);
@ -958,11 +952,11 @@ acceptance("User menu - Dismiss button", function (needs) {
);
await click(".d-modal__footer .btn-default"); // click cancel on the dismiss modal
assert.notOk(markRead, "mark-read request isn't sent");
assert.false(markRead, "mark-read request isn't sent");
await click(".user-menu .notifications-dismiss");
await click(".d-modal__footer .btn-primary"); // click confirm on the dismiss modal
assert.ok(markRead, "mark-read request is sent");
assert.true(markRead, "mark-read request is sent");
});
test("shows confirmation modal for the bookmarks list", async function (assert) {
@ -994,7 +988,7 @@ acceptance("User menu - Dismiss button", function (needs) {
}),
"confirmation modal is shown when there are unread bookmark reminder notifications"
);
assert.notOk(markRead, "mark-read request isn't sent");
assert.false(markRead, "mark-read request isn't sent");
await click(".d-modal__footer .btn-primary"); // confirm dismiss on the dismiss modal
@ -1007,7 +1001,7 @@ acceptance("User menu - Dismiss button", function (needs) {
assert
.dom("#user-menu-button-bookmarks .badge-notification")
.doesNotExist("bookmarks tab no longer has bubble");
assert.ok(markRead, "mark-read request is sent");
assert.true(markRead, "mark-read request is sent");
assert.strictEqual(
markReadRequestBody,
"dismiss_types=bookmark_reminder",
@ -1045,7 +1039,7 @@ acceptance("User menu - Dismiss button", function (needs) {
}),
"confirmation modal is shown when there are unread messages notifications"
);
assert.notOk(markRead, "mark-read request isn't sent");
assert.false(markRead, "mark-read request isn't sent");
await click(".d-modal__footer .btn-primary"); // confirm dismiss on the dismiss modal
@ -1058,7 +1052,7 @@ acceptance("User menu - Dismiss button", function (needs) {
assert
.dom("#user-menu-button-messages .badge-notification")
.doesNotExist("messages tab no longer has bubble");
assert.ok(markRead, "mark-read request is sent");
assert.true(markRead, "mark-read request is sent");
assert.strictEqual(
markReadRequestBody,
"dismiss_types=private_message%2Cgroup_message_summary",
@ -1073,7 +1067,7 @@ acceptance("User menu - Dismiss button", function (needs) {
await click("#user-menu-button-likes");
await click(".user-menu .notifications-dismiss");
assert.ok(
assert.true(
markRead,
"mark-read request is sent without a confirmation modal"
);
@ -1098,7 +1092,7 @@ acceptance("User menu - Dismiss button", function (needs) {
assert
.dom("#user-menu-button-other-notifications .badge-notification")
.doesNotExist();
assert.ok(
assert.true(
markRead,
"mark-read request is sent without a confirmation modal"
);
@ -1112,14 +1106,14 @@ acceptance("User menu - avatars", function (needs) {
show_user_menu_avatars: true,
});
test("It shows user avatars for various notifications on all notifications pane", async function (assert) {
test("shows user avatars for various notifications on all notifications pane", async function (assert) {
await visit("/");
await click(".d-header-icons .current-user button");
assert.dom("li.notification.edited .icon-avatar").exists();
assert.dom("li.notification.replied .icon-avatar").exists();
});
test("It shows user avatars for messages", async function (assert) {
test("shows user avatars for messages", async function (assert) {
await visit("/");
await click(".d-header-icons .current-user button");
await click("#user-menu-button-messages");
@ -1128,7 +1122,7 @@ acceptance("User menu - avatars", function (needs) {
assert.dom("li.message .icon-avatar").exists();
});
test("It shows user avatars for bookmark items and bookmark reminder notification items", async function (assert) {
test("shows user avatars for bookmark items and bookmark reminder notification items", async function (assert) {
await visit("/");
await click(".d-header-icons .current-user button");
await click("#user-menu-button-bookmarks");

@ -108,7 +108,7 @@ acceptance("User Preferences - Account", function (needs) {
await click(".dialog-footer .btn-primary");
assert.ok(
assert.true(
DiscourseURL.redirectAbsolute.calledWith("/"),
"redirects to home after deleting"
);
@ -119,7 +119,7 @@ acceptance("User Preferences - Account", function (needs) {
assert
.dom(".pref-associated-accounts")
.exists("it has the connected accounts section");
.exists("has the connected accounts section");
assert
.dom(
@ -296,7 +296,7 @@ acceptance("User Preferences — Account - Download Archive", function (needs) {
test("Can see and trigger download for account data", async function (assert) {
await visit(`/u/${currentUser}/preferences/account`);
assert.ok(query(".btn-request-archive"), "button exists");
assert.dom(".btn-request-archive").exists("button exists");
await click(".btn-request-archive");
await click("#dialog-holder .btn-primary");

@ -307,7 +307,7 @@ acceptance(
// dark scheme
await selectKit(".dark-color-scheme .combobox").expand();
assert.ok(
assert.true(
selectKit(".dark-color-scheme .combobox").rowByValue(1).exists(),
"default dark scheme is included"
);
@ -361,10 +361,9 @@ acceptance(
await selectKit(".light-color-scheme .combobox").expand();
await selectKit(".light-color-scheme .combobox").selectRowByValue(3);
assert.notOk(
document.querySelector("link#cs-preview-light"),
"stylesheet not loaded"
);
assert
.dom("link#cs-preview-light", document.body)
.doesNotExist("stylesheet not loaded");
});
}
);

@ -47,7 +47,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await watchedTagsSelector.expand();
assert.notOk(
assert.false(
watchedTagsSelector.rowByValue("monkey").exists(),
"tag that has already been selected is not available for selection"
);
@ -61,7 +61,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await mutedTagsSelector.expand();
["monkey", "gazelle"].forEach((tagName) => {
assert.notOk(
assert.false(
mutedTagsSelector.rowByValue(tagName).exists(),
`tag "${tagName}" has already been selected is not available for selection`
);
@ -76,7 +76,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await watchedFirstPostTagsSelector.expand();
["dog", "gazelle", "monkey"].forEach((tagName) => {
assert.notOk(
assert.false(
watchedFirstPostTagsSelector.rowByValue(tagName).exists(),
"tag `${tagName}` has already been selected is not available for selection"
);
@ -107,7 +107,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await trackedCategoriesSelector.expand();
assert.notOk(
assert.false(
trackedCategoriesSelector.rowByValue("3").exists(),
"category that has already been selected is not available for selection"
);
@ -121,7 +121,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await mutedCategoriesSelector.expand();
["3", "4"].forEach((categoryId) => {
assert.notOk(
assert.false(
mutedCategoriesSelector.rowByValue(categoryId).exists(),
`category id "${categoryId}" that has already been selected is not available for selection`
);
@ -136,7 +136,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await watchedFirstCategoriesSelector.expand();
["3", "4", "6"].forEach((categoryId) => {
assert.notOk(
assert.false(
watchedFirstCategoriesSelector.rowByValue(categoryId).exists(),
`category id "${categoryId}" that has already been selected is not available for selection`
);
@ -170,7 +170,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await trackedCategoriesSelector.expand();
assert.notOk(
assert.false(
trackedCategoriesSelector.rowByValue("4").exists(),
"category that is set to regular is not available for selection"
);

@ -704,11 +704,12 @@ acceptance(
test("suggested messages without new or unread", async function (assert) {
await visit("/t/12");
assert.strictEqual(
query(".more-topics__browse-more").innerText.trim(),
"Want to read more? Browse other messages in personal messages.",
"displays the right browse more message"
);
assert
.dom(".more-topics__browse-more")
.hasText(
"Want to read more? Browse other messages in personal messages.",
"displays the right browse more message"
);
});
test("suggested messages with new and unread", async function (assert) {
@ -716,40 +717,41 @@ acceptance(
await publishNewToMessageBus({ userId: 5, topicId: 1 });
assert.strictEqual(
query(".more-topics__browse-more").innerText.trim(),
"There is 1 new message remaining, or browse other personal messages",
"displays the right browse more message"
);
assert
.dom(".more-topics__browse-more")
.hasText(
"There is 1 new message remaining, or browse other personal messages",
"displays the right browse more message"
);
await publishUnreadToMessageBus({ userId: 5, topicId: 2 });
assert.strictEqual(
query(".more-topics__browse-more").innerText.trim(),
"There is 1 unread and 1 new message remaining, or browse other personal messages",
"displays the right browse more message"
);
assert
.dom(".more-topics__browse-more")
.hasText(
"There is 1 unread and 1 new message remaining, or browse other personal messages",
"displays the right browse more message"
);
await publishReadToMessageBus({ userId: 5, topicId: 2 });
assert.strictEqual(
query(".more-topics__browse-more").innerText.trim(),
"There is 1 new message remaining, or browse other personal messages",
"displays the right browse more message"
);
assert
.dom(".more-topics__browse-more")
.hasText(
"There is 1 new message remaining, or browse other personal messages",
"displays the right browse more message"
);
});
test("suggested messages for group messages without new or unread", async function (assert) {
await visit("/t/13");
assert.ok(
query(".more-topics__browse-more")
.innerText.trim()
.match(
/Want to read more\? Browse other messages in\s+awesome_group\./
),
"displays the right browse more message"
);
assert
.dom(".more-topics__browse-more")
.hasText(
/Want to read more\? Browse other messages in\s+awesome_group\./,
"displays the right browse more message"
);
});
test("suggested messages for group messages with new and unread", async function (assert) {
@ -757,25 +759,21 @@ acceptance(
await publishGroupNewToMessageBus({ groupIds: [14], topicId: 1 });
assert.ok(
query(".more-topics__browse-more")
.innerText.trim()
.match(
/There is 1 new message remaining, or browse other messages in\s+awesome_group/
),
"displays the right browse more message"
);
assert
.dom(".more-topics__browse-more")
.hasText(
/There is 1 new message remaining, or browse other messages in\s+awesome_group/,
"displays the right browse more message"
);
await publishGroupUnreadToMessageBus({ groupIds: [14], topicId: 2 });
assert.ok(
query(".more-topics__browse-more")
.innerText.trim()
.match(
/There is 1 unread and 1 new message remaining, or browse other messages in\s+awesome_group/
),
"displays the right browse more message"
);
assert
.dom(".more-topics__browse-more")
.hasText(
/There is 1 unread\s+and 1 new message remaining, or browse other messages in\s+awesome_group/,
"displays the right browse more message"
);
});
}
);

@ -5,7 +5,7 @@ import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object";
import { i18n } from "discourse-i18n";
let deleteAndBlock = null;
let deleteAndBlock;
acceptance("User Profile - Summary", function (needs) {
needs.user();
@ -142,11 +142,7 @@ acceptance("User Profile - Summary - Admin", function (needs) {
server.delete("/admin/users/5.json", (request) => {
const data = helper.parsePostData(request.requestBody);
if (data.block_email || data.block_ip || data.block_urls) {
deleteAndBlock = true;
} else {
deleteAndBlock = false;
}
deleteAndBlock = !!(data.block_email || data.block_ip || data.block_urls);
return helper.response({});
});
@ -161,7 +157,7 @@ acceptance("User Profile - Summary - Admin", function (needs) {
await click(".btn-delete-user");
await click(".dialog-footer .btn-primary");
assert.notOk(deleteAndBlock, "first button does not block user");
assert.false(deleteAndBlock, "first button does not block user");
});
test("Delete and block", async function (assert) {
@ -173,6 +169,6 @@ acceptance("User Profile - Summary - Admin", function (needs) {
.hasText(i18n("admin.user.delete_confirm_title"), "dialog has a title");
await click(".dialog-footer .btn-danger");
assert.ok(deleteAndBlock, "second button also block user");
assert.true(deleteAndBlock, "second button also block user");
});
});

@ -57,25 +57,27 @@ acceptance("User Directory", function () {
await visit("/u");
const firstRowUserField = query(
".directory .directory-table__body .directory-table__row:first-child .directory-table__value--user-field"
);
assert
.dom(
".directory .directory-table__body .directory-table__row:first-child .directory-table__value--user-field a"
)
.exists("User field is displayed as a link");
const userFieldLink = firstRowUserField.querySelector("a");
assert
.dom(
".directory .directory-table__body .directory-table__row:first-child .directory-table__value--user-field a"
)
.hasAttribute(
"href",
"/u?name=Blue&order=likes_received",
"The link points to the correct URL"
);
assert.ok(userFieldLink, "User field is displayed as a link");
assert.strictEqual(
userFieldLink.getAttribute("href"),
"/u?name=Blue&order=likes_received",
"The link points to the correct URL"
);
assert.strictEqual(
userFieldLink.textContent.trim(),
"Blue",
"Link text is correct"
);
assert
.dom(
".directory .directory-table__body .directory-table__row:first-child .directory-table__value--user-field a"
)
.hasText("Blue", "Link text is correct");
});
test("Visit With Group Filter", async function (assert) {
@ -104,10 +106,9 @@ acceptance("User Directory", function () {
await triggerKeyEvent(secondHeading, "keypress", "Enter");
assert.ok(
query(`${secondHeading} .d-icon-chevron-up`),
"list has been sorted"
);
assert
.dom(`${secondHeading} .d-icon-chevron-up`)
.exists("list has been sorted");
});
test("Visit with no users", async function (assert) {

@ -6,24 +6,22 @@ acceptance("Video Placeholder Test", function () {
test("placeholder shows up on posts with videos", async function (assert) {
await visit("/t/54081");
const postWithVideo = document.querySelector(
".video-placeholder-container"
);
assert.ok(
postWithVideo.hasAttribute("data-video-src"),
"Video placeholder should have the 'data-video-src' attribute"
);
const overlay = postWithVideo.querySelector(".video-placeholder-overlay");
assert
.dom(".video-placeholder-container")
.hasAttribute(
"data-video-src",
/^\/uploads\/.+/,
"Video placeholder has the 'data-video-src' attribute"
);
assert.dom("video").doesNotExist("The video element does not exist yet");
await click(overlay); // Play button is clicked
await click(".video-placeholder-overlay"); // Play button is clicked
assert.dom(".video-container").exists("The video container appears");
assert
.dom(postWithVideo)
.dom(".video-placeholder-container")
.hasStyle({ cursor: "auto" }, "The cursor is set back to normal");
assert
@ -40,7 +38,7 @@ acceptance("Video Placeholder Test", function () {
"Video src is correctly set"
);
const video = postWithVideo.querySelector("video");
const video = document.querySelector("video");
video.play = function () {}; // We don't actually want the video to play in our test
const canPlayEvent = new Event("canplay");
video.dispatchEvent(canPlayEvent);

@ -1288,7 +1288,7 @@ module(
tree.refresh();
assert.strictEqual(tree.nodes.length, 4);
assert.ok(tree.nodes[2].active);
assert.true(tree.nodes[2].active);
assert.dom(tree.nodes[2].textElement).hasText("level1 3");
assert.dom(TOP_LEVEL_ADD_BTN).hasText("level1");
});

@ -2,17 +2,6 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
function dateInput() {
return query(".date-picker");
}
function setDate(date) {
this.set("date", date);
}
function noop() {}
const DEFAULT_DATE = moment("2019-01-29");
@ -24,35 +13,35 @@ module("Integration | Component | date-input", function (hooks) {
await render(hbs`<DateInput @date={{this.date}} />`);
assert.strictEqual(dateInput().value, "2019-01-29");
assert.dom(".date-picker").hasValue("2019-01-29");
});
test("prevents mutations", async function (assert) {
this.setProperties({ date: DEFAULT_DATE });
this.set("onChange", noop);
this.set("onChange", () => {});
await render(
hbs`<DateInput @date={{this.date}} @onChange={{this.onChange}} />`
);
dateInput().value = "2019-01-02";
dateInput().dispatchEvent(new Event("change"));
document.querySelector(".date-picker").value = "2019-01-02";
document.querySelector(".date-picker").dispatchEvent(new Event("change"));
assert.ok(this.date.isSame(DEFAULT_DATE));
assert.true(this.date.isSame(DEFAULT_DATE));
});
test("allows mutations through actions", async function (assert) {
this.setProperties({ date: DEFAULT_DATE });
this.set("onChange", setDate);
this.set("onChange", (date) => this.set("date", date));
await render(
hbs`<DateInput @date={{this.date}} @onChange={{this.onChange}} />`
);
dateInput().value = "2019-02-02";
dateInput().dispatchEvent(new Event("change"));
document.querySelector(".date-picker").value = "2019-02-02";
document.querySelector(".date-picker").dispatchEvent(new Event("change"));
assert.ok(this.date.isSame(moment("2019-02-02")));
assert.true(this.date.isSame(moment("2019-02-02")));
});
test("always shows date in timezone of input timestamp", async function (assert) {
@ -63,11 +52,11 @@ module("Integration | Component | date-input", function (hooks) {
await render(
hbs`<DateInput @date={{this.date}} @onChange={{this.onChange}} />`
);
assert.strictEqual(dateInput().value, "2023-05-05");
assert.dom(".date-picker").hasValue("2023-05-05");
this.setProperties({
date: moment.tz("2023-05-05T10:00:00", "ETC/GMT+12"),
});
assert.strictEqual(dateInput().value, "2023-05-05");
assert.dom(".date-picker").hasValue("2023-05-05");
});
});

@ -37,7 +37,7 @@ module("Integration | Component | date-time-input", function (hooks) {
dateInput().value = "2019-01-02";
assert.ok(this.date.isSame(DEFAULT_DATE_TIME));
assert.true(this.date.isSame(DEFAULT_DATE_TIME));
});
test("allows mutations through actions", async function (assert) {
@ -51,7 +51,7 @@ module("Integration | Component | date-time-input", function (hooks) {
dateInput().value = "2019-01-02";
dateInput().dispatchEvent(new Event("change"));
assert.ok(this.date.isSame(moment("2019-01-02 14:45")));
assert.true(this.date.isSame(moment("2019-01-02 14:45")));
});
test("can hide time", async function (assert) {

@ -22,8 +22,8 @@ module("Integration | Component | dialog-holder", function (hooks) {
test("basics", async function (assert) {
await render(hbs`<DialogHolder />`);
assert.ok(query("#dialog-holder"), "element is in DOM");
assert.dom("#dialog-holder").hasText("", "dialog is empty by default");
assert.dom("#dialog-holder").exists("element is in DOM");
assert.dom("#dialog-holder").hasNoText("dialog is empty by default");
this.dialog.alert({
message: "This is an error",
@ -38,20 +38,20 @@ module("Integration | Component | dialog-holder", function (hooks) {
// dismiss by clicking on overlay
await click(".dialog-overlay");
assert.ok(query("#dialog-holder"), "element is still in DOM");
assert.dom("#dialog-holder").exists("element is still in DOM");
assert.strictEqual(
query(".dialog-overlay").offsetWidth,
0,
"overlay is not visible"
);
assert.dom("#dialog-holder").hasText("", "dialog is empty");
assert.dom("#dialog-holder").hasNoText("dialog is empty");
});
test("basics - dismiss using Esc", async function (assert) {
let cancelCallbackCalled = false;
await render(hbs`<DialogHolder />`);
assert.ok(query("#dialog-holder"), "element is in DOM");
assert.dom("#dialog-holder").hasText("", "dialog is empty by default");
assert.dom("#dialog-holder").exists("element is in DOM");
assert.dom("#dialog-holder").hasNoText("dialog is empty by default");
this.dialog.alert({
message: "This is an error",
@ -69,8 +69,8 @@ module("Integration | Component | dialog-holder", function (hooks) {
// dismiss by pressing Esc
await triggerKeyEvent(document.activeElement, "keydown", "Escape");
assert.ok(cancelCallbackCalled, "cancel callback called");
assert.ok(query("#dialog-holder"), "element is still in DOM");
assert.true(cancelCallbackCalled, "cancel callback called");
assert.dom("#dialog-holder").exists("element is still in DOM");
assert.strictEqual(
query(".dialog-overlay").offsetWidth,
@ -78,7 +78,7 @@ module("Integration | Component | dialog-holder", function (hooks) {
"overlay is not visible"
);
assert.dom("#dialog-holder").hasText("", "dialog is empty");
assert.dom("#dialog-holder").hasNoText("dialog is empty");
});
test("alert with title", async function (assert) {
@ -95,26 +95,23 @@ module("Integration | Component | dialog-holder", function (hooks) {
.dom("#dialog-title")
.hasText("And this is a title", "dialog has title");
assert.ok(
query("#dialog-holder[aria-labelledby='dialog-title']"),
"aria-labelledby is correctly set"
);
assert.dom("#dialog-holder").hasAria("labelledby", "dialog-title");
assert.ok(query(".dialog-close"), "close button present");
assert.ok(query("#dialog-holder"), "element is still in DOM");
assert.dom(".dialog-close").exists("close button present");
assert.dom("#dialog-holder").exists("element is still in DOM");
assert
.dom(".dialog-body")
.hasText("This is a note.", "dialog message is shown");
await click(".dialog-close");
assert.ok(query("#dialog-holder"), "element is still in DOM");
assert.dom("#dialog-holder").exists("element is still in DOM");
assert.strictEqual(
query(".dialog-overlay").offsetWidth,
0,
"overlay is not visible"
);
assert.dom("#dialog-holder").hasText("", "dialog is empty");
assert.dom("#dialog-holder").hasNoText("dialog is empty");
});
test("alert with a string parameter", async function (assert) {
@ -161,10 +158,10 @@ module("Integration | Component | dialog-holder", function (hooks) {
await click(".dialog-footer .btn-primary");
assert.ok(confirmCallbackCalled, "confirm callback called");
assert.notOk(cancelCallbackCalled, "cancel callback NOT called");
assert.true(confirmCallbackCalled, "confirm callback called");
assert.false(cancelCallbackCalled, "cancel callback NOT called");
assert.dom("#dialog-holder").hasText("", "dialog is empty");
assert.dom("#dialog-holder").hasNoText("dialog is empty");
});
test("cancel callback", async function (assert) {
@ -189,10 +186,10 @@ module("Integration | Component | dialog-holder", function (hooks) {
.hasText("A confirm message", "dialog message is shown");
await click(".dialog-footer .btn-default");
assert.notOk(confirmCallbackCalled, "confirm callback NOT called");
assert.ok(cancelCallbackCalled, "cancel callback called");
assert.false(confirmCallbackCalled, "confirm callback NOT called");
assert.true(cancelCallbackCalled, "cancel callback called");
assert.dom("#dialog-holder").hasText("", "dialog has been dismissed");
assert.dom("#dialog-holder").hasNoText("dialog has been dismissed");
});
test("yes/no confirm", async function (assert) {
@ -244,19 +241,17 @@ module("Integration | Component | dialog-holder", function (hooks) {
.dom(".dialog-footer .btn-danger")
.hasText("Danger ahead", "dialog custom button is present");
assert.notOk(
query(".dialog-footer .btn-primary"),
"default confirm button is not present"
);
assert.notOk(
query(".dialog-footer .btn-default"),
"default cancel button is not present"
);
assert
.dom(".dialog-footer .btn-primary")
.doesNotExist("default confirm button is not present");
assert
.dom(".dialog-footer .btn-default")
.doesNotExist("default cancel button is not present");
await click(".dialog-footer .btn-danger");
assert.ok(customCallbackTriggered, "custom action was triggered");
assert.true(customCallbackTriggered, "custom action was triggered");
assert.dom("#dialog-holder").hasText("", "dialog has been dismissed");
assert.dom("#dialog-holder").hasNoText("dialog has been dismissed");
});
test("alert with custom classes", async function (assert) {
@ -272,22 +267,25 @@ module("Integration | Component | dialog-holder", function (hooks) {
.dom(".dialog-body")
.hasText("An alert with custom classes", "dialog message is shown");
assert.ok(
query("#dialog-holder.dialog-special.dialog-super"),
"additional classes are present"
);
assert
.dom("#dialog-holder.dialog-special.dialog-super")
.exists("additional classes are present");
await click(".dialog-footer .btn-primary");
assert.notOk(
query("#dialog-holder.dialog-special"),
"additional class removed on dismissal"
);
assert
.dom("#dialog-holder")
.doesNotHaveClass(
"dialog-special",
"additional class removed on dismissal"
);
assert.notOk(
query("#dialog-holder.dialog-super"),
"additional class removed on dismissal"
);
assert
.dom("#dialog-holder")
.doesNotHaveClass(
"dialog-super",
"additional class removed on dismissal"
);
});
test("notice", async function (assert) {
@ -298,8 +296,8 @@ module("Integration | Component | dialog-holder", function (hooks) {
assert.dom(".dialog-body").hasText("Noted!", "message is shown");
assert.notOk(query(".dialog-footer"), "no footer");
assert.notOk(query(".dialog-header"), "no header");
assert.dom(".dialog-footer").doesNotExist("no footer");
assert.dom(".dialog-header").doesNotExist("no header");
});
test("delete confirm", async function (assert) {
@ -319,10 +317,9 @@ module("Integration | Component | dialog-holder", function (hooks) {
"dialog primary button use danger class and label is Delete"
);
assert.notOk(
query(".dialog-footer .btn-primary"),
".btn-primary element is not present in the dialog"
);
assert
.dom(".dialog-footer .btn-primary")
.doesNotExist(".btn-primary element is not present in the dialog");
});
test("delete confirm with confirmation phrase component", async function (assert) {

@ -62,7 +62,7 @@ module("Integration | Component | FloatKit | d-menu", function (hooks) {
hbs`<DMenu @inline={{true}} @onRegisterApi={{this.onRegisterApi}} />`
);
assert.ok(this.api instanceof DMenuInstance);
assert.true(this.api instanceof DMenuInstance);
});
test("@onShow", async function (assert) {
@ -320,7 +320,7 @@ module("Integration | Component | FloatKit | d-menu", function (hooks) {
await click(".second.fk-d-menu__trigger");
assert.dom(".fk-d-menu.first").exists("it doesnt autoclose");
assert.dom(".fk-d-menu.first").exists("doesnt autoclose");
assert.dom(".fk-d-menu.second").exists();
});

@ -6,10 +6,8 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import DToast from "float-kit/components/d-toast";
import DToastInstance from "float-kit/lib/d-toast-instance";
const TOAST_SELECTOR = ".fk-d-toast";
function createCustomToastInstance(owner, options, newClose) {
const custom = class CustomToastInstance extends DToastInstance {
class CustomToastInstance extends DToastInstance {
constructor() {
super(owner, options);
}
@ -18,9 +16,9 @@ function createCustomToastInstance(owner, options, newClose) {
close() {
newClose.apply(this);
}
};
}
return new custom(owner, options);
return new CustomToastInstance(owner, options);
}
module("Integration | Component | FloatKit | d-toast", function (hooks) {
@ -35,23 +33,23 @@ module("Integration | Component | FloatKit | d-toast", function (hooks) {
await render(<template><DToast @toast={{toast}} /></template>);
assert.dom(TOAST_SELECTOR).exists();
assert.dom(".fk-d-toast").exists();
await triggerEvent(TOAST_SELECTOR, "touchstart", {
await triggerEvent(".fk-d-toast", "touchstart", {
touches: [{ clientX: 0, clientY: 0 }],
changedTouches: [{ clientX: 0, clientY: 0 }],
});
await triggerEvent(TOAST_SELECTOR, "touchmove", {
await triggerEvent(".fk-d-toast", "touchmove", {
touches: [{ clientX: 0, clientY: -100 }],
changedTouches: [{ clientX: 0, clientY: -100 }],
});
await triggerEvent(TOAST_SELECTOR, "touchend", {
await triggerEvent(".fk-d-toast", "touchend", {
touches: [{ clientX: 0, clientY: -100 }],
changedTouches: [{ clientX: 0, clientY: -100 }],
});
assert.ok(closing);
assert.true(closing);
});
});

@ -55,7 +55,7 @@ module("Integration | Component | FloatKit | d-tooltip", function (hooks) {
hbs`<DTooltip @inline={{true}} @onRegisterApi={{this.onRegisterApi}} />`
);
assert.ok(this.api instanceof DTooltipInstance);
assert.true(this.api instanceof DTooltipInstance);
});
test("@onShow", async function (assert) {

@ -27,6 +27,6 @@ module("Integration | Component | load-more", function (hooks) {
</LoadMore>
`);
assert.ok(this.loadedMore);
assert.true(this.loadedMore);
});
});

@ -46,12 +46,12 @@ module("Integration | Component | select-kit/api", function (hooks) {
assert.strictEqual(this.comboBox.rows().length, 4);
const appendedRow = this.comboBox.rowByIndex(3);
assert.ok(appendedRow.exists());
assert.true(appendedRow.exists());
assert.strictEqual(appendedRow.value(), "alpaca");
await this.comboBox.collapse();
assert.notOk(this.singleSelect.rowByValue("alpaca").exists());
assert.false(this.singleSelect.rowByValue("alpaca").exists());
});
test("modifySelectKit(identifier).prependContent", async function (assert) {
@ -76,12 +76,12 @@ module("Integration | Component | select-kit/api", function (hooks) {
assert.strictEqual(this.comboBox.rows().length, 4);
const prependedRow = this.comboBox.rowByIndex(0);
assert.ok(prependedRow.exists());
assert.true(prependedRow.exists());
assert.strictEqual(prependedRow.value(), "alpaca");
await this.comboBox.collapse();
assert.notOk(this.singleSelect.rowByValue("alpaca").exists());
assert.false(this.singleSelect.rowByValue("alpaca").exists());
});
test("modifySelectKit(identifier).onChange", async function (assert) {
@ -125,11 +125,11 @@ module("Integration | Component | select-kit/api", function (hooks) {
assert.strictEqual(this.comboBox.rows().length, 1);
const replacementRow = this.comboBox.rowByIndex(0);
assert.ok(replacementRow.exists());
assert.true(replacementRow.exists());
assert.strictEqual(replacementRow.value(), "alpaca");
await this.comboBox.collapse();
assert.notOk(this.singleSelect.rowByValue("alpaca").exists());
assert.false(this.singleSelect.rowByValue("alpaca").exists());
});
});

@ -49,12 +49,9 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
/>
`);
const header = this.subject.header().el();
assert.ok(
header.querySelector(`.d-icon-caret-right`),
"it uses the correct default icon"
);
assert
.dom(".d-icon-caret-right", this.subject.header().el())
.exists("uses the correct default icon");
});
test("none", async function (assert) {
@ -69,7 +66,7 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
assert.strictEqual(
text,
i18n("categories.categories_label"),
"it uses the noneLabel"
"uses the noneLabel"
);
});
@ -90,10 +87,9 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
await this.subject.expand();
const row = this.subject.rowByValue(this.category.id);
assert.ok(
row.el().querySelector(".category-desc"),
"it shows category description for newcomers"
);
assert
.dom(".category-desc", row.el())
.exists("shows category description for newcomers");
});
test("[not staff - TL1] displayCategoryDescription", async function (assert) {
@ -113,10 +109,9 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
await this.subject.expand();
const row = this.subject.rowByValue(this.category.id);
assert.notOk(
row.el().querySelector(".category-desc"),
"it doesn't shows category description for TL0+"
);
assert
.dom(".category-desc", row.el())
.doesNotExist("doesn't shows category description for TL0+");
});
test("[staff - TL0] displayCategoryDescription", async function (assert) {
@ -136,10 +131,9 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
await this.subject.expand();
const row = this.subject.rowByValue(this.category.id);
assert.notOk(
row.el().querySelector(".category-desc"),
"it doesn't show category description for staff"
);
assert
.dom(".category-desc", row.el())
.doesNotExist("doesn't show category description for staff");
});
test("hideParentCategory (default: false)", async function (assert) {
@ -177,15 +171,14 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
await this.subject.expand();
const parentRow = this.subject.rowByValue(this.parentCategory.id);
assert.notOk(parentRow.exists(), "the parent row is not showing");
assert.false(parentRow.exists(), "the parent row is not showing");
const childCategory = this.categories.firstObject;
const childCategoryId = childCategory.id;
const childRow = this.subject.rowByValue(childCategoryId);
assert.ok(childRow.exists(), "the child row is showing");
assert.true(childRow.exists(), "the child row is showing");
const categoryStatus = childRow.el().querySelector(".category-status");
assert.ok(categoryStatus.innerText.trim().match(/^spec/));
assert.dom(".category-status", childRow.el()).includesText("spec");
});
test("allow_uncategorized_topics (true)", async function (assert) {
@ -204,7 +197,7 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
const uncategorizedCategoryId = this.site.uncategorized_category_id;
const row = this.subject.rowByValue(uncategorizedCategoryId);
assert.ok(row.exists(), "the uncategorized row is showing");
assert.true(row.exists(), "the uncategorized row is showing");
});
test("allow_uncategorized_topics (false)", async function (assert) {
@ -223,7 +216,7 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
const uncategorizedCategoryId = this.site.uncategorized_category_id;
const row = this.subject.rowByValue(uncategorizedCategoryId);
assert.notOk(row.exists(), "the uncategorized row is not showing");
assert.false(row.exists(), "the uncategorized row is not showing");
});
test("countSubcategories (default: false)", async function (assert) {
@ -246,7 +239,7 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
assert.strictEqual(
topicCount,
"× 481",
"it doesn't include the topic count of subcategories"
"doesn't include the topic count of subcategories"
);
});
@ -273,7 +266,7 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
assert.strictEqual(
topicCount,
"× 584",
"it includes the topic count of subcategories"
"includes the topic count of subcategories"
);
});
@ -369,9 +362,9 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
await this.subject.expand();
await this.subject.selectRowByValue(26);
assert.ok(
assert.true(
DiscourseURL.routeTo.calledWith("/c/feature/spec/26"),
"it builds a correct URL"
"builds a correct URL"
);
});
});

@ -49,10 +49,7 @@ module("Integration | Component | select-kit/combo-box", function (hooks) {
const header = this.subject.header();
assert.ok(
header.el().querySelector(".btn-clear"),
"it shows the clear button"
);
assert.dom(".btn-clear", header.el()).exists("shows the clear button");
assert.strictEqual(header.value(), DEFAULT_VALUE.toString());
await click(header.el().querySelector(".btn-clear"));
@ -82,16 +79,14 @@ module("Integration | Component | select-kit/combo-box", function (hooks) {
const header = this.subject.header().el();
assert.ok(
header.querySelector(`.d-icon-${this.caretDownIcon}`),
"it uses the icon provided"
);
assert
.dom(`.d-icon-${this.caretDownIcon}`, header)
.exists("uses the icon provided");
await this.subject.expand();
assert.ok(
header.querySelector(`.d-icon-${this.caretUpIcon}`),
"it uses the icon provided"
);
assert
.dom(`.d-icon-${this.caretUpIcon}`, header)
.exists("uses the icon provided");
});
});

@ -46,7 +46,7 @@ module(
`);
await this.subject.expand();
assert.ok(this.subject.isExpanded());
assert.true(this.subject.isExpanded());
await this.subject.selectRowByValue(DEFAULT_VALUE);
assert.false(
@ -83,7 +83,7 @@ module(
.hasAttribute(
"title",
"[en.test_none]",
"it adds a title attribute to the button"
"adds a title attribute to the button"
);
});
@ -100,10 +100,9 @@ module(
/>
`);
assert.ok(
this.subject.header().el().querySelector(".selected-name"),
"it shows the text of the selected item"
);
assert
.dom(".selected-name", this.subject.header().el())
.exists("shows the text of the selected item");
});
}
);

@ -45,7 +45,7 @@ module(
});
await render(hbs`<FormTemplateChooser />`);
assert.ok(this.subject.isDisabled());
assert.true(this.subject.isDisabled());
});
}
);

@ -89,7 +89,7 @@ module(
const options = getOptions();
const customDateAndTime = i18n("time_shortcut.custom");
assert.ok(options.includes(customDateAndTime));
assert.true(options.includes(customDateAndTime));
});
test("doesn't show 'Custom date and time' if disabled", async function (assert) {
@ -117,7 +117,7 @@ module(
const options = getOptions();
const now = i18n("time_shortcut.now");
assert.ok(options.includes(now));
assert.true(options.includes(now));
});
test("changing date/time updates the input correctly", async function (assert) {
@ -129,13 +129,13 @@ module(
await fillIn(".time-input", "11:15");
assert.ok(this.input.includes("2032-01-01"));
assert.ok(this.input.includes("11:15"));
assert.true(this.input.includes("2032-01-01"));
assert.true(this.input.includes("11:15"));
await fillIn(".date-picker", "2033-01-01 ");
assert.ok(this.input.includes("2033-01-01"));
assert.ok(this.input.includes("11:15"));
assert.true(this.input.includes("2033-01-01"));
assert.true(this.input.includes("11:15"));
});
}
);

@ -42,21 +42,21 @@ module("Integration | Component | select-kit/multi-select", function (hooks) {
await this.subject.expand();
const content = this.subject.displayedContent();
assert.strictEqual(content.length, 3, "it shows rows");
assert.strictEqual(content.length, 3, "shows rows");
assert.strictEqual(
content[0].name,
this.content.firstObject.name,
"it has the correct name"
"has the correct name"
);
assert.strictEqual(
content[0].id,
this.content.firstObject.id.toString(),
"it has the correct value"
"has the correct value"
);
assert.strictEqual(
this.subject.header().value(),
null,
"it doesn't set a value from the content"
"doesn't set a value from the content"
);
});
@ -79,9 +79,9 @@ module("Integration | Component | select-kit/multi-select", function (hooks) {
await this.subject.expand();
await this.subject.deselectItemByValue(1);
assert.ok(
assert.true(
this.subject.isExpanded(),
"it doesnt close the dropdown when no selection has been made"
"doesnt close the dropdown when no selection has been made"
);
});
@ -99,7 +99,7 @@ module("Integration | Component | select-kit/multi-select", function (hooks) {
await this.subject.expand();
await this.subject.selectRowByValue(1);
assert.ok(this.subject.isExpanded(), "it doesnt close the dropdown");
assert.true(this.subject.isExpanded(), "doesnt close the dropdown");
});
test("pasting", async function (assert) {
@ -129,6 +129,6 @@ module("Integration | Component | select-kit/multi-select", function (hooks) {
assert
.dom(".selected-content")
.doesNotExist("it doesnt render an empty content div");
.doesNotExist("doesnt render an empty content div");
});
});

@ -29,14 +29,14 @@ module(
/>
`);
assert.ok(this.subject.header().value());
assert.true(!!this.subject.header().value());
assert.ok(
assert.true(
this.subject
.header()
.label()
.includes(`${this.i18nPrefix}.regular${this.i18nPostfix}`),
"it shows the regular choice when value is not set"
"shows the regular choice when value is not set"
);
assert

@ -45,21 +45,21 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
await this.subject.expand();
const content = this.subject.displayedContent();
assert.strictEqual(content.length, 3, "it shows rows");
assert.strictEqual(content.length, 3, "shows rows");
assert.strictEqual(
content[0].name,
this.content.firstObject.name,
"it has the correct name"
"has the correct name"
);
assert.strictEqual(
content[0].id,
this.content.firstObject.id.toString(),
"it has the correct value"
"has the correct value"
);
assert.strictEqual(
this.subject.header().value(),
null,
"it doesn't set a value from the content"
"doesn't set a value from the content"
);
});
@ -71,17 +71,15 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
await this.subject.expand();
const content = this.subject.displayedContent();
assert.strictEqual(content.length, 3, "it shows rows");
assert.strictEqual(content.length, 3, "shows rows");
assert
.dom(".select-kit-header")
.isFocused("it should focus the header first");
assert.dom(".select-kit-header").isFocused("focuses the header first");
await tab();
assert
.dom(".select-kit-row:first-child")
.isFocused("it should focus the first row next");
.isFocused("focuses the first row next");
await tab();
@ -104,7 +102,7 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
await this.subject.expand();
assert.ok(this.subject.isExpanded(), "dropdown is expanded again");
assert.true(this.subject.isExpanded(), "dropdown is expanded again");
await tab({ backwards: true });
@ -127,7 +125,7 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
assert.strictEqual(
this.subject.header().value(this.content),
"1",
"it selects the correct content to display"
"selects the correct content to display"
);
});
@ -148,14 +146,14 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
`);
await this.subject.expand();
assert.ok(this.subject.filter().exists(), "it shows the filter");
assert.true(this.subject.filter().exists(), "shows the filter");
const filter = this.subject.displayedContent()[1].name;
await this.subject.fillInFilter(filter);
assert.strictEqual(
this.subject.displayedContent()[0].name,
filter,
"it filters the list"
"filters the list"
);
});
@ -182,7 +180,7 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
assert.strictEqual(
this.subject.displayedContent().length,
1,
"it returns only 1 result"
"returns only 1 result"
);
});
@ -474,7 +472,7 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
const header = query(".select-kit-header").getBoundingClientRect();
const body = query(".select-kit-body").getBoundingClientRect();
assert.ok(header.bottom > body.top, "it correctly offsets the body");
assert.true(header.bottom > body.top, "correctly offsets the body");
});
test("options.expandedOnInsert", async function (assert) {

@ -1,29 +1,19 @@
import { hash } from "@ember/helper";
import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from "discourse-i18n";
function initTags(context) {
const categories = context.site.categoriesList;
const category = categories.findBy("id", 2);
// top_tags
context.setProperties({
currentCategory: category,
tagId: "jeff",
});
}
import TagDrop from "select-kit/components/tag-drop";
module("Integration | Component | select-kit/tag-drop", function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
this.set("subject", selectKit());
this.subject = selectKit();
this.site.set("top_tags", ["jeff", "neil", "arpit", "régis"]);
this.site.top_tags = ["jeff", "neil", "arpit", "régis"];
pretender.get("/tags/filter/search", (params) => {
if (params.queryParams.q === "dav") {
@ -35,17 +25,16 @@ module("Integration | Component | select-kit/tag-drop", function (hooks) {
});
test("default", async function (assert) {
initTags(this);
const categories = this.site.categoriesList;
const category = categories.findBy("id", 2);
await render(hbs`
await render(<template>
<TagDrop
@currentCategory={{this.currentCategory}}
@tagId={{this.tagId}}
@options={{hash
tagId=this.tagId
}}
@currentCategory={{category}}
@tagId={{"jeff"}}
@options={{hash tagId="jeff"}}
/>
`);
</template>);
await this.subject.expand();
@ -54,46 +43,43 @@ module("Integration | Component | select-kit/tag-drop", function (hooks) {
assert.strictEqual(
content[0].name,
i18n("tagging.selector_remove_filter"),
"it has the correct label for removing the tag filter"
"has the correct label for removing the tag filter"
);
assert.strictEqual(
content[1].name,
i18n("tagging.selector_no_tags"),
"it has the translated label for no-tags"
"has the translated label for no-tags"
);
await this.subject.fillInFilter("dav");
assert.strictEqual(
this.subject.rows()[0].textContent.trim(),
"David",
"it has no tag count when filtering in a category context"
);
assert
.dom(this.subject.rows()[0])
.hasText(
"David",
"has no tag count when filtering in a category context"
);
});
test("default global (no category)", async function (assert) {
await render(hbs`<TagDrop />`);
await render(<template><TagDrop /></template>);
await this.subject.expand();
await this.subject.fillInFilter("dav");
assert.strictEqual(
this.subject.rows()[0].textContent.trim(),
"David x2",
"it has the tag count"
);
assert.dom(this.subject.rows()[0]).hasText("David x2", "has the tag count");
});
test("default global (no category)", async function (assert) {
test("default global (no category, max tags)", async function (assert) {
this.siteSettings.max_tags_in_filter_list = 3;
await render(hbs`<TagDrop />`);
await render(<template><TagDrop /></template>);
await this.subject.expand();
assert.dom(".filter-for-more").exists("it has the 'filter for more' note");
assert.dom(".filter-for-more").exists("has the 'filter for more' note");
await this.subject.fillInFilter("dav");
assert
.dom(".filter-for-more")
.doesNotExist("it does not have the 'filter for more' note");
.doesNotExist("does not have the 'filter for more' note");
});
});

@ -43,11 +43,11 @@ module(
[NOTIFICATION_TYPES.bookmark_reminder]: 72,
});
await render(template);
const dismiss = query(".panel-body-bottom .notifications-dismiss");
assert.ok(
dismiss,
"dismiss button is shown if the user has unread bookmark_reminder notifications"
);
assert
.dom(".panel-body-bottom .notifications-dismiss")
.exists(
"dismiss button is shown if the user has unread bookmark_reminder notifications"
);
assert
.dom(".panel-body-bottom .notifications-dismiss")
.hasAttribute(

@ -270,11 +270,11 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
});
await render(template);
const dismiss = query(".panel-body-bottom .notifications-dismiss");
assert.ok(
dismiss,
"dismiss button is shown if the user has unread private_message notifications"
);
assert
.dom(".panel-body-bottom .notifications-dismiss")
.exists(
"dismiss button is shown if the user has unread private_message notifications"
);
assert
.dom(".panel-body-bottom .notifications-dismiss")
.hasAttribute(

@ -115,7 +115,7 @@ module(
});
assert.strictEqual(notificationsFetches, 1);
await click(".panel-body-bottom .btn.notifications-dismiss");
assert.ok(markRead, "request to the server is made");
assert.true(markRead, "request to the server is made");
assert.strictEqual(
notificationsFetches,
2,
@ -213,23 +213,23 @@ module(
});
await render(template);
const items = queryAll("ul li");
assert.ok(
assert.true(
items[0].textContent.includes("hello world 0011"),
"the first pending reviewable is displayed 1st because it's most recent among pending reviewables and unread notifications"
);
assert.ok(
assert.true(
items[1].textContent.includes("Unread notification #01"),
"the first unread notification is displayed 2nd because it's the 2nd most recent among pending reviewables and unread notifications"
);
assert.ok(
assert.true(
items[2].textContent.includes("Unread notification #02"),
"the second unread notification is displayed 3rd because it's the 3rd most recent among pending reviewables and unread notifications"
);
assert.ok(
assert.true(
items[3].textContent.includes("hello world 0033"),
"the second pending reviewable is displayed 4th because it's the 4th most recent among pending reviewables and unread notifications"
);
assert.ok(
assert.true(
items[4].textContent.includes("Read notification #01"),
"read notifications come after the pending reviewables and unread notifications"
);

@ -30,7 +30,7 @@ module("Integration | Component | watched-word-uploader", function (hooks) {
)[0][1].meta.action_key,
"flag"
);
assert.ok(
assert.true(
dialog.alert.calledWith(
i18n("admin.watched_words.form.upload_successful")
),

@ -120,7 +120,7 @@ module(
`);
await click(".post-info .wiki");
assert.ok(
assert.true(
this.historyShown,
"clicking the wiki icon displays the post history"
);
@ -136,7 +136,7 @@ module(
`);
await click(".post-info .wiki");
assert.ok(this.editPostCalled, "clicking wiki icon edits the post");
assert.true(this.editPostCalled, "clicking wiki icon edits the post");
});
test("via-email", async function (assert) {
@ -149,7 +149,7 @@ module(
);
await click(".post-info.via-email");
assert.ok(
assert.true(
this.rawEmailShown,
"clicking the envelope shows the raw email"
);
@ -182,7 +182,7 @@ module(
);
await click(".post-info.edits button");
assert.ok(this.historyShown, "clicking the pencil shows the history");
assert.true(this.historyShown, "clicking the pencil shows the history");
});
test("history without view permission", async function (assert) {
@ -285,7 +285,7 @@ module(
);
await click(".topic-body .expand-hidden");
assert.ok(this.unhidden, "triggers the action");
assert.true(this.unhidden, "triggers the action");
});
test(`cooked content hidden - can't view hidden post`, async function (assert) {
@ -374,7 +374,7 @@ module(
await click(
"[data-content][data-identifier='admin-post-menu'] .permanently-delete"
);
assert.ok(this.deleted);
assert.true(this.deleted);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@ -409,7 +409,7 @@ module(
await click(
"[data-content][data-identifier='admin-post-menu'] .permanently-delete"
);
assert.ok(this.deleted);
assert.true(this.deleted);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@ -444,7 +444,7 @@ module(
"[data-content][data-identifier='admin-post-menu'] .toggle-post-type"
);
assert.ok(this.toggled);
assert.true(this.toggled);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@ -473,7 +473,7 @@ module(
await click(
"[data-content][data-identifier='admin-post-menu'] .rebuild-html"
);
assert.ok(this.baked);
assert.true(this.baked);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@ -499,7 +499,7 @@ module(
"[data-content][data-identifier='admin-post-menu'] .unhide-post"
);
assert.ok(unhidden);
assert.true(unhidden);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
@ -531,7 +531,7 @@ module(
await click(
"[data-content][data-identifier='admin-post-menu'] .change-owner"
);
assert.ok(this.owned);
assert.true(this.owned);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");

@ -101,7 +101,7 @@ module("Integration | Component | Widget | post", function (hooks) {
`);
await click(".post-info .wiki");
assert.ok(
assert.true(
this.historyShown,
"clicking the wiki icon displays the post history"
);
@ -116,7 +116,7 @@ module("Integration | Component | Widget | post", function (hooks) {
`);
await click(".post-info .wiki");
assert.ok(this.editPostCalled, "clicking wiki icon edits the post");
assert.true(this.editPostCalled, "clicking wiki icon edits the post");
});
test("via-email", async function (assert) {
@ -129,7 +129,10 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click(".post-info.via-email");
assert.ok(this.rawEmailShown, "clicking the envelope shows the raw email");
assert.true(
this.rawEmailShown,
"clicking the envelope shows the raw email"
);
});
test("via-email without permission", async function (assert) {
@ -159,7 +162,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click(".post-info.edits button");
assert.ok(this.historyShown, "clicking the pencil shows the history");
assert.true(this.historyShown, "clicking the pencil shows the history");
});
test("history without view permission", async function (assert) {
@ -254,7 +257,7 @@ module("Integration | Component | Widget | post", function (hooks) {
assert
.dom(".actions button.post-action-menu__copy-link")
.exists("it renders a copy link button");
.exists("renders a copy link button");
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@ -309,7 +312,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click(".actions button.like");
assert.ok(this.loginShown);
assert.true(this.loginShown);
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@ -323,7 +326,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click("button.edit");
assert.ok(this.editPostCalled, "it triggered the edit action");
assert.true(this.editPostCalled, "triggered the edit action");
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@ -347,7 +350,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click("button.delete");
assert.ok(this.deletePostCalled, "it triggered the delete action");
assert.true(this.deletePostCalled, "triggered the delete action");
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@ -395,7 +398,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click("button.recover");
assert.ok(this.recovered);
assert.true(this.recovered);
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@ -420,7 +423,7 @@ module("Integration | Component | Widget | post", function (hooks) {
await click(".show-more-actions");
await click("button.delete");
assert.ok(this.deletePostCalled, "it triggered the delete action");
assert.true(this.deletePostCalled, "triggered the delete action");
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@ -461,7 +464,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click("button.recover");
assert.ok(this.recovered);
assert.true(this.recovered);
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@ -486,7 +489,7 @@ module("Integration | Component | Widget | post", function (hooks) {
assert.dom("button.create-flag").exists();
await click("button.create-flag");
assert.ok(this.flagsShown, "it triggered the action");
assert.true(this.flagsShown, "triggered the action");
});
test(`flagging: can't flag`, async function (assert) {
@ -580,7 +583,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click(".topic-body .expand-hidden");
assert.ok(this.unhidden, "triggers the action");
assert.true(this.unhidden, "triggers the action");
});
test(`cooked content hidden - can't view hidden post`, async function (assert) {
@ -697,7 +700,7 @@ module("Integration | Component | Widget | post", function (hooks) {
await click(
"[data-content][data-identifier='admin-post-menu'] .permanently-delete"
);
assert.ok(this.deleted);
assert.true(this.deleted);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@ -732,7 +735,7 @@ module("Integration | Component | Widget | post", function (hooks) {
await click(
"[data-content][data-identifier='admin-post-menu'] .permanently-delete"
);
assert.ok(this.deleted);
assert.true(this.deleted);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@ -766,7 +769,7 @@ module("Integration | Component | Widget | post", function (hooks) {
"[data-content][data-identifier='admin-post-menu'] .toggle-post-type"
);
assert.ok(this.toggled);
assert.true(this.toggled);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@ -794,7 +797,7 @@ module("Integration | Component | Widget | post", function (hooks) {
await click(
"[data-content][data-identifier='admin-post-menu'] .rebuild-html"
);
assert.ok(this.baked);
assert.true(this.baked);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@ -827,7 +830,7 @@ module("Integration | Component | Widget | post", function (hooks) {
"[data-content][data-identifier='admin-post-menu'] .unhide-post"
);
assert.ok(unhidden);
assert.true(unhidden);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
@ -858,7 +861,7 @@ module("Integration | Component | Widget | post", function (hooks) {
await click(
"[data-content][data-identifier='admin-post-menu'] .change-owner"
);
assert.ok(this.owned);
assert.true(this.owned);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@ -874,7 +877,7 @@ module("Integration | Component | Widget | post", function (hooks) {
`);
await click(".post-controls .create");
assert.ok(this.replied);
assert.true(this.replied);
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb

@ -103,7 +103,7 @@ module("Unit | Controller | admin-user-badges", function (hooks) {
controller.performGrantBadge();
await settled();
assert.ok(
assert.true(
GrantBadgeStub.calledWith(badgeToGrant.id, user.username, badgeReason)
);

@ -25,12 +25,12 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
const model = this.store.createRecord("topic");
controller.setProperties({ model });
assert.notOk(controller.editingTopic, "we are not editing by default");
assert.false(controller.editingTopic, "we are not editing by default");
controller.set("model.details.can_edit", false);
controller.editTopic();
assert.notOk(
assert.false(
controller.editingTopic,
"calling editTopic doesn't enable editing unless the user can edit"
);
@ -38,7 +38,7 @@ module("Unit | Controller | topic", function (hooks) {
controller.set("model.details.can_edit", true);
controller.editTopic();
assert.ok(
assert.true(
controller.editingTopic,
"calling editTopic enables editing if the user can edit"
);
@ -47,7 +47,7 @@ module("Unit | Controller | topic", function (hooks) {
controller.send("cancelEditingTopic");
assert.notOk(
assert.false(
controller.editingTopic,
"cancelling edit mode reverts the property value"
);
@ -70,12 +70,12 @@ module("Unit | Controller | topic", function (hooks) {
model.set("views", 10000);
controller.send("deleteTopic");
assert.notOk(destroyed, "don't destroy popular topic");
assert.ok(modalDisplayed, "display confirmation modal for popular topic");
assert.false(destroyed, "don't destroy popular topic");
assert.true(modalDisplayed, "display confirmation modal for popular topic");
model.set("views", 3);
controller.send("deleteTopic");
assert.ok(destroyed, "destroy not popular topic");
assert.true(destroyed, "destroy not popular topic");
});
test("deleteTopic permanentDelete", function (assert) {
@ -104,7 +104,7 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
controller.setProperties({ model });
assert.notOk(
assert.false(
controller.multiSelect,
"multi selection mode is disabled by default"
);
@ -115,7 +115,7 @@ module("Unit | Controller | topic", function (hooks) {
controller.send("toggleMultiSelect");
await settled();
assert.ok(
assert.true(
controller.multiSelect,
"calling 'toggleMultiSelect' once enables multi selection mode"
);
@ -131,7 +131,7 @@ module("Unit | Controller | topic", function (hooks) {
controller.send("toggleMultiSelect");
await settled();
assert.notOk(
assert.false(
controller.multiSelect,
"calling 'toggleMultiSelect' twice disables multi selection mode"
);
@ -156,7 +156,7 @@ module("Unit | Controller | topic", function (hooks) {
2,
"selectedPosts only contains already loaded posts"
);
assert.notOk(
assert.false(
controller.selectedPosts.some((p) => p === undefined),
"selectedPosts only contains valid post objects"
);
@ -168,13 +168,13 @@ module("Unit | Controller | topic", function (hooks) {
controller.setProperties({ model });
controller.set("selectedPostIds", [1, 2]);
assert.notOk(controller.selectedAllPosts, "not all posts are selected");
assert.false(controller.selectedAllPosts, "not all posts are selected");
controller.selectedPostIds.pushObject(3);
assert.ok(controller.selectedAllPosts, "all posts are selected");
assert.true(controller.selectedAllPosts, "all posts are selected");
controller.selectedPostIds.pushObject(42);
assert.ok(
assert.true(
controller.selectedAllPosts,
"all posts (including filtered posts) are selected"
);
@ -183,9 +183,9 @@ module("Unit | Controller | topic", function (hooks) {
"postStream.isMegaTopic": true,
posts_count: 1,
});
assert.ok(
assert.true(
controller.selectedAllPosts,
"it uses the topic's post count for mega-topics"
"uses the topic's post count for mega-topics"
);
});
@ -241,18 +241,18 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
controller.setProperties({ model });
assert.notOk(controller.showSelectedPostsAtBottom, "false on desktop");
assert.false(controller.showSelectedPostsAtBottom, "false on desktop");
const site = getOwner(this).lookup("service:site");
site.set("mobileView", true);
assert.notOk(
assert.false(
controller.showSelectedPostsAtBottom,
"requires at least 3 posts on mobile"
);
model.set("posts_count", 4);
assert.ok(
assert.true(
controller.showSelectedPostsAtBottom,
"true when mobile and more than 3 posts"
);
@ -275,31 +275,31 @@ module("Unit | Controller | topic", function (hooks) {
currentUser,
});
assert.notOk(
assert.false(
controller.canDeleteSelected,
"false when no posts are selected"
);
controller.selectedPostIds.pushObject(1);
assert.notOk(
assert.false(
controller.canDeleteSelected,
"false when can't delete one of the selected posts"
);
controller.selectedPostIds.replace(0, 1, [2, 3]);
assert.ok(
assert.true(
controller.canDeleteSelected,
"true when all selected posts can be deleted"
);
controller.selectedPostIds.pushObject(1);
assert.notOk(
assert.false(
controller.canDeleteSelected,
"false when all posts are selected and user is staff"
);
currentUser.set("admin", true);
assert.ok(
assert.true(
controller.canDeleteSelected,
"true when all posts are selected and user is staff"
);
@ -319,33 +319,33 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
controller.setProperties({ model });
assert.notOk(
assert.false(
controller.canMergeTopic,
"can't merge topic when no posts are selected"
);
controller.selectedPostIds.pushObject(1);
assert.notOk(
assert.false(
controller.canMergeTopic,
"can't merge topic when can't move posts"
);
model.set("details.can_move_posts", true);
assert.ok(controller.canMergeTopic, "can merge topic");
assert.true(controller.canMergeTopic, "can merge topic");
controller.selectedPostIds.removeObject(1);
controller.selectedPostIds.pushObject(2);
assert.ok(
assert.true(
controller.canMergeTopic,
"can merge topic when 1st post is not a regular post"
);
controller.selectedPostIds.pushObject(3);
assert.ok(
assert.true(
controller.canMergeTopic,
"can merge topic when all posts are selected"
);
@ -365,19 +365,19 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
controller.setProperties({ model, currentUser });
assert.notOk(controller.canChangeOwner, "false when no posts are selected");
assert.false(controller.canChangeOwner, "false when no posts are selected");
controller.selectedPostIds.pushObject(1);
assert.notOk(controller.canChangeOwner, "false when not admin");
assert.false(controller.canChangeOwner, "false when not admin");
currentUser.set("admin", true);
assert.ok(
assert.true(
controller.canChangeOwner,
"true when admin and one post is selected"
);
controller.selectedPostIds.pushObject(2);
assert.notOk(
assert.false(
controller.canChangeOwner,
"false when admin but more than 1 user"
);
@ -400,19 +400,19 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
controller.setProperties({ model, currentUser });
assert.notOk(controller.canChangeOwner, "false when no posts are selected");
assert.false(controller.canChangeOwner, "false when no posts are selected");
controller.selectedPostIds.pushObject(1);
assert.notOk(controller.canChangeOwner, "false when not moderator");
assert.false(controller.canChangeOwner, "false when not moderator");
currentUser.set("moderator", true);
assert.ok(
assert.true(
controller.canChangeOwner,
"true when moderator and one post is selected"
);
controller.selectedPostIds.pushObject(2);
assert.notOk(
assert.false(
controller.canChangeOwner,
"false when moderator but more than 1 user"
);
@ -432,28 +432,28 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
controller.setProperties({ model });
assert.notOk(controller.canMergePosts, "false when no posts are selected");
assert.false(controller.canMergePosts, "false when no posts are selected");
controller.selectedPostIds.pushObject(1);
assert.notOk(
assert.false(
controller.canMergePosts,
"false when only one post is selected"
);
controller.selectedPostIds.pushObject(2);
assert.notOk(
assert.false(
controller.canMergePosts,
"false when selected posts are from different users"
);
controller.selectedPostIds.replace(1, 1, [3]);
assert.notOk(
assert.false(
controller.canMergePosts,
"false when selected posts can't be deleted"
);
controller.selectedPostIds.replace(1, 1, [4]);
assert.ok(
assert.true(
controller.canMergePosts,
"true when all selected posts are deletable and by the same user"
);
@ -553,19 +553,19 @@ module("Unit | Controller | topic", function (hooks) {
assert.strictEqual(
controller.selectedPostsCount,
2,
"It should select two, the post and its replies"
"selects two, the post and its replies"
);
controller.send("togglePostSelection", { id: 1 });
assert.strictEqual(
controller.selectedPostsCount,
1,
"It should be selecting one only "
"is selecting one only"
);
assert.strictEqual(
controller.selectedPostIds[0],
2,
"It should be selecting the reply id "
"is selecting the reply id"
);
controller.send("selectReplies", { id: 1 });
@ -574,7 +574,7 @@ module("Unit | Controller | topic", function (hooks) {
assert.strictEqual(
controller.selectedPostsCount,
2,
"It should be selecting two, even if reply was already selected"
"is selecting two, even if reply was already selected"
);
});
@ -591,7 +591,7 @@ module("Unit | Controller | topic", function (hooks) {
post: placeholder,
}),
undefined,
"it should work with a post-placeholder"
"works with a post-placeholder"
);
});
@ -620,7 +620,7 @@ module("Unit | Controller | topic", function (hooks) {
controller.send("deletePost", post);
next(() => {
assert.ok(destroyed, "post was destroyed");
assert.true(destroyed, "post was destroyed");
done();
});
});

@ -9,10 +9,10 @@ module("Unit | Utility | category-badge", function (hooks) {
setupTest(hooks);
test("categoryBadge without a category", function (assert) {
assert.blank(categoryBadgeHTML(), "it returns no HTML");
assert.blank(categoryBadgeHTML(), "returns no HTML");
});
test("Regular categoryBadge", function (assert) {
test("regular categoryBadge", function (assert) {
const store = getOwner(this).lookup("service:store");
const category = store.createRecord("category", {
name: "hello",
@ -23,11 +23,11 @@ module("Unit | Utility | category-badge", function (hooks) {
});
const tag = $.parseHTML(categoryBadgeHTML(category))[0];
assert.strictEqual(tag.tagName, "A", "it creates a `a` wrapper tag");
assert.strictEqual(tag.tagName, "A", "creates a `a` wrapper tag");
assert.strictEqual(
tag.className.trim(),
"badge-category__wrapper",
"it has the correct class"
"has the correct class"
);
const label = tag.children[0];
@ -37,7 +37,7 @@ module("Unit | Utility | category-badge", function (hooks) {
assert.strictEqual(
label.children[0].innerText,
"hello",
"it has the category name"
"has the category name"
);
});
@ -48,7 +48,7 @@ module("Unit | Utility | category-badge", function (hooks) {
assert.blank(
tag.attributes["style"],
"it has no color style because there are no colors"
"has no color style because there are no colors"
);
});
@ -56,9 +56,9 @@ module("Unit | Utility | category-badge", function (hooks) {
const store = getOwner(this).lookup("service:store");
const category = store.createRecord("category", { name: "hello", id: 123 });
assert.notOk(
assert.false(
categoryBadgeHTML(category).includes("topic-count"),
"it does not include topic count by default"
"does not include topic count by default"
);
assert.true(
categoryBadgeHTML(category, { topicCount: 20 }).indexOf("topic-count") >
@ -79,11 +79,11 @@ module("Unit | Utility | category-badge", function (hooks) {
assert.blank(
categoryBadgeHTML(uncategorized),
"it doesn't return HTML for uncategorized by default"
"doesn't return HTML for uncategorized by default"
);
assert.present(
categoryBadgeHTML(uncategorized, { allowUncategorized: true }),
"it returns HTML"
"returns HTML"
);
});

@ -5,18 +5,16 @@ import DAG from "discourse/lib/dag";
module("Unit | Lib | DAG", function (hooks) {
setupTest(hooks);
let dag;
test("DAG.from should create a DAG instance from the provided entries", function (assert) {
dag = DAG.from([
test("DAG.from creates a DAG instance from the provided entries", function (assert) {
const dag = DAG.from([
["key1", "value1", { after: "key2" }],
["key2", "value2", { before: "key3" }],
["key3", "value3", { before: "key1" }],
]);
assert.ok(dag.has("key1"));
assert.ok(dag.has("key2"));
assert.ok(dag.has("key3"));
assert.true(dag.has("key1"));
assert.true(dag.has("key2"));
assert.true(dag.has("key3"));
const resolved = dag.resolve();
const keys = resolved.map((entry) => entry.key);
@ -24,32 +22,32 @@ module("Unit | Lib | DAG", function (hooks) {
assert.deepEqual(keys, ["key2", "key3", "key1"]);
});
test("should add items to the map", function (assert) {
dag = new DAG();
test("adds items to the map", function (assert) {
const dag = new DAG();
dag.add("key1", "value1");
dag.add("key2", "value2");
dag.add("key3", "value3");
assert.ok(dag.has("key1"));
assert.ok(dag.has("key2"));
assert.ok(dag.has("key3"));
assert.true(dag.has("key1"));
assert.true(dag.has("key2"));
assert.true(dag.has("key3"));
// adding a new item
assert.ok(
assert.true(
dag.add("key4", "value4"),
"adding an item returns true when the item is added"
);
assert.ok(dag.has("key4"));
assert.true(dag.has("key4"));
// adding an item that already exists
assert.notOk(
assert.false(
dag.add("key1", "value1"),
"adding an item returns false when the item already exists"
);
});
test("should not throw an error when throwErrorOnCycle is false when adding an item creates a cycle", function (assert) {
dag = new DAG({
test("does not throw an error when throwErrorOnCycle is false when adding an item creates a cycle", function (assert) {
const dag = new DAG({
throwErrorOnCycle: false,
defaultPosition: { before: "key3" },
});
@ -60,9 +58,9 @@ module("Unit | Lib | DAG", function (hooks) {
// This would normally cause a cycle if throwErrorOnCycle was true
dag.add("key3", "value3", { after: "key1" });
assert.ok(dag.has("key1"));
assert.ok(dag.has("key2"));
assert.ok(dag.has("key3"));
assert.true(dag.has("key1"));
assert.true(dag.has("key2"));
assert.true(dag.has("key3"));
const resolved = dag.resolve();
const keys = resolved.map((entry) => entry.key);
@ -71,10 +69,10 @@ module("Unit | Lib | DAG", function (hooks) {
assert.deepEqual(keys, ["key3", "key2", "key1"]);
});
test("should call the method specified for onAddItem callback when an item is added", function (assert) {
test("calls the method specified for onAddItem callback when an item is added", function (assert) {
let called = 0;
dag = new DAG({
const dag = new DAG({
onAddItem: () => {
called++;
},
@ -87,28 +85,28 @@ module("Unit | Lib | DAG", function (hooks) {
assert.strictEqual(called, 1, "the callback was not called");
});
test("should remove an item from the map", function (assert) {
dag = new DAG();
test("removes an item from the map", function (assert) {
const dag = new DAG();
dag.add("key1", "value1");
dag.add("key2", "value2");
dag.add("key3", "value3");
let removed = dag.delete("key2");
assert.ok(dag.has("key1"));
assert.true(dag.has("key1"));
assert.false(dag.has("key2"));
assert.ok(dag.has("key3"));
assert.true(dag.has("key3"));
assert.ok(removed, "delete returns true when the item is removed");
assert.true(removed, "delete returns true when the item is removed");
removed = dag.delete("key2");
assert.notOk(removed, "delete returns false when the item doesn't exist");
assert.false(removed, "delete returns false when the item doesn't exist");
});
test("should call the method specified for onDeleteItem callback when an item is removed", function (assert) {
test("calls the method specified for onDeleteItem callback when an item is removed", function (assert) {
let called = 0;
dag = new DAG({
const dag = new DAG({
onDeleteItem: () => {
called++;
},
@ -122,8 +120,8 @@ module("Unit | Lib | DAG", function (hooks) {
assert.strictEqual(called, 1, "the callback was not called");
});
test("should replace the value from an item in the map", function (assert) {
dag = new DAG();
test("replaces the value from an item in the map", function (assert) {
const dag = new DAG();
dag.add("key1", "value1");
dag.add("key2", "value2");
dag.add("key3", "value3");
@ -136,7 +134,7 @@ module("Unit | Lib | DAG", function (hooks) {
["value1", "replaced-value2", "value3"],
"replace allows simply replacing the value"
);
assert.ok(replaced, "replace returns true when the item is replaced");
assert.true(replaced, "replace returns true when the item is replaced");
// also changing the position
dag.replace("key2", "replaced-value2-again", { before: "key1" });
@ -149,13 +147,13 @@ module("Unit | Lib | DAG", function (hooks) {
// replacing an item that doesn't exist
replaced = dag.replace("key4", "replaced-value4");
assert.notOk(replaced, "replace returns false when the item doesn't exist");
assert.false(replaced, "replace returns false when the item doesn't exist");
});
test("should call the method specified for onReplaceItem callback when an item is replaced", function (assert) {
test("calls the method specified for onReplaceItem callback when an item is replaced", function (assert) {
let called = 0;
dag = new DAG({
const dag = new DAG({
onReplaceItem: () => {
called++;
},
@ -169,14 +167,14 @@ module("Unit | Lib | DAG", function (hooks) {
assert.strictEqual(called, 1, "the callback was not called");
});
test("should reposition an item in the map", function (assert) {
dag = new DAG();
test("repositions an item in the map", function (assert) {
const dag = new DAG();
dag.add("key1", "value1");
dag.add("key2", "value2");
dag.add("key3", "value3");
let repositioned = dag.reposition("key3", { before: "key1" });
assert.ok(
assert.true(
repositioned,
"reposition returns true when the item is repositioned"
);
@ -188,16 +186,16 @@ module("Unit | Lib | DAG", function (hooks) {
// repositioning an item that doesn't exist
repositioned = dag.reposition("key4", { before: "key1" });
assert.notOk(
assert.false(
repositioned,
"reposition returns false when the item doesn't exist"
);
});
test("should call the method specified for onRepositionItem callback when an item is repositioned", function (assert) {
test("calls the method specified for onRepositionItem callback when an item is repositioned", function (assert) {
let called = 0;
dag = new DAG({
const dag = new DAG({
onRepositionItem: () => {
called++;
},
@ -211,14 +209,14 @@ module("Unit | Lib | DAG", function (hooks) {
assert.strictEqual(called, 1, "the callback was not called");
});
test("should return the entries in the map", function (assert) {
test("returns the entries in the map", function (assert) {
const entries = [
["key1", "value1", { after: "key2" }],
["key2", "value2", { before: "key3" }],
["key3", "value3", { before: "key1" }],
];
dag = DAG.from(entries);
const dag = DAG.from(entries);
const dagEntries = dag.entries();
entries.forEach((entry, index) => {
@ -241,8 +239,8 @@ module("Unit | Lib | DAG", function (hooks) {
});
});
test("should resolve the map in the correct order", function (assert) {
dag = new DAG();
test("resolves the map in the correct order", function (assert) {
const dag = new DAG();
dag.add("key1", "value1");
dag.add("key2", "value2");
dag.add("key3", "value3");
@ -254,7 +252,7 @@ module("Unit | Lib | DAG", function (hooks) {
});
test("allows for custom before and after default positioning", function (assert) {
dag = new DAG({ defaultPosition: { before: "key3", after: "key2" } });
const dag = new DAG({ defaultPosition: { before: "key3", after: "key2" } });
dag.add("key1", "value1", {});
dag.add("key2", "value2", { after: "key1" });
dag.add("key3", "value3", { after: "key2" });
@ -277,8 +275,8 @@ module("Unit | Lib | DAG", function (hooks) {
);
});
test("should resolve only existing keys", function (assert) {
dag = new DAG();
test("resolves only existing keys", function (assert) {
const dag = new DAG();
dag.add("key1", "value1");
dag.add("key2", "value2", { before: "key1" });
dag.add("key3", "value3");
@ -292,7 +290,7 @@ module("Unit | Lib | DAG", function (hooks) {
});
test("throws on bad positioning", function (assert) {
dag = new DAG();
const dag = new DAG();
assert.throws(
() => dag.add("key1", "value1", { before: "key1" }),

@ -102,7 +102,7 @@ END:VCALENDAR`
endsAt: "2021-10-12T16:00:00.000Z",
},
]);
assert.ok(
assert.true(
window.open.calledWith(
"https://www.google.com/calendar/event?action=TEMPLATE&text=event&dates=20211012T150000Z%2F20211012T160000Z",
"_blank",
@ -123,7 +123,7 @@ END:VCALENDAR`
],
{ recurrenceRule: "FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR" }
);
assert.ok(
assert.true(
window.open.calledWith(
"https://www.google.com/calendar/event?action=TEMPLATE&text=event&dates=20211012T150000Z%2F20211012T160000Z&recur=RRULE%3AFREQ%3DDAILY%3BBYDAY%3DMO%2CTU%2CWE%2CTH%2CFR",
"_blank",
@ -144,7 +144,7 @@ END:VCALENDAR`
],
{ location: "Paris" }
);
assert.ok(
assert.true(
window.open.calledWith(
"https://www.google.com/calendar/event?action=TEMPLATE&text=event&dates=20211012T150000Z%2F20211012T160000Z&location=Paris",
"_blank",
@ -165,7 +165,7 @@ END:VCALENDAR`
],
{ details: "Cool" }
);
assert.ok(
assert.true(
window.open.calledWith(
"https://www.google.com/calendar/event?action=TEMPLATE&text=event&dates=20211012T150000Z%2F20211012T160000Z&details=Cool",
"_blank",

@ -172,7 +172,7 @@ module("Unit | Utility | emoji", function (hooks) {
test("search does partial-match on emoji aliases", function (assert) {
const matches = emojiSearch("instru");
assert.ok(matches.includes("woman_teacher"));
assert.ok(matches.includes("violin"));
assert.true(matches.includes("woman_teacher"));
assert.true(matches.includes("violin"));
});
});

@ -117,9 +117,9 @@ module("Unit | Utility | i18n", function (hooks) {
assert.strictEqual(
I18n.defaultLocale,
"en",
"it has English as default locale"
"has English as default locale"
);
assert.ok(I18n.pluralizationRules["en"], "it has English pluralizer");
assert.true(!!I18n.pluralizationRules["en"], "has English pluralizer");
});
test("translations", function (assert) {
@ -185,19 +185,19 @@ module("Unit | Utility | i18n", function (hooks) {
assert.strictEqual(
i18n("admin.dashboard.title"),
"Raporty",
"it uses extra translations when they exists"
"uses extra translations when they exists"
);
assert.strictEqual(
i18n("admin.web_hooks.events.incoming", { count: 2 }),
"Istnieją 2 nowe wydarzenia.",
"it uses pluralized extra translation when it exists"
"uses pluralized extra translation when it exists"
);
assert.strictEqual(
i18n("admin.dashboard.backup_count", { count: 2 }),
"2 backups",
"it falls back to English and uses extra translations when they exists"
"falls back to English and uses extra translations when they exists"
);
});
@ -360,11 +360,11 @@ module("Unit | Utility | i18n", function (hooks) {
});
test("messageFormat", function (assert) {
assert.ok(
I18n.messageFormat("posts_likes_MF", { count: 2, ratio: "high" }).match(
/2 replies/
assert.true(
/2 replies/.test(
I18n.messageFormat("posts_likes_MF", { count: 2, ratio: "high" })
),
"It works properly"
"works properly"
);
I18n._mfMessages = null;
assert.strictEqual(

@ -18,20 +18,20 @@ module("Unit | Utility | keyboard-shortcuts", function (hooks) {
});
KeyboardShortcuts.goBack();
assert.ok(called, "history.back is called");
assert.true(called, "history.back is called");
});
test("nextSection calls _changeSection with 1", function (assert) {
let spy = sinon.spy(KeyboardShortcuts, "_changeSection");
KeyboardShortcuts.nextSection();
assert.ok(spy.calledWith(1), "_changeSection is called with 1");
assert.true(spy.calledWith(1), "_changeSection is called with 1");
});
test("prevSection calls _changeSection with -1", function (assert) {
let spy = sinon.spy(KeyboardShortcuts, "_changeSection");
KeyboardShortcuts.prevSection();
assert.ok(spy.calledWith(-1), "_changeSection is called with -1");
assert.true(spy.calledWith(-1), "_changeSection is called with -1");
});
});

@ -17,7 +17,7 @@ module("Unit | Utility | link-lookup", function (hooks) {
});
test("works with https", function (assert) {
assert.ok(
assert.true(
this.linkLookup.check(
this.post,
"https://en.wikipedia.org/wiki/handheld_game_console"
@ -26,7 +26,7 @@ module("Unit | Utility | link-lookup", function (hooks) {
});
test("works with http", function (assert) {
assert.ok(
assert.true(
this.linkLookup.check(
this.post,
"http://en.wikipedia.org/wiki/handheld_game_console"
@ -35,7 +35,7 @@ module("Unit | Utility | link-lookup", function (hooks) {
});
test("works with trailing slash", function (assert) {
assert.ok(
assert.true(
this.linkLookup.check(
this.post,
"https://en.wikipedia.org/wiki/handheld_game_console/"
@ -44,7 +44,7 @@ module("Unit | Utility | link-lookup", function (hooks) {
});
test("works with uppercase characters", function (assert) {
assert.ok(
assert.true(
this.linkLookup.check(
this.post,
"https://en.wikipedia.org/wiki/Handheld_game_console"

@ -31,7 +31,7 @@ module("Unit | Utility | oneboxer", function (hooks) {
assert.strictEqual(
loadOnebox(element),
undefined,
"it returns early for a failed cache"
"returns early for a failed cache"
);
});
@ -41,15 +41,15 @@ module("Unit | Utility | oneboxer", function (hooks) {
await loadOnebox(element);
assert.ok(
assert.true(
localCache["http://somegoodurl.com"].outerHTML.includes(
"Yet another collaboration tool"
),
"stores the html of the onebox in a local cache"
);
assert.ok(
assert.true(
loadOnebox(element).includes("Yet another collaboration tool"),
"it returns the html from the cache"
"returns the html from the cache"
);
});
});

@ -61,7 +61,7 @@ module("Unit | Utility | preload-store", function (hooks) {
test("returns falsy values without calling finder", async function (assert) {
PreloadStore.store("falsy", false);
const result = await PreloadStore.getAndRemove("falsy", () =>
assert.ok(false)
assert.true(false)
);
assert.false(result);
});

@ -43,7 +43,7 @@ module("Unit | Utility | sanitizer", function (hooks) {
cooked(
"hello<script>alert(42)</script>",
"<p>hello</p>",
"it sanitizes while cooking"
"sanitizes while cooking"
);
cooked(
@ -52,47 +52,47 @@ module("Unit | Utility | sanitizer", function (hooks) {
"we can embed proper links"
);
cooked("<center>hello</center>", "hello", "it does not allow centering");
cooked("<center>hello</center>", "hello", "does not allow centering");
cooked(
"<blockquote>a\n</blockquote>\n",
"<blockquote>a\n</blockquote>",
"it does not double sanitize"
"does not double sanitize"
);
cooked(
'<iframe src="http://discourse.org" width="100" height="42"></iframe>',
"",
"it does not allow most iframes"
"does not allow most iframes"
);
cooked(
'<iframe src="https://www.google.com/maps/embed?pb=!1m10!1m8!1m3!1d2624.9983685732213!2d2.29432085!3d48.85824149999999!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2s!4v1385737436368" width="100" height="42"></iframe>',
'<iframe src="https://www.google.com/maps/embed?pb=!1m10!1m8!1m3!1d2624.9983685732213!2d2.29432085!3d48.85824149999999!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2s!4v1385737436368" width="100" height="42"></iframe>',
"it allows iframe to google maps"
"allows iframe to google maps"
);
cooked(
'<iframe width="425" height="350" frameborder="0" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=22.49454975128174%2C51.220338322410775%2C22.523088455200195%2C51.23345342732931&amp;layer=mapnik"></iframe>',
'<iframe width="425" height="350" frameborder="0" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=22.49454975128174%2C51.220338322410775%2C22.523088455200195%2C51.23345342732931&amp;layer=mapnik"></iframe>',
"it allows iframe to OpenStreetMap"
"allows iframe to OpenStreetMap"
);
cooked(
`BEFORE\n\n<iframe src=http://example.com>\n\nINSIDE\n\n</iframe>\n\nAFTER`,
`<p>BEFORE</p>\n\n<p>AFTER</p>`,
"it strips unauthorized iframes - unallowed src"
"strips unauthorized iframes - unallowed src"
);
cooked(
`BEFORE\n\n<iframe src=''>\n\nINSIDE\n\n</iframe>\n\nAFTER`,
`<p>BEFORE</p>\n\n<p>AFTER</p>`,
"it strips unauthorized iframes - empty src"
"strips unauthorized iframes - empty src"
);
cooked(
`BEFORE\n\n<iframe src='http://example.com'>\n\nAFTER`,
`<p>BEFORE</p>`,
"it strips unauthorized partial iframes"
"strips unauthorized partial iframes"
);
assert.strictEqual(engine.sanitize("<textarea>hullo</textarea>"), "hullo");
@ -109,29 +109,29 @@ module("Unit | Utility | sanitizer", function (hooks) {
cooked(
"[the answer](javascript:alert(42))",
"<p>[the answer](javascript:alert(42))</p>",
"it prevents XSS"
"prevents XSS"
);
cooked(
'<i class="fa fa-bug fa-spin" style="font-size:600%"></i>\n<!-- -->',
"<p><i></i></p>",
"it doesn't circumvent XSS with comments"
"doesn't circumvent XSS with comments"
);
cooked(
'<span class="-bbcode-s fa fa-spin">a</span>',
"<p><span>a</span></p>",
"it sanitizes spans"
"sanitizes spans"
);
cooked(
'<span class="fa fa-spin -bbcode-s">a</span>',
"<p><span>a</span></p>",
"it sanitizes spans"
"sanitizes spans"
);
cooked(
'<span class="bbcode-s">a</span>',
'<p><span class="bbcode-s">a</span></p>',
"it sanitizes spans"
"sanitizes spans"
);
cooked(
@ -216,26 +216,26 @@ module("Unit | Utility | sanitizer", function (hooks) {
test("autoplay videos must be muted", function (assert) {
let engine = build({ siteSettings: {} });
assert.ok(
engine
.sanitize(
assert.true(
/muted/.test(
engine.sanitize(
`<p>Hey</p><video autoplay src="http://example.com/music.mp4"/>`
)
.match(/muted/)
)
);
assert.ok(
engine
.sanitize(
assert.true(
/muted/.test(
engine.sanitize(
`<p>Hey</p><video autoplay><source src="http://example.com/music.mp4" type="audio/mpeg"></video>`
)
.match(/muted/)
)
);
assert.ok(
engine
.sanitize(
assert.true(
/muted/.test(
engine.sanitize(
`<p>Hey</p><video autoplay muted><source src="http://example.com/music.mp4" type="audio/mpeg"></video>`
)
.match(/muted/)
)
);
assert.false(
/muted/.test(

@ -9,9 +9,7 @@ module(
"Unit | Lib | time-shortcut | hideDynamicTimeShortcuts",
function (hooks) {
hooks.afterEach(function () {
if (this.clock) {
this.clock.restore();
}
this.clock?.restore();
});
test("hides 'Later Today' at the end of the day", function (assert) {
@ -20,7 +18,7 @@ module(
this.clock = fakeTime("2100-04-19 08:00:00", timezone, true); // morning
let result = hideDynamicTimeShortcuts(shortcuts, timezone).mapBy("id");
assert.ok(
assert.true(
result.includes("later_today"),
"shows later_today in the morning"
);
@ -37,7 +35,7 @@ module(
this.clock = fakeTime("2100-04-21 18:00:00", timezone, true); // Wednesday
let result = hideDynamicTimeShortcuts(shortcuts, timezone).mapBy("id");
assert.ok(
assert.true(
result.includes("later_this_week"),
"shows later_this_week on Wednesdays"
);
@ -70,7 +68,7 @@ module(
timezone,
siteSettings
).mapBy("id");
assert.ok(
assert.true(
result.includes("this_weekend"),
"shows this_weekend on Thursdays"
);

@ -43,7 +43,7 @@ module("Unit | Utility | uploads", function (hooks) {
assert.false(
validateUploadedFiles([1, 2], { siteSettings: this.siteSettings })
);
assert.ok(dialog.alert.calledWith(i18n("post.errors.too_many_uploads")));
assert.true(dialog.alert.calledWith(i18n("post.errors.too_many_uploads")));
});
test("new user cannot upload images", function (assert) {
@ -57,7 +57,7 @@ module("Unit | Utility | uploads", function (hooks) {
}),
"the upload is not valid"
);
assert.ok(
assert.true(
dialog.alert.calledWith(
i18n("post.errors.image_upload_not_allowed_for_new_user")
),
@ -70,7 +70,7 @@ module("Unit | Utility | uploads", function (hooks) {
this.siteSettings.default_trust_level = 0;
sinon.stub(dialog, "alert");
assert.ok(
assert.true(
validateUploadedFiles([{ name: "image.png" }], {
user: this.store.createRecord("user"),
siteSettings: this.siteSettings,
@ -82,7 +82,7 @@ module("Unit | Utility | uploads", function (hooks) {
this.siteSettings.newuser_max_embedded_media = 0;
sinon.stub(dialog, "alert");
assert.ok(
assert.true(
validateUploadedFiles([{ name: "image.png" }], {
user: this.store.createRecord("user", { trust_level: 1 }),
siteSettings: this.siteSettings,
@ -100,7 +100,7 @@ module("Unit | Utility | uploads", function (hooks) {
siteSettings: this.siteSettings,
})
);
assert.ok(
assert.true(
dialog.alert.calledWith(
i18n("post.errors.attachment_upload_not_allowed_for_new_user")
)
@ -114,7 +114,7 @@ module("Unit | Utility | uploads", function (hooks) {
siteSettings: this.siteSettings,
})
);
assert.ok(
assert.true(
dialog.alert.calledWith(
i18n("post.errors.upload_not_authorized", {
authorized_extensions: authorizedExtensions(
@ -136,7 +136,7 @@ module("Unit | Utility | uploads", function (hooks) {
siteSettings: this.siteSettings,
})
);
assert.ok(
assert.true(
validateUploadedFiles(files, {
skipValidation: true,
siteSettings: this.siteSettings,
@ -155,7 +155,7 @@ module("Unit | Utility | uploads", function (hooks) {
siteSettings: this.siteSettings,
})
);
assert.ok(
assert.true(
dialog.alert.calledWith(i18n("post.errors.no_uploads_authorized"))
);
});
@ -171,7 +171,7 @@ module("Unit | Utility | uploads", function (hooks) {
siteSettings: this.siteSettings,
})
);
assert.ok(
assert.true(
dialog.alert.calledWith(i18n("post.errors.no_uploads_authorized"))
);
});
@ -185,7 +185,7 @@ module("Unit | Utility | uploads", function (hooks) {
assert.false(
validateUploadedFiles(files, { user, siteSettings: this.siteSettings })
);
assert.ok(
assert.true(
validateUploadedFiles(files, {
isPrivateMessage: true,
allowStaffToUploadAnyFileInPm: true,
@ -219,12 +219,12 @@ module("Unit | Utility | uploads", function (hooks) {
// image
let image = { name: "image.png", size: imageSize };
assert.ok(
assert.true(
validateUploadedFiles([image], { user, siteSettings: this.siteSettings })
);
// pasted image
let pastedImage = dummyBlob();
assert.ok(
assert.true(
validateUploadedFiles([pastedImage], {
user,
siteSettings: this.siteSettings,
@ -238,8 +238,8 @@ module("Unit | Utility | uploads", function (hooks) {
["png", "webp", "jpg", "jpeg", "gif", "ico", "avif"].forEach(
(extension) => {
let image = "image." + extension;
assert.ok(isImage(image), image + " is recognized as an image");
assert.ok(
assert.true(isImage(image), image + " is recognized as an image");
assert.true(
isImage("http://foo.bar/path/to/" + image),
image + " is recognized as an image"
);
@ -252,22 +252,22 @@ module("Unit | Utility | uploads", function (hooks) {
test("allowsImages", function (assert) {
this.siteSettings.authorized_extensions = "jpg|jpeg|gif";
assert.ok(allowsImages(false, this.siteSettings), "works");
assert.true(allowsImages(false, this.siteSettings), "works");
this.siteSettings.authorized_extensions = ".jpg|.jpeg|.gif";
assert.ok(
assert.true(
allowsImages(false, this.siteSettings),
"works with old extensions syntax"
);
this.siteSettings.authorized_extensions = "txt|pdf|*";
assert.ok(
assert.true(
allowsImages(false, this.siteSettings),
"images are allowed when all extensions are allowed"
);
this.siteSettings.authorized_extensions = "json|jpg|pdf|txt";
assert.ok(
assert.true(
allowsImages(false, this.siteSettings),
"images are allowed when at least one extension is an image extension"
);
@ -281,19 +281,19 @@ module("Unit | Utility | uploads", function (hooks) {
);
this.siteSettings.authorized_extensions = "jpg|jpeg|gif|*";
assert.ok(
assert.true(
allowsAttachments(false, this.siteSettings),
"attachments are allowed when all extensions are allowed"
);
this.siteSettings.authorized_extensions = "jpg|jpeg|gif|pdf";
assert.ok(
assert.true(
allowsAttachments(false, this.siteSettings),
"attachments are allowed when at least one extension is not an image extension"
);
this.siteSettings.authorized_extensions = ".jpg|.jpeg|.gif|.pdf";
assert.ok(
assert.true(
allowsAttachments(false, this.siteSettings),
"works with old extensions syntax"
);
@ -369,7 +369,7 @@ module("Unit | Utility | uploads", function (hooks) {
{ max_attachment_size_kb: 4096, max_image_size_kb: 4096 },
"non-backup-tar-gz-file.tar.gz"
);
assert.ok(
assert.true(
dialog.alert.calledWith(
i18n("post.errors.file_too_large_humanized", {
max_size: I18n.toHumanSize(4096 * 1024),
@ -391,7 +391,7 @@ module("Unit | Utility | uploads", function (hooks) {
{ max_attachment_size_kb: 4096, max_image_size_kb: 4096 },
"backup-2023-09-07-092329-v20230728055813.tar.gz"
);
assert.ok(
assert.true(
dialog.alert.calledWith(i18n("post.errors.backup_too_large")),
"the alert is called"
);
@ -406,7 +406,10 @@ module("Unit | Utility | uploads", function (hooks) {
{ max_attachment_size_kb: 1024, max_image_size_kb: 1024 },
"test.png"
);
assert.ok(dialog.alert.calledWith("upload failed"), "the alert is called");
assert.true(
dialog.alert.calledWith("upload failed"),
"the alert is called"
);
});
test("displayErrorForUpload - jquery file upload - jqXHR missing, errors present", function (assert) {
@ -418,7 +421,10 @@ module("Unit | Utility | uploads", function (hooks) {
{ max_attachment_size_kb: 1024, max_image_size_kb: 1024 },
"test.png"
);
assert.ok(dialog.alert.calledWith("upload failed"), "the alert is called");
assert.true(
dialog.alert.calledWith("upload failed"),
"the alert is called"
);
});
test("displayErrorForUpload - jquery file upload - no errors", function (assert) {
@ -431,7 +437,7 @@ module("Unit | Utility | uploads", function (hooks) {
},
"test.png"
);
assert.ok(
assert.true(
dialog.alert.calledWith(
i18n("post.errors.upload", { file_name: "test.png" })
),
@ -449,6 +455,9 @@ module("Unit | Utility | uploads", function (hooks) {
"test.png",
{ max_attachment_size_kb: 1024, max_image_size_kb: 1024 }
);
assert.ok(dialog.alert.calledWith("upload failed"), "the alert is called");
assert.true(
dialog.alert.calledWith("upload failed"),
"the alert is called"
);
});
});

@ -108,9 +108,9 @@ module("Unit | Utility | url", function (hooks) {
});
sinon.stub(DiscourseURL, "handleURL");
DiscourseURL.routeTo("/my/messages");
assert.ok(
assert.true(
DiscourseURL.handleURL.calledWith(`/my/messages`),
"it should navigate to the messages page"
"navigates to the messages page"
);
});
@ -124,33 +124,33 @@ module("Unit | Utility | url", function (hooks) {
});
DiscourseURL.routeTo("http://example.com/foo1");
assert.ok(
assert.true(
DiscourseURL.handleURL.calledWith(`/foo1`),
"it strips the protocol and domain when http"
"strips the protocol and domain when http"
);
DiscourseURL.routeTo("https://example.com/foo2");
assert.ok(
assert.true(
DiscourseURL.handleURL.calledWith(`/foo2`),
"it strips the protocol and domain when https"
"strips the protocol and domain when https"
);
DiscourseURL.routeTo("//example.com/foo3");
assert.ok(
assert.true(
DiscourseURL.handleURL.calledWith(`/foo3`),
"it strips the protocol and domain when protocol-less"
"strips the protocol and domain when protocol-less"
);
DiscourseURL.routeTo("https://example.com/t//1");
assert.ok(
assert.true(
DiscourseURL.handleURL.calledWith(`/t//1`),
"it does not strip double-slash in the middle of urls"
"does not strip double-slash in the middle of urls"
);
DiscourseURL.routeTo("/t//2");
assert.ok(
assert.true(
DiscourseURL.handleURL.calledWith(`/t//2`),
"it does not strip double-slash in the middle of urls, even without a domain"
"does not strip double-slash in the middle of urls, even without a domain"
);
});
@ -161,9 +161,9 @@ module("Unit | Utility | url", function (hooks) {
});
sinon.stub(DiscourseURL, "handleURL");
DiscourseURL.routeTo("/myfeed");
assert.ok(
assert.true(
DiscourseURL.handleURL.calledWith(`/myfeed`),
"it should navigate to the unmodified route"
"navigates to the unmodified route"
);
});
@ -224,7 +224,7 @@ module("Unit | Utility | url", function (hooks) {
sinon.stub(DiscourseURL, "redirectTo");
sinon.stub(DiscourseURL, "handleURL");
DiscourseURL.routeTo("/secure-uploads/original/1X/test.pdf");
assert.ok(
assert.true(
DiscourseURL.redirectTo.calledWith("/secure-uploads/original/1X/test.pdf")
);
});
@ -233,11 +233,11 @@ module("Unit | Utility | url", function (hooks) {
sinon.stub(DiscourseURL, "jumpToElement");
sinon.stub(DiscourseURL, "replaceState");
DiscourseURL.routeTo("#heading1");
assert.ok(
assert.true(
DiscourseURL.jumpToElement.calledWith("heading1"),
"in-page anchors call jumpToElement"
);
assert.ok(
assert.true(
DiscourseURL.replaceState.calledWith("#heading1"),
"in-page anchors call replaceState with the url fragment"
);

@ -53,11 +53,11 @@ module("Unit | Utilities", function (hooks) {
});
test("emailValid", function (assert) {
assert.ok(
assert.true(
emailValid("Bob@example.com"),
"allows upper case in the first part of emails"
);
assert.ok(
assert.true(
emailValid("bob@EXAMPLE.com"),
"allows upper case in the email domain"
);

@ -431,7 +431,7 @@ module("Unit | Model | composer", function (hooks) {
"composer.title_or_link_placeholder",
"placeholder invites you to paste a link"
);
assert.ok(composer.canEditTopicFeaturedLink, "can paste link");
assert.true(composer.canEditTopicFeaturedLink, "can paste link");
});
test("targetRecipientsArray contains types", function (assert) {

@ -8,9 +8,9 @@ module("Unit | Model | email-log", function (hooks) {
test("create", function (assert) {
const store = getOwner(this).lookup("service:store");
assert.ok(
store.createRecord("email-log"),
"it can be created without arguments"
assert.true(
!!store.createRecord("email-log"),
"can be created without arguments"
);
});

@ -7,9 +7,9 @@ module("Unit | Model | invite", function (hooks) {
test("create", function (assert) {
const store = getOwner(this).lookup("service:store");
assert.ok(
store.createRecord("invite"),
"it can be created without arguments"
assert.true(
!!store.createRecord("invite"),
"can be created without arguments"
);
});
});

@ -17,7 +17,7 @@ module("Unit | Model | post", function (hooks) {
test("new_user", function (assert) {
const post = this.store.createRecord("post", { trust_level: 0 });
assert.ok(post.new_user, "post is from a new user");
assert.true(post.new_user, "post is from a new user");
post.set("trust_level", 1);
assert.false(post.new_user, "post is no longer from a new user");

@ -39,7 +39,7 @@ module("Unit | Model | private-message-topic-tracking-state", function (hooks) {
pmTopicTrackingState.set("isTracking", true);
pmTopicTrackingState.removeTopics([]);
assert.ok(callbackCalled);
assert.true(callbackCalled);
});
});

@ -8,12 +8,10 @@ function reportWithData(data) {
return store.createRecord("report", {
type: "topics",
data: data.map((val, index) => {
return {
x: moment().subtract(index, "days").format("YYYY-MM-DD"),
y: val,
};
}),
data: data.map((val, index) => ({
x: moment().subtract(index, "days").format("YYYY-MM-DD"),
y: val,
})),
});
}
@ -85,8 +83,8 @@ module("Unit | Model | report", function (hooks) {
this,
[6, 8, 5, 2, 1]
).yesterdayCountTitle;
assert.ok(title.includes("+60%"));
assert.ok(title.match(/Was 5/));
assert.true(title.includes("+60%"));
assert.true(/Was 5/.test(title));
});
test("yesterdayCountTitle when two days ago was 0", function (assert) {
@ -95,7 +93,7 @@ module("Unit | Model | report", function (hooks) {
[6, 8, 0, 2, 1]
).yesterdayCountTitle;
assert.false(title.includes("%"));
assert.ok(title.match(/Was 0/));
assert.true(/Was 0/.test(title));
});
test("sevenDaysCountTitle", function (assert) {
@ -103,22 +101,22 @@ module("Unit | Model | report", function (hooks) {
this,
[100, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 100, 100]
).sevenDaysCountTitle;
assert.ok(title.match(/-50%/));
assert.ok(title.match(/Was 14/));
assert.true(/-50%/.test(title));
assert.true(/Was 14/.test(title));
});
test("thirtyDaysCountTitle", function (assert) {
const report = reportWithData.call(this, [5, 5, 5, 5]);
report.set("prev30Days", 10);
assert.ok(report.thirtyDaysCountTitle.includes("+50%"));
assert.ok(report.thirtyDaysCountTitle.match(/Was 10/));
assert.true(report.thirtyDaysCountTitle.includes("+50%"));
assert.true(/Was 10/.test(report.thirtyDaysCountTitle));
const report2 = reportWithData.call(this, [5, 5, 5, 5]);
report2.set("prev_period", 20);
assert.ok(report2.thirtyDaysCountTitle.includes("-25%"));
assert.ok(report2.thirtyDaysCountTitle.match(/Was 20/));
assert.true(report2.thirtyDaysCountTitle.includes("-25%"));
assert.true(/Was 20/.test(report2.thirtyDaysCountTitle));
});
test("sevenDaysTrend", function (assert) {

@ -20,27 +20,31 @@ module("Unit | Model | rest-model", function (hooks) {
getOwner(this).register("model:grape", Grape);
const g = store.createRecord("grape", { store, percent: 0.4 });
assert.strictEqual(g.inverse, 0.6, "it runs `munge` on `create`");
assert.strictEqual(g.inverse, 0.6, "runs `munge` on `create`");
});
test("update", async function (assert) {
const store = getOwner(this).lookup("service:store");
const widget = await store.find("widget", 123);
assert.strictEqual(widget.name, "Trout Lure");
assert.false(widget.isSaving, "it is not saving");
assert.false(widget.isSaving, "is not saving");
const spyBeforeUpdate = sinon.spy(widget, "beforeUpdate");
const spyAfterUpdate = sinon.spy(widget, "afterUpdate");
const promise = widget.update({ name: "new name" });
assert.true(widget.isSaving, "it is saving");
assert.true(widget.isSaving, "is saving");
assert.true(spyBeforeUpdate.calledOn(widget));
const result = await promise;
assert.true(spyAfterUpdate.calledOn(widget));
assert.false(widget.isSaving, "it is no longer saving");
assert.false(widget.isSaving, "is no longer saving");
assert.strictEqual(widget.name, "new name");
assert.ok(result.target, "it has a reference to the record");
assert.notStrictEqual(
result.target,
undefined,
"has a reference to the record"
);
assert.strictEqual(result.target.name, widget.name);
});
@ -61,25 +65,29 @@ module("Unit | Model | rest-model", function (hooks) {
const store = getOwner(this).lookup("service:store");
const widget = store.createRecord("widget");
assert.true(widget.isNew, "it is a new record");
assert.false(widget.isCreated, "it is not created");
assert.false(widget.isSaving, "it is not saving");
assert.true(widget.isNew, "is a new record");
assert.false(widget.isCreated, "is not created");
assert.false(widget.isSaving, "is not saving");
const spyBeforeCreate = sinon.spy(widget, "beforeCreate");
const spyAfterCreate = sinon.spy(widget, "afterCreate");
const promise = widget.save({ name: "Evil Widget" });
assert.true(widget.isSaving, "it is not saving");
assert.true(widget.isSaving, "is not saving");
assert.true(spyBeforeCreate.calledOn(widget));
const result = await promise;
assert.true(spyAfterCreate.calledOn(widget));
assert.false(widget.isSaving, "it is no longer saving");
assert.ok(widget.id, "it has an id");
assert.ok(widget.name, "Evil Widget");
assert.true(widget.isCreated, "it is created");
assert.false(widget.isNew, "it is no longer new");
assert.false(widget.isSaving, "is no longer saving");
assert.notStrictEqual(widget.id, undefined, "has an id");
assert.strictEqual(widget.name, "Evil Widget");
assert.true(widget.isCreated, " is created");
assert.false(widget.isNew, "is no longer new");
assert.ok(result.target, "it has a reference to the record");
assert.notStrictEqual(
result.target,
undefined,
"has a reference to the record"
);
assert.strictEqual(result.target.name, widget.name);
});
@ -100,7 +108,9 @@ module("Unit | Model | rest-model", function (hooks) {
const store = getOwner(this).lookup("service:store");
const widget = await store.find("widget", 123);
assert.ok(await widget.destroyRecord());
assert.deepEqual(await widget.destroyRecord(), {
success: true,
});
});
test("custom api name", async function (assert) {
@ -122,7 +132,7 @@ module("Unit | Model | rest-model", function (hooks) {
// Create
const widget = store.createRecord("my-widget");
await widget.save({ name: "Evil Widget" });
assert.strictEqual(widget.id, 100, "it saved a new record successfully");
assert.strictEqual(widget.id, 100, "saved a new record successfully");
assert.strictEqual(widget.name, "Evil Widget");
// Update

@ -8,7 +8,7 @@ module("Unit | Model | site", function (hooks) {
test("create", function (assert) {
const store = getOwner(this).lookup("service:store");
assert.ok(store.createRecord("site"), "it can create with no parameters");
assert.true(!!store.createRecord("site"), "can create with no parameters");
});
test("instance", function (assert) {

@ -7,9 +7,9 @@ module("Unit | Model | staff-action-log", function (hooks) {
test("create", function (assert) {
const store = getOwner(this).lookup("service:store");
assert.ok(
store.createRecord("staff-action-log"),
"it can be created without arguments"
assert.true(
!!store.createRecord("staff-action-log"),
"can be created without arguments"
);
});
});

@ -26,6 +26,6 @@ module("Unit | Model | tag", function (hooks) {
tag.set("pm_only", true);
assert.ok(tag.pmOnly);
assert.true(tag.pmOnly);
});
});

@ -16,26 +16,22 @@ module("Unit | Model | theme", function (hooks) {
],
});
assert.ok(
assert.true(
theme.settings[0] instanceof ThemeSettings,
"should be an instance of ThemeSettings"
"is an instance of ThemeSettings"
);
assert.ok(
assert.true(
theme.settings[1] instanceof ThemeSettings,
"should be an instance of ThemeSettings"
"is an instance of ThemeSettings"
);
});
test("can add an upload correctly", function (assert) {
test("adds an upload correctly", function (assert) {
const store = getOwner(this).lookup("service:store");
const theme = store.createRecord("theme");
assert.strictEqual(
theme.uploads.length,
0,
"uploads should be an empty array"
);
assert.strictEqual(theme.uploads.length, 0, "uploads are an empty array");
theme.setField("common", "bob", "", 999, 2);
let fields = theme.theme_fields;

@ -28,10 +28,10 @@ module("Unit | Model | topic", function (hooks) {
assert.false(topic.visited, "not visited unless we've read all the posts");
topic.set("last_read_post_number", 2);
assert.ok(topic.visited, "is visited once we've read all the posts");
assert.true(topic.visited, "is visited once we've read all the posts");
topic.set("last_read_post_number", 3);
assert.ok(
assert.true(
topic.visited,
"is visited if we've read all the posts and some are deleted at the end"
);

@ -380,7 +380,7 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
trackingState.loadStates([{ topic_id: 111 }, { topic_id: 222 }]);
trackingState.set("_trackedTopicLimit", 5);
trackingState.sync(list, "unread");
assert.ok(
assert.true(
trackingState.states.has("t111"),
"expect state for topic 111 not to be deleted"
);
@ -591,7 +591,7 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
1,
"increments message count"
);
assert.ok(
assert.true(
DiscourseURL.redirectTo.calledWith("/"),
"redirect to / because topic is destroyed"
);

@ -34,7 +34,7 @@ module("Unit | Model | user-badge", function (hooks) {
const userBadges = UserBadge.createFromJson(
cloneJSON(badgeFixtures["/user-badges/:username"])
);
assert.ok(Array.isArray(userBadges), "returns an array");
assert.true(Array.isArray(userBadges), "returns an array");
assert.strictEqual(
userBadges[0].granted_by,
undefined,
@ -44,12 +44,12 @@ module("Unit | Model | user-badge", function (hooks) {
test("findByUsername", async function (assert) {
const badges = await UserBadge.findByUsername("anne3");
assert.ok(Array.isArray(badges), "returns an array");
assert.true(Array.isArray(badges), "returns an array");
});
test("findByBadgeId", async function (assert) {
const badges = await UserBadge.findByBadgeId(880);
assert.ok(Array.isArray(badges), "returns an array");
assert.true(Array.isArray(badges), "returns an array");
});
test("grant", async function (assert) {
@ -70,6 +70,6 @@ module("Unit | Model | user-badge", function (hooks) {
assert.strictEqual(userBadge.is_favorite, undefined);
await userBadge.favorite();
assert.ok(userBadge.is_favorite);
assert.true(userBadge.is_favorite);
});
});

@ -36,13 +36,13 @@ module("Unit | Model | user", function (hooks) {
test("isAllowedToUploadAFile", function (assert) {
const store = getOwner(this).lookup("service:store");
const user = store.createRecord("user", { trust_level: 0, admin: true });
assert.ok(
assert.true(
user.isAllowedToUploadAFile("image"),
"admin can always upload a file"
);
user.setProperties({ admin: false, moderator: true });
assert.ok(
assert.true(
user.isAllowedToUploadAFile("image"),
"moderator can always upload a file"
);
@ -111,7 +111,7 @@ module("Unit | Model | user", function (hooks) {
User.createCurrent();
assert.ok(spyMomentGuess.notCalled);
assert.false(spyMomentGuess.called);
});
test("subsequent calls to trackStatus and stopTrackingStatus increase and decrease subscribers counter", function (assert) {

@ -6,6 +6,6 @@ acceptance("current-user", function (needs) {
test("currentUser has appEvents", function (assert) {
let currentUser = this.container.lookup("service:current-user");
assert.ok(currentUser.appEvents);
assert.notStrictEqual(currentUser.appEvents, undefined);
});
});

@ -11,8 +11,8 @@ module("Unit | Service | header", function (hooks) {
test("it registers hiders", function (assert) {
this.header.registerHider(this, ["search", "login"]);
assert.ok(this.header.headerButtonsHidden.includes("search"));
assert.ok(this.header.headerButtonsHidden.includes("login"));
assert.true(this.header.headerButtonsHidden.includes("search"));
assert.true(this.header.headerButtonsHidden.includes("login"));
});
test("it does not register invalid buttons for hiders", function (assert) {

@ -214,8 +214,8 @@ module("Unit | Service | presence | subscribing", function (hooks) {
await channelDup.subscribe();
assert.true(channelDup.subscribed, "channelDup can subscribe");
assert.ok(
channelDup._presenceState,
assert.true(
!!channelDup._presenceState,
"channelDup has a valid internal state"
);
assert.strictEqual(

@ -21,7 +21,7 @@ module("Unit | Service | site-settings", function (hooks) {
});
test("contains settings", function (assert) {
assert.ok(this.siteSettings.title);
assert.strictEqual(typeof this.siteSettings.title, "string");
});
test("notifies getters", function (assert) {

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