2021-03-22 12:33:58 +01:00
|
|
|
"use strict";
|
|
|
|
|
2024-10-09 00:25:41 +02:00
|
|
|
const assert = require("node:assert/strict");
|
2021-03-22 12:33:58 +01:00
|
|
|
|
2024-11-13 07:05:32 +01:00
|
|
|
const {zrequire} = require("./lib/namespace.cjs");
|
|
|
|
const {run_test} = require("./lib/test.cjs");
|
2021-03-22 12:33:58 +01:00
|
|
|
|
|
|
|
const settings_config = zrequire("settings_config");
|
2024-10-09 22:44:13 +02:00
|
|
|
const {set_realm} = zrequire("state_data");
|
2024-10-09 08:44:21 +02:00
|
|
|
const {initialize_user_settings} = zrequire("user_settings");
|
|
|
|
|
2024-10-09 22:44:13 +02:00
|
|
|
set_realm({});
|
2024-10-09 08:44:21 +02:00
|
|
|
const user_settings = {};
|
|
|
|
initialize_user_settings({user_settings});
|
2021-03-22 12:33:58 +01:00
|
|
|
|
2024-10-09 21:10:22 +02:00
|
|
|
run_test("all_notifications", ({override}) => {
|
|
|
|
override(user_settings, "enable_stream_desktop_notifications", false);
|
|
|
|
override(user_settings, "enable_stream_audible_notifications", true);
|
|
|
|
override(user_settings, "enable_stream_push_notifications", true);
|
|
|
|
override(user_settings, "enable_stream_email_notifications", false);
|
|
|
|
override(user_settings, "enable_desktop_notifications", false);
|
|
|
|
override(user_settings, "enable_sounds", true);
|
|
|
|
override(user_settings, "enable_offline_push_notifications", false);
|
|
|
|
override(user_settings, "enable_offline_email_notifications", true);
|
|
|
|
override(user_settings, "enable_followed_topic_desktop_notifications", false);
|
|
|
|
override(user_settings, "enable_followed_topic_audible_notifications", true);
|
|
|
|
override(user_settings, "enable_followed_topic_push_notifications", false);
|
|
|
|
override(user_settings, "enable_followed_topic_email_notifications", true);
|
|
|
|
override(user_settings, "enable_followed_topic_wildcard_mentions_notify", false);
|
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-27 15:46:23 +02:00
|
|
|
let error_message;
|
|
|
|
let error_name;
|
|
|
|
try {
|
|
|
|
settings_config.all_notifications(user_settings);
|
|
|
|
} catch (error) {
|
|
|
|
error_name = error.name;
|
|
|
|
error_message = error.message;
|
|
|
|
}
|
|
|
|
assert.equal(error_name, "TypeError");
|
|
|
|
assert.equal(error_message, "Incorrect setting_name passed: wildcard_mentions_notify");
|
2021-07-23 19:42:57 +02:00
|
|
|
|
2024-10-09 21:10:22 +02:00
|
|
|
override(user_settings, "wildcard_mentions_notify", false);
|
2021-08-27 15:46:23 +02:00
|
|
|
const notifications = settings_config.all_notifications(user_settings);
|
2021-03-22 12:33:58 +01:00
|
|
|
|
|
|
|
assert.deepEqual(notifications.general_settings, [
|
|
|
|
{
|
2024-04-18 18:36:57 +02:00
|
|
|
label: "translated: Channels",
|
2021-03-22 12:33:58 +01:00
|
|
|
notification_settings: [
|
|
|
|
{
|
|
|
|
is_checked: false,
|
|
|
|
is_disabled: false,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: false,
|
2021-03-22 12:33:58 +01:00
|
|
|
setting_name: "enable_stream_desktop_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: true,
|
|
|
|
is_disabled: false,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: false,
|
2021-03-22 12:33:58 +01:00
|
|
|
setting_name: "enable_stream_audible_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: true,
|
|
|
|
is_disabled: true,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: true,
|
2021-03-22 12:33:58 +01:00
|
|
|
setting_name: "enable_stream_push_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: false,
|
|
|
|
is_disabled: false,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: false,
|
2021-03-22 12:33:58 +01:00
|
|
|
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,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: false,
|
2021-03-22 12:33:58 +01:00
|
|
|
setting_name: "wildcard_mentions_notify",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2023-01-24 19:49:56 +01:00
|
|
|
label: "translated: DMs, mentions, and alerts",
|
2021-03-22 12:33:58 +01:00
|
|
|
notification_settings: [
|
|
|
|
{
|
|
|
|
is_checked: false,
|
|
|
|
is_disabled: false,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: false,
|
2021-03-22 12:33:58 +01:00
|
|
|
setting_name: "enable_desktop_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: true,
|
|
|
|
is_disabled: false,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: false,
|
2021-03-22 12:33:58 +01:00
|
|
|
setting_name: "enable_sounds",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: false,
|
|
|
|
is_disabled: true,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: true,
|
2021-03-22 12:33:58 +01:00
|
|
|
setting_name: "enable_offline_push_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: true,
|
|
|
|
is_disabled: false,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: false,
|
2021-03-22 12:33:58 +01:00
|
|
|
setting_name: "enable_offline_email_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: false,
|
|
|
|
is_disabled: true,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: false,
|
2021-03-22 12:33:58 +01:00
|
|
|
setting_name: "",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-06-13 13:18:55 +02:00
|
|
|
{
|
|
|
|
label: "translated: Followed topics",
|
|
|
|
notification_settings: [
|
|
|
|
{
|
|
|
|
is_checked: false,
|
|
|
|
is_disabled: false,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: false,
|
2023-06-13 13:18:55 +02:00
|
|
|
setting_name: "enable_followed_topic_desktop_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: true,
|
|
|
|
is_disabled: false,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: false,
|
2023-06-13 13:18:55 +02:00
|
|
|
setting_name: "enable_followed_topic_audible_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: false,
|
|
|
|
is_disabled: true,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: true,
|
2023-06-13 13:18:55 +02:00
|
|
|
setting_name: "enable_followed_topic_push_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: true,
|
|
|
|
is_disabled: false,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: false,
|
2023-06-13 13:18:55 +02:00
|
|
|
setting_name: "enable_followed_topic_email_notifications",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
is_checked: false,
|
|
|
|
is_disabled: false,
|
2023-11-27 23:50:45 +01:00
|
|
|
is_mobile_checkbox: false,
|
2023-06-13 13:18:55 +02:00
|
|
|
setting_name: "enable_followed_topic_wildcard_mentions_notify",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-03-22 12:33:58 +01:00
|
|
|
]);
|
|
|
|
});
|