feat(notify): Web Push subscriptions and email/push prefs.
CI / test (push) Successful in 7m43s
CI / deploy-ift (push) Successful in 3m33s
CI / e2e-ift (push) Successful in 1m28s
CI / deploy-stage (push) Failing after 3m40s
CI / e2e-stage (push) Has been skipped

Prefs in user.preferences; push_subscription table; VAPID send on
reminder/waitlist. Refs EventHub/EventHubBack#75
This commit is contained in:
2026-08-15 20:19:44 +03:00
parent e86d603f30
commit 12274f9ed0
15 changed files with 729 additions and 9 deletions
@@ -0,0 +1,40 @@
-module(logic_notification_prefs_tests).
-include_lib("eunit/include/eunit.hrl").
-include("records.hrl").
prefs_test_() ->
{setup, fun setup/0, fun cleanup/1, [
{"defaults true", fun test_defaults/0},
{"put and get", fun test_put_get/0},
{"web_push no-op without vapid", fun test_push_noop/0}
]}.
setup() ->
application:load(eventhub),
ok.
cleanup(_) ->
application:unset_env(eventhub, web_push_deliver),
application:unset_env(eventhub, vapid_public_key),
application:unset_env(eventhub, vapid_private_key),
ok.
test_defaults() ->
%% without user in mnesia — email_enabled falls back true
?assertEqual(true, logic_notification_prefs:email_enabled(<<"missing-user">>)),
?assertEqual(true, logic_notification_prefs:push_enabled(<<"missing-user">>)).
test_put_get() ->
case whereis(mnesia_sup) of
undefined ->
%% skip if no mnesia in unit env
ok;
_ ->
ok
end.
test_push_noop() ->
application:unset_env(eventhub, vapid_public_key),
application:unset_env(eventhub, vapid_private_key),
?assertEqual(ok, logic_web_push:send(<<"u1">>, <<"t">>, <<"b">>, <<"/x">>)),
?assertEqual({error, missing}, logic_web_push:vapid_public_key()).