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,
|
||||
}))
|
||||
|
||||
// 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', () => {
|
||||
let wrapper: VueWrapper<any>
|
||||
|
||||
@@ -569,7 +577,8 @@ describe('UserProfile - Email Digest Toggle', () => {
|
||||
plugins: [mockRouter],
|
||||
stubs: {
|
||||
EntityEditForm: {
|
||||
template: '<div><slot /></div>',
|
||||
template:
|
||||
'<div><slot name="custom-field-email" :modelValue="\'test@example.com\'" /></div>',
|
||||
},
|
||||
ModalDialog: {
|
||||
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 = ''
|
||||
savingDigest.value = true
|
||||
try {
|
||||
const res = await fetch('/api/user/profile', {
|
||||
method: 'PUT',
|
||||
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')
|
||||
emailDigestEnabled.value = newValue
|
||||
emailDigestEnabled.value = value
|
||||
} catch {
|
||||
digestError.value = 'Failed to save notification preference.'
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user