mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 12:41:54 +08:00
DEV: migrate acceptance tests to async/await
This commit is contained in:
@ -50,8 +50,8 @@ QUnit.test("suspend, then unsuspend a user", async assert => {
|
|||||||
"disabled by default"
|
"disabled by default"
|
||||||
);
|
);
|
||||||
|
|
||||||
suspendUntilCombobox.expandAwait();
|
await suspendUntilCombobox.expandAwait();
|
||||||
suspendUntilCombobox.selectRowByValueAwait("tomorrow");
|
await suspendUntilCombobox.selectRowByValueAwait("tomorrow");
|
||||||
|
|
||||||
await fillIn(".suspend-reason", "for breaking the rules");
|
await fillIn(".suspend-reason", "for breaking the rules");
|
||||||
await fillIn(".suspend-message", "this is an email reason why");
|
await fillIn(".suspend-message", "this is an email reason why");
|
||||||
|
@ -13,7 +13,7 @@ QUnit.test("does not display uncategorized if not allowed", async assert => {
|
|||||||
await visit("/");
|
await visit("/");
|
||||||
await click("#create-topic");
|
await click("#create-topic");
|
||||||
|
|
||||||
categoryChooser.expandAwait();
|
await categoryChooser.expandAwait();
|
||||||
|
|
||||||
assert.ok(categoryChooser.rowByIndex(0).name() !== "uncategorized");
|
assert.ok(categoryChooser.rowByIndex(0).name() !== "uncategorized");
|
||||||
});
|
});
|
||||||
|
@ -33,7 +33,7 @@ QUnit.test("removing a permission", async assert => {
|
|||||||
await click(".edit-category");
|
await click(".edit-category");
|
||||||
await click("li.edit-category-security a");
|
await click("li.edit-category-security a");
|
||||||
await click(".edit-category-tab-security .edit-permission");
|
await click(".edit-category-tab-security .edit-permission");
|
||||||
availableGroups.expand();
|
await availableGroups.expandAwait();
|
||||||
|
|
||||||
assert.notOk(
|
assert.notOk(
|
||||||
availableGroups.rowByValue("everyone").exists(),
|
availableGroups.rowByValue("everyone").exists(),
|
||||||
@ -43,7 +43,7 @@ QUnit.test("removing a permission", async assert => {
|
|||||||
await click(
|
await click(
|
||||||
".edit-category-tab-security .permission-list li:first-of-type .remove-permission"
|
".edit-category-tab-security .permission-list li:first-of-type .remove-permission"
|
||||||
);
|
);
|
||||||
availableGroups.expand();
|
await availableGroups.expandAwait();
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
availableGroups.rowByValue("everyone").exists(),
|
availableGroups.rowByValue("everyone").exists(),
|
||||||
@ -60,8 +60,10 @@ QUnit.test("adding a permission", async assert => {
|
|||||||
await click(".edit-category");
|
await click(".edit-category");
|
||||||
await click("li.edit-category-security a");
|
await click("li.edit-category-security a");
|
||||||
await click(".edit-category-tab-security .edit-permission");
|
await click(".edit-category-tab-security .edit-permission");
|
||||||
availableGroups.expand().selectRowByValue("staff");
|
await availableGroups.expandAwait();
|
||||||
permissionSelector.expand().selectRowByValue("2");
|
await availableGroups.selectRowByValueAwait("staff");
|
||||||
|
await permissionSelector.expandAwait();
|
||||||
|
await permissionSelector.selectRowByValueAwait("2");
|
||||||
await click(".edit-category-tab-security .add-permission");
|
await click(".edit-category-tab-security .add-permission");
|
||||||
|
|
||||||
const $addedPermissionItem = find(
|
const $addedPermissionItem = find(
|
||||||
@ -93,7 +95,8 @@ QUnit.test("adding a previously removed permission", async assert => {
|
|||||||
"it removes the permission from the list"
|
"it removes the permission from the list"
|
||||||
);
|
);
|
||||||
|
|
||||||
availableGroups.expand().selectRowByValue("everyone");
|
await availableGroups.expandAwait();
|
||||||
|
await availableGroups.selectRowByValueAwait("everyone");
|
||||||
await click(".edit-category-tab-security .add-permission");
|
await click(".edit-category-tab-security .add-permission");
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
|
@ -78,7 +78,8 @@ QUnit.test("Subcategory list settings", async assert => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await click(".edit-category-general");
|
await click(".edit-category-general");
|
||||||
categoryChooser.expand().selectRowByValue(3);
|
await categoryChooser.expandAwait();
|
||||||
|
await categoryChooser.selectRowByValueAwait(3);
|
||||||
|
|
||||||
await click(".edit-category-settings a");
|
await click(".edit-category-settings a");
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ QUnit.test("Disable body until category is selected", async assert => {
|
|||||||
|
|
||||||
await fillIn(".d-editor-input", "Now I can type stuff");
|
await fillIn(".d-editor-input", "Now I can type stuff");
|
||||||
await categoryChooser.expandAwait();
|
await categoryChooser.expandAwait();
|
||||||
await categoryChooser.selectRowByValue("__none__");
|
await categoryChooser.selectRowByValueAwait("__none__");
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
find(".d-editor-textarea-wrapper.disabled").length === 0,
|
find(".d-editor-textarea-wrapper.disabled").length === 0,
|
||||||
|
@ -3,101 +3,86 @@ import { acceptance } from "helpers/qunit-helpers";
|
|||||||
let userFound = false;
|
let userFound = false;
|
||||||
|
|
||||||
acceptance("Forgot password", {
|
acceptance("Forgot password", {
|
||||||
beforeEach() {
|
pretend(server, helper) {
|
||||||
const response = object => {
|
server.post("/session/forgot_password", () => {
|
||||||
return [200, { "Content-Type": "application/json" }, object];
|
return helper.response({
|
||||||
};
|
user_found: userFound
|
||||||
|
});
|
||||||
// prettier-ignore
|
|
||||||
server.post("/session/forgot_password", () => { // eslint-disable-line no-undef
|
|
||||||
return response({ user_found: userFound });
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("requesting password reset", assert => {
|
QUnit.test("requesting password reset", async assert => {
|
||||||
visit("/");
|
await visit("/");
|
||||||
click("header .login-button");
|
await click("header .login-button");
|
||||||
click("#forgot-password-link");
|
await click("#forgot-password-link");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".forgot-password-reset").attr("disabled"),
|
||||||
find(".forgot-password-reset").attr("disabled"),
|
"disabled",
|
||||||
"disabled",
|
"it should disable the button until the field is filled"
|
||||||
"it should disable the button until the field is filled"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn("#username-or-email", "someuser");
|
await fillIn("#username-or-email", "someuser");
|
||||||
click(".forgot-password-reset");
|
await click(".forgot-password-reset");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".alert-error")
|
||||||
find(".alert-error")
|
.html()
|
||||||
.html()
|
.trim(),
|
||||||
.trim(),
|
I18n.t("forgot_password.complete_username_not_found", {
|
||||||
I18n.t("forgot_password.complete_username_not_found", {
|
username: "someuser"
|
||||||
username: "someuser"
|
}),
|
||||||
}),
|
"it should display an error for an invalid username"
|
||||||
"it should display an error for an invalid username"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn("#username-or-email", "someuser@gmail.com");
|
await fillIn("#username-or-email", "someuser@gmail.com");
|
||||||
click(".forgot-password-reset");
|
await click(".forgot-password-reset");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".alert-error")
|
||||||
find(".alert-error")
|
.html()
|
||||||
.html()
|
.trim(),
|
||||||
.trim(),
|
I18n.t("forgot_password.complete_email_not_found", {
|
||||||
I18n.t("forgot_password.complete_email_not_found", {
|
email: "someuser@gmail.com"
|
||||||
email: "someuser@gmail.com"
|
}),
|
||||||
}),
|
"it should display an error for an invalid email"
|
||||||
"it should display an error for an invalid email"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn("#username-or-email", "someuser");
|
await fillIn("#username-or-email", "someuser");
|
||||||
|
|
||||||
andThen(() => {
|
userFound = true;
|
||||||
userFound = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".forgot-password-reset");
|
await click(".forgot-password-reset");
|
||||||
|
|
||||||
andThen(() => {
|
assert.notOk(
|
||||||
assert.notOk(
|
exists(find(".alert-error")),
|
||||||
exists(find(".alert-error")),
|
"it should remove the flash error when succeeding"
|
||||||
"it should remove the flash error when succeeding"
|
);
|
||||||
);
|
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".modal-body")
|
find(".modal-body")
|
||||||
.html()
|
.html()
|
||||||
.trim(),
|
.trim(),
|
||||||
I18n.t("forgot_password.complete_username_found", {
|
I18n.t("forgot_password.complete_username_found", {
|
||||||
username: "someuser"
|
username: "someuser"
|
||||||
}),
|
}),
|
||||||
"it should display a success message for a valid username"
|
"it should display a success message for a valid username"
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
visit("/");
|
await visit("/");
|
||||||
click("header .login-button");
|
await click("header .login-button");
|
||||||
click("#forgot-password-link");
|
await click("#forgot-password-link");
|
||||||
fillIn("#username-or-email", "someuser@gmail.com");
|
await fillIn("#username-or-email", "someuser@gmail.com");
|
||||||
click(".forgot-password-reset");
|
await click(".forgot-password-reset");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".modal-body")
|
||||||
find(".modal-body")
|
.html()
|
||||||
.html()
|
.trim(),
|
||||||
.trim(),
|
I18n.t("forgot_password.complete_email_found", {
|
||||||
I18n.t("forgot_password.complete_email_found", {
|
email: "someuser@gmail.com"
|
||||||
email: "someuser@gmail.com"
|
}),
|
||||||
}),
|
"it should display a success message for a valid email"
|
||||||
"it should display a success message for a valid email"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -2,14 +2,9 @@ import { acceptance } from "helpers/qunit-helpers";
|
|||||||
|
|
||||||
acceptance("Group logs", {
|
acceptance("Group logs", {
|
||||||
loggedIn: true,
|
loggedIn: true,
|
||||||
beforeEach() {
|
pretend(server, helper) {
|
||||||
const response = object => {
|
server.get("/groups/snorlax.json", () => {
|
||||||
return [200, { "Content-Type": "application/json" }, object];
|
return helper.response({
|
||||||
};
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
server.get("/groups/snorlax.json", () => { // eslint-disable-line no-undef
|
|
||||||
return response({
|
|
||||||
group: {
|
group: {
|
||||||
id: 41,
|
id: 41,
|
||||||
automatic: false,
|
automatic: false,
|
||||||
@ -37,10 +32,9 @@ acceptance("Group logs", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Workaround while awaiting https://github.com/tildeio/route-recognizer/issues/53
|
// Workaround while awaiting https://github.com/tildeio/route-recognizer/issues/53
|
||||||
// prettier-ignore
|
server.get("/groups/snorlax/logs.json", request => {
|
||||||
server.get("/groups/snorlax/logs.json", request => { // eslint-disable-line no-undef
|
|
||||||
if (request.queryParams["filters[action]"]) {
|
if (request.queryParams["filters[action]"]) {
|
||||||
return response({
|
return helper.response({
|
||||||
logs: [
|
logs: [
|
||||||
{
|
{
|
||||||
action: "change_group_setting",
|
action: "change_group_setting",
|
||||||
@ -59,7 +53,7 @@ acceptance("Group logs", {
|
|||||||
all_loaded: true
|
all_loaded: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return response({
|
return helper.response({
|
||||||
logs: [
|
logs: [
|
||||||
{
|
{
|
||||||
action: "change_group_setting",
|
action: "change_group_setting",
|
||||||
@ -99,21 +93,16 @@ acceptance("Group logs", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Browsing group logs", assert => {
|
QUnit.test("Browsing group logs", async assert => {
|
||||||
visit("/groups/snorlax/manage/logs");
|
await visit("/groups/snorlax/manage/logs");
|
||||||
|
assert.ok(
|
||||||
|
find("tr.group-manage-logs-row").length === 2,
|
||||||
|
"it should display the right number of logs"
|
||||||
|
);
|
||||||
|
|
||||||
andThen(() => {
|
await click(find(".group-manage-logs-row button")[0]);
|
||||||
assert.ok(
|
assert.ok(
|
||||||
find("tr.group-manage-logs-row").length === 2,
|
find("tr.group-manage-logs-row").length === 1,
|
||||||
"it should display the right number of logs"
|
"it should display the right number of logs"
|
||||||
);
|
);
|
||||||
click(find(".group-manage-logs-row button")[0]);
|
|
||||||
});
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.ok(
|
|
||||||
find("tr.group-manage-logs-row").length === 1,
|
|
||||||
"it should display the right number of logs"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,13 @@ import { acceptance, logIn } from "helpers/qunit-helpers";
|
|||||||
acceptance("Group", {
|
acceptance("Group", {
|
||||||
settings: {
|
settings: {
|
||||||
enable_group_directory: true
|
enable_group_directory: true
|
||||||
|
},
|
||||||
|
pretend(server, helper) {
|
||||||
|
server.post("/groups/Macdonald/request_membership", () => {
|
||||||
|
return helper.response({
|
||||||
|
relative_url: "/t/internationalization-localization/280"
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -72,76 +79,59 @@ QUnit.test("Anonymous Viewing Group", async assert => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Anonymous Viewing Automatic Group", assert => {
|
QUnit.test("Anonymous Viewing Automatic Group", async assert => {
|
||||||
visit("/groups/moderators");
|
await visit("/groups/moderators");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
count(".nav-pills li a[title='Manage']"),
|
||||||
count(".nav-pills li a[title='Manage']"),
|
0,
|
||||||
0,
|
"it deos not show group messages navigation link"
|
||||||
"it deos not show group messages navigation link"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("User Viewing Group", assert => {
|
QUnit.test("User Viewing Group", async assert => {
|
||||||
logIn();
|
logIn();
|
||||||
Discourse.reset();
|
Discourse.reset();
|
||||||
|
|
||||||
visit("/groups");
|
await visit("/groups");
|
||||||
click(".group-index-request");
|
await click(".group-index-request");
|
||||||
|
|
||||||
// prettier-ignore
|
assert.equal(
|
||||||
server.post("/groups/Macdonald/request_membership", () => { // eslint-disable-line no-undef
|
find(".modal-header")
|
||||||
return [
|
.text()
|
||||||
200,
|
.trim(),
|
||||||
{ "Content-Type": "application/json" },
|
I18n.t("groups.membership_request.title", { group_name: "Macdonald" })
|
||||||
{ relative_url: "/t/internationalization-localization/280" }
|
);
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".request-group-membership-form textarea").val(),
|
||||||
find(".modal-header")
|
"Please add me"
|
||||||
.text()
|
);
|
||||||
.trim(),
|
|
||||||
I18n.t("groups.membership_request.title", { group_name: "Macdonald" })
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.equal(
|
await click(".modal-footer .btn-primary");
|
||||||
find(".request-group-membership-form textarea").val(),
|
|
||||||
"Please add me"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".modal-footer .btn-primary");
|
assert.equal(
|
||||||
|
find(".fancy-title")
|
||||||
|
.text()
|
||||||
|
.trim(),
|
||||||
|
"Internationalization / localization"
|
||||||
|
);
|
||||||
|
|
||||||
andThen(() => {
|
await visit("/groups/discourse");
|
||||||
assert.equal(
|
|
||||||
find(".fancy-title")
|
|
||||||
.text()
|
|
||||||
.trim(),
|
|
||||||
"Internationalization / localization"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
visit("/groups/discourse");
|
await click(".group-message-button");
|
||||||
|
|
||||||
click(".group-message-button");
|
assert.ok(count("#reply-control") === 1, "it opens the composer");
|
||||||
|
assert.equal(
|
||||||
andThen(() => {
|
find(".ac-wrap .item").text(),
|
||||||
assert.ok(count("#reply-control") === 1, "it opens the composer");
|
"discourse",
|
||||||
assert.equal(
|
"it prefills the group name"
|
||||||
find(".ac-wrap .item").text(),
|
);
|
||||||
"discourse",
|
|
||||||
"it prefills the group name"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test(
|
QUnit.test(
|
||||||
"Admin viewing group messages when there are no messages",
|
"Admin viewing group messages when there are no messages",
|
||||||
assert => {
|
async assert => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
server.get("/topics/private-messages-group/eviltrout/discourse.json", () => { // eslint-disable-line no-undef
|
server.get("/topics/private-messages-group/eviltrout/discourse.json", () => { // eslint-disable-line no-undef
|
||||||
return response({ topic_list: { topics: [] } });
|
return response({ topic_list: { topics: [] } });
|
||||||
@ -150,23 +140,21 @@ QUnit.test(
|
|||||||
logIn();
|
logIn();
|
||||||
Discourse.reset();
|
Discourse.reset();
|
||||||
|
|
||||||
visit("/groups/discourse");
|
await visit("/groups/discourse");
|
||||||
|
|
||||||
click(".nav-pills li a[title='Messages']");
|
await click(".nav-pills li a[title='Messages']");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".alert")
|
||||||
find(".alert")
|
.text()
|
||||||
.text()
|
.trim(),
|
||||||
.trim(),
|
I18n.t("choose_topic.none_found"),
|
||||||
I18n.t("choose_topic.none_found"),
|
"it should display the right alert"
|
||||||
"it should display the right alert"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
QUnit.test("Admin viewing group messages", assert => {
|
QUnit.test("Admin viewing group messages", async assert => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
server.get("/topics/private-messages-group/eviltrout/discourse.json", () => { // eslint-disable-line no-undef
|
server.get("/topics/private-messages-group/eviltrout/discourse.json", () => { // eslint-disable-line no-undef
|
||||||
return response({
|
return response({
|
||||||
@ -252,41 +240,37 @@ QUnit.test("Admin viewing group messages", assert => {
|
|||||||
logIn();
|
logIn();
|
||||||
Discourse.reset();
|
Discourse.reset();
|
||||||
|
|
||||||
visit("/groups/discourse");
|
await visit("/groups/discourse");
|
||||||
click(".nav-pills li a[title='Messages']");
|
await click(".nav-pills li a[title='Messages']");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".topic-list-item .link-top-line")
|
||||||
find(".topic-list-item .link-top-line")
|
.text()
|
||||||
.text()
|
.trim(),
|
||||||
.trim(),
|
"This is a private message 1",
|
||||||
"This is a private message 1",
|
"it should display the list of group topics"
|
||||||
"it should display the list of group topics"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Admin Viewing Group", assert => {
|
QUnit.test("Admin Viewing Group", async assert => {
|
||||||
logIn();
|
logIn();
|
||||||
Discourse.reset();
|
Discourse.reset();
|
||||||
|
|
||||||
visit("/groups/discourse");
|
await visit("/groups/discourse");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(
|
||||||
assert.ok(
|
find(".nav-pills li a[title='Manage']").length === 1,
|
||||||
find(".nav-pills li a[title='Manage']").length === 1,
|
"it should show manage group tab if user is admin"
|
||||||
"it should show manage group tab if user is admin"
|
);
|
||||||
);
|
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
count(".group-message-button"),
|
count(".group-message-button"),
|
||||||
1,
|
1,
|
||||||
"it displays show group message button"
|
"it displays show group message button"
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".group-info-name").text(),
|
find(".group-info-name").text(),
|
||||||
"Awesome Team",
|
"Awesome Team",
|
||||||
"it should display the group name"
|
"it should display the group name"
|
||||||
);
|
);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -17,21 +17,19 @@ acceptance("Login with email - hide email address taken", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("with hide_email_address_taken enabled", assert => {
|
QUnit.test("with hide_email_address_taken enabled", async assert => {
|
||||||
visit("/");
|
await visit("/");
|
||||||
click("header .login-button");
|
await click("header .login-button");
|
||||||
fillIn("#login-account-name", "someuser@example.com");
|
await fillIn("#login-account-name", "someuser@example.com");
|
||||||
click(".login-with-email-button");
|
await click(".login-with-email-button");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".alert-success")
|
||||||
find(".alert-success")
|
.html()
|
||||||
.html()
|
.trim(),
|
||||||
.trim(),
|
I18n.t("email_login.complete_email_found", {
|
||||||
I18n.t("email_login.complete_email_found", {
|
email: "someuser@example.com"
|
||||||
email: "someuser@example.com"
|
}),
|
||||||
}),
|
"it should display the success message for any email address"
|
||||||
"it should display the success message for any email address"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -4,32 +4,21 @@ acceptance("Login with email - no social logins", {
|
|||||||
settings: {
|
settings: {
|
||||||
enable_local_logins_via_email: true
|
enable_local_logins_via_email: true
|
||||||
},
|
},
|
||||||
beforeEach() {
|
pretend(server, helper) {
|
||||||
const response = object => {
|
server.post("/u/email-login", () => helper.response({ success: "OK" }));
|
||||||
return [200, { "Content-Type": "application/json" }, object];
|
|
||||||
};
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
server.post("/u/email-login", () => { // eslint-disable-line no-undef
|
|
||||||
return response({ success: "OK" });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("with login with email enabled", assert => {
|
QUnit.test("with login with email enabled", async assert => {
|
||||||
visit("/");
|
await visit("/");
|
||||||
click("header .login-button");
|
await click("header .login-button");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(exists(".login-with-email-button"));
|
||||||
assert.ok(exists(".login-with-email-button"));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("with login with email disabled", assert => {
|
QUnit.test("with login with email disabled", async assert => {
|
||||||
visit("/");
|
await visit("/");
|
||||||
click("header .login-button");
|
await click("header .login-button");
|
||||||
|
|
||||||
andThen(() => {
|
assert.notOk(find(".login-buttons").is(":visible"));
|
||||||
assert.notOk(find(".login-buttons").is(":visible"));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -7,96 +7,77 @@ acceptance("Login with email", {
|
|||||||
enable_local_logins_via_email: true,
|
enable_local_logins_via_email: true,
|
||||||
enable_facebook_logins: true
|
enable_facebook_logins: true
|
||||||
},
|
},
|
||||||
beforeEach() {
|
pretend(server, helper) {
|
||||||
const response = object => {
|
server.post("/u/email-login", () =>
|
||||||
return [200, { "Content-Type": "application/json" }, object];
|
helper.response({ success: "OK", user_found: userFound })
|
||||||
};
|
);
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
server.post("/u/email-login", () => { // eslint-disable-line no-undef
|
|
||||||
return response({ success: "OK", user_found: userFound });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("with email button", assert => {
|
QUnit.test("with email button", async assert => {
|
||||||
visit("/");
|
await visit("/");
|
||||||
click("header .login-button");
|
await click("header .login-button");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(
|
||||||
assert.ok(
|
exists(".btn-social.facebook"),
|
||||||
exists(".btn-social.facebook"),
|
"it displays the facebook login button"
|
||||||
"it displays the facebook login button"
|
);
|
||||||
);
|
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
exists(".login-with-email-button"),
|
exists(".login-with-email-button"),
|
||||||
"it displays the login with email button"
|
"it displays the login with email button"
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
fillIn("#login-account-name", "someuser");
|
await fillIn("#login-account-name", "someuser");
|
||||||
click(".login-with-email-button");
|
await click(".login-with-email-button");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".alert-error").html(),
|
||||||
find(".alert-error").html(),
|
I18n.t("email_login.complete_username_not_found", {
|
||||||
I18n.t("email_login.complete_username_not_found", {
|
username: "someuser"
|
||||||
username: "someuser"
|
}),
|
||||||
}),
|
"it should display an error for an invalid username"
|
||||||
"it should display an error for an invalid username"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn("#login-account-name", "someuser@gmail.com");
|
await fillIn("#login-account-name", "someuser@gmail.com");
|
||||||
click(".login-with-email-button");
|
await click(".login-with-email-button");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".alert-error").html(),
|
||||||
find(".alert-error").html(),
|
I18n.t("email_login.complete_email_not_found", {
|
||||||
I18n.t("email_login.complete_email_not_found", {
|
email: "someuser@gmail.com"
|
||||||
email: "someuser@gmail.com"
|
}),
|
||||||
}),
|
"it should display an error for an invalid email"
|
||||||
"it should display an error for an invalid email"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn("#login-account-name", "someuser");
|
await fillIn("#login-account-name", "someuser");
|
||||||
|
|
||||||
andThen(() => {
|
userFound = true;
|
||||||
userFound = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".login-with-email-button");
|
await click(".login-with-email-button");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".alert-success")
|
||||||
find(".alert-success")
|
.html()
|
||||||
.html()
|
.trim(),
|
||||||
.trim(),
|
I18n.t("email_login.complete_username_found", { username: "someuser" }),
|
||||||
I18n.t("email_login.complete_username_found", { username: "someuser" }),
|
"it should display a success message for a valid username"
|
||||||
"it should display a success message for a valid username"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
visit("/");
|
await visit("/");
|
||||||
click("header .login-button");
|
await click("header .login-button");
|
||||||
fillIn("#login-account-name", "someuser@gmail.com");
|
await fillIn("#login-account-name", "someuser@gmail.com");
|
||||||
click(".login-with-email-button");
|
await click(".login-with-email-button");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".alert-success")
|
||||||
find(".alert-success")
|
.html()
|
||||||
.html()
|
.trim(),
|
||||||
.trim(),
|
I18n.t("email_login.complete_email_found", {
|
||||||
I18n.t("email_login.complete_email_found", {
|
email: "someuser@gmail.com"
|
||||||
email: "someuser@gmail.com"
|
}),
|
||||||
}),
|
"it should display a success message for a valid email"
|
||||||
"it should display a success message for a valid email"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
andThen(() => {
|
userFound = false;
|
||||||
userFound = false;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -3,52 +3,47 @@ import PreloadStore from "preload-store";
|
|||||||
import { parsePostData } from "helpers/create-pretender";
|
import { parsePostData } from "helpers/create-pretender";
|
||||||
|
|
||||||
acceptance("Password Reset", {
|
acceptance("Password Reset", {
|
||||||
beforeEach() {
|
pretend(server, helper) {
|
||||||
const response = object => {
|
server.get("/u/confirm-email-token/myvalidtoken.json", () =>
|
||||||
return [200, { "Content-Type": "application/json" }, object];
|
helper.response(200, { success: "OK" })
|
||||||
};
|
);
|
||||||
|
|
||||||
// prettier-ignore
|
server.get("/u/confirm-email-token/requiretwofactor.json", () =>
|
||||||
server.get("/u/confirm-email-token/myvalidtoken.json", () => { //eslint-disable-line
|
helper.response(200, { success: "OK" })
|
||||||
return response({ success: "OK" });
|
);
|
||||||
});
|
|
||||||
|
|
||||||
// prettier-ignore
|
server.put("/u/password-reset/myvalidtoken.json", request => {
|
||||||
server.put("/u/password-reset/myvalidtoken.json", request => { //eslint-disable-line
|
|
||||||
const body = parsePostData(request.requestBody);
|
const body = parsePostData(request.requestBody);
|
||||||
if (body.password === "jonesyAlienSlayer") {
|
if (body.password === "jonesyAlienSlayer") {
|
||||||
return response({
|
return helper.response(200, {
|
||||||
success: false,
|
success: false,
|
||||||
errors: { password: ["is the name of your cat"] }
|
errors: { password: ["is the name of your cat"] }
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return response({
|
return helper.response(200, {
|
||||||
success: "OK",
|
success: "OK",
|
||||||
message: I18n.t("password_reset.success")
|
message: I18n.t("password_reset.success")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// prettier-ignore
|
server.put("/u/password-reset/requiretwofactor.json", request => {
|
||||||
server.get("/u/confirm-email-token/requiretwofactor.json", () => { //eslint-disable-line
|
|
||||||
return response({ success: "OK" });
|
|
||||||
});
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
server.put("/u/password-reset/requiretwofactor.json", request => { //eslint-disable-line
|
|
||||||
const body = parsePostData(request.requestBody);
|
const body = parsePostData(request.requestBody);
|
||||||
if (
|
if (
|
||||||
body.password === "perf3ctly5ecur3" &&
|
body.password === "perf3ctly5ecur3" &&
|
||||||
body.second_factor_token === "123123"
|
body.second_factor_token === "123123"
|
||||||
) {
|
) {
|
||||||
return response({
|
return helper.response(200, {
|
||||||
success: "OK",
|
success: "OK",
|
||||||
message: I18n.t("password_reset.success")
|
message: I18n.t("password_reset.success")
|
||||||
});
|
});
|
||||||
} else if (body.second_factor_token === "123123") {
|
} else if (body.second_factor_token === "123123") {
|
||||||
return response({ success: false, errors: { password: ["invalid"] } });
|
return helper.response(200, {
|
||||||
|
success: false,
|
||||||
|
errors: { password: ["invalid"] }
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
return response({
|
return helper.response(200, {
|
||||||
success: false,
|
success: false,
|
||||||
message: "invalid token",
|
message: "invalid token",
|
||||||
errors: { user_second_factors: ["invalid token"] }
|
errors: { user_second_factors: ["invalid token"] }
|
||||||
@ -58,88 +53,70 @@ acceptance("Password Reset", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Password Reset Page", assert => {
|
QUnit.test("Password Reset Page", async assert => {
|
||||||
PreloadStore.store("password_reset", { is_developer: false });
|
PreloadStore.store("password_reset", { is_developer: false });
|
||||||
|
|
||||||
visit("/u/password-reset/myvalidtoken");
|
await visit("/u/password-reset/myvalidtoken");
|
||||||
andThen(() => {
|
assert.ok(exists(".password-reset input"), "shows the input");
|
||||||
assert.ok(exists(".password-reset input"), "shows the input");
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn(".password-reset input", "perf3ctly5ecur3");
|
await fillIn(".password-reset input", "perf3ctly5ecur3");
|
||||||
andThen(() => {
|
assert.ok(exists(".password-reset .tip.good"), "input looks good");
|
||||||
assert.ok(exists(".password-reset .tip.good"), "input looks good");
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn(".password-reset input", "123");
|
await fillIn(".password-reset input", "123");
|
||||||
andThen(() => {
|
assert.ok(exists(".password-reset .tip.bad"), "input is not valid");
|
||||||
assert.ok(exists(".password-reset .tip.bad"), "input is not valid");
|
assert.ok(
|
||||||
assert.ok(
|
find(".password-reset .tip.bad")
|
||||||
find(".password-reset .tip.bad")
|
.html()
|
||||||
.html()
|
.indexOf(I18n.t("user.password.too_short")) > -1,
|
||||||
.indexOf(I18n.t("user.password.too_short")) > -1,
|
"password too short"
|
||||||
"password too short"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn(".password-reset input", "jonesyAlienSlayer");
|
await fillIn(".password-reset input", "jonesyAlienSlayer");
|
||||||
click(".password-reset form button");
|
await click(".password-reset form button");
|
||||||
andThen(() => {
|
assert.ok(exists(".password-reset .tip.bad"), "input is not valid");
|
||||||
assert.ok(exists(".password-reset .tip.bad"), "input is not valid");
|
assert.ok(
|
||||||
assert.ok(
|
find(".password-reset .tip.bad")
|
||||||
find(".password-reset .tip.bad")
|
.html()
|
||||||
.html()
|
.indexOf("is the name of your cat") > -1,
|
||||||
.indexOf("is the name of your cat") > -1,
|
"server validation error message shows"
|
||||||
"server validation error message shows"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn(".password-reset input", "perf3ctly5ecur3");
|
await fillIn(".password-reset input", "perf3ctly5ecur3");
|
||||||
click(".password-reset form button");
|
await click(".password-reset form button");
|
||||||
andThen(() => {
|
assert.ok(!exists(".password-reset form"), "form is gone");
|
||||||
assert.ok(!exists(".password-reset form"), "form is gone");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Password Reset Page With Second Factor", assert => {
|
QUnit.test("Password Reset Page With Second Factor", async assert => {
|
||||||
PreloadStore.store("password_reset", {
|
PreloadStore.store("password_reset", {
|
||||||
is_developer: false,
|
is_developer: false,
|
||||||
second_factor_required: true
|
second_factor_required: true
|
||||||
});
|
});
|
||||||
|
|
||||||
visit("/u/password-reset/requiretwofactor");
|
await visit("/u/password-reset/requiretwofactor");
|
||||||
|
|
||||||
andThen(() => {
|
assert.notOk(exists("#new-account-password"), "does not show the input");
|
||||||
assert.notOk(exists("#new-account-password"), "does not show the input");
|
assert.ok(exists("#second-factor"), "shows the second factor prompt");
|
||||||
assert.ok(exists("#second-factor"), "shows the second factor prompt");
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn("input#second-factor", "0000");
|
await fillIn("input#second-factor", "0000");
|
||||||
click(".password-reset form button");
|
await click(".password-reset form button");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(exists(".alert-error"), "shows 2 factor error");
|
||||||
assert.ok(exists(".alert-error"), "shows 2 factor error");
|
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
find(".alert-error")
|
find(".alert-error")
|
||||||
.html()
|
.html()
|
||||||
.indexOf("invalid token") > -1,
|
.indexOf("invalid token") > -1,
|
||||||
"shows server validation error message"
|
"shows server validation error message"
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
fillIn("input#second-factor", "123123");
|
await fillIn("input#second-factor", "123123");
|
||||||
click(".password-reset form button");
|
await click(".password-reset form button");
|
||||||
|
|
||||||
andThen(() => {
|
assert.notOk(exists(".alert-error"), "hides error");
|
||||||
assert.notOk(exists(".alert-error"), "hides error");
|
assert.ok(exists("#new-account-password"), "shows the input");
|
||||||
assert.ok(exists("#new-account-password"), "shows the input");
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn(".password-reset input", "perf3ctly5ecur3");
|
await fillIn(".password-reset input", "perf3ctly5ecur3");
|
||||||
click(".password-reset form button");
|
await click(".password-reset form button");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(!exists(".password-reset form"), "form is gone");
|
||||||
assert.ok(!exists(".password-reset form"), "form is gone");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -166,13 +166,11 @@ QUnit.test("second factor backup", async assert => {
|
|||||||
assert.ok(exists(".backup-codes-area"), "shows backup codes");
|
assert.ok(exists(".backup-codes-area"), "shows backup codes");
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("default avatar selector", assert => {
|
QUnit.test("default avatar selector", async assert => {
|
||||||
visit("/u/eviltrout/preferences");
|
await visit("/u/eviltrout/preferences");
|
||||||
|
|
||||||
click(".pref-avatar .btn");
|
await click(".pref-avatar .btn");
|
||||||
andThen(() => {
|
assert.ok(exists(".avatar-choice", "opens the avatar selection modal"));
|
||||||
assert.ok(exists(".avatar-choice", "opens the avatar selection modal"));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
acceptance("Avatar selector when selectable avatars is enabled", {
|
acceptance("Avatar selector when selectable avatars is enabled", {
|
||||||
@ -202,15 +200,13 @@ acceptance("User Preferences when badges are disabled", {
|
|||||||
settings: { enable_badges: false }
|
settings: { enable_badges: false }
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("visit my preferences", assert => {
|
QUnit.test("visit my preferences", async assert => {
|
||||||
visit("/u/eviltrout/preferences");
|
await visit("/u/eviltrout/preferences");
|
||||||
andThen(() => {
|
assert.ok($("body.user-preferences-page").length, "has the body class");
|
||||||
assert.ok($("body.user-preferences-page").length, "has the body class");
|
assert.equal(
|
||||||
assert.equal(
|
currentURL(),
|
||||||
currentURL(),
|
"/u/eviltrout/preferences/account",
|
||||||
"/u/eviltrout/preferences/account",
|
"defaults to account tab"
|
||||||
"defaults to account tab"
|
);
|
||||||
);
|
assert.ok(exists(".user-preferences"), "it shows the preferences");
|
||||||
assert.ok(exists(".user-preferences"), "it shows the preferences");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -2,99 +2,93 @@ import { acceptance } from "helpers/qunit-helpers";
|
|||||||
|
|
||||||
acceptance("Queued Posts", {
|
acceptance("Queued Posts", {
|
||||||
loggedIn: true,
|
loggedIn: true,
|
||||||
settings: { tagging_enabled: true }
|
settings: { tagging_enabled: true },
|
||||||
|
pretend(server, helper) {
|
||||||
|
server.get("/queued_posts", () => {
|
||||||
|
return helper.response({
|
||||||
|
users: [
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
username: "test_user",
|
||||||
|
avatar_template:
|
||||||
|
"/letter_avatar_proxy/v2/letter/t/eada6e/{size}.png",
|
||||||
|
active: true,
|
||||||
|
admin: false,
|
||||||
|
moderator: false,
|
||||||
|
last_seen_at: "2017-08-11T20:48:05.405Z",
|
||||||
|
last_emailed_at: null,
|
||||||
|
created_at: "2017-08-07T02:23:33.309Z",
|
||||||
|
last_seen_age: "1d",
|
||||||
|
last_emailed_age: null,
|
||||||
|
created_at_age: "6d",
|
||||||
|
username_lower: "test_user",
|
||||||
|
trust_level: 0,
|
||||||
|
trust_level_locked: false,
|
||||||
|
flag_level: 0,
|
||||||
|
title: null,
|
||||||
|
suspended_at: null,
|
||||||
|
suspended_till: null,
|
||||||
|
suspended: null,
|
||||||
|
silenced: false,
|
||||||
|
time_read: "19m",
|
||||||
|
staged: false,
|
||||||
|
days_visited: 4,
|
||||||
|
posts_read_count: 12,
|
||||||
|
topics_entered: 6,
|
||||||
|
post_count: 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
queued_posts: [
|
||||||
|
{
|
||||||
|
id: 22,
|
||||||
|
queue: "default",
|
||||||
|
user_id: 3,
|
||||||
|
state: 1,
|
||||||
|
topic_id: null,
|
||||||
|
approved_by_id: null,
|
||||||
|
rejected_by_id: null,
|
||||||
|
raw: "some content",
|
||||||
|
post_options: {
|
||||||
|
archetype: "regular",
|
||||||
|
category: "1",
|
||||||
|
typing_duration_msecs: "3200",
|
||||||
|
composer_open_duration_msecs: "19007",
|
||||||
|
visible: true,
|
||||||
|
is_warning: false,
|
||||||
|
title: "a new topic that needs to be reviewed",
|
||||||
|
ip_address: "172.17.0.1",
|
||||||
|
first_post_checks: true,
|
||||||
|
is_poll: true
|
||||||
|
},
|
||||||
|
created_at: "2017-08-11T20:43:41.115Z",
|
||||||
|
category_id: 1,
|
||||||
|
can_delete_user: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
__rest_serializer: "1",
|
||||||
|
refresh_queued_posts: "/queued_posts?status=new"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test(
|
QUnit.test(
|
||||||
"For topics: body of post, title, category and tags are all editbale",
|
"For topics: body of post, title, category and tags are all editable",
|
||||||
assert => {
|
async assert => {
|
||||||
// prettier-ignore
|
await visit("/queued-posts");
|
||||||
server.get("/queued_posts", () => { //eslint-disable-line no-undef
|
await click(".queued-posts .queued-post button.edit");
|
||||||
return [
|
|
||||||
200,
|
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
{
|
|
||||||
users: [
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
username: "test_user",
|
|
||||||
avatar_template:
|
|
||||||
"/letter_avatar_proxy/v2/letter/t/eada6e/{size}.png",
|
|
||||||
active: true,
|
|
||||||
admin: false,
|
|
||||||
moderator: false,
|
|
||||||
last_seen_at: "2017-08-11T20:48:05.405Z",
|
|
||||||
last_emailed_at: null,
|
|
||||||
created_at: "2017-08-07T02:23:33.309Z",
|
|
||||||
last_seen_age: "1d",
|
|
||||||
last_emailed_age: null,
|
|
||||||
created_at_age: "6d",
|
|
||||||
username_lower: "test_user",
|
|
||||||
trust_level: 0,
|
|
||||||
trust_level_locked: false,
|
|
||||||
flag_level: 0,
|
|
||||||
title: null,
|
|
||||||
suspended_at: null,
|
|
||||||
suspended_till: null,
|
|
||||||
suspended: null,
|
|
||||||
silenced: false,
|
|
||||||
time_read: "19m",
|
|
||||||
staged: false,
|
|
||||||
days_visited: 4,
|
|
||||||
posts_read_count: 12,
|
|
||||||
topics_entered: 6,
|
|
||||||
post_count: 2
|
|
||||||
}
|
|
||||||
],
|
|
||||||
queued_posts: [
|
|
||||||
{
|
|
||||||
id: 22,
|
|
||||||
queue: "default",
|
|
||||||
user_id: 3,
|
|
||||||
state: 1,
|
|
||||||
topic_id: null,
|
|
||||||
approved_by_id: null,
|
|
||||||
rejected_by_id: null,
|
|
||||||
raw: "some content",
|
|
||||||
post_options: {
|
|
||||||
archetype: "regular",
|
|
||||||
category: "1",
|
|
||||||
typing_duration_msecs: "3200",
|
|
||||||
composer_open_duration_msecs: "19007",
|
|
||||||
visible: true,
|
|
||||||
is_warning: false,
|
|
||||||
title: "a new topic that needs to be reviewed",
|
|
||||||
ip_address: "172.17.0.1",
|
|
||||||
first_post_checks: true,
|
|
||||||
is_poll: true
|
|
||||||
},
|
|
||||||
created_at: "2017-08-11T20:43:41.115Z",
|
|
||||||
category_id: 1,
|
|
||||||
can_delete_user: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
__rest_serializer: "1",
|
|
||||||
refresh_queued_posts: "/queued_posts?status=new"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
visit("/queued-posts");
|
assert.ok(exists(".d-editor-container"), "the body should be editable");
|
||||||
click(".queued-posts .queued-post button.edit");
|
assert.ok(
|
||||||
|
exists(".edit-title .ember-text-field"),
|
||||||
andThen(() => {
|
"the title should be editable"
|
||||||
assert.ok(exists(".d-editor-container"), "the body should be editable");
|
);
|
||||||
assert.ok(
|
assert.ok(exists(".category-chooser"), "category should be editable");
|
||||||
exists(".edit-title .ember-text-field"),
|
assert.ok(exists(".tag-chooser"), "tags should be editable");
|
||||||
"the title should be editable"
|
|
||||||
);
|
|
||||||
assert.ok(exists(".category-chooser"), "category should be editbale");
|
|
||||||
assert.ok(exists(".tag-chooser"), "tags should be editable");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
QUnit.test("For replies: only the body of post is editbale", assert => {
|
QUnit.test("For replies: only the body of post is editable", async assert => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
server.get("/queued_posts", () => { //eslint-disable-line no-undef
|
server.get("/queued_posts", () => { //eslint-disable-line no-undef
|
||||||
return [
|
return [
|
||||||
@ -176,19 +170,14 @@ QUnit.test("For replies: only the body of post is editbale", assert => {
|
|||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
visit("/queued-posts");
|
await visit("/queued-posts");
|
||||||
click(".queued-posts .queued-post button.edit");
|
await click(".queued-posts .queued-post button.edit");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(exists(".d-editor-container"), "the body should be editable");
|
||||||
assert.ok(exists(".d-editor-container"), "the body should be editable");
|
assert.notOk(
|
||||||
assert.notOk(
|
exists(".edit-title .ember-text-field"),
|
||||||
exists(".edit-title .ember-text-field"),
|
"title should not be editbale"
|
||||||
"title should not be editbale"
|
);
|
||||||
);
|
assert.notOk(exists(".category-chooser"), "category should not be editable");
|
||||||
assert.notOk(
|
assert.notOk(exists("div.tag-chooser"), "tags should not be editable");
|
||||||
exists(".category-chooser"),
|
|
||||||
"category should not be editable"
|
|
||||||
);
|
|
||||||
assert.notOk(exists("div.tag-chooser"), "tags should not be editable");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -2,19 +2,13 @@ import { acceptance, waitFor } from "helpers/qunit-helpers";
|
|||||||
acceptance("Search - Full Page", {
|
acceptance("Search - Full Page", {
|
||||||
settings: { tagging_enabled: true },
|
settings: { tagging_enabled: true },
|
||||||
loggedIn: true,
|
loggedIn: true,
|
||||||
beforeEach() {
|
pretend(server, helper) {
|
||||||
const response = object => {
|
server.get("/tags/filter/search", () => {
|
||||||
return [200, { "Content-Type": "application/json" }, object];
|
return helper.response({ results: [{ text: "monkey", count: 1 }] });
|
||||||
};
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
server.get("/tags/filter/search", () => { //eslint-disable-line
|
|
||||||
return response({ results: [{ text: "monkey", count: 1 }] });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// prettier-ignore
|
server.get("/u/search/users", () => {
|
||||||
server.get("/u/search/users", () => { //eslint-disable-line
|
return helper.response({
|
||||||
return response({
|
|
||||||
users: [
|
users: [
|
||||||
{
|
{
|
||||||
username: "admin",
|
username: "admin",
|
||||||
@ -25,36 +19,32 @@ acceptance("Search - Full Page", {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// prettier-ignore
|
server.get("/admin/groups.json", () => {
|
||||||
server.get("/admin/groups.json", () => { //eslint-disable-line
|
return helper.response({
|
||||||
return response([
|
id: 2,
|
||||||
{
|
automatic: true,
|
||||||
id: 2,
|
name: "moderators",
|
||||||
automatic: true,
|
user_count: 4,
|
||||||
name: "moderators",
|
alias_level: 0,
|
||||||
user_count: 4,
|
visible: true,
|
||||||
alias_level: 0,
|
automatic_membership_email_domains: null,
|
||||||
visible: true,
|
automatic_membership_retroactive: false,
|
||||||
automatic_membership_email_domains: null,
|
primary_group: false,
|
||||||
automatic_membership_retroactive: false,
|
title: null,
|
||||||
primary_group: false,
|
grant_trust_level: null,
|
||||||
title: null,
|
incoming_email: null,
|
||||||
grant_trust_level: null,
|
notification_level: null,
|
||||||
incoming_email: null,
|
has_messages: true,
|
||||||
notification_level: null,
|
is_member: true,
|
||||||
has_messages: true,
|
mentionable: false,
|
||||||
is_member: true,
|
flair_url: null,
|
||||||
mentionable: false,
|
flair_bg_color: null,
|
||||||
flair_url: null,
|
flair_color: null
|
||||||
flair_bg_color: null,
|
});
|
||||||
flair_color: null
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// prettier-ignore
|
server.get("/badges.json", () => {
|
||||||
server.get("/badges.json", () => { //eslint-disable-line
|
return helper.response({
|
||||||
return response({
|
|
||||||
badge_types: [{ id: 3, name: "Bronze", sort_order: 7 }],
|
badge_types: [{ id: 3, name: "Bronze", sort_order: 7 }],
|
||||||
badge_groupings: [
|
badge_groupings: [
|
||||||
{
|
{
|
||||||
@ -92,105 +82,93 @@ acceptance("Search - Full Page", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("perform various searches", assert => {
|
QUnit.test("perform various searches", async assert => {
|
||||||
visit("/search");
|
await visit("/search");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok($("body.search-page").length, "has body class");
|
||||||
assert.ok($("body.search-page").length, "has body class");
|
assert.ok(exists(".search-container"), "has container class");
|
||||||
assert.ok(exists(".search-container"), "has container class");
|
assert.ok(find(".search-query").length > 0);
|
||||||
assert.ok(find(".search-query").length > 0);
|
assert.ok(find(".fps-topic").length === 0);
|
||||||
assert.ok(find(".fps-topic").length === 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn(".search-query", "none");
|
await fillIn(".search-query", "none");
|
||||||
click(".search-cta");
|
await click(".search-cta");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(find(".fps-topic").length === 0, "has no results");
|
||||||
assert.ok(find(".fps-topic").length === 0, "has no results");
|
assert.ok(find(".no-results-suggestion .google-search-form"));
|
||||||
assert.ok(find(".no-results-suggestion .google-search-form"));
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn(".search-query", "posts");
|
await fillIn(".search-query", "posts");
|
||||||
click(".search-cta");
|
await click(".search-cta");
|
||||||
|
|
||||||
andThen(() => assert.ok(find(".fps-topic").length === 1, "has one post"));
|
assert.ok(find(".fps-topic").length === 1, "has one post");
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("escape search term", assert => {
|
QUnit.test("escape search term", async assert => {
|
||||||
visit("/search");
|
await visit("/search");
|
||||||
fillIn(".search-query", "@<script>prompt(1337)</script>gmail.com");
|
await fillIn(".search-query", "@<script>prompt(1337)</script>gmail.com");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(
|
||||||
|
exists(
|
||||||
|
'.search-advanced-options span:contains("<script>prompt(1337)</script>gmail.com")'
|
||||||
|
),
|
||||||
|
"it escapes search term"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.test("update username through advanced search ui", async assert => {
|
||||||
|
await visit("/search");
|
||||||
|
await fillIn(".search-query", "none");
|
||||||
|
await fillIn(".search-advanced-options .user-selector", "admin");
|
||||||
|
await click(".search-advanced-options .user-selector");
|
||||||
|
await keyEvent(".search-advanced-options .user-selector", "keydown", 8);
|
||||||
|
|
||||||
|
waitFor(assert, async () => {
|
||||||
|
assert.ok(
|
||||||
|
visible(".search-advanced-options .autocomplete"),
|
||||||
|
'"autocomplete" popup is visible'
|
||||||
|
);
|
||||||
assert.ok(
|
assert.ok(
|
||||||
exists(
|
exists(
|
||||||
'.search-advanced-options span:contains("<script>prompt(1337)</script>gmail.com")'
|
'.search-advanced-options .autocomplete ul li a span.username:contains("admin")'
|
||||||
),
|
),
|
||||||
"it escapes search term"
|
'"autocomplete" popup has an entry for "admin"'
|
||||||
|
);
|
||||||
|
|
||||||
|
await click(".search-advanced-options .autocomplete ul li a:first");
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
exists('.search-advanced-options span:contains("admin")'),
|
||||||
|
'has "admin" pre-populated'
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
find(".search-query").val(),
|
||||||
|
"none @admin",
|
||||||
|
'has updated search term to "none user:admin"'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("update username through advanced search ui", assert => {
|
QUnit.test("update category through advanced search ui", async assert => {
|
||||||
visit("/search");
|
|
||||||
fillIn(".search-query", "none");
|
|
||||||
fillIn(".search-advanced-options .user-selector", "admin");
|
|
||||||
click(".search-advanced-options .user-selector");
|
|
||||||
keyEvent(".search-advanced-options .user-selector", "keydown", 8);
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
waitFor(assert, () => {
|
|
||||||
assert.ok(
|
|
||||||
visible(".search-advanced-options .autocomplete"),
|
|
||||||
'"autocomplete" popup is visible'
|
|
||||||
);
|
|
||||||
assert.ok(
|
|
||||||
exists(
|
|
||||||
'.search-advanced-options .autocomplete ul li a span.username:contains("admin")'
|
|
||||||
),
|
|
||||||
'"autocomplete" popup has an entry for "admin"'
|
|
||||||
);
|
|
||||||
|
|
||||||
click(".search-advanced-options .autocomplete ul li a:first");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.ok(
|
|
||||||
exists('.search-advanced-options span:contains("admin")'),
|
|
||||||
'has "admin" pre-populated'
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
find(".search-query").val(),
|
|
||||||
"none @admin",
|
|
||||||
'has updated search term to "none user:admin"'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test("update category through advanced search ui", assert => {
|
|
||||||
const categoryChooser = selectKit(
|
const categoryChooser = selectKit(
|
||||||
".search-advanced-options .category-chooser"
|
".search-advanced-options .category-chooser"
|
||||||
);
|
);
|
||||||
|
|
||||||
visit("/search");
|
await visit("/search");
|
||||||
|
|
||||||
fillIn(".search-query", "none");
|
await fillIn(".search-query", "none");
|
||||||
categoryChooser
|
|
||||||
.expand()
|
|
||||||
.fillInFilter("faq")
|
|
||||||
.selectRowByValue(4);
|
|
||||||
|
|
||||||
andThen(() => {
|
await categoryChooser.expandAwait();
|
||||||
assert.ok(
|
await categoryChooser.fillInFilter("faq");
|
||||||
exists('.search-advanced-options .badge-category:contains("faq")'),
|
await categoryChooser.selectRowByValueAwait(4);
|
||||||
'has "faq" populated'
|
|
||||||
);
|
assert.ok(
|
||||||
assert.equal(
|
exists('.search-advanced-options .badge-category:contains("faq")'),
|
||||||
find(".search-query").val(),
|
'has "faq" populated'
|
||||||
"none #faq",
|
);
|
||||||
'has updated search term to "none #faq"'
|
assert.equal(
|
||||||
);
|
find(".search-query").val(),
|
||||||
});
|
"none #faq",
|
||||||
|
'has updated search term to "none #faq"'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// test("update group through advanced search ui", assert => {
|
// test("update group through advanced search ui", assert => {
|
||||||
@ -297,12 +275,13 @@ QUnit.test(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
QUnit.test("update in:private filter through advanced search ui", assert => {
|
QUnit.test(
|
||||||
visit("/search");
|
"update in:private filter through advanced search ui",
|
||||||
fillIn(".search-query", "none");
|
async assert => {
|
||||||
click(".search-advanced-options .in-private");
|
await visit("/search");
|
||||||
|
await fillIn(".search-query", "none");
|
||||||
|
await click(".search-advanced-options .in-private");
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
exists(".search-advanced-options .in-private:checked"),
|
exists(".search-advanced-options .in-private:checked"),
|
||||||
'has "are in my messages" populated'
|
'has "are in my messages" populated'
|
||||||
@ -312,128 +291,119 @@ QUnit.test("update in:private filter through advanced search ui", assert => {
|
|||||||
"none in:private",
|
"none in:private",
|
||||||
'has updated search term to "none in:private"'
|
'has updated search term to "none in:private"'
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
QUnit.test("update in:seen filter through advanced search ui", async 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.equal(
|
||||||
|
find(".search-query").val(),
|
||||||
|
"none in:seen",
|
||||||
|
"it should update the search term"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("update in:seen filter through advanced search ui", assert => {
|
QUnit.test("update in filter through advanced search ui", async assert => {
|
||||||
visit("/search");
|
|
||||||
fillIn(".search-query", "none");
|
|
||||||
click(".search-advanced-options .in-seen");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.ok(
|
|
||||||
exists(".search-advanced-options .in-seen:checked"),
|
|
||||||
"it should check the right checkbox"
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.equal(
|
|
||||||
find(".search-query").val(),
|
|
||||||
"none in:seen",
|
|
||||||
"it should update the search term"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test("update in filter through advanced search ui", assert => {
|
|
||||||
const inSelector = selectKit(".search-advanced-options .select-kit#in");
|
const inSelector = selectKit(".search-advanced-options .select-kit#in");
|
||||||
|
|
||||||
visit("/search");
|
await visit("/search");
|
||||||
|
|
||||||
fillIn(".search-query", "none");
|
await fillIn(".search-query", "none");
|
||||||
inSelector.expand().selectRowByValue("bookmarks");
|
await inSelector.expandAwait();
|
||||||
|
await inSelector.selectRowByValueAwait("bookmarks");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(
|
||||||
assert.ok(
|
inSelector.rowByName("I bookmarked").exists(),
|
||||||
inSelector.rowByName("I bookmarked").exists(),
|
'has "I bookmarked" populated'
|
||||||
'has "I bookmarked" populated'
|
);
|
||||||
);
|
assert.equal(
|
||||||
assert.equal(
|
find(".search-query").val(),
|
||||||
find(".search-query").val(),
|
"none in:bookmarks",
|
||||||
"none in:bookmarks",
|
'has updated search term to "none in:bookmarks"'
|
||||||
'has updated search term to "none in:bookmarks"'
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("update status through advanced search ui", assert => {
|
QUnit.test("update status through advanced search ui", async assert => {
|
||||||
const statusSelector = selectKit(
|
const statusSelector = selectKit(
|
||||||
".search-advanced-options .select-kit#status"
|
".search-advanced-options .select-kit#status"
|
||||||
);
|
);
|
||||||
|
|
||||||
visit("/search");
|
await visit("/search");
|
||||||
|
|
||||||
fillIn(".search-query", "none");
|
await fillIn(".search-query", "none");
|
||||||
statusSelector.expand().selectRowByValue("closed");
|
await statusSelector.expandAwait();
|
||||||
|
await statusSelector.selectRowByValueAwait("closed");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(
|
||||||
assert.ok(
|
statusSelector.rowByName("are closed").exists(),
|
||||||
statusSelector.rowByName("are closed").exists(),
|
'has "are closed" populated'
|
||||||
'has "are closed" populated'
|
);
|
||||||
);
|
assert.equal(
|
||||||
assert.equal(
|
find(".search-query").val(),
|
||||||
find(".search-query").val(),
|
"none status:closed",
|
||||||
"none status:closed",
|
'has updated search term to "none status:closed"'
|
||||||
'has updated search term to "none status:closed"'
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("update post time through advanced search ui", assert => {
|
QUnit.test("update post time through advanced search ui", async assert => {
|
||||||
const postTimeSelector = selectKit(
|
const postTimeSelector = selectKit(
|
||||||
".search-advanced-options .select-kit#postTime"
|
".search-advanced-options .select-kit#postTime"
|
||||||
);
|
);
|
||||||
|
|
||||||
visit("/search");
|
await visit("/search");
|
||||||
|
|
||||||
fillIn(".search-query", "none");
|
await fillIn(".search-query", "none");
|
||||||
fillIn("#search-post-date .date-picker", "2016-10-05");
|
await fillIn("#search-post-date .date-picker", "2016-10-05");
|
||||||
postTimeSelector.expand().selectRowByValue("after");
|
await postTimeSelector.expandAwait();
|
||||||
|
await postTimeSelector.selectRowByValueAwait("after");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(
|
||||||
assert.ok(
|
postTimeSelector.rowByName("after").exists(),
|
||||||
postTimeSelector.rowByName("after").exists(),
|
'has "after" populated'
|
||||||
'has "after" populated'
|
);
|
||||||
);
|
assert.equal(
|
||||||
assert.equal(
|
find(".search-query").val(),
|
||||||
find(".search-query").val(),
|
"none after:2016-10-05",
|
||||||
"none after:2016-10-05",
|
'has updated search term to "none after:2016-10-05"'
|
||||||
'has updated search term to "none after:2016-10-05"'
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("update min post count through advanced search ui", assert => {
|
QUnit.test("update min post count through advanced search ui", async assert => {
|
||||||
visit("/search");
|
await visit("/search");
|
||||||
fillIn(".search-query", "none");
|
await fillIn(".search-query", "none");
|
||||||
fillIn("#search-min-post-count", "5");
|
await fillIn("#search-min-post-count", "5");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".search-advanced-options #search-min-post-count").val(),
|
||||||
find(".search-advanced-options #search-min-post-count").val(),
|
"5",
|
||||||
"5",
|
'has "5" populated'
|
||||||
'has "5" populated'
|
);
|
||||||
);
|
assert.equal(
|
||||||
assert.equal(
|
find(".search-query").val(),
|
||||||
find(".search-query").val(),
|
"none min_post_count:5",
|
||||||
"none min_post_count:5",
|
'has updated search term to "none min_post_count:5"'
|
||||||
'has updated search term to "none min_post_count:5"'
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("validate advanced search when initially empty", assert => {
|
QUnit.test("validate advanced search when initially empty", async assert => {
|
||||||
visit("/search?expanded=true");
|
await visit("/search?expanded=true");
|
||||||
click(".search-advanced-options .in-likes");
|
await click(".search-advanced-options .in-likes");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(
|
||||||
assert.ok(
|
exists(".search-advanced-options .in-likes:checked"),
|
||||||
exists(".search-advanced-options .in-likes:checked"),
|
'has "I liked" populated'
|
||||||
'has "I liked" populated'
|
);
|
||||||
);
|
assert.equal(
|
||||||
assert.equal(
|
find(".search-query").val(),
|
||||||
find(".search-query").val(),
|
"in:likes",
|
||||||
"in:likes",
|
'has updated search term to "in:likes"'
|
||||||
'has updated search term to "in:likes"'
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -3,50 +3,37 @@ import { acceptance } from "helpers/qunit-helpers";
|
|||||||
acceptance("Tag Hashtag", {
|
acceptance("Tag Hashtag", {
|
||||||
loggedIn: true,
|
loggedIn: true,
|
||||||
settings: { tagging_enabled: true },
|
settings: { tagging_enabled: true },
|
||||||
beforeEach() {
|
pretend(server, helper) {
|
||||||
const response = object => {
|
server.get("/tags/filter/search", () => {
|
||||||
return [200, { "Content-Type": "application/json" }, object];
|
return helper.response({ results: [{ text: "monkey", count: 1 }] });
|
||||||
};
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
server.get("/tags/filter/search", () => { //eslint-disable-line
|
|
||||||
return response({ results: [{ text: "monkey", count: 1 }] });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// prettier-ignore
|
server.get("/tags/check", () => {
|
||||||
server.get("/category_hashtags/check", () => { //eslint-disable-line
|
return helper.response({
|
||||||
return response({ valid: [] });
|
valid: [{ value: "monkey", url: "/tags/monkey" }]
|
||||||
});
|
});
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
server.get("/tags/check", () => { //eslint-disable-line
|
|
||||||
return response({ valid: [{ value: "monkey", url: "/tags/monkey" }] });
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("tag is cooked properly", assert => {
|
QUnit.test("tag is cooked properly", async assert => {
|
||||||
visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
click("#topic-footer-buttons .btn.create");
|
await click("#topic-footer-buttons .btn.create");
|
||||||
|
|
||||||
fillIn(".d-editor-input", "this is a tag hashtag #monkey::tag");
|
await fillIn(".d-editor-input", "this is a tag hashtag #monkey::tag");
|
||||||
andThen(() => {
|
// TODO: Test that the autocomplete shows
|
||||||
// TODO: Test that the autocomplete shows
|
assert.equal(
|
||||||
assert.equal(
|
find(".d-editor-preview:visible")
|
||||||
find(".d-editor-preview:visible")
|
.html()
|
||||||
.html()
|
.trim(),
|
||||||
.trim(),
|
'<p>this is a tag hashtag <a href="/tags/monkey" class="hashtag">#<span>monkey</span></a></p>'
|
||||||
'<p>this is a tag hashtag <a href="/tags/monkey" class="hashtag">#<span>monkey</span></a></p>'
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
click("#reply-control .btn.create");
|
await click("#reply-control .btn.create");
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".topic-post:last .cooked")
|
||||||
find(".topic-post:last .cooked")
|
.html()
|
||||||
.html()
|
.trim(),
|
||||||
.trim(),
|
'<p>this is a tag hashtag <a href="/tags/monkey" class="hashtag">#<span>monkey</span></a></p>'
|
||||||
'<p>this is a tag hashtag <a href="/tags/monkey" class="hashtag">#<span>monkey</span></a></p>'
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
import { acceptance } from "helpers/qunit-helpers";
|
import { acceptance } from "helpers/qunit-helpers";
|
||||||
acceptance("Tags", { loggedIn: true });
|
acceptance("Tags", { loggedIn: true });
|
||||||
|
|
||||||
QUnit.test("list the tags", assert => {
|
QUnit.test("list the tags", async assert => {
|
||||||
visit("/tags");
|
await visit("/tags");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok($("body.tags-page").length, "has the body class");
|
||||||
assert.ok($("body.tags-page").length, "has the body class");
|
assert.ok(exists(".tag-eviltrout"), "shows the evil trout tag");
|
||||||
assert.ok(exists(".tag-eviltrout"), "shows the evil trout tag");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
acceptance("Tags listed by group", {
|
acceptance("Tags listed by group", {
|
||||||
@ -17,7 +15,7 @@ acceptance("Tags listed by group", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("list the tags in groups", assert => {
|
QUnit.test("list the tags in groups", async assert => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
server.get("/tags", () => { // eslint-disable-line no-undef
|
server.get("/tags", () => { // eslint-disable-line no-undef
|
||||||
return [
|
return [
|
||||||
@ -57,30 +55,28 @@ QUnit.test("list the tags in groups", assert => {
|
|||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
visit("/tags");
|
await visit("/tags");
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
$(".tag-list").length,
|
||||||
$(".tag-list").length,
|
4,
|
||||||
4,
|
"shows separate lists for the 3 groups and the ungrouped tags"
|
||||||
"shows separate lists for the 3 groups and the ungrouped tags"
|
);
|
||||||
);
|
assert.ok(
|
||||||
assert.ok(
|
_.isEqual(
|
||||||
_.isEqual(
|
_.map($(".tag-list h3"), i => {
|
||||||
_.map($(".tag-list h3"), i => {
|
return $(i).text();
|
||||||
return $(i).text();
|
}),
|
||||||
}),
|
["Ford Cars", "Honda Cars", "Makes", "Other Tags"]
|
||||||
["Ford Cars", "Honda Cars", "Makes", "Other Tags"]
|
),
|
||||||
),
|
"shown in given order and with tags that are not in a group"
|
||||||
"shown in given order and with tags that are not in a group"
|
);
|
||||||
);
|
assert.ok(
|
||||||
assert.ok(
|
_.isEqual(
|
||||||
_.isEqual(
|
_.map($(".tag-list:first .discourse-tag"), i => {
|
||||||
_.map($(".tag-list:first .discourse-tag"), i => {
|
return $(i).text();
|
||||||
return $(i).text();
|
}),
|
||||||
}),
|
["focus", "escort"]
|
||||||
["focus", "escort"]
|
),
|
||||||
),
|
"shows the tags in default sort (by count)"
|
||||||
"shows the tags in default sort (by count)"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -1,271 +1,9 @@
|
|||||||
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
||||||
acceptance("Topic - Edit timer", { loggedIn: true });
|
acceptance("Topic - Edit timer", {
|
||||||
|
loggedIn: true,
|
||||||
const response = object => [
|
pretend(server, helper) {
|
||||||
200,
|
server.post("/t/280/timer", () =>
|
||||||
{ "Content-Type": "application/json" },
|
helper.response({
|
||||||
object
|
|
||||||
];
|
|
||||||
|
|
||||||
QUnit.test("default", assert => {
|
|
||||||
const timerType = selectKit(".select-kit.timer-type");
|
|
||||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
||||||
|
|
||||||
visit("/t/internationalization-localization");
|
|
||||||
click(".toggle-admin-menu");
|
|
||||||
click(".topic-admin-status-update button");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(
|
|
||||||
futureDateInputSelector.header().title(),
|
|
||||||
"Select a timeframe"
|
|
||||||
);
|
|
||||||
assert.equal(futureDateInputSelector.header().value(), null);
|
|
||||||
});
|
|
||||||
|
|
||||||
click("#private-topic-timer");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(timerType.header().title(), "Remind Me");
|
|
||||||
assert.equal(timerType.header().value(), "reminder");
|
|
||||||
|
|
||||||
assert.equal(
|
|
||||||
futureDateInputSelector.header().title(),
|
|
||||||
"Select a timeframe"
|
|
||||||
);
|
|
||||||
assert.equal(futureDateInputSelector.header().value(), null);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test("autoclose - specific time", assert => {
|
|
||||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
||||||
|
|
||||||
visit("/t/internationalization-localization");
|
|
||||||
click(".toggle-admin-menu");
|
|
||||||
click(".topic-admin-status-update button");
|
|
||||||
|
|
||||||
futureDateInputSelector.expand().selectRowByValue("next_week");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
|
||||||
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
|
||||||
|
|
||||||
const regex = /will automatically close in/g;
|
|
||||||
const html = find(".future-date-input .topic-status-info")
|
|
||||||
.html()
|
|
||||||
.trim();
|
|
||||||
assert.ok(regex.test(html));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test("autoclose", assert => {
|
|
||||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
||||||
|
|
||||||
visit("/t/internationalization-localization");
|
|
||||||
click(".toggle-admin-menu");
|
|
||||||
click(".topic-admin-status-update button");
|
|
||||||
|
|
||||||
futureDateInputSelector.expand().selectRowByValue("next_week");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
|
||||||
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
|
||||||
|
|
||||||
const regex = /will automatically close in/g;
|
|
||||||
const html = find(".future-date-input .topic-status-info")
|
|
||||||
.html()
|
|
||||||
.trim();
|
|
||||||
assert.ok(regex.test(html));
|
|
||||||
});
|
|
||||||
|
|
||||||
futureDateInputSelector.expand().selectRowByValue("pick_date_and_time");
|
|
||||||
|
|
||||||
fillIn(".future-date-input .date-picker", "2099-11-24");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(
|
|
||||||
futureDateInputSelector.header().title(),
|
|
||||||
"Pick date and time"
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
futureDateInputSelector.header().value(),
|
|
||||||
"pick_date_and_time"
|
|
||||||
);
|
|
||||||
|
|
||||||
const regex = /will automatically close in/g;
|
|
||||||
const html = find(".future-date-input .topic-status-info")
|
|
||||||
.html()
|
|
||||||
.trim();
|
|
||||||
assert.ok(regex.test(html));
|
|
||||||
});
|
|
||||||
|
|
||||||
futureDateInputSelector.expand().selectRowByValue("set_based_on_last_post");
|
|
||||||
|
|
||||||
fillIn(".future-date-input input[type=number]", "2");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(
|
|
||||||
futureDateInputSelector.header().title(),
|
|
||||||
"Close based on last post"
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
futureDateInputSelector.header().value(),
|
|
||||||
"set_based_on_last_post"
|
|
||||||
);
|
|
||||||
|
|
||||||
const regex = /This topic will close.*after the last reply/g;
|
|
||||||
const html = find(".future-date-input .topic-status-info")
|
|
||||||
.html()
|
|
||||||
.trim();
|
|
||||||
assert.ok(regex.test(html));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test("close temporarily", assert => {
|
|
||||||
const timerType = selectKit(".select-kit.timer-type");
|
|
||||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
||||||
|
|
||||||
visit("/t/internationalization-localization");
|
|
||||||
click(".toggle-admin-menu");
|
|
||||||
click(".topic-admin-status-update button");
|
|
||||||
|
|
||||||
timerType.expand().selectRowByValue("open");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(
|
|
||||||
futureDateInputSelector.header().title(),
|
|
||||||
"Select a timeframe"
|
|
||||||
);
|
|
||||||
assert.equal(futureDateInputSelector.header().value(), null);
|
|
||||||
});
|
|
||||||
|
|
||||||
futureDateInputSelector.expand().selectRowByValue("next_week");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
|
||||||
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
|
||||||
|
|
||||||
const regex = /will automatically open in/g;
|
|
||||||
const html = find(".future-date-input .topic-status-info")
|
|
||||||
.html()
|
|
||||||
.trim();
|
|
||||||
assert.ok(regex.test(html));
|
|
||||||
});
|
|
||||||
|
|
||||||
futureDateInputSelector.expand().selectRowByValue("pick_date_and_time");
|
|
||||||
|
|
||||||
fillIn(".future-date-input .date-picker", "2099-11-24");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(
|
|
||||||
futureDateInputSelector.header().title(),
|
|
||||||
"Pick date and time"
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
futureDateInputSelector.header().value(),
|
|
||||||
"pick_date_and_time"
|
|
||||||
);
|
|
||||||
|
|
||||||
const regex = /will automatically open in/g;
|
|
||||||
const html = find(".future-date-input .topic-status-info")
|
|
||||||
.html()
|
|
||||||
.trim();
|
|
||||||
assert.ok(regex.test(html));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test("schedule", assert => {
|
|
||||||
const timerType = selectKit(".select-kit.timer-type");
|
|
||||||
const categoryChooser = selectKit(".modal-body .category-chooser");
|
|
||||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
||||||
|
|
||||||
visit("/t/internationalization-localization");
|
|
||||||
click(".toggle-admin-menu");
|
|
||||||
click(".topic-admin-status-update button");
|
|
||||||
|
|
||||||
timerType.expand().selectRowByValue("publish_to_category");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(categoryChooser.header().title(), "uncategorized");
|
|
||||||
assert.equal(categoryChooser.header().value(), null);
|
|
||||||
|
|
||||||
assert.equal(
|
|
||||||
futureDateInputSelector.header().title(),
|
|
||||||
"Select a timeframe"
|
|
||||||
);
|
|
||||||
assert.equal(futureDateInputSelector.header().value(), null);
|
|
||||||
});
|
|
||||||
|
|
||||||
categoryChooser.expand().selectRowByValue("7");
|
|
||||||
|
|
||||||
futureDateInputSelector.expand().selectRowByValue("next_week");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
|
||||||
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
|
||||||
|
|
||||||
const regex = /will be published to #dev/g;
|
|
||||||
const text = find(".future-date-input .topic-status-info")
|
|
||||||
.text()
|
|
||||||
.trim();
|
|
||||||
assert.ok(regex.test(text));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test("TL4 can't auto-delete", assert => {
|
|
||||||
replaceCurrentUser({ staff: false, trust_level: 4 });
|
|
||||||
|
|
||||||
visit("/t/internationalization-localization");
|
|
||||||
click(".toggle-admin-menu");
|
|
||||||
click(".topic-admin-status-update button");
|
|
||||||
|
|
||||||
const timerType = selectKit(".select-kit.timer-type");
|
|
||||||
|
|
||||||
timerType.expand();
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.ok(!timerType.rowByValue("delete").exists());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test("auto delete", assert => {
|
|
||||||
const timerType = selectKit(".select-kit.timer-type");
|
|
||||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
|
||||||
|
|
||||||
visit("/t/internationalization-localization");
|
|
||||||
click(".toggle-admin-menu");
|
|
||||||
click(".topic-admin-status-update button");
|
|
||||||
|
|
||||||
timerType.expand().selectRowByValue("delete");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(
|
|
||||||
futureDateInputSelector.header().title(),
|
|
||||||
"Select a timeframe"
|
|
||||||
);
|
|
||||||
assert.equal(futureDateInputSelector.header().value(), null);
|
|
||||||
});
|
|
||||||
|
|
||||||
futureDateInputSelector.expand().selectRowByValue("two_weeks");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(futureDateInputSelector.header().title(), "Two Weeks");
|
|
||||||
assert.equal(futureDateInputSelector.header().value(), "two_weeks");
|
|
||||||
|
|
||||||
const regex = /will be automatically deleted/g;
|
|
||||||
const html = find(".future-date-input .topic-status-info")
|
|
||||||
.html()
|
|
||||||
.trim();
|
|
||||||
assert.ok(regex.test(html));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test(
|
|
||||||
"Manually closing before the timer will clear the status text",
|
|
||||||
async assert => {
|
|
||||||
// prettier-ignore
|
|
||||||
server.post("/t/280/timer", () => // eslint-disable-line no-undef
|
|
||||||
response({
|
|
||||||
success: "OK",
|
success: "OK",
|
||||||
execute_at: new Date(
|
execute_at: new Date(
|
||||||
new Date().getTime() + 1 * 60 * 60 * 1000
|
new Date().getTime() + 1 * 60 * 60 * 1000
|
||||||
@ -277,14 +15,228 @@ QUnit.test(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// prettier-ignore
|
server.put("/t/internationalization-localization/280/status", () =>
|
||||||
server.put("/t/internationalization-localization/280/status", () => // eslint-disable-line no-undef
|
helper.response({
|
||||||
response({
|
|
||||||
success: "OK",
|
success: "OK",
|
||||||
topic_status_update: null
|
topic_status_update: null
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.test("default", async assert => {
|
||||||
|
const timerType = selectKit(".select-kit.timer-type");
|
||||||
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||||
|
|
||||||
|
await visit("/t/internationalization-localization");
|
||||||
|
await click(".toggle-admin-menu");
|
||||||
|
await click(".topic-admin-status-update button");
|
||||||
|
|
||||||
|
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
|
||||||
|
assert.equal(futureDateInputSelector.header().value(), null);
|
||||||
|
|
||||||
|
await click("#private-topic-timer");
|
||||||
|
|
||||||
|
assert.equal(timerType.header().title(), "Remind Me");
|
||||||
|
assert.equal(timerType.header().value(), "reminder");
|
||||||
|
|
||||||
|
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
|
||||||
|
assert.equal(futureDateInputSelector.header().value(), null);
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.test("autoclose - specific time", async assert => {
|
||||||
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||||
|
|
||||||
|
await visit("/t/internationalization-localization");
|
||||||
|
await click(".toggle-admin-menu");
|
||||||
|
await click(".topic-admin-status-update button");
|
||||||
|
|
||||||
|
await futureDateInputSelector.expandAwait();
|
||||||
|
await futureDateInputSelector.selectRowByValueAwait("next_week");
|
||||||
|
|
||||||
|
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
||||||
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
||||||
|
|
||||||
|
const regex = /will automatically close in/g;
|
||||||
|
const html = find(".future-date-input .topic-status-info")
|
||||||
|
.html()
|
||||||
|
.trim();
|
||||||
|
assert.ok(regex.test(html));
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.test("autoclose", async assert => {
|
||||||
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||||
|
|
||||||
|
await visit("/t/internationalization-localization");
|
||||||
|
await click(".toggle-admin-menu");
|
||||||
|
await click(".topic-admin-status-update button");
|
||||||
|
|
||||||
|
await futureDateInputSelector.expandAwait();
|
||||||
|
await futureDateInputSelector.selectRowByValueAwait("next_week");
|
||||||
|
|
||||||
|
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
||||||
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
||||||
|
|
||||||
|
const regex1 = /will automatically close in/g;
|
||||||
|
const html1 = find(".future-date-input .topic-status-info")
|
||||||
|
.html()
|
||||||
|
.trim();
|
||||||
|
assert.ok(regex1.test(html1));
|
||||||
|
|
||||||
|
await futureDateInputSelector.expandAwait();
|
||||||
|
await futureDateInputSelector.selectRowByValueAwait("pick_date_and_time");
|
||||||
|
|
||||||
|
await fillIn(".future-date-input .date-picker", "2099-11-24");
|
||||||
|
|
||||||
|
assert.equal(futureDateInputSelector.header().title(), "Pick date and time");
|
||||||
|
assert.equal(futureDateInputSelector.header().value(), "pick_date_and_time");
|
||||||
|
|
||||||
|
const regex2 = /will automatically close in/g;
|
||||||
|
const html2 = find(".future-date-input .topic-status-info")
|
||||||
|
.html()
|
||||||
|
.trim();
|
||||||
|
assert.ok(regex2.test(html2));
|
||||||
|
|
||||||
|
await futureDateInputSelector.expandAwait();
|
||||||
|
await futureDateInputSelector.selectRowByValueAwait("set_based_on_last_post");
|
||||||
|
|
||||||
|
await fillIn(".future-date-input input[type=number]", "2");
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
futureDateInputSelector.header().title(),
|
||||||
|
"Close based on last post"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
futureDateInputSelector.header().value(),
|
||||||
|
"set_based_on_last_post"
|
||||||
|
);
|
||||||
|
|
||||||
|
const regex3 = /This topic will close.*after the last reply/g;
|
||||||
|
const html3 = find(".future-date-input .topic-status-info")
|
||||||
|
.html()
|
||||||
|
.trim();
|
||||||
|
assert.ok(regex3.test(html3));
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.test("close temporarily", async assert => {
|
||||||
|
const timerType = selectKit(".select-kit.timer-type");
|
||||||
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||||
|
|
||||||
|
await visit("/t/internationalization-localization");
|
||||||
|
await click(".toggle-admin-menu");
|
||||||
|
await click(".topic-admin-status-update button");
|
||||||
|
|
||||||
|
await timerType.expandAwait();
|
||||||
|
await timerType.selectRowByValueAwait("open");
|
||||||
|
|
||||||
|
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
|
||||||
|
assert.equal(futureDateInputSelector.header().value(), null);
|
||||||
|
|
||||||
|
await futureDateInputSelector.expandAwait();
|
||||||
|
await futureDateInputSelector.selectRowByValueAwait("next_week");
|
||||||
|
|
||||||
|
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
||||||
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
||||||
|
|
||||||
|
const regex1 = /will automatically open in/g;
|
||||||
|
const html1 = find(".future-date-input .topic-status-info")
|
||||||
|
.html()
|
||||||
|
.trim();
|
||||||
|
assert.ok(regex1.test(html1));
|
||||||
|
|
||||||
|
await futureDateInputSelector.expandAwait();
|
||||||
|
await futureDateInputSelector.selectRowByValueAwait("pick_date_and_time");
|
||||||
|
|
||||||
|
await fillIn(".future-date-input .date-picker", "2099-11-24");
|
||||||
|
|
||||||
|
assert.equal(futureDateInputSelector.header().title(), "Pick date and time");
|
||||||
|
assert.equal(futureDateInputSelector.header().value(), "pick_date_and_time");
|
||||||
|
|
||||||
|
const regex2 = /will automatically open in/g;
|
||||||
|
const html2 = find(".future-date-input .topic-status-info")
|
||||||
|
.html()
|
||||||
|
.trim();
|
||||||
|
assert.ok(regex2.test(html2));
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.test("schedule", async assert => {
|
||||||
|
const timerType = selectKit(".select-kit.timer-type");
|
||||||
|
const categoryChooser = selectKit(".modal-body .category-chooser");
|
||||||
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||||
|
|
||||||
|
await visit("/t/internationalization-localization");
|
||||||
|
await click(".toggle-admin-menu");
|
||||||
|
await click(".topic-admin-status-update button");
|
||||||
|
|
||||||
|
await timerType.expandAwait();
|
||||||
|
await timerType.selectRowByValueAwait("publish_to_category");
|
||||||
|
|
||||||
|
assert.equal(categoryChooser.header().title(), "uncategorized");
|
||||||
|
assert.equal(categoryChooser.header().value(), null);
|
||||||
|
|
||||||
|
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
|
||||||
|
assert.equal(futureDateInputSelector.header().value(), null);
|
||||||
|
|
||||||
|
await categoryChooser.expandAwait();
|
||||||
|
await categoryChooser.selectRowByValueAwait("7");
|
||||||
|
|
||||||
|
await futureDateInputSelector.expandAwait();
|
||||||
|
await futureDateInputSelector.selectRowByValueAwait("next_week");
|
||||||
|
|
||||||
|
assert.equal(futureDateInputSelector.header().title(), "Next week");
|
||||||
|
assert.equal(futureDateInputSelector.header().value(), "next_week");
|
||||||
|
|
||||||
|
const regex = /will be published to #dev/g;
|
||||||
|
const text = find(".future-date-input .topic-status-info")
|
||||||
|
.text()
|
||||||
|
.trim();
|
||||||
|
assert.ok(regex.test(text));
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.test("TL4 can't auto-delete", async assert => {
|
||||||
|
replaceCurrentUser({ staff: false, trust_level: 4 });
|
||||||
|
|
||||||
|
await visit("/t/internationalization-localization");
|
||||||
|
await click(".toggle-admin-menu");
|
||||||
|
await click(".topic-admin-status-update button");
|
||||||
|
|
||||||
|
const timerType = selectKit(".select-kit.timer-type");
|
||||||
|
|
||||||
|
await timerType.expandAwait();
|
||||||
|
|
||||||
|
assert.ok(!timerType.rowByValue("delete").exists());
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.test("auto delete", async assert => {
|
||||||
|
const timerType = selectKit(".select-kit.timer-type");
|
||||||
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||||
|
|
||||||
|
await visit("/t/internationalization-localization");
|
||||||
|
await click(".toggle-admin-menu");
|
||||||
|
await click(".topic-admin-status-update button");
|
||||||
|
|
||||||
|
await timerType.expandAwait();
|
||||||
|
await timerType.selectRowByValueAwait("delete");
|
||||||
|
|
||||||
|
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
|
||||||
|
assert.equal(futureDateInputSelector.header().value(), null);
|
||||||
|
|
||||||
|
await futureDateInputSelector.expandAwait();
|
||||||
|
await futureDateInputSelector.selectRowByValueAwait("two_weeks");
|
||||||
|
|
||||||
|
assert.equal(futureDateInputSelector.header().title(), "Two Weeks");
|
||||||
|
assert.equal(futureDateInputSelector.header().value(), "two_weeks");
|
||||||
|
|
||||||
|
const regex = /will be automatically deleted/g;
|
||||||
|
const html = find(".future-date-input .topic-status-info")
|
||||||
|
.html()
|
||||||
|
.trim();
|
||||||
|
assert.ok(regex.test(html));
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.test(
|
||||||
|
"Manually closing before the timer will clear the status text",
|
||||||
|
async assert => {
|
||||||
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
const futureDateInputSelector = selectKit(".future-date-input-selector");
|
||||||
|
|
||||||
await visit("/t/internationalization-localization");
|
await visit("/t/internationalization-localization");
|
||||||
|
@ -1,39 +1,31 @@
|
|||||||
import { acceptance } from "helpers/qunit-helpers";
|
import { acceptance } from "helpers/qunit-helpers";
|
||||||
acceptance("Topic Notifications button", {
|
acceptance("Topic Notifications button", {
|
||||||
loggedIn: true,
|
loggedIn: true,
|
||||||
beforeEach() {
|
pretend(server, helper) {
|
||||||
const response = object => {
|
server.post("/t/280/notifications", () => {
|
||||||
return [200, { "Content-Type": "application/json" }, object];
|
return helper.response({});
|
||||||
};
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
server.post("/t/280/notifications", () => { // eslint-disable-line no-undef
|
|
||||||
return response({});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Updating topic notification level", assert => {
|
QUnit.test("Updating topic notification level", async assert => {
|
||||||
const notificationOptions = selectKit(
|
const notificationOptions = selectKit(
|
||||||
"#topic-footer-buttons .topic-notifications-options"
|
"#topic-footer-buttons .topic-notifications-options"
|
||||||
);
|
);
|
||||||
|
|
||||||
visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(
|
||||||
assert.ok(
|
notificationOptions.exists(),
|
||||||
notificationOptions.exists(),
|
"it should display the notification options button in the topic's footer"
|
||||||
"it should display the notification options button in the topic's footer"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
notificationOptions.expand().selectRowByValue("3");
|
await notificationOptions.expandAwait();
|
||||||
|
await notificationOptions.selectRowByValueAwait("3");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
notificationOptions.selectedRow().name(),
|
||||||
notificationOptions.selectedRow().name(),
|
"Watching",
|
||||||
"Watching",
|
"it should display the right notification level"
|
||||||
"it should display the right notification level"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
import { acceptance } from "helpers/qunit-helpers";
|
import { acceptance } from "helpers/qunit-helpers";
|
||||||
acceptance("Topic", { loggedIn: true });
|
acceptance("Topic", {
|
||||||
|
loggedIn: true,
|
||||||
|
pretend(server, helper) {
|
||||||
|
server.put("/posts/398/wiki", () => {
|
||||||
|
return helper.response({});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test("Share Popup", assert => {
|
QUnit.test("Share Popup", async assert => {
|
||||||
visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
andThen(() => {
|
assert.ok(!exists("#share-link.visible"), "it is not visible");
|
||||||
assert.ok(!exists("#share-link.visible"), "it is not visible");
|
|
||||||
});
|
|
||||||
|
|
||||||
click("button[data-share-url]");
|
await click("button[data-share-url]");
|
||||||
andThen(() => {
|
assert.ok(exists("#share-link.visible"), "it shows the popup");
|
||||||
assert.ok(exists("#share-link.visible"), "it shows the popup");
|
|
||||||
});
|
|
||||||
|
|
||||||
click("#share-link .close-share");
|
await click("#share-link .close-share");
|
||||||
andThen(() => {
|
assert.ok(!exists("#share-link.visible"), "it closes the popup");
|
||||||
assert.ok(!exists("#share-link.visible"), "it closes the popup");
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO tgxworld This fails on Travis but we need to push the security fix out
|
// TODO tgxworld This fails on Travis but we need to push the security fix out
|
||||||
// first.
|
// first.
|
||||||
@ -30,183 +31,159 @@ QUnit.test("Share Popup", assert => {
|
|||||||
// });
|
// });
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Showing and hiding the edit controls", assert => {
|
QUnit.test("Showing and hiding the edit controls", async assert => {
|
||||||
visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
|
|
||||||
click("#topic-title .d-icon-pencil");
|
await click("#topic-title .d-icon-pencil");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(exists("#edit-title"), "it shows the editing controls");
|
||||||
assert.ok(exists("#edit-title"), "it shows the editing controls");
|
assert.ok(
|
||||||
assert.ok(
|
!exists(".title-wrapper .remove-featured-link"),
|
||||||
!exists(".title-wrapper .remove-featured-link"),
|
"link to remove featured link is not shown"
|
||||||
"link to remove featured link is not shown"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn("#edit-title", "this is the new title");
|
await fillIn("#edit-title", "this is the new title");
|
||||||
click("#topic-title .cancel-edit");
|
await click("#topic-title .cancel-edit");
|
||||||
andThen(() => {
|
assert.ok(!exists("#edit-title"), "it hides the editing controls");
|
||||||
assert.ok(!exists("#edit-title"), "it hides the editing controls");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Updating the topic title and category", assert => {
|
QUnit.test("Updating the topic title and category", async assert => {
|
||||||
const categoryChooser = selectKit(".title-wrapper .category-chooser");
|
const categoryChooser = selectKit(".title-wrapper .category-chooser");
|
||||||
|
|
||||||
visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
|
|
||||||
click("#topic-title .d-icon-pencil");
|
await click("#topic-title .d-icon-pencil");
|
||||||
fillIn("#edit-title", "this is the new title");
|
await fillIn("#edit-title", "this is the new title");
|
||||||
categoryChooser.expand().selectRowByValue(4);
|
await categoryChooser.expandAwait();
|
||||||
click("#topic-title .submit-edit");
|
await categoryChooser.selectRowByValueAwait(4);
|
||||||
|
await click("#topic-title .submit-edit");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find("#topic-title .badge-category").text(),
|
||||||
find("#topic-title .badge-category").text(),
|
"faq",
|
||||||
"faq",
|
"it displays the new category"
|
||||||
"it displays the new category"
|
);
|
||||||
);
|
assert.equal(
|
||||||
assert.equal(
|
find(".fancy-title")
|
||||||
find(".fancy-title")
|
.text()
|
||||||
.text()
|
.trim(),
|
||||||
.trim(),
|
"this is the new title",
|
||||||
"this is the new title",
|
"it displays the new title"
|
||||||
"it displays the new title"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Marking a topic as wiki", assert => {
|
QUnit.test("Marking a topic as wiki", async assert => {
|
||||||
// prettier-ignore
|
await visit("/t/internationalization-localization/280");
|
||||||
server.put("/posts/398/wiki", () => { // eslint-disable-line no-undef
|
|
||||||
return [200, { "Content-Type": "application/json" }, {}];
|
|
||||||
});
|
|
||||||
|
|
||||||
visit("/t/internationalization-localization/280");
|
assert.ok(find("a.wiki").length === 0, "it does not show the wiki icon");
|
||||||
|
|
||||||
andThen(() => {
|
await click(".topic-post:eq(0) button.show-more-actions");
|
||||||
assert.ok(find("a.wiki").length === 0, "it does not show the wiki icon");
|
await click(".topic-post:eq(0) button.show-post-admin-menu");
|
||||||
});
|
await click(".btn.wiki");
|
||||||
|
|
||||||
click(".topic-post:eq(0) button.show-more-actions");
|
assert.ok(find("a.wiki").length === 1, "it shows the wiki icon");
|
||||||
click(".topic-post:eq(0) button.show-post-admin-menu");
|
|
||||||
click(".btn.wiki");
|
|
||||||
|
|
||||||
andThen(() => {
|
|
||||||
assert.ok(find("a.wiki").length === 1, "it shows the wiki icon");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Reply as new topic", assert => {
|
QUnit.test("Reply as new topic", async assert => {
|
||||||
visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
click("button.share:eq(0)");
|
await click("button.share:eq(0)");
|
||||||
click(".reply-as-new-topic a");
|
await click(".reply-as-new-topic a");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(exists(".d-editor-input"), "the composer input is visible");
|
||||||
assert.ok(exists(".d-editor-input"), "the composer input is visible");
|
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".d-editor-input")
|
find(".d-editor-input")
|
||||||
.val()
|
.val()
|
||||||
.trim(),
|
.trim(),
|
||||||
`Continuing the discussion from [Internationalization / localization](${
|
`Continuing the discussion from [Internationalization / localization](${
|
||||||
window.location.origin
|
window.location.origin
|
||||||
}/t/internationalization-localization/280):`,
|
}/t/internationalization-localization/280):`,
|
||||||
"it fills composer with the ring string"
|
"it fills composer with the ring string"
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
selectKit(".category-chooser")
|
selectKit(".category-chooser")
|
||||||
.header()
|
.header()
|
||||||
.value(),
|
.value(),
|
||||||
"2",
|
"2",
|
||||||
"it fills category selector with the right category"
|
"it fills category selector with the right category"
|
||||||
);
|
);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Reply as new message", assert => {
|
QUnit.test("Reply as new message", async assert => {
|
||||||
visit("/t/pm-for-testing/12");
|
await visit("/t/pm-for-testing/12");
|
||||||
click("button.share:eq(0)");
|
await click("button.share:eq(0)");
|
||||||
click(".reply-as-new-topic a");
|
await click(".reply-as-new-topic a");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(exists(".d-editor-input"), "the composer input is visible");
|
||||||
assert.ok(exists(".d-editor-input"), "the composer input is visible");
|
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".d-editor-input")
|
find(".d-editor-input")
|
||||||
.val()
|
.val()
|
||||||
.trim(),
|
.trim(),
|
||||||
`Continuing the discussion from [PM for testing](${
|
`Continuing the discussion from [PM for testing](${
|
||||||
window.location.origin
|
window.location.origin
|
||||||
}/t/pm-for-testing/12):`,
|
}/t/pm-for-testing/12):`,
|
||||||
"it fills composer with the ring string"
|
"it fills composer with the ring string"
|
||||||
);
|
);
|
||||||
|
|
||||||
const targets = find(".item span", ".composer-fields");
|
const targets = find(".item span", ".composer-fields");
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
$(targets[0]).text(),
|
$(targets[0]).text(),
|
||||||
"someguy",
|
"someguy",
|
||||||
"it fills up the composer with the right user to start the PM to"
|
"it fills up the composer with the right user to start the PM to"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
$(targets[1]).text(),
|
$(targets[1]).text(),
|
||||||
"test",
|
"test",
|
||||||
"it fills up the composer with the right user to start the PM to"
|
"it fills up the composer with the right user to start the PM to"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
$(targets[2]).text(),
|
$(targets[2]).text(),
|
||||||
"Group",
|
"Group",
|
||||||
"it fills up the composer with the right group to start the PM to"
|
"it fills up the composer with the right group to start the PM to"
|
||||||
);
|
);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Visit topic routes", assert => {
|
QUnit.test("Visit topic routes", async assert => {
|
||||||
visit("/t/12");
|
await visit("/t/12");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".fancy-title")
|
||||||
find(".fancy-title")
|
.text()
|
||||||
.text()
|
.trim(),
|
||||||
.trim(),
|
"PM for testing",
|
||||||
"PM for testing",
|
"it routes to the right topic"
|
||||||
"it routes to the right topic"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
visit("/t/280/20");
|
await visit("/t/280/20");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".fancy-title")
|
||||||
find(".fancy-title")
|
.text()
|
||||||
.text()
|
.trim(),
|
||||||
.trim(),
|
"Internationalization / localization",
|
||||||
"Internationalization / localization",
|
"it routes to the right topic"
|
||||||
"it routes to the right topic"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Updating the topic title with emojis", assert => {
|
QUnit.test("Updating the topic title with emojis", async assert => {
|
||||||
visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
click("#topic-title .d-icon-pencil");
|
await click("#topic-title .d-icon-pencil");
|
||||||
|
|
||||||
fillIn("#edit-title", "emojis title :bike: :blonde_woman:t6:");
|
await fillIn("#edit-title", "emojis title :bike: :blonde_woman:t6:");
|
||||||
|
|
||||||
click("#topic-title .submit-edit");
|
await click("#topic-title .submit-edit");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".fancy-title")
|
||||||
find(".fancy-title")
|
.html()
|
||||||
.html()
|
.trim(),
|
||||||
.trim(),
|
'emojis title <img src="/images/emoji/emoji_one/bike.png?v=5" title="bike" alt="bike" class="emoji"> <img src="/images/emoji/emoji_one/blonde_woman/6.png?v=5" title="blonde_woman:t6" alt="blonde_woman:t6" class="emoji">',
|
||||||
'emojis title <img src="/images/emoji/emoji_one/bike.png?v=5" title="bike" alt="bike" class="emoji"> <img src="/images/emoji/emoji_one/blonde_woman/6.png?v=5" title="blonde_woman:t6" alt="blonde_woman:t6" class="emoji">',
|
"it displays the new title with emojis"
|
||||||
"it displays the new title with emojis"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
acceptance("Topic featured links", {
|
acceptance("Topic featured links", {
|
||||||
@ -217,29 +194,23 @@ acceptance("Topic featured links", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("remove featured link", assert => {
|
QUnit.test("remove featured link", async assert => {
|
||||||
visit("/t/299/1");
|
await visit("/t/299/1");
|
||||||
andThen(() => {
|
assert.ok(
|
||||||
assert.ok(
|
exists(".title-wrapper .topic-featured-link"),
|
||||||
exists(".title-wrapper .topic-featured-link"),
|
"link is shown with topic title"
|
||||||
"link is shown with topic title"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".title-wrapper .edit-topic");
|
await click(".title-wrapper .edit-topic");
|
||||||
andThen(() => {
|
assert.ok(
|
||||||
assert.ok(
|
exists(".title-wrapper .remove-featured-link"),
|
||||||
exists(".title-wrapper .remove-featured-link"),
|
"link to remove featured link"
|
||||||
"link to remove featured link"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// this test only works in a browser:
|
// this test only works in a browser:
|
||||||
// click('.title-wrapper .remove-featured-link');
|
// await click('.title-wrapper .remove-featured-link');
|
||||||
// click('.title-wrapper .submit-edit');
|
// await click('.title-wrapper .submit-edit');
|
||||||
// andThen(() => {
|
// assert.ok(!exists('.title-wrapper .topic-featured-link'), 'link is gone');
|
||||||
// assert.ok(!exists('.title-wrapper .topic-featured-link'), 'link is gone');
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("selecting posts", async assert => {
|
QUnit.test("selecting posts", async assert => {
|
||||||
|
Reference in New Issue
Block a user