2021-03-22 12:33:58 +01:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const {strict: assert} = require("assert");
|
|
|
|
|
2021-03-25 22:35:45 +01:00
|
|
|
const {zrequire} = require("../zjsunit/namespace");
|
2021-03-22 12:33:58 +01:00
|
|
|
const {run_test} = require("../zjsunit/test");
|
2021-07-28 16:00:58 +02:00
|
|
|
const {user_settings} = require("../zjsunit/zpage_params");
|
2021-03-22 12:33:58 +01:00
|
|
|
|
|
|
|
const settings_config = zrequire("settings_config");
|
|
|
|
|
|
|
|
run_test("all_notifications", () => {
|
2021-07-28 16:00:58 +02:00
|
|
|
user_settings.enable_stream_desktop_notifications = false;
|
|
|
|
user_settings.enable_stream_audible_notifications = true;
|
|
|
|
user_settings.enable_stream_push_notifications = true;
|
|
|
|
user_settings.enable_stream_email_notifications = false;
|
|
|
|
user_settings.enable_desktop_notifications = false;
|
|
|
|
user_settings.enable_sounds = true;
|
|
|
|
user_settings.enable_offline_push_notifications = false;
|
|
|
|
user_settings.enable_offline_email_notifications = true;
|
2021-03-22 12:33:58 +01:00
|
|
|
|
2021-07-23 19:42:57 +02:00
|
|
|
// Check that it throws error if incorrect settings name
|
|
|
|
// is passed. In this case, we articulate that with
|
|
|
|
// wildcard_mentions_notify being undefined, which will be
|
|
|
|
// the case, if a wrong setting_name is passed.
|
2021-08-10 22:18:53 +02:00
|
|
|
assert.throws(settings_config.all_notifications, {
|
|
|
|
name: "TypeError",
|
|
|
|
message: "Incorrect setting_name passed: wildcard_mentions_notify",
|
|
|
|
});
|
2021-07-23 19:42:57 +02:00
|
|
|
|
2021-07-28 16:00:58 +02:00
|
|
|
user_settings.wildcard_mentions_notify = false;
|
2021-03-22 12:33:58 +01:00
|
|
|
const notifications = settings_config.all_notifications();
|
|
|
|
|
|
|
|
assert.deepEqual(notifications.general_settings, [
|
|
|
|
{
|
|
|
|
label: "translated: Streams",
|
|
|
|
notification_settings: [
|
|
|
|
{
|
|
|
|
is_checked: false,
|
|
|
|
is_disabled: false,
|
|
|
|
setting_name: "enable_stream_desktop_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: true,
|
|
|
|
is_disabled: false,
|
|
|
|
setting_name: "enable_stream_audible_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: true,
|
|
|
|
is_disabled: true,
|
|
|
|
setting_name: "enable_stream_push_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: false,
|
|
|
|
is_disabled: false,
|
|
|
|
setting_name: "enable_stream_email_notifications",
|
|
|
|
},
|
|
|
|
{
|
2021-07-23 19:42:57 +02:00
|
|
|
is_checked: false,
|
2021-03-22 12:33:58 +01:00
|
|
|
is_disabled: false,
|
|
|
|
setting_name: "wildcard_mentions_notify",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "translated: PMs, mentions, and alerts",
|
|
|
|
notification_settings: [
|
|
|
|
{
|
|
|
|
is_checked: false,
|
|
|
|
is_disabled: false,
|
|
|
|
setting_name: "enable_desktop_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: true,
|
|
|
|
is_disabled: false,
|
|
|
|
setting_name: "enable_sounds",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: false,
|
|
|
|
is_disabled: true,
|
|
|
|
setting_name: "enable_offline_push_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: true,
|
|
|
|
is_disabled: false,
|
|
|
|
setting_name: "enable_offline_email_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: false,
|
|
|
|
is_disabled: true,
|
|
|
|
setting_name: "",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
});
|