2018-06-15 23:03:24 +08:00
|
|
|
import { moduleForWidget, widgetTest } from "helpers/widget-test";
|
2016-01-05 04:18:09 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
moduleForWidget("actions-summary");
|
2016-01-05 04:18:09 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
widgetTest("listing actions", {
|
2016-01-05 04:18:09 +08:00
|
|
|
template: '{{mount-widget widget="actions-summary" args=args}}',
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2018-06-15 23:03:24 +08:00
|
|
|
this.set("args", {
|
2016-01-05 04:18:09 +08:00
|
|
|
actionsSummary: [
|
2018-06-15 23:03:24 +08:00
|
|
|
{ id: 1, action: "off_topic", description: "very off topic" },
|
|
|
|
{ id: 2, action: "spam", description: "suspicious message" }
|
2016-01-05 04:18:09 +08:00
|
|
|
]
|
|
|
|
});
|
|
|
|
},
|
2018-07-24 23:49:42 +08:00
|
|
|
async test(assert) {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(this.$(".post-actions .post-action").length, 2);
|
2016-01-05 04:18:09 +08:00
|
|
|
|
2018-07-24 23:49:42 +08:00
|
|
|
await click(".post-action:eq(0) .action-link a");
|
|
|
|
assert.equal(
|
|
|
|
this.$(".post-action:eq(0) img.avatar").length,
|
|
|
|
1,
|
|
|
|
"clicking it shows the user"
|
|
|
|
);
|
2016-01-05 04:18:09 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
widgetTest("undo", {
|
|
|
|
template:
|
|
|
|
'{{mount-widget widget="actions-summary" args=args undoPostAction=undoPostAction}}',
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2018-06-15 23:03:24 +08:00
|
|
|
this.set("args", {
|
2016-01-05 04:18:09 +08:00
|
|
|
actionsSummary: [
|
2018-06-15 23:03:24 +08:00
|
|
|
{ action: "off_topic", description: "very off topic", canUndo: true }
|
2016-01-05 04:18:09 +08:00
|
|
|
]
|
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
this.set("undoPostAction", () => (this.undid = true));
|
2016-01-05 04:18:09 +08:00
|
|
|
},
|
2018-07-24 23:49:42 +08:00
|
|
|
async test(assert) {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(this.$(".post-actions .post-action").length, 1);
|
2016-01-05 04:18:09 +08:00
|
|
|
|
2018-07-24 23:49:42 +08:00
|
|
|
await click(".action-link.undo");
|
|
|
|
assert.ok(this.undid, "it triggered the action");
|
2016-01-05 04:18:09 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
widgetTest("deferFlags", {
|
|
|
|
template:
|
2019-01-10 18:06:01 +08:00
|
|
|
'{{mount-widget widget="actions-summary" args=args deferPostActionFlags=(action "deferPostActionFlags")}}',
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2018-06-15 23:03:24 +08:00
|
|
|
this.set("args", {
|
2016-01-05 04:18:09 +08:00
|
|
|
actionsSummary: [
|
2018-06-15 23:03:24 +08:00
|
|
|
{
|
|
|
|
action: "off_topic",
|
|
|
|
description: "very off topic",
|
|
|
|
canDeferFlags: true,
|
|
|
|
count: 1
|
|
|
|
}
|
2016-01-05 04:18:09 +08:00
|
|
|
]
|
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
this.on("deferPostActionFlags", () => (this.deferred = true));
|
2016-01-05 04:18:09 +08:00
|
|
|
},
|
2018-07-24 23:49:42 +08:00
|
|
|
async test(assert) {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(this.$(".post-actions .post-action").length, 1);
|
2016-01-05 04:18:09 +08:00
|
|
|
|
2018-07-24 23:49:42 +08:00
|
|
|
await click(".action-link.defer-flags");
|
|
|
|
assert.ok(this.deferred, "it triggered the action");
|
2016-01-05 04:18:09 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
widgetTest("post deleted", {
|
2016-01-05 04:18:09 +08:00
|
|
|
template: '{{mount-widget widget="actions-summary" args=args}}',
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2018-06-15 23:03:24 +08:00
|
|
|
this.set("args", {
|
2016-03-04 00:40:35 +08:00
|
|
|
deleted_at: "2016-01-01",
|
2018-06-15 23:03:24 +08:00
|
|
|
deletedByUsername: "eviltrout",
|
|
|
|
deletedByAvatarTemplate: "/images/avatar.png"
|
2016-01-05 04:18:09 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
test(assert) {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.ok(
|
2019-01-22 19:02:02 +08:00
|
|
|
this.$(".post-action .d-icon-far-trash-alt").length === 1,
|
2018-06-15 23:03:24 +08:00
|
|
|
"it has the deleted icon"
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
this.$(".avatar[title=eviltrout]").length === 1,
|
|
|
|
"it has the deleted by avatar"
|
|
|
|
);
|
2016-01-05 04:18:09 +08:00
|
|
|
}
|
|
|
|
});
|