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