mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 10:42:45 +08:00
parent
93b2714e2f
commit
8d4c9523ee
|
@ -1,32 +1,28 @@
|
|||
import { visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
acceptance("About", function () {
|
||||
test("viewing", async function (assert) {
|
||||
await visit("/about");
|
||||
|
||||
assert.ok(document.body.classList.contains("about-page"), "has body class");
|
||||
assert.ok(exists(".about.admins .user-info"), "has admins");
|
||||
assert.ok(exists(".about.moderators .user-info"), "has moderators");
|
||||
assert.ok(
|
||||
exists(".about.stats tr.about-topic-count td"),
|
||||
"has topic stats"
|
||||
);
|
||||
assert.ok(exists(".about.stats tr.about-post-count td"), "has post stats");
|
||||
assert.ok(exists(".about.stats tr.about-user-count td"), "has user stats");
|
||||
assert.ok(
|
||||
exists(".about.stats tr.about-active-user-count td"),
|
||||
"has active user stats"
|
||||
);
|
||||
assert.ok(exists(".about.stats tr.about-like-count td"), "has like stats");
|
||||
assert.ok(
|
||||
exists(".about.stats tr.about-chat_messages-count td"),
|
||||
"has plugin stats"
|
||||
);
|
||||
assert.notOk(
|
||||
exists(".about.stats tr.about-chat_users-count td"),
|
||||
"does not show hidden plugin stats"
|
||||
);
|
||||
assert.dom(document.body).hasClass("about-page", "has body class");
|
||||
assert.dom(".about.admins .user-info").exists("has admins");
|
||||
assert.dom(".about.moderators .user-info").exists("has moderators");
|
||||
assert
|
||||
.dom(".about.stats tr.about-topic-count td")
|
||||
.exists("has topic stats");
|
||||
assert.dom(".about.stats tr.about-post-count td").exists("has post stats");
|
||||
assert.dom(".about.stats tr.about-user-count td").exists("has user stats");
|
||||
assert
|
||||
.dom(".about.stats tr.about-active-user-count td")
|
||||
.exists("has active user stats");
|
||||
assert.dom(".about.stats tr.about-like-count td").exists("has like stats");
|
||||
assert
|
||||
.dom(".about.stats tr.about-chat_messages-count td")
|
||||
.exists("has plugin stats");
|
||||
assert
|
||||
.dom(".about.stats tr.about-chat_users-count td")
|
||||
.doesNotExist("does not show hidden plugin stats");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
|
||||
acceptance("Badges", function (needs) {
|
||||
|
@ -9,23 +9,21 @@ acceptance("Badges", function (needs) {
|
|||
test("Visit Badge Pages", async function (assert) {
|
||||
await visit("/badges");
|
||||
|
||||
assert.ok(
|
||||
document.body.classList.contains("badges-page"),
|
||||
"has body class"
|
||||
);
|
||||
assert.ok(exists(".badge-groups .badge-card"), "has a list of badges");
|
||||
assert.dom(document.body).hasClass("badges-page", "has body class");
|
||||
assert.dom(".badge-groups .badge-card").exists("has a list of badges");
|
||||
|
||||
await visit("/badges/9/autobiographer");
|
||||
|
||||
assert.ok(exists(".badge-card"), "has the badge in the listing");
|
||||
assert.ok(exists(".user-info"), "has the list of users with that badge");
|
||||
assert.ok(!exists(".badge-card:nth-of-type(1) script"));
|
||||
assert.dom(".badge-card").exists("has the badge in the listing");
|
||||
assert.dom(".user-info").exists("has the list of users with that badge");
|
||||
assert.dom(".badge-card:nth-of-type(1) script").doesNotExist();
|
||||
});
|
||||
|
||||
test("shows correct badge titles to choose from", async function (assert) {
|
||||
const availableBadgeTitles = selectKit(".select-kit");
|
||||
await visit("/badges/50/custombadge");
|
||||
await availableBadgeTitles.expand();
|
||||
|
||||
assert.strictEqual(
|
||||
availableBadgeTitles.rowByIndex(1).name(),
|
||||
"CustomBadge"
|
||||
|
|
|
@ -22,7 +22,7 @@ const FORM_TEMPLATES = [
|
|||
label: "Description"
|
||||
- type: input
|
||||
id: disabled-input
|
||||
attributes:
|
||||
attributes:
|
||||
label: "Disabled input"
|
||||
disabled: true
|
||||
`,
|
||||
|
@ -96,6 +96,7 @@ acceptance("Composer Form Template", function (needs) {
|
|||
server.get("/posts/419", () => {
|
||||
return helper.response({ id: 419 });
|
||||
});
|
||||
|
||||
server.get("/composer/mentions", () => {
|
||||
return helper.response({
|
||||
users: [],
|
||||
|
@ -105,6 +106,7 @@ acceptance("Composer Form Template", function (needs) {
|
|||
max_users_notified_per_group_mention: 100,
|
||||
});
|
||||
});
|
||||
|
||||
server.get("/t/960.json", () => {
|
||||
const topicList = cloneJSON(TopicFixtures["/t/9/1.json"]);
|
||||
topicList.post_stream.posts[2].post_type = 4;
|
||||
|
@ -124,17 +126,11 @@ acceptance("Composer Form Template", function (needs) {
|
|||
);
|
||||
assert.strictEqual(selectKit(".category-chooser").header().value(), "1");
|
||||
|
||||
assert.ok(
|
||||
document.querySelector("#reply-control").classList.contains("open"),
|
||||
"reply control is open"
|
||||
);
|
||||
assert.dom("#reply-control").hasClass("open", "reply control is open");
|
||||
|
||||
assert.ok(
|
||||
document.querySelector(
|
||||
".form-template-field__input[name='disabled-input']"
|
||||
).disabled,
|
||||
"disabled-input is disabled"
|
||||
);
|
||||
assert
|
||||
.dom(".form-template-field__input[name='disabled-input']")
|
||||
.isDisabled();
|
||||
|
||||
await fillIn(".form-template-field__input[name='full-name']", "John Smith");
|
||||
|
||||
|
@ -145,32 +141,29 @@ acceptance("Composer Form Template", function (needs) {
|
|||
|
||||
await click(".toggle-minimize");
|
||||
|
||||
assert.ok(
|
||||
document.querySelector("#reply-control").classList.contains("draft"),
|
||||
"reply control is minimized into draft mode"
|
||||
);
|
||||
assert
|
||||
.dom("#reply-control")
|
||||
.hasClass("draft", "reply control is minimized into draft mode");
|
||||
|
||||
await click(".toggle-fullscreen");
|
||||
|
||||
assert.ok(
|
||||
document.querySelector("#reply-control").classList.contains("open"),
|
||||
"reply control is opened from draft mode"
|
||||
);
|
||||
assert
|
||||
.dom("#reply-control")
|
||||
.hasClass("open", "reply control is opened from draft mode");
|
||||
|
||||
assert.strictEqual(
|
||||
document.querySelector(".form-template-field__input[name='full-name']")
|
||||
.value,
|
||||
"John Smith",
|
||||
"keeps the value of the input field when composer is re-opened from draft mode"
|
||||
);
|
||||
assert
|
||||
.dom(".form-template-field__input[name='full-name']")
|
||||
.hasValue(
|
||||
"John Smith",
|
||||
"keeps the value of the input field when composer is re-opened from draft mode"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
document.querySelector(
|
||||
".form-template-field__textarea[name='description']"
|
||||
).value,
|
||||
"Community manager",
|
||||
"keeps the value of the textarea field when composer is re-opened from draft mode"
|
||||
);
|
||||
assert
|
||||
.dom(".form-template-field__textarea[name='description']")
|
||||
.hasValue(
|
||||
"Community manager",
|
||||
"keeps the value of the textarea field when composer is re-opened from draft mode"
|
||||
);
|
||||
});
|
||||
|
||||
test("Composer opens with the specified form template selected", async function (assert) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import DiscoveryFixtures from "discourse/tests/fixtures/discovery-fixtures";
|
||||
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
acceptance("Encoded Sub Category Discovery", function (needs) {
|
||||
needs.settings({
|
||||
|
@ -47,19 +47,13 @@ acceptance("Encoded Sub Category Discovery", function (needs) {
|
|||
"category-%E6%BC%A2%E5%AD%97-parent-%E6%BC%A2%E5%AD%97-subcategory";
|
||||
|
||||
await visit("/c/%E6%BC%A2%E5%AD%97-parent/%E6%BC%A2%E5%AD%97-subcategory");
|
||||
assert.ok(
|
||||
document.body.classList.contains(bodyClass),
|
||||
"has the default navigation"
|
||||
);
|
||||
assert.ok(exists(".topic-list"), "The list of topics was rendered");
|
||||
assert.ok(exists(".topic-list .topic-list-item"), "has topics");
|
||||
assert.dom(document.body).hasClass(bodyClass, "has the default navigation");
|
||||
assert.dom(".topic-list").exists("The list of topics was rendered");
|
||||
assert.dom(".topic-list .topic-list-item").exists("has topics");
|
||||
|
||||
await visit("/c/漢字-parent/漢字-subcategory");
|
||||
assert.ok(
|
||||
document.body.classList.contains(bodyClass),
|
||||
"has the default navigation"
|
||||
);
|
||||
assert.ok(exists(".topic-list"), "The list of topics was rendered");
|
||||
assert.ok(exists(".topic-list .topic-list-item"), "has topics");
|
||||
assert.dom(document.body).hasClass(bodyClass, "has the default navigation");
|
||||
assert.dom(".topic-list").exists("The list of topics was rendered");
|
||||
assert.dom(".topic-list .topic-list-item").exists("has topics");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,11 +2,7 @@ import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
|
|||
import { test } from "qunit";
|
||||
import PreloadStore from "discourse/lib/preload-store";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
import {
|
||||
acceptance,
|
||||
exists,
|
||||
query,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import I18n from "discourse-i18n";
|
||||
|
||||
function setAuthenticationData(hooks, json) {
|
||||
|
@ -73,14 +69,14 @@ acceptance("Invite accept", function (needs) {
|
|||
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
|
||||
assert.ok(
|
||||
query(".col-form").innerText.includes(
|
||||
I18n.t("invites.social_login_available")
|
||||
),
|
||||
"shows social login hint"
|
||||
);
|
||||
assert
|
||||
.dom(".col-form")
|
||||
.includesText(
|
||||
I18n.t("invites.social_login_available"),
|
||||
"shows social login hint"
|
||||
);
|
||||
|
||||
assert.ok(!exists("#new-account-email"), "hides the email input");
|
||||
assert.dom("#new-account-email").doesNotExist("hides the email input");
|
||||
});
|
||||
|
||||
test("invite link", async function (assert) {
|
||||
|
@ -99,95 +95,78 @@ acceptance("Invite accept", function (needs) {
|
|||
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
|
||||
assert.notOk(
|
||||
document.body.classList.contains("has-sidebar-page"),
|
||||
"does not display the sidebar on the invites page"
|
||||
);
|
||||
assert
|
||||
.dom(document.body)
|
||||
.hasNoClass(
|
||||
"has-sidebar-page",
|
||||
"does not display the sidebar on the invites page"
|
||||
);
|
||||
|
||||
assert.notOk(
|
||||
exists(".d-header"),
|
||||
"does not display the site header on the invites page"
|
||||
);
|
||||
assert
|
||||
.dom(".d-header")
|
||||
.doesNotExist("does not display the site header on the invites page");
|
||||
|
||||
assert.ok(exists("#new-account-email"), "shows the email input");
|
||||
assert.ok(exists("#new-account-username"), "shows the username input");
|
||||
assert.strictEqual(
|
||||
query("#new-account-username").value,
|
||||
"invited",
|
||||
"username is prefilled"
|
||||
);
|
||||
assert.ok(exists("#new-account-name"), "shows the name input");
|
||||
assert.ok(exists("#new-account-password"), "shows the password input");
|
||||
assert.ok(
|
||||
exists(".invites-show .btn-primary:disabled"),
|
||||
"submit is disabled because name and email is not filled"
|
||||
);
|
||||
assert.dom("#new-account-email").exists("shows the email input");
|
||||
assert.dom("#new-account-username").exists("shows the username input");
|
||||
assert
|
||||
.dom("#new-account-username")
|
||||
.hasValue("invited", "username is prefilled");
|
||||
assert.dom("#new-account-name").exists("shows the name input");
|
||||
assert.dom("#new-account-password").exists("shows the password input");
|
||||
assert
|
||||
.dom(".invites-show .btn-primary")
|
||||
.isDisabled("submit is disabled because name and email is not filled");
|
||||
assert
|
||||
.dom("#new-account-password")
|
||||
.hasAttribute("type", "password", "password is masked by default");
|
||||
|
||||
assert.ok(
|
||||
exists("#new-account-password[type='password']"),
|
||||
"password is masked by default"
|
||||
);
|
||||
await click(".toggle-password-mask");
|
||||
assert.ok(
|
||||
exists("#new-account-password[type='text']"),
|
||||
"password is unmasked when toggle is clicked"
|
||||
);
|
||||
assert
|
||||
.dom("#new-account-password")
|
||||
.hasAttribute(
|
||||
"type",
|
||||
"text",
|
||||
"password is unmasked when toggle is clicked"
|
||||
);
|
||||
|
||||
await fillIn("#new-account-name", "John Doe");
|
||||
assert.ok(
|
||||
exists(".invites-show .btn-primary:disabled"),
|
||||
"submit is disabled because email is not filled"
|
||||
);
|
||||
assert
|
||||
.dom(".invites-show .btn-primary")
|
||||
.isDisabled("submit is disabled because email is not filled");
|
||||
|
||||
await fillIn("#new-account-email", "john.doe@example.com");
|
||||
assert.ok(
|
||||
exists(".invites-show .btn-primary:disabled"),
|
||||
"submit is disabled because password is not filled"
|
||||
);
|
||||
assert
|
||||
.dom(".invites-show .btn-primary")
|
||||
.isDisabled("submit is disabled because password is not filled");
|
||||
|
||||
await fillIn("#new-account-password", "top$ecretzz");
|
||||
assert.notOk(
|
||||
exists(".invites-show .btn-primary:disabled"),
|
||||
"submit is enabled"
|
||||
);
|
||||
assert.dom(".invites-show .btn-primary").isEnabled("submit is enabled");
|
||||
|
||||
await fillIn("#new-account-username", "a");
|
||||
assert.ok(exists(".username-input .bad"), "username is not valid");
|
||||
assert.ok(
|
||||
exists(".invites-show .btn-primary:disabled"),
|
||||
"submit is disabled"
|
||||
);
|
||||
assert.dom(".username-input .bad").exists("username is not valid");
|
||||
assert.dom(".invites-show .btn-primary").isDisabled("submit is disabled");
|
||||
|
||||
await fillIn("#new-account-password", "aaa");
|
||||
assert.ok(exists(".password-input .bad"), "password is not valid");
|
||||
assert.ok(
|
||||
exists(".invites-show .btn-primary:disabled"),
|
||||
"submit is disabled"
|
||||
);
|
||||
assert.dom(".password-input .bad").exists("password is not valid");
|
||||
assert.dom(".invites-show .btn-primary").isDisabled("submit is disabled");
|
||||
|
||||
await fillIn("#new-account-email", "john.doe@example");
|
||||
assert.ok(exists(".email-input .bad"), "email is not valid");
|
||||
assert.ok(
|
||||
exists(".invites-show .btn-primary:disabled"),
|
||||
"submit is disabled"
|
||||
);
|
||||
assert.dom(".email-input .bad").exists("email is not valid");
|
||||
assert.dom(".invites-show .btn-primary").isDisabled("submit is disabled");
|
||||
|
||||
await fillIn("#new-account-username", "valid-name");
|
||||
await fillIn("#new-account-password", "secur3ty4Y0uAndMe");
|
||||
await fillIn("#new-account-email", "john.doe@example.com");
|
||||
assert.ok(exists(".username-input .good"), "username is valid");
|
||||
assert.ok(exists(".password-input .good"), "password is valid");
|
||||
assert.ok(exists(".email-input .good"), "email is valid");
|
||||
assert.notOk(
|
||||
exists(".invites-show .btn-primary:disabled"),
|
||||
"submit is enabled"
|
||||
);
|
||||
assert.dom(".username-input .good").exists("username is valid");
|
||||
assert.dom(".password-input .good").exists("password is valid");
|
||||
assert.dom(".email-input .good").exists("email is valid");
|
||||
assert.dom(".invites-show .btn-primary").isEnabled("submit is enabled");
|
||||
});
|
||||
|
||||
test("invite name is required only if full name is required", async function (assert) {
|
||||
preloadInvite();
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
assert.ok(exists(".name-input .required"), "Full name is required");
|
||||
assert.dom(".name-input .required").exists("Full name is required");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -199,16 +178,16 @@ acceptance("Invite accept when local login is disabled", function (needs) {
|
|||
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
|
||||
assert.ok(exists(".btn-social.facebook"), "shows Facebook login button");
|
||||
assert.ok(!exists("form"), "does not display the form");
|
||||
assert.dom(".btn-social.facebook").exists("shows Facebook login button");
|
||||
assert.dom("form").doesNotExist("does not display the form");
|
||||
});
|
||||
|
||||
test("email invite link", async function (assert) {
|
||||
preloadInvite();
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
|
||||
assert.ok(exists(".btn-social.facebook"), "shows Facebook login button");
|
||||
assert.ok(!exists("form"), "does not display the form");
|
||||
assert.dom(".btn-social.facebook").exists("shows Facebook login button");
|
||||
assert.dom("form").doesNotExist("does not display the form");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -225,16 +204,16 @@ acceptance(
|
|||
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
|
||||
assert.ok(
|
||||
!exists(".btn-social.facebook"),
|
||||
"does not show Facebook login button"
|
||||
);
|
||||
assert.ok(!exists("form"), "does not display the form");
|
||||
assert.ok(
|
||||
!exists(".email-message"),
|
||||
"does not show the email message with the prefilled email"
|
||||
);
|
||||
assert.ok(exists(".discourse-connect"), "shows the Continue button");
|
||||
assert
|
||||
.dom(".btn-social.facebook")
|
||||
.doesNotExist("does not show Facebook login button");
|
||||
assert.dom("form").doesNotExist("does not display the form");
|
||||
assert
|
||||
.dom(".email-message")
|
||||
.doesNotExist(
|
||||
"does not show the email message with the prefilled email"
|
||||
);
|
||||
assert.dom(".discourse-connect").exists("shows the Continue button");
|
||||
});
|
||||
|
||||
test("email invite link", async function (assert) {
|
||||
|
@ -242,19 +221,15 @@ acceptance(
|
|||
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
|
||||
assert.ok(
|
||||
!exists(".btn-social.facebook"),
|
||||
"does not show Facebook login button"
|
||||
);
|
||||
assert.ok(!exists("form"), "does not display the form");
|
||||
assert.ok(
|
||||
exists(".email-message"),
|
||||
"shows the email message with the prefilled email"
|
||||
);
|
||||
assert.ok(exists(".discourse-connect"), "shows the Continue button");
|
||||
assert.ok(
|
||||
query(".email-message").innerText.includes("foobar@example.com")
|
||||
);
|
||||
assert
|
||||
.dom(".btn-social.facebook")
|
||||
.doesNotExist("does not show Facebook login button");
|
||||
assert.dom("form").doesNotExist("does not display the form");
|
||||
assert
|
||||
.dom(".email-message")
|
||||
.exists("shows the email message with the prefilled email");
|
||||
assert.dom(".discourse-connect").exists("shows the Continue button");
|
||||
assert.dom(".email-message").includesText("foobar@example.com");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -271,7 +246,7 @@ acceptance(
|
|||
preloadInvite({ link: true });
|
||||
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
assert.ok(!exists("form"), "does not display the form");
|
||||
assert.dom("form").doesNotExist("does not display the form");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -292,34 +267,25 @@ acceptance("Invite link with authentication data", function (needs) {
|
|||
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
|
||||
assert.ok(
|
||||
!exists(".btn-social.facebook"),
|
||||
"does not show Facebook login button"
|
||||
);
|
||||
assert
|
||||
.dom(".btn-social.facebook")
|
||||
.doesNotExist("does not show Facebook login button");
|
||||
|
||||
assert.ok(!exists("#new-account-password"), "does not show password field");
|
||||
assert
|
||||
.dom("#new-account-password")
|
||||
.doesNotExist("does not show password field");
|
||||
|
||||
assert.ok(
|
||||
exists("#new-account-email[disabled]"),
|
||||
"email field is disabled"
|
||||
);
|
||||
assert.dom("#new-account-email").isDisabled("email field is disabled");
|
||||
|
||||
assert.strictEqual(
|
||||
query("#account-email-validation").innerText.trim(),
|
||||
I18n.t("user.email.authenticated", { provider: "Facebook" })
|
||||
);
|
||||
assert
|
||||
.dom("#account-email-validation")
|
||||
.hasText(I18n.t("user.email.authenticated", { provider: "Facebook" }));
|
||||
|
||||
assert.strictEqual(
|
||||
query("#new-account-username").value,
|
||||
"foobar",
|
||||
"username is prefilled"
|
||||
);
|
||||
assert
|
||||
.dom("#new-account-username")
|
||||
.hasValue("foobar", "username is prefilled");
|
||||
|
||||
assert.strictEqual(
|
||||
query("#new-account-name").value,
|
||||
"barfoo",
|
||||
"name is prefilled"
|
||||
);
|
||||
assert.dom("#new-account-name").hasValue("barfoo", "name is prefilled");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -339,12 +305,13 @@ acceptance("Email Invite link with authentication data", function (needs) {
|
|||
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
|
||||
assert.strictEqual(
|
||||
query("#account-email-validation").innerText.trim(),
|
||||
I18n.t("user.email.invite_auth_email_invalid", { provider: "Facebook" })
|
||||
);
|
||||
assert
|
||||
.dom("#account-email-validation")
|
||||
.hasText(
|
||||
I18n.t("user.email.invite_auth_email_invalid", { provider: "Facebook" })
|
||||
);
|
||||
|
||||
assert.ok(!exists("form"), "does not display the form");
|
||||
assert.dom("form").doesNotExist("does not display the form");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -366,33 +333,26 @@ acceptance(
|
|||
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
|
||||
assert.ok(
|
||||
!exists(".btn-social.facebook"),
|
||||
"does not show Facebook login button"
|
||||
);
|
||||
assert
|
||||
.dom(".btn-social.facebook")
|
||||
.doesNotExist("does not show Facebook login button");
|
||||
|
||||
assert.ok(
|
||||
!exists("#new-account-password"),
|
||||
"does not show password field"
|
||||
);
|
||||
assert.ok(!exists("#new-account-email"), "does not show email field");
|
||||
assert
|
||||
.dom("#new-account-password")
|
||||
.doesNotExist("does not show password field");
|
||||
assert
|
||||
.dom("#new-account-email")
|
||||
.doesNotExist("does not show email field");
|
||||
|
||||
assert.strictEqual(
|
||||
query("#account-email-validation").innerText.trim(),
|
||||
I18n.t("user.email.authenticated", { provider: "Facebook" })
|
||||
);
|
||||
assert
|
||||
.dom("#account-email-validation")
|
||||
.hasText(I18n.t("user.email.authenticated", { provider: "Facebook" }));
|
||||
|
||||
assert.strictEqual(
|
||||
query("#new-account-username").value,
|
||||
"foobar",
|
||||
"username is prefilled"
|
||||
);
|
||||
assert
|
||||
.dom("#new-account-username")
|
||||
.hasValue("foobar", "username is prefilled");
|
||||
|
||||
assert.strictEqual(
|
||||
query("#new-account-name").value,
|
||||
"barfoo",
|
||||
"name is prefilled"
|
||||
);
|
||||
assert.dom("#new-account-name").hasValue("barfoo", "name is prefilled");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -415,10 +375,11 @@ acceptance(
|
|||
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
|
||||
assert.strictEqual(
|
||||
query(".bad").textContent.trim(),
|
||||
"Your invitation email does not match the email authenticated by Facebook"
|
||||
);
|
||||
assert
|
||||
.dom(".bad")
|
||||
.hasText(
|
||||
"Your invitation email does not match the email authenticated by Facebook"
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -441,12 +402,13 @@ acceptance(
|
|||
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
|
||||
assert.ok(!exists("#new-account-email"), "does not show email field");
|
||||
assert
|
||||
.dom("#new-account-email")
|
||||
.doesNotExist("does not show email field");
|
||||
|
||||
assert.strictEqual(
|
||||
query("#account-email-validation").innerText.trim(),
|
||||
I18n.t("user.email.authenticated_by_invite")
|
||||
);
|
||||
assert
|
||||
.dom("#account-email-validation")
|
||||
.hasText(I18n.t("user.email.authenticated_by_invite"));
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -469,12 +431,11 @@ acceptance(
|
|||
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
|
||||
assert.ok(!exists("#new-account-email"), "does not show email field");
|
||||
assert
|
||||
.dom("#new-account-email")
|
||||
.doesNotExist("does not show email field");
|
||||
|
||||
assert.strictEqual(
|
||||
query("#account-email-validation").innerText.trim(),
|
||||
I18n.t("user.email.ok")
|
||||
);
|
||||
assert.dom("#account-email-validation").hasText(I18n.t("user.email.ok"));
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -498,10 +459,9 @@ acceptance(
|
|||
|
||||
await visit("/invites/my-valid-invite-token");
|
||||
|
||||
assert.ok(
|
||||
exists(".create-account-associate-link"),
|
||||
"shows the associate account link"
|
||||
);
|
||||
assert
|
||||
.dom(".create-account-associate-link")
|
||||
.exists("shows the associate account link");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
@ -8,7 +8,6 @@ import {
|
|||
import { test } from "qunit";
|
||||
import {
|
||||
acceptance,
|
||||
exists,
|
||||
query,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
|
@ -40,10 +39,9 @@ acceptance("User Preferences", function (needs) {
|
|||
test("update some fields", async function (assert) {
|
||||
await visit("/u/eviltrout/preferences");
|
||||
|
||||
assert.ok(
|
||||
document.body.classList.contains("user-preferences-page"),
|
||||
"has the body class"
|
||||
);
|
||||
assert
|
||||
.dom(document.body)
|
||||
.hasClass("user-preferences-page", "has the body class");
|
||||
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
|
@ -51,12 +49,12 @@ acceptance("User Preferences", function (needs) {
|
|||
"defaults to account tab"
|
||||
);
|
||||
|
||||
assert.ok(exists(".user-preferences"), "it shows the preferences");
|
||||
assert.dom(".user-preferences").exists("it shows the preferences");
|
||||
|
||||
const savePreferences = async () => {
|
||||
assert.ok(!exists(".saved"), "it hasn't been saved yet");
|
||||
assert.dom(".saved").doesNotExist("it hasn't been saved yet");
|
||||
await click(".save-changes");
|
||||
assert.ok(exists(".saved"), "it displays the saved message");
|
||||
assert.dom(".saved").exists("it displays the saved message");
|
||||
query(".saved").remove();
|
||||
};
|
||||
|
||||
|
@ -102,10 +100,11 @@ acceptance("User Preferences", function (needs) {
|
|||
|
||||
await visit("/u/eviltrout/preferences/tracking");
|
||||
|
||||
assert.notOk(
|
||||
exists(".tag-notifications"),
|
||||
"updating tags tracking preferences isn't visible when tags are disabled"
|
||||
);
|
||||
assert
|
||||
.dom(".tag-notifications")
|
||||
.doesNotExist(
|
||||
"updating tags tracking preferences isn't visible when tags are disabled"
|
||||
);
|
||||
|
||||
await click(".user-nav__preferences-interface a");
|
||||
await click(".control-group.other input[type=checkbox]:nth-of-type(1)");
|
||||
|
@ -130,7 +129,7 @@ acceptance("Custom User Fields", function (needs) {
|
|||
|
||||
test("can select an option from a dropdown", async function (assert) {
|
||||
await visit("/u/eviltrout/preferences/profile");
|
||||
assert.ok(exists(".user-field"), "it has at least one user field");
|
||||
assert.dom(".user-field").exists("it has at least one user field");
|
||||
await click(".user-field.dropdown");
|
||||
|
||||
const field = selectKit(
|
||||
|
@ -156,14 +155,14 @@ acceptance(
|
|||
|
||||
test("selecting bookmarks as home directs home to bookmarks", async function (assert) {
|
||||
await visit("/u/eviltrout/preferences/interface");
|
||||
assert.ok(exists(".home .combo-box"), "it has a home selector combo-box");
|
||||
assert.dom(".home .combo-box").exists("it has a home selector combo-box");
|
||||
|
||||
const field = selectKit(".home .combo-box");
|
||||
await field.expand();
|
||||
await field.selectRowByValue("6");
|
||||
await click(".save-changes");
|
||||
await visit("/");
|
||||
assert.ok(exists(".topic-list"), "The list of topics was rendered");
|
||||
assert.dom(".topic-list").exists("The list of topics was rendered");
|
||||
assert.strictEqual(
|
||||
currentRouteName(),
|
||||
"discovery.bookmarks",
|
||||
|
@ -193,22 +192,21 @@ acceptance("Ignored users", function (needs) {
|
|||
],
|
||||
});
|
||||
|
||||
assert.ok(
|
||||
!exists(".user-ignore"),
|
||||
"it does not show the list of ignored users"
|
||||
);
|
||||
assert
|
||||
.dom(".user-ignore")
|
||||
.doesNotExist("it does not show the list of ignored users");
|
||||
});
|
||||
|
||||
test("when user is allowed to ignore", async function (assert) {
|
||||
await visit(`/u/eviltrout/preferences/users`);
|
||||
updateCurrentUser({ can_ignore_users: true });
|
||||
assert.ok(exists(".user-ignore"), "it shows the list of ignored users");
|
||||
assert.dom(".user-ignore").exists("it shows the list of ignored users");
|
||||
});
|
||||
|
||||
test("staff can always see ignored users", async function (assert) {
|
||||
await visit(`/u/eviltrout/preferences/users`);
|
||||
updateCurrentUser({ moderator: true });
|
||||
assert.ok(exists(".user-ignore"), "it shows the list of ignored users");
|
||||
assert.dom(".user-ignore").exists("it shows the list of ignored users");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -224,26 +222,23 @@ acceptance(
|
|||
test("staged user doesn't show category and tag preferences", async function (assert) {
|
||||
await visit("/u/staged/preferences");
|
||||
|
||||
assert.ok(
|
||||
document.body.classList.contains("user-preferences-page"),
|
||||
"has the body class"
|
||||
);
|
||||
assert
|
||||
.dom(document.body)
|
||||
.hasClass("user-preferences-page", "has the body class");
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
"/u/staged/preferences/account",
|
||||
"defaults to account tab"
|
||||
);
|
||||
assert.ok(exists(".user-preferences"), "it shows the preferences");
|
||||
assert.dom(".user-preferences").exists("it shows the preferences");
|
||||
|
||||
assert.ok(
|
||||
!exists(".preferences-nav .nav-categories a"),
|
||||
"categories tab isn't there for staged users"
|
||||
);
|
||||
assert
|
||||
.dom(".preferences-nav .nav-categories a")
|
||||
.doesNotExist("categories tab isn't there for staged users");
|
||||
|
||||
assert.ok(
|
||||
!exists(".preferences-nav .nav-tags a"),
|
||||
"tags tab isn't there for staged users"
|
||||
);
|
||||
assert
|
||||
.dom(".preferences-nav .nav-tags a")
|
||||
.doesNotExist("tags tab isn't there for staged users");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
@ -5,14 +5,7 @@ import {
|
|||
SEARCH_TYPE_DEFAULT,
|
||||
SEARCH_TYPE_USERS,
|
||||
} from "discourse/controllers/full-page-search";
|
||||
import {
|
||||
acceptance,
|
||||
count,
|
||||
exists,
|
||||
query,
|
||||
selectDate,
|
||||
visible,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance, selectDate } from "discourse/tests/helpers/qunit-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
|
||||
let lastBody;
|
||||
|
@ -112,25 +105,22 @@ acceptance("Search - Full Page", function (needs) {
|
|||
test("perform various searches", async function (assert) {
|
||||
await visit("/search");
|
||||
|
||||
assert.ok(
|
||||
document.body.classList.contains("search-page"),
|
||||
"has body class"
|
||||
);
|
||||
assert.ok(exists(".search-container"), "has container class");
|
||||
assert.ok(exists(".search-query"));
|
||||
assert.ok(!exists(".fps-topic"));
|
||||
assert.dom(document.body).hasClass("search-page", "has body class");
|
||||
assert.dom(".search-container").exists("has container class");
|
||||
assert.dom(".search-query").exists();
|
||||
assert.dom(".fps-topic").doesNotExist();
|
||||
|
||||
await fillIn(".search-query", "none");
|
||||
await click(".search-cta");
|
||||
|
||||
assert.ok(!exists(".fps-topic"), "has no results");
|
||||
assert.ok(exists(".no-results-suggestion"));
|
||||
assert.ok(exists(".google-search-form"));
|
||||
assert.dom(".fps-topic").doesNotExist("has no results");
|
||||
assert.dom(".no-results-suggestion").exists();
|
||||
assert.dom(".google-search-form").exists();
|
||||
|
||||
await fillIn(".search-query", "discourse");
|
||||
await click(".search-cta");
|
||||
|
||||
assert.strictEqual(count(".fps-topic"), 1, "has one post");
|
||||
assert.dom(".fps-topic").exists({ count: 1 }, "has one post");
|
||||
});
|
||||
|
||||
test("search for personal messages", async function (assert) {
|
||||
|
@ -139,30 +129,30 @@ acceptance("Search - Full Page", function (needs) {
|
|||
await fillIn(".search-query", "discourse in:messages");
|
||||
await click(".search-cta");
|
||||
|
||||
assert.strictEqual(count(".fps-topic"), 1, "has one post");
|
||||
assert.dom(".fps-topic").exists({ count: 1 }, "has one post");
|
||||
|
||||
assert.strictEqual(
|
||||
count(".topic-status .personal_message"),
|
||||
1,
|
||||
"shows the right icon"
|
||||
);
|
||||
assert
|
||||
.dom(".topic-status .personal_message")
|
||||
.exists({ count: 1 }, "shows the right icon");
|
||||
|
||||
assert.strictEqual(count(".search-highlight"), 1, "search highlights work");
|
||||
assert
|
||||
.dom(".search-highlight")
|
||||
.exists({ count: 1 }, "search highlights work");
|
||||
});
|
||||
|
||||
test("escape search term", async function (assert) {
|
||||
await visit("/search");
|
||||
await fillIn(".search-query", "@<script>prompt(1337)</script>gmail.com");
|
||||
|
||||
assert.ok(
|
||||
exists(
|
||||
'.search-advanced-options span:contains("<script>prompt(1337)</script>gmail.com")'
|
||||
),
|
||||
"it escapes search term"
|
||||
await click(".advanced-filters > summary");
|
||||
|
||||
assert.strictEqual(
|
||||
selectKit("#search-posted-by").header().label(),
|
||||
"<script>prompt(1337)</script>gmail.com"
|
||||
);
|
||||
});
|
||||
|
||||
test("update category through advanced search ui", async function (assert) {
|
||||
test("update category through advanced search UI", async function (assert) {
|
||||
const categoryChooser = selectKit(
|
||||
".search-advanced-options .category-chooser"
|
||||
);
|
||||
|
@ -175,18 +165,18 @@ acceptance("Search - Full Page", function (needs) {
|
|||
await categoryChooser.fillInFilter("faq");
|
||||
await categoryChooser.selectRowByValue(4);
|
||||
|
||||
assert.ok(
|
||||
exists('.search-advanced-options .badge-category:contains("faq")'),
|
||||
'has "faq" populated'
|
||||
);
|
||||
await click(".advanced-filters > summary");
|
||||
assert.strictEqual(
|
||||
query(".search-query").value,
|
||||
"none #faq",
|
||||
'has updated search term to "none #faq"'
|
||||
selectKit("#search-in-category").header().label(),
|
||||
"faq"
|
||||
);
|
||||
|
||||
assert
|
||||
.dom(".search-query")
|
||||
.hasValue("none #faq", 'has updated search term to "none #faq"');
|
||||
});
|
||||
|
||||
test("update category without slug through advanced search ui", async function (assert) {
|
||||
test("update category without slug through advanced search UI", async function (assert) {
|
||||
const categoryChooser = selectKit(
|
||||
".search-advanced-options .category-chooser"
|
||||
);
|
||||
|
@ -199,105 +189,96 @@ acceptance("Search - Full Page", function (needs) {
|
|||
await categoryChooser.fillInFilter("快乐的");
|
||||
await categoryChooser.selectRowByValue(240);
|
||||
|
||||
assert.ok(
|
||||
exists('.search-advanced-options .badge-category:contains("快乐的")'),
|
||||
'has "快乐的" populated'
|
||||
);
|
||||
await click(".advanced-filters > summary");
|
||||
assert.strictEqual(
|
||||
query(".search-query").value,
|
||||
"none category:240",
|
||||
'has updated search term to "none category:240"'
|
||||
selectKit("#search-in-category").header().label(),
|
||||
"快乐的"
|
||||
);
|
||||
|
||||
assert
|
||||
.dom(".search-query")
|
||||
.hasValue(
|
||||
"none category:240",
|
||||
'has updated search term to "none category:240"'
|
||||
);
|
||||
});
|
||||
|
||||
test("update in:title filter through advanced search ui", async function (assert) {
|
||||
test("update in:title filter through advanced search UI", async function (assert) {
|
||||
await visit("/search");
|
||||
await fillIn(".search-query", "none");
|
||||
await click(".search-advanced-options .in-title");
|
||||
|
||||
assert.ok(
|
||||
exists(".search-advanced-options .in-title:checked"),
|
||||
'has "in title" populated'
|
||||
);
|
||||
assert.strictEqual(
|
||||
query(".search-query").value,
|
||||
"none in:title",
|
||||
'has updated search term to "none in:title"'
|
||||
);
|
||||
assert
|
||||
.dom(".search-advanced-options .in-title")
|
||||
.isChecked('has "in title" populated');
|
||||
assert
|
||||
.dom(".search-query")
|
||||
.hasValue("none in:title", 'has updated search term to "none in:title"');
|
||||
|
||||
await fillIn(".search-query", "none in:titleasd");
|
||||
|
||||
assert.notOk(
|
||||
exists(".search-advanced-options .in-title:checked"),
|
||||
"does not populate title only checkbox"
|
||||
);
|
||||
assert
|
||||
.dom(".search-advanced-options .in-title")
|
||||
.isNotChecked("does not populate title only checkbox");
|
||||
});
|
||||
|
||||
test("update in:likes filter through advanced search ui", async function (assert) {
|
||||
test("update in:likes filter through advanced search UI", async function (assert) {
|
||||
await visit("/search");
|
||||
await fillIn(".search-query", "none");
|
||||
await click(".search-advanced-options .in-likes");
|
||||
|
||||
assert.ok(
|
||||
exists(".search-advanced-options .in-likes:checked"),
|
||||
'has "I liked" populated'
|
||||
);
|
||||
assert.strictEqual(
|
||||
query(".search-query").value,
|
||||
"none in:likes",
|
||||
'has updated search term to "none in:likes"'
|
||||
);
|
||||
assert
|
||||
.dom(".search-advanced-options .in-likes")
|
||||
.isChecked('has "I liked" populated');
|
||||
assert
|
||||
.dom(".search-query")
|
||||
.hasValue("none in:likes", 'has updated search term to "none in:likes"');
|
||||
});
|
||||
|
||||
test("update in:messages filter through advanced search ui", async function (assert) {
|
||||
test("update in:messages filter through advanced search UI", async function (assert) {
|
||||
await visit("/search");
|
||||
await fillIn(".search-query", "none");
|
||||
await click(".search-advanced-options .in-private");
|
||||
|
||||
assert.ok(
|
||||
exists(".search-advanced-options .in-private:checked"),
|
||||
'has "are in my messages" populated'
|
||||
);
|
||||
assert
|
||||
.dom(".search-advanced-options .in-private")
|
||||
.isChecked('has "are in my messages" populated');
|
||||
|
||||
assert.strictEqual(
|
||||
query(".search-query").value,
|
||||
"none in:messages",
|
||||
'has updated search term to "none in:messages"'
|
||||
);
|
||||
assert
|
||||
.dom(".search-query")
|
||||
.hasValue(
|
||||
"none in:messages",
|
||||
'has updated search term to "none in:messages"'
|
||||
);
|
||||
|
||||
await fillIn(".search-query", "none in:personal-direct");
|
||||
|
||||
assert.notOk(
|
||||
exists(".search-advanced-options .in-private:checked"),
|
||||
"does not populate messages checkbox"
|
||||
);
|
||||
assert
|
||||
.dom(".search-advanced-options .in-private")
|
||||
.isNotChecked("does not populate messages checkbox");
|
||||
});
|
||||
|
||||
test("update in:seen filter through advanced search ui", async function (assert) {
|
||||
test("update in:seen filter through advanced search UI", async function (assert) {
|
||||
await visit("/search");
|
||||
await fillIn(".search-query", "none");
|
||||
await click(".search-advanced-options .in-seen");
|
||||
|
||||
assert.ok(
|
||||
exists(".search-advanced-options .in-seen:checked"),
|
||||
"it should check the right checkbox"
|
||||
);
|
||||
assert
|
||||
.dom(".search-advanced-options .in-seen")
|
||||
.isChecked("it should check the right checkbox");
|
||||
|
||||
assert.strictEqual(
|
||||
query(".search-query").value,
|
||||
"none in:seen",
|
||||
"it should update the search term"
|
||||
);
|
||||
assert
|
||||
.dom(".search-query")
|
||||
.hasValue("none in:seen", "it should update the search term");
|
||||
|
||||
await fillIn(".search-query", "none in:seenasdan");
|
||||
|
||||
assert.notOk(
|
||||
exists(".search-advanced-options .in-seen:checked"),
|
||||
"does not populate seen checkbox"
|
||||
);
|
||||
assert
|
||||
.dom(".search-advanced-options .in-seen")
|
||||
.isNotChecked("does not populate seen checkbox");
|
||||
});
|
||||
|
||||
test("update in filter through advanced search ui", async function (assert) {
|
||||
test("update in filter through advanced search UI", async function (assert) {
|
||||
const inSelector = selectKit(".search-advanced-options .select-kit#in");
|
||||
|
||||
await visit("/search");
|
||||
|
@ -312,14 +293,15 @@ acceptance("Search - Full Page", function (needs) {
|
|||
"I bookmarked",
|
||||
'has "I bookmarked" populated'
|
||||
);
|
||||
assert.strictEqual(
|
||||
query(".search-query").value,
|
||||
"none in:bookmarks",
|
||||
'has updated search term to "none in:bookmarks"'
|
||||
);
|
||||
assert
|
||||
.dom(".search-query")
|
||||
.hasValue(
|
||||
"none in:bookmarks",
|
||||
'has updated search term to "none in:bookmarks"'
|
||||
);
|
||||
});
|
||||
|
||||
test("update status through advanced search ui", async function (assert) {
|
||||
test("update status through advanced search UI", async function (assert) {
|
||||
const statusSelector = selectKit(
|
||||
".search-advanced-options .select-kit#search-status-options"
|
||||
);
|
||||
|
@ -336,11 +318,12 @@ acceptance("Search - Full Page", function (needs) {
|
|||
"are closed",
|
||||
'has "are closed" populated'
|
||||
);
|
||||
assert.strictEqual(
|
||||
query(".search-query").value,
|
||||
"none status:closed",
|
||||
'has updated search term to "none status:closed"'
|
||||
);
|
||||
assert
|
||||
.dom(".search-query")
|
||||
.hasValue(
|
||||
"none status:closed",
|
||||
'has updated search term to "none status:closed"'
|
||||
);
|
||||
});
|
||||
|
||||
test("doesn't update status filter header if wrong value entered through searchbox", async function (assert) {
|
||||
|
@ -375,14 +358,15 @@ acceptance("Search - Full Page", function (needs) {
|
|||
);
|
||||
});
|
||||
|
||||
test("update post time through advanced search ui", async function (assert) {
|
||||
test("update post time through advanced search UI", async function (assert) {
|
||||
await visit("/search?expanded=true&q=after:2018-08-22");
|
||||
|
||||
assert.strictEqual(
|
||||
query(".search-query").value,
|
||||
"after:2018-08-22",
|
||||
"it should update the search term correctly"
|
||||
);
|
||||
assert
|
||||
.dom(".search-query")
|
||||
.hasValue(
|
||||
"after:2018-08-22",
|
||||
"it should update the search term correctly"
|
||||
);
|
||||
|
||||
await visit("/search");
|
||||
await click(".advanced-filters > summary");
|
||||
|
@ -402,70 +386,65 @@ acceptance("Search - Full Page", function (needs) {
|
|||
'has "after" populated'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
query(".search-query").value,
|
||||
"none after:2016-10-05",
|
||||
'has updated search term to "none after:2016-10-05"'
|
||||
);
|
||||
assert
|
||||
.dom(".search-query")
|
||||
.hasValue(
|
||||
"none after:2016-10-05",
|
||||
'has updated search term to "none after:2016-10-05"'
|
||||
);
|
||||
});
|
||||
|
||||
test("update min post count through advanced search ui", async function (assert) {
|
||||
test("update min post count through advanced search UI", async function (assert) {
|
||||
await visit("/search");
|
||||
await click(".advanced-filters > summary");
|
||||
await fillIn(".search-query", "none");
|
||||
await fillIn("#search-min-post-count", "5");
|
||||
|
||||
assert.strictEqual(
|
||||
query(".search-advanced-additional-options #search-min-post-count").value,
|
||||
"5",
|
||||
'has "5" populated'
|
||||
);
|
||||
assert.strictEqual(
|
||||
query(".search-query").value,
|
||||
"none min_posts:5",
|
||||
'has updated search term to "none min_posts:5"'
|
||||
);
|
||||
assert
|
||||
.dom(".search-advanced-additional-options #search-min-post-count")
|
||||
.hasValue("5", 'has "5" populated');
|
||||
assert
|
||||
.dom(".search-query")
|
||||
.hasValue(
|
||||
"none min_posts:5",
|
||||
'has updated search term to "none min_posts:5"'
|
||||
);
|
||||
});
|
||||
|
||||
test("update max post count through advanced search ui", async function (assert) {
|
||||
test("update max post count through advanced search UI", async function (assert) {
|
||||
await visit("/search");
|
||||
await click(".advanced-filters > summary");
|
||||
await fillIn(".search-query", "none");
|
||||
await fillIn("#search-max-post-count", "5");
|
||||
|
||||
assert.strictEqual(
|
||||
query(".search-advanced-additional-options #search-max-post-count").value,
|
||||
"5",
|
||||
'has "5" populated'
|
||||
);
|
||||
assert.strictEqual(
|
||||
query(".search-query").value,
|
||||
"none max_posts:5",
|
||||
'has updated search term to "none max_posts:5"'
|
||||
);
|
||||
assert
|
||||
.dom(".search-advanced-additional-options #search-max-post-count")
|
||||
.hasValue("5", 'has "5" populated');
|
||||
assert
|
||||
.dom(".search-query")
|
||||
.hasValue(
|
||||
"none max_posts:5",
|
||||
'has updated search term to "none max_posts:5"'
|
||||
);
|
||||
});
|
||||
|
||||
test("validate advanced search when initially empty", async function (assert) {
|
||||
await visit("/search?expanded=true");
|
||||
await click(".search-advanced-options .in-likes");
|
||||
|
||||
assert.ok(
|
||||
selectKit(".search-advanced-options .in-likes:checked"),
|
||||
'has "I liked" populated'
|
||||
);
|
||||
assert
|
||||
.dom(".search-advanced-options .in-likes")
|
||||
.isChecked('has "I liked" populated');
|
||||
|
||||
assert.strictEqual(
|
||||
query(".search-query").value,
|
||||
"in:likes",
|
||||
'has updated search term to "in:likes"'
|
||||
);
|
||||
assert
|
||||
.dom(".search-query")
|
||||
.hasValue("in:likes", 'has updated search term to "in:likes"');
|
||||
|
||||
await fillIn(".search-query", "in:likesasdas");
|
||||
|
||||
assert.notOk(
|
||||
exists(".search-advanced-options .in-likes:checked"),
|
||||
"does not populate the likes checkbox"
|
||||
);
|
||||
assert
|
||||
.dom(".search-advanced-options .in-likes")
|
||||
.isNotChecked("does not populate the likes checkbox");
|
||||
});
|
||||
|
||||
test("all tags checkbox only visible for two or more tags", async function (assert) {
|
||||
|
@ -476,10 +455,10 @@ acceptance("Search - Full Page", function (needs) {
|
|||
await tagSelector.expand();
|
||||
await tagSelector.selectRowByValue("monkey");
|
||||
|
||||
assert.ok(!visible("input.all-tags"), "all tags checkbox not visible");
|
||||
assert.dom("input.all-tags").isNotVisible("all tags checkbox not visible");
|
||||
|
||||
await tagSelector.selectRowByValue("gazelle");
|
||||
assert.ok(visible("input.all-tags"), "all tags checkbox is visible");
|
||||
assert.dom("input.all-tags").isVisible("all tags checkbox is visible");
|
||||
});
|
||||
|
||||
test("search for users", async function (assert) {
|
||||
|
@ -488,26 +467,25 @@ acceptance("Search - Full Page", function (needs) {
|
|||
const typeSelector = selectKit(".search-bar .select-kit#search-type");
|
||||
|
||||
await fillIn(".search-query", "admin");
|
||||
assert.ok(!exists(".fps-user-item"), "has no user results");
|
||||
assert.dom(".fps-user-item").doesNotExist("has no user results");
|
||||
|
||||
await click(".advanced-filters > summary");
|
||||
await typeSelector.expand();
|
||||
await typeSelector.selectRowByValue(SEARCH_TYPE_USERS);
|
||||
|
||||
assert.ok(!exists(".search-filters"), "has no filters");
|
||||
assert.dom(".search-filters").doesNotExist("has no filters");
|
||||
|
||||
await click(".search-cta");
|
||||
|
||||
assert.strictEqual(count(".fps-user-item"), 1, "has one user result");
|
||||
assert.dom(".fps-user-item").exists({ count: 1 }, "has one user result");
|
||||
|
||||
await typeSelector.expand();
|
||||
await typeSelector.selectRowByValue(SEARCH_TYPE_DEFAULT);
|
||||
|
||||
assert.ok(
|
||||
exists(".search-filters"),
|
||||
"returning to topic/posts shows filters"
|
||||
);
|
||||
assert.ok(!exists(".fps-user-item"), "has no user results");
|
||||
assert
|
||||
.dom(".search-filters")
|
||||
.exists("returning to topic/posts shows filters");
|
||||
assert.dom(".fps-user-item").doesNotExist("has no user results");
|
||||
});
|
||||
|
||||
test("search for categories/tags", async function (assert) {
|
||||
|
@ -516,54 +494,51 @@ acceptance("Search - Full Page", function (needs) {
|
|||
await fillIn(".search-query", "none");
|
||||
const typeSelector = selectKit(".search-bar .select-kit#search-type");
|
||||
|
||||
assert.ok(!exists(".fps-tag-item"), "has no category/tag results");
|
||||
assert.dom(".fps-tag-item").doesNotExist("has no category/tag results");
|
||||
|
||||
await click(".advanced-filters > summary");
|
||||
await typeSelector.expand();
|
||||
await typeSelector.selectRowByValue(SEARCH_TYPE_CATS_TAGS);
|
||||
await click(".search-cta");
|
||||
|
||||
assert.ok(!exists(".search-filters"), "has no filters");
|
||||
assert.strictEqual(count(".fps-tag-item"), 4, "has four tag results");
|
||||
assert.dom(".search-filters").doesNotExist("has no filters");
|
||||
assert.dom(".fps-tag-item").exists({ count: 4 }, "has four tag results");
|
||||
|
||||
await typeSelector.expand();
|
||||
await typeSelector.selectRowByValue(SEARCH_TYPE_DEFAULT);
|
||||
|
||||
assert.ok(
|
||||
exists(".search-filters"),
|
||||
"returning to topic/posts shows filters"
|
||||
);
|
||||
assert.ok(!exists(".fps-tag-item"), "has no tag results");
|
||||
assert
|
||||
.dom(".search-filters")
|
||||
.exists("returning to topic/posts shows filters");
|
||||
assert.dom(".fps-tag-item").doesNotExist("has no tag results");
|
||||
});
|
||||
|
||||
test("filters expand/collapse as expected", async function (assert) {
|
||||
await visit("/search?expanded=true");
|
||||
|
||||
assert.ok(
|
||||
visible(".search-advanced-options"),
|
||||
"advanced filters are expanded when url query param is included"
|
||||
);
|
||||
assert
|
||||
.dom(".search-advanced-options")
|
||||
.isVisible(
|
||||
"advanced filters are expanded when url query param is included"
|
||||
);
|
||||
|
||||
await fillIn(".search-query", "none");
|
||||
await click(".search-cta");
|
||||
|
||||
assert.notOk(
|
||||
exists(".advanced-filters[open]"),
|
||||
"launching a search collapses advanced filters"
|
||||
);
|
||||
assert
|
||||
.dom(".advanced-filters[open]")
|
||||
.doesNotExist("launching a search collapses advanced filters");
|
||||
|
||||
await visit("/search");
|
||||
|
||||
assert.notOk(
|
||||
exists(".advanced-filters[open]"),
|
||||
"filters are collapsed when query param is not present"
|
||||
);
|
||||
assert
|
||||
.dom(".advanced-filters[open]")
|
||||
.doesNotExist("filters are collapsed when query param is not present");
|
||||
|
||||
await click(".advanced-filters > summary");
|
||||
assert.ok(
|
||||
visible(".search-advanced-options"),
|
||||
"clicking on element expands filters"
|
||||
);
|
||||
assert
|
||||
.dom(".search-advanced-options")
|
||||
.isVisible("clicking on element expands filters");
|
||||
});
|
||||
|
||||
test("bulk operations work", async function (assert) {
|
||||
|
@ -582,11 +557,11 @@ acceptance("Search - Full Page", function (needs) {
|
|||
|
||||
await fillIn(".search-query", "discourse");
|
||||
await click(".search-cta");
|
||||
assert.equal(count(".visited"), 0);
|
||||
assert.dom(".visited").doesNotExist();
|
||||
|
||||
await fillIn(".search-query", "discourse visited");
|
||||
await click(".search-cta");
|
||||
assert.equal(count(".visited"), 1);
|
||||
assert.dom(".visited").exists({ count: 1 });
|
||||
});
|
||||
|
||||
test("result link click tracking is invoked", async function (assert) {
|
||||
|
@ -598,6 +573,6 @@ acceptance("Search - Full Page", function (needs) {
|
|||
await click("a.search-link:first-child");
|
||||
|
||||
assert.strictEqual(currentURL(), "/t/lorem-ipsum-dolor-sit-amet/130");
|
||||
assert.ok(searchResultClickTracked);
|
||||
assert.true(searchResultClickTracked);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { getOwner } from "@ember/application";
|
||||
import { getOwner } from "@ember/owner";
|
||||
import {
|
||||
click,
|
||||
find,
|
||||
render,
|
||||
triggerEvent,
|
||||
triggerKeyEvent,
|
||||
|
@ -218,30 +217,24 @@ module("Integration | Component | FloatKit | d-tooltip", function (hooks) {
|
|||
);
|
||||
await hover();
|
||||
|
||||
assert.ok(
|
||||
find(".fk-d-tooltip__content")
|
||||
.getAttribute("style")
|
||||
.includes("max-width: 20px;")
|
||||
);
|
||||
assert
|
||||
.dom(".fk-d-tooltip__content")
|
||||
.hasAttribute("style", /max-width: 20px;/);
|
||||
});
|
||||
|
||||
test("applies position", async function (assert) {
|
||||
await render(hbs`<DTooltip @inline={{true}} @label="label" />`);
|
||||
await hover();
|
||||
|
||||
assert.ok(
|
||||
find(".fk-d-tooltip__content").getAttribute("style").includes("left: ")
|
||||
);
|
||||
assert.ok(
|
||||
find(".fk-d-tooltip__content").getAttribute("style").includes("top: ")
|
||||
);
|
||||
assert.dom(".fk-d-tooltip__content").hasAttribute("style", /left: /);
|
||||
assert.dom(".fk-d-tooltip__content").hasAttribute("style", /top: /);
|
||||
});
|
||||
|
||||
test("a tooltip can be closed by identifier", async function (assert) {
|
||||
await render(
|
||||
hbs`<DTooltip @inline={{true}} @label="label" @identifier="test">test</DTooltip>`
|
||||
);
|
||||
await open();
|
||||
await hover();
|
||||
|
||||
await getOwner(this).lookup("service:tooltip").close("test");
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@ import { click, fillIn, render, triggerKeyEvent } from "@ember/test-helpers";
|
|||
import hbs from "htmlbars-inline-precompile";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import pretender from "discourse/tests/helpers/create-pretender";
|
||||
import { exists, query, queryAll } from "discourse/tests/helpers/qunit-helpers";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
|
||||
function emojisResponse() {
|
||||
return {
|
||||
|
@ -61,9 +60,7 @@ module("Discourse Chat | Component | chat-emoji-picker", function (hooks) {
|
|||
});
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
pretender.get("/chat/emojis.json", () => {
|
||||
return [200, {}, emojisResponse()];
|
||||
});
|
||||
pretender.get("/chat/emojis.json", () => response(emojisResponse()));
|
||||
|
||||
this.chatEmojiPickerManager = this.container.lookup(
|
||||
"service:chat-emoji-picker-manager"
|
||||
|
@ -83,23 +80,18 @@ module("Discourse Chat | Component | chat-emoji-picker", function (hooks) {
|
|||
test("When displaying navigation", async function (assert) {
|
||||
await render(hbs`<ChatEmojiPicker />`);
|
||||
|
||||
assert.true(
|
||||
exists(
|
||||
`.chat-emoji-picker__section-btn.active[data-section="favorites"]`
|
||||
),
|
||||
"it renders first section as active"
|
||||
);
|
||||
assert.true(
|
||||
exists(
|
||||
`.chat-emoji-picker__section-btn[data-section="smileys_&_emotion"]`
|
||||
)
|
||||
);
|
||||
assert.true(
|
||||
exists(`.chat-emoji-picker__section-btn[data-section="people_&_body"]`)
|
||||
);
|
||||
assert.true(
|
||||
exists(`.chat-emoji-picker__section-btn[data-section="objects"]`)
|
||||
);
|
||||
assert
|
||||
.dom(`.chat-emoji-picker__section-btn.active[data-section="favorites"]`)
|
||||
.exists("it renders first section as active");
|
||||
assert
|
||||
.dom(`.chat-emoji-picker__section-btn[data-section="smileys_&_emotion"]`)
|
||||
.exists();
|
||||
assert
|
||||
.dom(`.chat-emoji-picker__section-btn[data-section="people_&_body"]`)
|
||||
.exists();
|
||||
assert
|
||||
.dom(`.chat-emoji-picker__section-btn[data-section="objects"]`)
|
||||
.exists();
|
||||
});
|
||||
|
||||
test("When changing tone scale", async function (assert) {
|
||||
|
@ -107,14 +99,12 @@ module("Discourse Chat | Component | chat-emoji-picker", function (hooks) {
|
|||
await click(".chat-emoji-picker__fitzpatrick-modifier-btn.current.t1");
|
||||
await click(".chat-emoji-picker__fitzpatrick-modifier-btn.t6");
|
||||
|
||||
assert.true(
|
||||
exists(`img[src="/images/emoji/twitter/raised_hands/6.png"]`),
|
||||
"it applies the tone to emojis"
|
||||
);
|
||||
assert.true(
|
||||
exists(".chat-emoji-picker__fitzpatrick-modifier-btn.current.t6"),
|
||||
"it changes the current scale to t6"
|
||||
);
|
||||
assert
|
||||
.dom(`img[src="/images/emoji/twitter/raised_hands/6.png"]`)
|
||||
.exists("it applies the tone to emojis");
|
||||
assert
|
||||
.dom(".chat-emoji-picker__fitzpatrick-modifier-btn.current.t6")
|
||||
.exists("it changes the current scale to t6");
|
||||
});
|
||||
|
||||
test("When requesting section", async function (assert) {
|
||||
|
@ -138,83 +128,85 @@ module("Discourse Chat | Component | chat-emoji-picker", function (hooks) {
|
|||
await render(hbs`<ChatEmojiPicker />`);
|
||||
await fillIn(".dc-filter-input", "grinning");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".chat-emoji-picker__section.filtered > img").length,
|
||||
1,
|
||||
"it filters the emojis list"
|
||||
);
|
||||
assert.true(
|
||||
exists('.chat-emoji-picker__section.filtered > img[alt="grinning"]'),
|
||||
"it filters the correct emoji"
|
||||
);
|
||||
assert
|
||||
.dom(".chat-emoji-picker__section.filtered > img")
|
||||
.exists({ count: 1 }, "it filters the emojis list");
|
||||
assert
|
||||
.dom('.chat-emoji-picker__section.filtered > img[alt="grinning"]')
|
||||
.exists("it filters the correct emoji");
|
||||
|
||||
await fillIn(".dc-filter-input", "Grinning");
|
||||
|
||||
assert.true(
|
||||
exists('.chat-emoji-picker__section.filtered > img[alt="grinning"]'),
|
||||
"it is case insensitive"
|
||||
);
|
||||
assert
|
||||
.dom('.chat-emoji-picker__section.filtered > img[alt="grinning"]')
|
||||
.exists("it is case insensitive");
|
||||
|
||||
await fillIn(".dc-filter-input", "smiley_cat");
|
||||
|
||||
assert.true(
|
||||
exists('.chat-emoji-picker__section.filtered > img[alt="grinning"]'),
|
||||
"it filters the correct emoji using search alias"
|
||||
);
|
||||
assert
|
||||
.dom('.chat-emoji-picker__section.filtered > img[alt="grinning"]')
|
||||
.exists("it filters the correct emoji using search alias");
|
||||
});
|
||||
|
||||
test("When selecting an emoji", async function (assert) {
|
||||
let selection;
|
||||
this.didSelectEmoji = (emoji) => {
|
||||
selection = emoji;
|
||||
};
|
||||
this.didSelectEmoji = (emoji) => assert.step(emoji);
|
||||
|
||||
await render(
|
||||
hbs`<ChatEmojiPicker @didSelectEmoji={{this.didSelectEmoji}} />`
|
||||
);
|
||||
await click('img.emoji[data-emoji="grinning"]');
|
||||
|
||||
assert.strictEqual(selection, "grinning");
|
||||
assert.verifySteps(["grinning"]);
|
||||
});
|
||||
|
||||
test("When navigating sections", async function (assert) {
|
||||
await render(hbs`<ChatEmojiPicker />`);
|
||||
|
||||
await triggerKeyEvent(document.activeElement, "keydown", "ArrowDown");
|
||||
assert.strictEqual(
|
||||
document.activeElement.dataset.emoji,
|
||||
"grinning",
|
||||
"ArrowDown focuses on the first favorite emoji"
|
||||
);
|
||||
assert
|
||||
.dom(document.activeElement)
|
||||
.hasAttribute(
|
||||
"data-emoji",
|
||||
"grinning",
|
||||
"ArrowDown focuses on the first favorite emoji"
|
||||
);
|
||||
|
||||
await triggerKeyEvent(document.activeElement, "keydown", "ArrowDown");
|
||||
await triggerKeyEvent(document.activeElement, "keydown", "ArrowDown");
|
||||
assert.strictEqual(
|
||||
document.activeElement.dataset.emoji,
|
||||
"raised_hands",
|
||||
"ArrowDown focuses on the first emoji form the third section"
|
||||
);
|
||||
assert
|
||||
.dom(document.activeElement)
|
||||
.hasAttribute(
|
||||
"data-emoji",
|
||||
"raised_hands",
|
||||
"ArrowDown focuses on the first emoji form the third section"
|
||||
);
|
||||
|
||||
await triggerKeyEvent(document.activeElement, "keydown", "ArrowRight");
|
||||
assert.strictEqual(
|
||||
document.activeElement.dataset.emoji,
|
||||
"man_rowing_boat",
|
||||
"ArrowRight focuses on the emoji at the right"
|
||||
);
|
||||
assert
|
||||
.dom(document.activeElement)
|
||||
.hasAttribute(
|
||||
"data-emoji",
|
||||
"man_rowing_boat",
|
||||
"ArrowRight focuses on the emoji at the right"
|
||||
);
|
||||
|
||||
await triggerKeyEvent(document.activeElement, "keydown", "ArrowLeft");
|
||||
assert.strictEqual(
|
||||
document.activeElement.dataset.emoji,
|
||||
"raised_hands",
|
||||
"ArrowLeft focuses on the emoji at the left"
|
||||
);
|
||||
assert
|
||||
.dom(document.activeElement)
|
||||
.hasAttribute(
|
||||
"data-emoji",
|
||||
"raised_hands",
|
||||
"ArrowLeft focuses on the emoji at the left"
|
||||
);
|
||||
|
||||
await triggerKeyEvent(document.activeElement, "keydown", "ArrowUp");
|
||||
assert.strictEqual(
|
||||
document.activeElement.dataset.emoji,
|
||||
"grinning",
|
||||
"ArrowUp focuses on the first emoji form the second section"
|
||||
);
|
||||
assert
|
||||
.dom(document.activeElement)
|
||||
.hasAttribute(
|
||||
"data-emoji",
|
||||
"grinning",
|
||||
"ArrowUp focuses on the first emoji form the second section"
|
||||
);
|
||||
});
|
||||
|
||||
test("When navigating filtered emojis", async function (assert) {
|
||||
|
@ -222,32 +214,35 @@ module("Discourse Chat | Component | chat-emoji-picker", function (hooks) {
|
|||
await fillIn(".dc-filter-input", "man");
|
||||
|
||||
await triggerKeyEvent(document.activeElement, "keydown", "ArrowDown");
|
||||
assert.strictEqual(
|
||||
document.activeElement.dataset.emoji,
|
||||
"man_rowing_boat",
|
||||
"ArrowDown focuses on the first filtered emoji"
|
||||
);
|
||||
assert
|
||||
.dom(document.activeElement)
|
||||
.hasAttribute(
|
||||
"data-emoji",
|
||||
"man_rowing_boat",
|
||||
"ArrowDown focuses on the first filtered emoji"
|
||||
);
|
||||
|
||||
await triggerKeyEvent(document.activeElement, "keydown", "ArrowRight");
|
||||
assert.strictEqual(
|
||||
document.activeElement.dataset.emoji,
|
||||
"womans_clothes",
|
||||
"ArrowRight focuses on the emoji at the right"
|
||||
);
|
||||
assert
|
||||
.dom(document.activeElement)
|
||||
.hasAttribute(
|
||||
"data-emoji",
|
||||
"womans_clothes",
|
||||
"ArrowRight focuses on the emoji at the right"
|
||||
);
|
||||
|
||||
await triggerKeyEvent(document.activeElement, "keydown", "ArrowLeft");
|
||||
assert.strictEqual(
|
||||
document.activeElement.dataset.emoji,
|
||||
"man_rowing_boat",
|
||||
"ArrowLeft focuses on the emoji at the left"
|
||||
);
|
||||
assert
|
||||
.dom(document.activeElement)
|
||||
.hasAttribute(
|
||||
"data-emoji",
|
||||
"man_rowing_boat",
|
||||
"ArrowLeft focuses on the emoji at the left"
|
||||
);
|
||||
});
|
||||
|
||||
test("When selecting a toned an emoji", async function (assert) {
|
||||
let selection;
|
||||
this.didSelectEmoji = (emoji) => {
|
||||
selection = emoji;
|
||||
};
|
||||
this.didSelectEmoji = (emoji) => assert.step(emoji);
|
||||
|
||||
await render(
|
||||
hbs`<ChatEmojiPicker @didSelectEmoji={{this.didSelectEmoji}} />`
|
||||
|
@ -255,62 +250,58 @@ module("Discourse Chat | Component | chat-emoji-picker", function (hooks) {
|
|||
this.emojiReactionStore.diversity = 1;
|
||||
await click('img.emoji[data-emoji="man_rowing_boat"]');
|
||||
|
||||
assert.strictEqual(selection, "man_rowing_boat");
|
||||
|
||||
this.emojiReactionStore.diversity = 2;
|
||||
await click('img.emoji[data-emoji="man_rowing_boat"]');
|
||||
|
||||
assert.strictEqual(selection, "man_rowing_boat:t2");
|
||||
assert.verifySteps(["man_rowing_boat", "man_rowing_boat:t2"]);
|
||||
});
|
||||
|
||||
test("When opening the picker", async function (assert) {
|
||||
await render(hbs`<ChatEmojiPicker />`);
|
||||
|
||||
assert.true(document.activeElement.classList.contains("dc-filter-input"));
|
||||
assert.dom(document.activeElement).hasClass("dc-filter-input");
|
||||
});
|
||||
|
||||
test("When hovering an emoji", async function (assert) {
|
||||
await render(hbs`<ChatEmojiPicker />`);
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
assert
|
||||
.dom(
|
||||
'.chat-emoji-picker__section[data-section="people_&_body"] img.emoji:nth-child(1)'
|
||||
).title,
|
||||
":raised_hands:",
|
||||
"first emoji has a title"
|
||||
);
|
||||
)
|
||||
.hasAttribute("title", ":raised_hands:", "first emoji has a title");
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
assert
|
||||
.dom(
|
||||
'.chat-emoji-picker__section[data-section="people_&_body"] img.emoji:nth-child(2)'
|
||||
).title,
|
||||
":man_rowing_boat:",
|
||||
"second emoji has a title"
|
||||
);
|
||||
)
|
||||
.hasAttribute("title", ":man_rowing_boat:", "second emoji has a title");
|
||||
|
||||
await fillIn(".dc-filter-input", "grinning");
|
||||
assert.strictEqual(
|
||||
query('img.emoji[data-emoji="grinning"]').title,
|
||||
":grinning:",
|
||||
"filtered emoji have a title"
|
||||
);
|
||||
assert
|
||||
.dom('img.emoji[data-emoji="grinning"]')
|
||||
.hasAttribute("title", ":grinning:", "filtered emoji have a title");
|
||||
|
||||
this.emojiReactionStore.diversity = 1;
|
||||
await render(hbs`<ChatEmojiPicker />`);
|
||||
|
||||
assert.strictEqual(
|
||||
query('img.emoji[data-emoji="man_rowing_boat"]').title,
|
||||
":man_rowing_boat:",
|
||||
"it has a title without the scale as diversity value is 1"
|
||||
);
|
||||
assert
|
||||
.dom('img.emoji[data-emoji="man_rowing_boat"]')
|
||||
.hasAttribute(
|
||||
"title",
|
||||
":man_rowing_boat:",
|
||||
"it has a title without the scale as diversity value is 1"
|
||||
);
|
||||
|
||||
this.emojiReactionStore.diversity = 2;
|
||||
await render(hbs`<ChatEmojiPicker />`);
|
||||
|
||||
assert.strictEqual(
|
||||
query('img.emoji[data-emoji="man_rowing_boat"]').title,
|
||||
":man_rowing_boat:t2:",
|
||||
"it has a title with the scale"
|
||||
);
|
||||
assert
|
||||
.dom('img.emoji[data-emoji="man_rowing_boat"]')
|
||||
.hasAttribute(
|
||||
"title",
|
||||
":man_rowing_boat:t2:",
|
||||
"it has a title with the scale"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
import { visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import {
|
||||
acceptance,
|
||||
count,
|
||||
query,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
acceptance("Rendering polls with pie charts", function (needs) {
|
||||
needs.user();
|
||||
|
@ -16,30 +12,18 @@ acceptance("Rendering polls with pie charts", function (needs) {
|
|||
test("Displays the pie chart", async function (assert) {
|
||||
await visit("/t/-/topic_with_pie_chart_poll");
|
||||
|
||||
const poll = query(".poll");
|
||||
assert
|
||||
.dom(".poll .poll-info_counts-count:first-child .info-number")
|
||||
.hasText("2", "it should display the right number of voters");
|
||||
|
||||
assert.strictEqual(
|
||||
query(".info-number", poll).innerHTML,
|
||||
"2",
|
||||
"it should display the right number of voters"
|
||||
);
|
||||
assert
|
||||
.dom(".poll .poll-info_counts-count:last-child .info-number")
|
||||
.hasText("5", "it should display the right number of votes");
|
||||
|
||||
assert.strictEqual(
|
||||
poll.querySelectorAll(".info-number")[1].innerHTML,
|
||||
"5",
|
||||
"it should display the right number of votes"
|
||||
);
|
||||
assert.dom(".poll").hasClass("pie", "pie class is present on poll div");
|
||||
|
||||
assert.strictEqual(
|
||||
poll.classList.contains("pie"),
|
||||
true,
|
||||
"pie class is present on poll div"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
count(".poll-results-chart", poll),
|
||||
1,
|
||||
"Renders the chart div instead of bar container"
|
||||
);
|
||||
assert
|
||||
.dom(".poll .poll-results-chart")
|
||||
.exists({ count: 1 }, "Renders the chart div instead of bar container");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user