feat: add Daily Digest and Push Notifications toggles to User Profile with corresponding functionality
All checks were successful
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 2m37s

This commit is contained in:
2026-04-18 23:37:19 -04:00
parent 9efbb455d7
commit d7b1962903
2 changed files with 14 additions and 4 deletions

View File

@@ -26,6 +26,14 @@ vi.mock('../stores/auth', () => ({
suppressForceLogout: mockSuppressForceLogout, suppressForceLogout: mockSuppressForceLogout,
})) }))
// Mock push subscription service
vi.mock('../services/pushSubscription', () => ({
isSubscribedToPush: vi.fn().mockResolvedValue(false),
subscribeToPushWithResult: vi.fn().mockResolvedValue({ ok: true }),
unsubscribeFromPush: vi.fn().mockResolvedValue(undefined),
getPushPermissionState: vi.fn().mockReturnValue('default'),
}))
describe('UserProfile - Delete Account', () => { describe('UserProfile - Delete Account', () => {
let wrapper: VueWrapper<any> let wrapper: VueWrapper<any>
@@ -569,7 +577,8 @@ describe('UserProfile - Email Digest Toggle', () => {
plugins: [mockRouter], plugins: [mockRouter],
stubs: { stubs: {
EntityEditForm: { EntityEditForm: {
template: '<div><slot /></div>', template:
'<div><slot name="custom-field-email" :modelValue="\'test@example.com\'" /></div>',
}, },
ModalDialog: { ModalDialog: {
template: '<div class="mock-modal" v-if="show"><slot /></div>', template: '<div class="mock-modal" v-if="show"><slot /></div>',

View File

@@ -317,17 +317,18 @@ async function resetPassword() {
} }
} }
async function toggleDigest(newValue: boolean) { async function toggleDigest(newValue?: boolean) {
const value = newValue ?? !emailDigestEnabled.value
digestError.value = '' digestError.value = ''
savingDigest.value = true savingDigest.value = true
try { try {
const res = await fetch('/api/user/profile', { const res = await fetch('/api/user/profile', {
method: 'PUT', method: 'PUT',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email_digest_enabled: newValue }), body: JSON.stringify({ email_digest_enabled: value }),
}) })
if (!res.ok) throw new Error('Failed to update preference') if (!res.ok) throw new Error('Failed to update preference')
emailDigestEnabled.value = newValue emailDigestEnabled.value = value
} catch { } catch {
digestError.value = 'Failed to save notification preference.' digestError.value = 'Failed to save notification preference.'
} finally { } finally {