fix(calls): incoming-call ringtone respects quiet hours, DND, Focus Assist and snooze
CI / Build & Quality Checks (push) Canceled after 11s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Secret scan (gitleaks) (push) Canceled after 0s
CI / Docker image build & smoke test (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
CI / Build & Quality Checks (push) Canceled after 11s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Secret scan (gitleaks) (push) Canceled after 0s
CI / Docker image build & smoke test (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
The "should we make noise" predicate used for message sounds is extracted into useNotificationsQuiet() (unit-tested) and applied to the ringtone in both the full-screen incoming-call overlay and the compact in-call banner. The overlay/banner still show so the call can be answered; only the audio is skipped. Join/media paths untouched. Fixes #28 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
1 parent
4cdd221eff
commit
3dead4b3e1
4 files changed
+130
-42
No files matched your search
@@ -0,0 +1,55 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
// `useNotificationsQuiet.ts` pulls in `state/notificationSnooze.ts`, whose
|
||||
// `atomWithStorage(..., { getOnInit: true })` reads `localStorage` eagerly at
|
||||
// module-import time. Plain `node:test` has no `localStorage`, so install a
|
||||
// minimal stub before dynamically importing the module under test (mirrors the
|
||||
// mocking approach in `state/settings.test.ts`).
|
||||
(globalThis as { localStorage?: unknown }).localStorage = {
|
||||
getItem: () => null,
|
||||
setItem: () => undefined,
|
||||
removeItem: () => undefined,
|
||||
};
|
||||
|
||||
const { isNotificationsQuiet } = await import('./useNotificationsQuiet');
|
||||
|
||||
const base = {
|
||||
focusAssistActive: false,
|
||||
manualDnd: false,
|
||||
snoozeUntil: 0,
|
||||
quietHoursEnabled: false,
|
||||
quietHoursStart: '22:00',
|
||||
quietHoursEnd: '07:00',
|
||||
};
|
||||
|
||||
test('isNotificationsQuiet: quiet when none of the inputs are active', () => {
|
||||
assert.equal(isNotificationsQuiet(base), false);
|
||||
});
|
||||
|
||||
test('isNotificationsQuiet: active quiet-hours window suppresses (#28)', () => {
|
||||
const now = new Date(2026, 0, 1, 23, 0);
|
||||
assert.equal(isNotificationsQuiet({ ...base, quietHoursEnabled: true, now }), true);
|
||||
// Disabled setting is not enough on its own, even inside the window.
|
||||
assert.equal(isNotificationsQuiet({ ...base, quietHoursEnabled: false, now }), false);
|
||||
// Outside the window, enabling it does not suppress.
|
||||
const outside = new Date(2026, 0, 1, 12, 0);
|
||||
assert.equal(isNotificationsQuiet({ ...base, quietHoursEnabled: true, now: outside }), false);
|
||||
});
|
||||
|
||||
test('isNotificationsQuiet: presence/manual DND suppresses (#28)', () => {
|
||||
assert.equal(isNotificationsQuiet({ ...base, focusAssistActive: true }), true);
|
||||
assert.equal(isNotificationsQuiet({ ...base, manualDnd: true }), true);
|
||||
});
|
||||
|
||||
test('isNotificationsQuiet: an active snooze suppresses (#28)', () => {
|
||||
const now = Date.now();
|
||||
assert.equal(
|
||||
isNotificationsQuiet({ ...base, snoozeUntil: now + 60_000, now: new Date(now) }),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
isNotificationsQuiet({ ...base, snoozeUntil: now - 60_000, now: new Date(now) }),
|
||||
false,
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user