Skip to content

Commit 6f4c8ea

Browse files
committed
Suppress email errors during tests.
1 parent b7ec17b commit 6f4c8ea

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

app/composables/useAuth.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,29 @@ export const useAuth = () => {
118118

119119
const isLoggedIn = computed(() => !!user.value)
120120

121+
const deleteAccount = async (password: string) => {
122+
try {
123+
const response = await $fetch('/api/profile/account', {
124+
method: 'DELETE',
125+
body: { password }
126+
}) as { success: boolean; message?: string }
127+
128+
if (response.success) {
129+
user.value = null
130+
clearCache()
131+
await navigateTo('/login')
132+
return { success: true }
133+
}
134+
135+
return { success: false, message: 'Account deletion failed' }
136+
} catch (error: any) {
137+
return {
138+
success: false,
139+
message: error.data?.statusMessage || 'An error occurred while deleting your account'
140+
}
141+
}
142+
}
143+
121144
return {
122145
user: readonly(user),
123146
authReady: readonly(authReady),
@@ -127,6 +150,7 @@ export const useAuth = () => {
127150
checkAuth,
128151
restoreFromCache,
129152
isLoggedIn,
153+
deleteAccount,
130154
setAuthReady: (value: boolean) => { authReady.value = value }
131155
}
132156
}

server/utils/email.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ export async function sendEmail(options: EmailOptions): Promise<boolean> {
205205

206206
return true
207207
} catch (error) {
208-
console.error('[Email] Error sending:', error)
208+
if (!process.env.VITEST) {
209+
console.error('[Email] Error sending:', error)
210+
}
209211
return false
210212
}
211213
}
@@ -246,7 +248,9 @@ export async function sendTemplateEmail(options: TemplateEmailOptions): Promise<
246248
from: options.from
247249
})
248250
} catch (error) {
249-
console.error('[Email] Error sending template email:', error)
251+
if (!process.env.VITEST) {
252+
console.error('[Email] Error sending template email:', error)
253+
}
250254
return false
251255
}
252256
}

0 commit comments

Comments
 (0)