2019-10-29 15:23:50 -04:00
|
|
|
import EmberObject from "@ember/object";
|
2018-06-15 11:03:24 -04:00
|
|
|
import { moduleForWidget, widgetTest } from "helpers/widget-test";
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
moduleForWidget("post");
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("basic elements", {
|
2016-01-04 15:18:09 -05:00
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { shareUrl: "/example", post_number: 1 });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find(".names").length, "includes poster name");
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find("a.post-date").length, "includes post date");
|
|
|
|
assert.ok(find("a.post-date[data-share-url]").length);
|
|
|
|
assert.ok(find("a.post-date[data-post-number]").length);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-03-31 08:09:30 -04:00
|
|
|
widgetTest("post - links", {
|
|
|
|
template: '{{mount-widget widget="post-contents" args=args}}',
|
|
|
|
beforeEach() {
|
|
|
|
this.set("args", {
|
|
|
|
cooked:
|
|
|
|
"<a href='http://link1.example.com/'>first link</a> and <a href='http://link2.example.com/?some=query'>second link</a>",
|
|
|
|
linkCounts: [
|
|
|
|
{ url: "http://link1.example.com/", clicks: 1, internal: true },
|
|
|
|
{ url: "http://link2.example.com/", clicks: 2, internal: true }
|
|
|
|
]
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async test(assert) {
|
|
|
|
assert.equal(find(".badge.clicks:nth(0)").text(), "1");
|
|
|
|
assert.equal(find(".badge.clicks:nth(1)").text(), "2");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("wiki", {
|
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args showHistory=(action "showHistory")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { wiki: true, version: 2, canViewEditHistory: true });
|
|
|
|
this.on("showHistory", () => (this.historyShown = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".post-info .wiki");
|
|
|
|
assert.ok(
|
|
|
|
this.historyShown,
|
|
|
|
"clicking the wiki icon displays the post history"
|
|
|
|
);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("wiki without revision", {
|
2019-01-10 05:06:01 -05:00
|
|
|
template:
|
|
|
|
'{{mount-widget widget="post" args=args editPost=(action "editPost")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { wiki: true, version: 1, canViewEditHistory: true });
|
|
|
|
this.on("editPost", () => (this.editPostCalled = true));
|
2017-01-20 01:37:22 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".post-info .wiki");
|
|
|
|
assert.ok(this.editPostCalled, "clicking wiki icon edits the post");
|
2017-01-20 01:37:22 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("via-email", {
|
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args showRawEmail=(action "showRawEmail")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { via_email: true, canViewRawEmail: true });
|
|
|
|
this.on("showRawEmail", () => (this.rawEmailShown = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".post-info.via-email");
|
2019-02-12 05:34:25 -05:00
|
|
|
assert.ok(this.rawEmailShown, "clicking the envelope shows the raw email");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("via-email without permission", {
|
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args showRawEmail=(action "showRawEmail")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { via_email: true, canViewRawEmail: false });
|
|
|
|
this.on("showRawEmail", () => (this.rawEmailShown = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".post-info.via-email");
|
|
|
|
assert.ok(
|
|
|
|
!this.rawEmailShown,
|
2019-02-12 05:34:25 -05:00
|
|
|
"clicking the envelope doesn't show the raw email"
|
2018-07-24 11:49:42 -04:00
|
|
|
);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("history", {
|
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args showHistory=(action "showHistory")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { version: 3, canViewEditHistory: true });
|
|
|
|
this.on("showHistory", () => (this.historyShown = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".post-info.edits");
|
|
|
|
assert.ok(this.historyShown, "clicking the pencil shows the history");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("history without view permission", {
|
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args showHistory=(action "showHistory")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { version: 3, canViewEditHistory: false });
|
|
|
|
this.on("showHistory", () => (this.historyShown = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".post-info.edits");
|
|
|
|
assert.ok(
|
|
|
|
!this.historyShown,
|
|
|
|
`clicking the pencil doesn't show the history`
|
|
|
|
);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("whisper", {
|
2016-01-04 15:18:09 -05:00
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { isWhisper: true });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find(".topic-post.whisper").length === 1);
|
|
|
|
assert.ok(find(".post-info.whisper").length === 1);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("like count button", {
|
2016-01-04 15:18:09 -05:00
|
|
|
template: '{{mount-widget widget="post" model=post args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach(store) {
|
2018-06-15 11:03:24 -04:00
|
|
|
const topic = store.createRecord("topic", { id: 123 });
|
|
|
|
const post = store.createRecord("post", {
|
2016-01-04 15:18:09 -05:00
|
|
|
id: 1,
|
|
|
|
post_number: 1,
|
|
|
|
topic,
|
|
|
|
like_count: 3,
|
2018-06-15 11:03:24 -04:00
|
|
|
actions_summary: [{ id: 2, count: 1, hidden: false, can_act: true }]
|
2016-01-04 15:18:09 -05:00
|
|
|
});
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("post", post);
|
2019-05-06 20:03:34 -04:00
|
|
|
this.set("args", { likeCount: 1 });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find("button.like-count").length === 1);
|
|
|
|
assert.ok(find(".who-liked").length === 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
|
|
|
|
// toggle it on
|
2018-07-24 11:49:42 -04:00
|
|
|
await click("button.like-count");
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find(".who-liked").length === 1);
|
|
|
|
assert.ok(find(".who-liked a.trigger-user-card").length === 1);
|
2016-01-04 15:18:09 -05:00
|
|
|
|
|
|
|
// toggle it off
|
2018-07-24 11:49:42 -04:00
|
|
|
await click("button.like-count");
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find(".who-liked").length === 0);
|
|
|
|
assert.ok(find(".who-liked a.trigger-user-card").length === 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest(`like count with no likes`, {
|
|
|
|
template: '{{mount-widget widget="post" model=post args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { likeCount: 0 });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find("button.like-count").length === 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("share button", {
|
2016-01-04 15:18:09 -05:00
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { shareUrl: "http://share-me.example.com" });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.ok(
|
2019-02-25 10:04:55 -05:00
|
|
|
!!find(".actions button[data-share-url]").length,
|
2018-06-15 11:03:24 -04:00
|
|
|
"it renders a share button"
|
|
|
|
);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("liking", {
|
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post-menu" args=args toggleLike=(action "toggleLike")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-01-04 15:18:09 -05:00
|
|
|
const args = { showLike: true, canToggleLike: true };
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", args);
|
|
|
|
this.on("toggleLike", () => {
|
2016-01-04 15:18:09 -05:00
|
|
|
args.liked = !args.liked;
|
|
|
|
args.likeCount = args.liked ? 1 : 0;
|
|
|
|
});
|
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(!!find(".actions button.like").length);
|
|
|
|
assert.ok(find(".actions button.like-count").length === 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
await click(".actions button.like");
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(!find(".actions button.like").length);
|
|
|
|
assert.ok(!!find(".actions button.has-like").length);
|
|
|
|
assert.ok(find(".actions button.like-count").length === 1);
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
await click(".actions button.has-like");
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(!!find(".actions button.like").length);
|
|
|
|
assert.ok(!find(".actions button.has-like").length);
|
|
|
|
assert.ok(find(".actions button.like-count").length === 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("anon liking", {
|
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post-menu" args=args showLogin=(action "showLogin")}}',
|
2016-07-05 00:17:29 -04:00
|
|
|
anonymous: true,
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-07-05 00:17:29 -04:00
|
|
|
const args = { showLike: true };
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", args);
|
|
|
|
this.on("showLogin", () => (this.loginShown = true));
|
2016-07-05 00:17:29 -04:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(!!find(".actions button.like").length);
|
|
|
|
assert.ok(find(".actions button.like-count").length === 0);
|
2016-07-05 00:17:29 -04:00
|
|
|
|
2018-10-24 09:58:42 -04:00
|
|
|
assert.equal(
|
2019-02-25 10:04:55 -05:00
|
|
|
find("button.like").attr("title"),
|
2018-10-24 09:58:42 -04:00
|
|
|
I18n.t("post.controls.like"),
|
|
|
|
`shows the right button title for anonymous users`
|
|
|
|
);
|
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
await click(".actions button.like");
|
|
|
|
assert.ok(this.loginShown);
|
2016-07-05 00:17:29 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("edit button", {
|
2019-01-10 05:06:01 -05:00
|
|
|
template:
|
|
|
|
'{{mount-widget widget="post" args=args editPost=(action "editPost")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canEdit: true });
|
|
|
|
this.on("editPost", () => (this.editPostCalled = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click("button.edit");
|
|
|
|
assert.ok(this.editPostCalled, "it triggered the edit action");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest(`edit button - can't edit`, {
|
2019-01-10 05:06:01 -05:00
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canEdit: false });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("button.edit").length, 0, `button is not displayed`);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("recover button", {
|
2019-01-10 05:06:01 -05:00
|
|
|
template:
|
|
|
|
'{{mount-widget widget="post" args=args deletePost=(action "deletePost")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canDelete: true });
|
|
|
|
this.on("deletePost", () => (this.deletePostCalled = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click("button.delete");
|
|
|
|
assert.ok(this.deletePostCalled, "it triggered the delete action");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("delete topic button", {
|
2019-01-10 05:06:01 -05:00
|
|
|
template:
|
|
|
|
'{{mount-widget widget="post" args=args deletePost=(action "deletePost")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canDeleteTopic: true });
|
|
|
|
this.on("deletePost", () => (this.deletePostCalled = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click("button.delete");
|
|
|
|
assert.ok(this.deletePostCalled, "it triggered the delete action");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest(`delete topic button - can't delete`, {
|
2019-01-10 05:06:01 -05:00
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canDeleteTopic: false });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("button.delete").length, 0, `button is not displayed`);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-07-18 17:31:37 -04:00
|
|
|
widgetTest(
|
|
|
|
`delete topic button - can't delete when topic author without permission`,
|
|
|
|
{
|
2019-01-10 05:06:01 -05:00
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2018-07-18 17:31:37 -04:00
|
|
|
beforeEach() {
|
|
|
|
this.set("args", {
|
|
|
|
canDeleteTopic: false,
|
2019-05-30 14:27:28 -04:00
|
|
|
showFlagDelete: true
|
2018-07-18 17:31:37 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("button.delete").length, 1, `button is displayed`);
|
2018-07-18 17:31:37 -04:00
|
|
|
assert.equal(
|
2019-02-25 10:04:55 -05:00
|
|
|
find("button.delete").attr("title"),
|
2018-07-18 17:31:37 -04:00
|
|
|
I18n.t("post.controls.delete_topic_disallowed"),
|
|
|
|
`shows the right button title for users without permissions`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("recover topic button", {
|
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args recoverPost=(action "recoverPost")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canRecoverTopic: true });
|
|
|
|
this.on("recoverPost", () => (this.recovered = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click("button.recover");
|
|
|
|
assert.ok(this.recovered);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest(`recover topic button - can't recover`, {
|
2019-01-10 05:06:01 -05:00
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canRecoverTopic: false });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("button.recover").length, 0, `button is not displayed`);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("delete post button", {
|
2019-01-10 05:06:01 -05:00
|
|
|
template:
|
|
|
|
'{{mount-widget widget="post" args=args deletePost=(action "deletePost")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canDelete: true });
|
|
|
|
this.on("deletePost", () => (this.deletePostCalled = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click("button.delete");
|
|
|
|
assert.ok(this.deletePostCalled, "it triggered the delete action");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest(`delete post button - can't delete`, {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canDelete: false });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("button.delete").length, 0, `button is not displayed`);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("recover post button", {
|
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args recoverPost=(action "recoverPost")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canRecover: true });
|
|
|
|
this.on("recoverPost", () => (this.recovered = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click("button.recover");
|
|
|
|
assert.ok(this.recovered);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest(`recover post button - can't recover`, {
|
2019-01-10 05:06:01 -05:00
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canRecover: false });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("button.recover").length, 0, `button is not displayed`);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest(`flagging`, {
|
2019-01-10 05:06:01 -05:00
|
|
|
template:
|
|
|
|
'{{mount-widget widget="post" args=args showFlags=(action "showFlags")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canFlag: true });
|
|
|
|
this.on("showFlags", () => (this.flagsShown = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find("button.create-flag").length === 1);
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
await click("button.create-flag");
|
|
|
|
assert.ok(this.flagsShown, "it triggered the action");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest(`flagging: can't flag`, {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canFlag: false });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find("button.create-flag").length === 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-11-02 13:54:45 -04:00
|
|
|
widgetTest(`flagging: can't flag when post is hidden`, {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
|
|
|
beforeEach() {
|
|
|
|
this.set("args", { canFlag: true, hidden: true });
|
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find("button.create-flag").length === 0);
|
2018-11-02 13:54:45 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-01-04 15:18:09 -05:00
|
|
|
widgetTest(`read indicator`, {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { read: true });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find(".read-state.read").length);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest(`unread indicator`, {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { read: false });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find(".read-state").length);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("reply directly above (supressed)", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", {
|
|
|
|
replyToUsername: "eviltrout",
|
|
|
|
replyToAvatarTemplate: "/images/avatar.png",
|
2016-01-04 15:18:09 -05:00
|
|
|
replyDirectlyAbove: true
|
|
|
|
});
|
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("a.reply-to-tab").length, 0, "hides the tab");
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(
|
2019-02-25 10:04:55 -05:00
|
|
|
find(".avoid-tab").length,
|
2018-06-15 11:03:24 -04:00
|
|
|
0,
|
|
|
|
"doesn't have the avoid tab class"
|
|
|
|
);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("reply a few posts above (supressed)", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", {
|
|
|
|
replyToUsername: "eviltrout",
|
|
|
|
replyToAvatarTemplate: "/images/avatar.png",
|
2016-01-04 15:18:09 -05:00
|
|
|
replyDirectlyAbove: false
|
|
|
|
});
|
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find("a.reply-to-tab").length, "shows the tab");
|
|
|
|
assert.equal(find(".avoid-tab").length, 1, "has the avoid tab class");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("reply directly above", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", {
|
|
|
|
replyToUsername: "eviltrout",
|
|
|
|
replyToAvatarTemplate: "/images/avatar.png",
|
2016-01-04 15:18:09 -05:00
|
|
|
replyDirectlyAbove: true
|
|
|
|
});
|
|
|
|
this.siteSettings.suppress_reply_directly_above = false;
|
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".avoid-tab").length, 1, "has the avoid tab class");
|
2018-07-24 11:49:42 -04:00
|
|
|
await click("a.reply-to-tab");
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("section.embedded-posts.top .cooked").length, 1);
|
|
|
|
assert.equal(find("section.embedded-posts .d-icon-arrow-up").length, 1);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("cooked content hidden", {
|
2018-06-15 11:03:24 -04:00
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args expandHidden=(action "expandHidden")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { cooked_hidden: true });
|
|
|
|
this.on("expandHidden", () => (this.unhidden = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".topic-body .expand-hidden");
|
|
|
|
assert.ok(this.unhidden, "triggers the action");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("expand first post", {
|
|
|
|
template: '{{mount-widget widget="post" model=post args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach(store) {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { expandablePost: true });
|
|
|
|
this.set("post", store.createRecord("post", { id: 1234 }));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".topic-body .expand-post");
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".expand-post").length, 0, "button is gone");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("can't bookmark", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canBookmark: false });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("button.bookmark").length, 0);
|
|
|
|
assert.equal(find("button.bookmarked").length, 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("bookmark", {
|
2018-06-15 11:03:24 -04:00
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args toggleBookmark=(action "toggleBookmark")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-01-04 15:18:09 -05:00
|
|
|
const args = { canBookmark: true };
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", args);
|
|
|
|
this.on("toggleBookmark", () => (args.bookmarked = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".post-menu-area .bookmark").length, 1);
|
|
|
|
assert.equal(find("button.bookmarked").length, 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
await click("button.bookmark");
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("button.bookmarked").length, 1);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("can't show admin menu when you can't manage", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canManage: false });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".post-menu-area .show-post-admin-menu").length, 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("show admin menu", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canManage: true });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".post-admin-menu").length, 0);
|
2018-07-24 11:49:42 -04:00
|
|
|
await click(".post-menu-area .show-post-admin-menu");
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".post-admin-menu").length, 1, "it shows the popup");
|
2018-07-24 11:49:42 -04:00
|
|
|
await click(".post-menu-area");
|
|
|
|
assert.equal(
|
2019-02-25 10:04:55 -05:00
|
|
|
find(".post-admin-menu").length,
|
2018-07-24 11:49:42 -04:00
|
|
|
0,
|
|
|
|
"clicking outside clears the popup"
|
|
|
|
);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("toggle moderator post", {
|
2018-06-15 11:03:24 -04:00
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args togglePostType=(action "togglePostType")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2019-07-24 16:01:08 -04:00
|
|
|
this.currentUser.set("moderator", true);
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canManage: true });
|
|
|
|
this.on("togglePostType", () => (this.toggled = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".post-menu-area .show-post-admin-menu");
|
|
|
|
await click(".post-admin-menu .toggle-post-type");
|
2019-01-10 05:06:01 -05:00
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
assert.ok(this.toggled);
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".post-admin-menu").length, 0, "also hides the menu");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
widgetTest("toggle moderator post", {
|
2018-06-15 11:03:24 -04:00
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args togglePostType=(action "togglePostType")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2019-07-24 16:01:08 -04:00
|
|
|
this.currentUser.set("moderator", true);
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canManage: true });
|
|
|
|
this.on("togglePostType", () => (this.toggled = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".post-menu-area .show-post-admin-menu");
|
|
|
|
await click(".post-admin-menu .toggle-post-type");
|
2019-01-10 05:06:01 -05:00
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
assert.ok(this.toggled);
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".post-admin-menu").length, 0, "also hides the menu");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("rebake post", {
|
2019-01-10 05:06:01 -05:00
|
|
|
template:
|
|
|
|
'{{mount-widget widget="post" args=args rebakePost=(action "rebakePost")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canManage: true });
|
|
|
|
this.on("rebakePost", () => (this.baked = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".post-menu-area .show-post-admin-menu");
|
|
|
|
await click(".post-admin-menu .rebuild-html");
|
|
|
|
assert.ok(this.baked);
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".post-admin-menu").length, 0, "also hides the menu");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("unhide post", {
|
2019-01-10 05:06:01 -05:00
|
|
|
template:
|
|
|
|
'{{mount-widget widget="post" args=args unhidePost=(action "unhidePost")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canManage: true, hidden: true });
|
|
|
|
this.on("unhidePost", () => (this.unhidden = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".post-menu-area .show-post-admin-menu");
|
|
|
|
await click(".post-admin-menu .unhide-post");
|
|
|
|
assert.ok(this.unhidden);
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".post-admin-menu").length, 0, "also hides the menu");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("change owner", {
|
2018-06-15 11:03:24 -04:00
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args changePostOwner=(action "changePostOwner")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-01-04 15:18:09 -05:00
|
|
|
this.currentUser.admin = true;
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canManage: true });
|
|
|
|
this.on("changePostOwner", () => (this.owned = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".post-menu-area .show-post-admin-menu");
|
|
|
|
await click(".post-admin-menu .change-owner");
|
|
|
|
assert.ok(this.owned);
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".post-admin-menu").length, 0, "also hides the menu");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("reply", {
|
2018-06-15 11:03:24 -04:00
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args replyToPost=(action "replyToPost")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canCreatePost: true });
|
|
|
|
this.on("replyToPost", () => (this.replied = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click(".post-controls .create");
|
|
|
|
assert.ok(this.replied);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("reply - without permissions", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { canCreatePost: false });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".post-controls .create").length, 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("replies - no replies", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { replyCount: 0 });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("button.show-replies").length, 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("replies - multiple replies", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-01-04 15:18:09 -05:00
|
|
|
this.siteSettings.suppress_reply_directly_below = true;
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { replyCount: 2, replyDirectlyBelow: true });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("button.show-replies").length, 1);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("replies - one below, suppressed", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-01-04 15:18:09 -05:00
|
|
|
this.siteSettings.suppress_reply_directly_below = true;
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { replyCount: 1, replyDirectlyBelow: true });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("button.show-replies").length, 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("replies - one below, not suppressed", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-01-04 15:18:09 -05:00
|
|
|
this.siteSettings.suppress_reply_directly_below = false;
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { id: 6654, replyCount: 1, replyDirectlyBelow: true });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
|
|
|
await click("button.show-replies");
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("section.embedded-posts.bottom .cooked").length, 1);
|
|
|
|
assert.equal(find("section.embedded-posts .d-icon-arrow-down").length, 1);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("topic map not shown", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { showTopicMap: false });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".topic-map").length, 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("topic map - few posts", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", {
|
2016-01-04 15:18:09 -05:00
|
|
|
showTopicMap: true,
|
|
|
|
topicPostsCount: 2,
|
2018-06-15 11:03:24 -04:00
|
|
|
participants: [{ username: "eviltrout" }, { username: "codinghorror" }]
|
2016-01-04 15:18:09 -05:00
|
|
|
});
|
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(
|
2019-02-25 10:04:55 -05:00
|
|
|
find("li.avatars a.poster").length,
|
2018-06-15 11:03:24 -04:00
|
|
|
0,
|
|
|
|
"shows no participants when collapsed"
|
|
|
|
);
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
await click("nav.buttons button");
|
|
|
|
assert.equal(
|
2019-02-25 10:04:55 -05:00
|
|
|
find(".topic-map-expanded a.poster").length,
|
2018-07-24 11:49:42 -04:00
|
|
|
2,
|
|
|
|
"shows all when expanded"
|
|
|
|
);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("topic map - participants", {
|
2016-05-11 15:09:36 -04:00
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", {
|
2016-01-04 15:18:09 -05:00
|
|
|
showTopicMap: true,
|
|
|
|
topicPostsCount: 10,
|
|
|
|
participants: [
|
2018-06-15 11:03:24 -04:00
|
|
|
{ username: "eviltrout" },
|
|
|
|
{ username: "codinghorror" },
|
|
|
|
{ username: "sam" },
|
|
|
|
{ username: "ZogStrIP" }
|
2016-01-04 15:18:09 -05:00
|
|
|
],
|
2018-06-15 11:03:24 -04:00
|
|
|
userFilters: ["sam", "codinghorror"]
|
2016-01-04 15:18:09 -05:00
|
|
|
});
|
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(
|
2019-02-25 10:04:55 -05:00
|
|
|
find("li.avatars a.poster").length,
|
2018-06-15 11:03:24 -04:00
|
|
|
3,
|
|
|
|
"limits to three participants"
|
|
|
|
);
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
await click("nav.buttons button");
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("li.avatars a.poster").length, 0);
|
2018-07-24 11:49:42 -04:00
|
|
|
assert.equal(
|
2019-02-25 10:04:55 -05:00
|
|
|
find(".topic-map-expanded a.poster").length,
|
2018-07-24 11:49:42 -04:00
|
|
|
4,
|
|
|
|
"shows all when expanded"
|
|
|
|
);
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find("a.poster.toggled").length, 2, "two are toggled");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("topic map - links", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", {
|
2016-01-04 15:18:09 -05:00
|
|
|
showTopicMap: true,
|
|
|
|
topicLinks: [
|
2018-06-15 11:03:24 -04:00
|
|
|
{ url: "http://link1.example.com", clicks: 0 },
|
|
|
|
{ url: "http://link2.example.com", clicks: 0 },
|
|
|
|
{ url: "http://link3.example.com", clicks: 0 },
|
|
|
|
{ url: "http://link4.example.com", clicks: 0 },
|
|
|
|
{ url: "http://link5.example.com", clicks: 0 },
|
|
|
|
{ url: "http://link6.example.com", clicks: 0 }
|
2016-01-04 15:18:09 -05:00
|
|
|
]
|
|
|
|
});
|
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".topic-map").length, 1);
|
|
|
|
assert.equal(find(".map.map-collapsed").length, 1);
|
|
|
|
assert.equal(find(".topic-map-expanded").length, 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
await click("nav.buttons button");
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".map.map-collapsed").length, 0);
|
|
|
|
assert.equal(find(".topic-map .d-icon-chevron-up").length, 1);
|
|
|
|
assert.equal(find(".topic-map-expanded").length, 1);
|
2018-07-24 11:49:42 -04:00
|
|
|
assert.equal(
|
2019-02-25 10:04:55 -05:00
|
|
|
find(".topic-map-expanded .topic-link").length,
|
2018-07-24 11:49:42 -04:00
|
|
|
5,
|
|
|
|
"it limits the links displayed"
|
|
|
|
);
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
await click(".link-summary button");
|
|
|
|
assert.equal(
|
2019-02-25 10:04:55 -05:00
|
|
|
find(".topic-map-expanded .topic-link").length,
|
2018-07-24 11:49:42 -04:00
|
|
|
6,
|
|
|
|
"all links now shown"
|
|
|
|
);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("topic map - no summary", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { showTopicMap: true });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".toggle-summary").length, 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("topic map - has summary", {
|
2018-06-15 11:03:24 -04:00
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="post" args=args toggleSummary=(action "toggleSummary")}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { showTopicMap: true, hasTopicSummary: true });
|
|
|
|
this.on("toggleSummary", () => (this.summaryToggled = true));
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".toggle-summary").length, 1);
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
await click(".toggle-summary button");
|
|
|
|
assert.ok(this.summaryToggled);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("pm map", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", {
|
2016-01-04 15:18:09 -05:00
|
|
|
showTopicMap: true,
|
|
|
|
showPMMap: true,
|
|
|
|
allowedGroups: [],
|
2019-10-29 15:23:50 -04:00
|
|
|
allowedUsers: [EmberObject.create({ username: "eviltrout" })]
|
2016-01-04 15:18:09 -05:00
|
|
|
});
|
|
|
|
},
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.equal(find(".private-message-map").length, 1);
|
|
|
|
assert.equal(find(".private-message-map .user").length, 1);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
2019-03-08 03:48:35 -05:00
|
|
|
|
2019-03-13 15:16:09 -04:00
|
|
|
widgetTest("post notice - with username", {
|
2019-03-08 03:48:35 -05:00
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
|
|
|
beforeEach() {
|
2019-04-10 13:44:54 -04:00
|
|
|
const twoDaysAgo = new Date();
|
|
|
|
twoDaysAgo.setDate(twoDaysAgo.getDate() - 2);
|
2019-07-19 04:05:48 -04:00
|
|
|
this.siteSettings.display_name_on_posts = false;
|
2019-03-13 15:16:09 -04:00
|
|
|
this.siteSettings.prioritize_username_in_ux = true;
|
2019-03-18 12:20:49 -04:00
|
|
|
this.siteSettings.old_post_notice_days = 14;
|
2019-03-08 03:48:35 -05:00
|
|
|
this.set("args", {
|
2019-04-19 10:53:58 -04:00
|
|
|
noticeType: "returning_user",
|
|
|
|
noticeTime: twoDaysAgo,
|
2019-03-13 15:16:09 -04:00
|
|
|
username: "codinghorror",
|
2019-03-18 12:20:49 -04:00
|
|
|
name: "Jeff",
|
|
|
|
created_at: new Date()
|
2019-03-08 03:48:35 -05:00
|
|
|
});
|
|
|
|
},
|
|
|
|
test(assert) {
|
|
|
|
assert.equal(
|
2019-03-18 12:20:49 -04:00
|
|
|
find(".post-notice.returning-user:not(.old)")
|
2019-03-08 03:48:35 -05:00
|
|
|
.text()
|
|
|
|
.trim(),
|
2019-04-19 10:53:58 -04:00
|
|
|
I18n.t("post.notice.returning_user", {
|
|
|
|
user: "codinghorror",
|
2019-09-11 06:00:53 -04:00
|
|
|
time: "2 days ago"
|
2019-04-19 10:53:58 -04:00
|
|
|
})
|
2019-03-08 03:48:35 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2019-03-13 15:16:09 -04:00
|
|
|
|
|
|
|
widgetTest("post notice - with name", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
|
|
|
beforeEach() {
|
2019-07-19 04:05:48 -04:00
|
|
|
this.siteSettings.display_name_on_posts = true;
|
2019-03-13 15:16:09 -04:00
|
|
|
this.siteSettings.prioritize_username_in_ux = false;
|
2019-03-18 12:20:49 -04:00
|
|
|
this.siteSettings.old_post_notice_days = 14;
|
2019-03-13 15:16:09 -04:00
|
|
|
this.set("args", {
|
2019-04-19 10:53:58 -04:00
|
|
|
noticeType: "new_user",
|
2019-03-13 15:16:09 -04:00
|
|
|
username: "codinghorror",
|
2019-03-18 12:20:49 -04:00
|
|
|
name: "Jeff",
|
|
|
|
created_at: new Date(2019, 0, 1)
|
2019-03-13 15:16:09 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
test(assert) {
|
|
|
|
assert.equal(
|
2019-03-18 12:20:49 -04:00
|
|
|
find(".post-notice.old.new-user")
|
2019-03-13 15:16:09 -04:00
|
|
|
.text()
|
|
|
|
.trim(),
|
2019-04-19 10:53:58 -04:00
|
|
|
I18n.t("post.notice.new_user", { user: "Jeff", time: "Jan '10" })
|
2019-03-13 15:16:09 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2020-03-24 05:12:52 -04:00
|
|
|
|
|
|
|
widgetTest("show group request in post", {
|
|
|
|
template: '{{mount-widget widget="post" args=args}}',
|
|
|
|
beforeEach() {
|
|
|
|
this.set("args", {
|
|
|
|
username: "foo",
|
|
|
|
requestedGroupName: "testGroup"
|
|
|
|
});
|
|
|
|
},
|
|
|
|
test(assert) {
|
|
|
|
const link = find(".group-request a");
|
|
|
|
assert.equal(link.text().trim(), I18n.t("groups.requests.handle"));
|
|
|
|
assert.equal(link.attr("href"), "/g/testGroup/requests?filter=foo");
|
|
|
|
}
|
|
|
|
});
|