Files
supabase/apps/docs/components/Feedback/Feedback.utils.test.ts
Taha Le BrasandClaude Opus 4.8 de76c83238 feat(docs): route docs page feedback comments to Postgres (#46941)
## What

- Route docs page feedback **comments** to Postgres instead of `POST
/platform/feedback/docs` (which created duplicate Linear issues); the
👍/👎 vote is unchanged
- Store the comment on the **existing `feedback` row**: add `user_id` /
`title` / `comment`; submitting a comment updates the vote row the user
just created
- Capture the real `user_id` (`default auth.uid()`) so feedback is tied
to the user
- Owner-scoped RLS — `select`/`update` for authenticated users where
`user_id = auth.uid()`; anonymous votes stay insert-only
- Linear issues still get created, now via the data pipeline instead of
directly from the UI

## Linear

[DATAENG-1468](https://linear.app/supabase/issue/DATAENG-1468)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Feedback follow-ups now support saving a detailed title and comment,
tied to the signed-in user.
* **Bug Fixes**
* Follow-up submissions are now persisted in Supabase, ensuring the vote
and later details stay consistent for logged-in users.
* **Tests**
  * Added coverage for updating a feedback entry’s title and comment.
* **Chores**
* Removed the previous feedback submission endpoint/mutation flow in
favor of a Supabase update-based approach.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 12:32:09 +02:00

26 lines
796 B
TypeScript

import { describe, expect, it, vi } from 'vitest'
import { updateDocsFeedbackComment } from './Feedback.utils'
describe('updateDocsFeedbackComment', () => {
it('updates the feedback row by id with the comment', async () => {
const eq = vi.fn().mockResolvedValue({ error: null })
const update = vi.fn(() => ({ eq }))
const from = vi.fn(() => ({ update }))
const supabase = { from } as any
await updateDocsFeedbackComment(supabase, {
id: 42,
title: 'Great explanation',
comment: 'This page was really helpful.',
})
expect(from).toHaveBeenCalledWith('feedback')
expect(update).toHaveBeenCalledWith({
title: 'Great explanation',
comment: 'This page was really helpful.',
})
expect(eq).toHaveBeenCalledWith('id', 42)
})
})