notifications: delete obsolete alerts

This commit is contained in:
Girish Ramakrishnan
2021-06-23 22:44:30 -07:00
parent 89607d2c64
commit 54dec7ae08
3 changed files with 47 additions and 13 deletions
+30
View File
@@ -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);
});
});