Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,25 @@ describe('recommendationTelemetry', () => {
)
})

it('returns early without calling update when prisma client is unavailable', async () => {
mockGetPrismaClient.mockReturnValue(null)
const args: RecordSkipReasonArgs = {
recommendationId: 'rec-id-123',
skipReason: 'too_chill',
}

await recordRecommendationSkipReason(args)

expect(mockUpdate).not.toHaveBeenCalled()
})

it('persistence failure does not break skip flow', async () => {
const args: RecordSkipReasonArgs = {
recommendationId: 'rec-id-123',
skipReason: 'generic_dislike',
}

mockUpdate.mockRejectedValue(
new Error('Network timeout'),
)
mockUpdate.mockRejectedValue(new Error('Network timeout'))

const result = await recordRecommendationSkipReason(args)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ export async function recordRecommendationSkipReason(
): Promise<void> {
try {
const prisma = getPrismaClient()
if (!prisma) {
return
}

await prisma.recommendation.update({
where: { id: args.recommendationId },
Expand Down
Loading