discourse/test/javascripts/widgets/actions-summary-test.js.es6

92 lines
2.3 KiB
Plaintext
Raw Normal View History

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