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
All checks were successful
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 2m37s
This commit is contained in:
@@ -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>',
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user