notifications: delete obsolete alerts
This commit is contained in:
@@ -80,4 +80,34 @@ describe('Notifications', function () {
|
||||
const [error] = await safe(notifications.del('random'));
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
});
|
||||
|
||||
let alertId;
|
||||
it('can add alert', async function () {
|
||||
alertId = await notifications.alert(notifications.ALERT_BOX_UPDATE, 'Cloudron xx is available', 'Awesome changelog');
|
||||
|
||||
const result = await notifications.get(alertId);
|
||||
expect(result.title).to.be('Cloudron xx is available');
|
||||
expect(result.message).to.be('Awesome changelog');
|
||||
expect(result.acknowledged).to.be(false);
|
||||
});
|
||||
|
||||
it('can update the alert', async function () {
|
||||
await notifications.update({ id: alertId }, { acknowledged: true }); // ack the alert
|
||||
|
||||
const id = await notifications.alert(notifications.ALERT_BOX_UPDATE, 'Cloudron xx is available', 'Awesome new changelog');
|
||||
expect(id).to.be(alertId);
|
||||
|
||||
const result = await notifications.get(alertId);
|
||||
expect(result.title).to.be('Cloudron xx is available');
|
||||
expect(result.message).to.be('Awesome new changelog');
|
||||
expect(result.acknowledged).to.be(false); // notification resurfaces
|
||||
});
|
||||
|
||||
it('can delete the alert', async function () {
|
||||
const id = await notifications.alert(notifications.ALERT_BOX_UPDATE, 'Cloudron xx is available', '');
|
||||
expect(id).to.be(null);
|
||||
|
||||
const result = await notifications.get(alertId);
|
||||
expect(result).to.be(null);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user