Skip to content
76 changes: 76 additions & 0 deletions apps/web/e2e/QUARANTINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -750,3 +750,79 @@ no such part beyond the wrong notification).
revisit) is swallowed and the invitee sees "Something went wrong". The
invite is accepted all the same. Fix: use the router's `isRedirect(err)`.
owner: unassigned, review by: 2026-12-03.

### Product suite: feedback admin (inbox and posts)

- `feedback/admin-inbox.spec.ts` › FBA-I-11 Responded lists posts with a public
team reply; a private note is not a response. Product bug: the Team response
filter (and its counts) treats a private internal note as a response, because
`teamResponseExistsSql` (`apps/web/src/lib/server/domains/posts/post.inbox.ts:43`)
matches any live comment with `is_team_member = true`. Fix: add
`AND post_comments.is_private = false` (and `moderation_state <> 'pending'`)
to that EXISTS. owner: unassigned, review by: 2026-12-03.
- `feedback/admin-inbox.spec.ts` › FBA-I-12 Has duplicates lists only posts with a
pending suggestion, and nothing when none has one. Product bug: the filter
runs in the browser (`feedback-table-view.tsx:244`) and is skipped when the
counts map is `undefined`, which `inbox-container.tsx:85` returns whenever no
loaded post has a pending suggestion, so every post is listed. Fix: filter on
the server (`hasDuplicates` in `post.inbox.ts`), or treat a missing map as
"no post has duplicates" when the filter is on. owner: unassigned, review by:
- `feedback/admin-inbox.spec.ts` › FBA-I-32 a failed list read shows Failed to
load feedback, and Try again recovers. Product bug: the error component's Try
again (`apps/web/src/routes/admin/feedback.index.tsx:71`) calls only the error
boundary's `reset`, so the failed loader is never re-run and the alert stays
until a full reload. Fix: `onClick={() => { router.invalidate(); reset() }}`
(or `useQueryErrorResetBoundary`). owner: unassigned, review by: 2026-12-03.
- `feedback/admin-post-actions.spec.ts` › FBA-P-04 a post created over REST
without a status gets the workspace default status (`@isolated`). Product
bug: `createPost` falls back to the status slugged `open`
(`apps/web/src/lib/server/domains/posts/post.service.ts:145`), not the one
marked default, so REST, MCP and Track as feedback ignore a changed default
while the portal and admin dialog follow it. Fix: look up
`is_default = true` there (falling back to `open`). owner: unassigned,
review by: 2026-12-03.
- `feedback/admin-post-actions.spec.ts` › FBA-P-08 choosing the status a post
already has changes nothing. Product bug: `changeStatus`
(`apps/web/src/lib/server/domains/posts/post.status.ts:72`) has no
same-status guard, so re-picking the current status writes a
`status.changed` activity, fires `post.status_changed` (Open to Open) and
emails subscribers. Fix: return early when the post already has `statusId`.
owner: unassigned, review by: 2026-12-03.
- `feedback/admin-post-actions.spec.ts` › FBA-P-11 a post owner must be a
teammate. Product bug: `setPostOwnerFn`
(`apps/web/src/lib/server/functions/posts.ts:497`) accepts any principal
id, so a customer can be made owner (and gets the owner bell). Fix: load the
principal and refuse unless its role is admin or member. owner: unassigned,
review by: 2026-12-03.
- `feedback/admin-post-actions.spec.ts` › FBA-P-17 post.deleted from the post
modal names who deleted it. Product bug: `softDeletePost` builds the event
actor from principal and user ids only
(`apps/web/src/lib/server/domains/posts/post.user-actions.ts:332`), so
`dispatchPostDeleted` (`apps/web/src/lib/server/events/dispatch.ts:265`)
finds no email or name and the webhook carries no `deletedBy`. Fix: pass the
actor's email and display name into `buildEventActor`. owner: unassigned,
review by: 2026-12-03.
- `feedback/admin-post-actions.spec.ts` › FBA-P-21 deleting a canonical post
does not hide its merged duplicates. Product bug: `softDeletePost`
(`apps/web/src/lib/server/domains/posts/post.user-actions.ts:243`) only
recounts when the deleted post is itself a duplicate; the duplicates of a
deleted canonical keep `canonical_post_id`, and the inbox hides every such
post (`apps/web/src/lib/server/domains/posts/post.inbox.ts:100`). Fix:
unmerge (or re-point) the duplicates when a canonical is deleted. owner:
unassigned, review by: 2026-12-03.
- `feedback/admin-post-comments.spec.ts` › FBA-P-30 a teammate without
post.set_status cannot change status through a comment. Product bug:
`createComment` applies `statusId` for any team author
(`apps/web/src/lib/server/domains/comments/comment.service.ts:146`) and
`createCommentFn` checks no status permission, so a role without
post.set_status changes status through the comment box. Fix: require
post.set_status for `shouldChangeStatus`. owner: unassigned, review by:
2026-12-03.
- `feedback/admin-inbox.spec.ts` › FBA-I-27 a teammate cannot delete a colleague’s
private saved view. Product bug: `deletePostViewFn` checks only post.edit and
`deleteView` (`apps/web/src/lib/server/domains/post-views/post-views.service.ts:76`)
updates by id with no owner or shared check, so any post.edit holder deletes
a private view they cannot even list (or anyone's shared view). Fix: pass the
caller and add `created_by_principal_id = caller OR (is_shared AND caller is
admin)` to the update; refuse when no row matched. owner: unassigned, review
by: 2026-12-03.
160 changes: 160 additions & 0 deletions apps/web/e2e/product/feedback-admin-inbox.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/**
* Helpers for the feedback inbox journeys (FBA-I-*, e2e/tests/feedback/admin-inbox.spec.ts).
* The shared seeding helpers are in ./feedback-admin.ts.
*/
import { expect, type APIRequestContext, type Locator, type Page } from '@playwright/test'
import { fromUuid, generateId, toUuid } from '@quackback/ids'
import { callServerFn } from '../support/server-fns'
import { supportDb } from '../support/db'
import { uuid } from './feedback-admin'

/** An option in the inbox's filter pane, by its accessible name `Name, count`. */
export function filterOption(page: Page, name: string, count?: number): Locator {
return page.getByRole('option', {
name:
count === undefined ? new RegExp(`^${escapeRegExp(name)}(, \\d+)?$`) : `${name}, ${count}`,
exact: count !== undefined,
})
}

/** A comment on a post by whoever `api` is (a teammate), via createCommentFn. */
export async function addComment(
api: APIRequestContext,
postId: string,
content: string,
opts: { isPrivate?: boolean } = {}
): Promise<string> {
const res = await callServerFn<{ id: string }>(api, 'createCommentFn', {
postId,
content,
...opts,
})
if (!res.ok) throw new Error(`createCommentFn failed: ${res.raw.slice(0, 300)}`)
return res.data.id
}

/** Set (or clear with null) a post's owner via setPostOwnerFn. */
export async function setOwner(
api: APIRequestContext,
postId: string,
ownerId: string | null
): Promise<void> {
const res = await callServerFn(api, 'setPostOwnerFn', { id: postId, ownerId })
if (!res.ok) throw new Error(`setPostOwnerFn failed: ${res.raw.slice(0, 300)}`)
}

/** Put tags on a post via updatePostTagsFn. */
export async function setTags(
api: APIRequestContext,
postId: string,
tagIds: string[]
): Promise<void> {
const res = await callServerFn(api, 'updatePostTagsFn', { id: postId, tagIds })
if (!res.ok) throw new Error(`updatePostTagsFn failed: ${res.raw.slice(0, 300)}`)
}

/** A pending merge suggestion between two posts (source is the likely duplicate). */
export async function insertSuggestion(
sourcePostId: string,
targetPostId: string
): Promise<string> {
const id = toUuid(generateId('post_merge_suggestion'))
await supportDb()`
INSERT INTO post_merge_suggestions
(id, source_post_id, target_post_id, status, vector_score, fts_score, hybrid_score, llm_confidence)
VALUES (${id}, ${uuid(sourcePostId)}, ${uuid(targetPostId)}, 'pending', 0.9, 0.5, 0.8, 0.9)`
return id
}

/** Set a post's timestamps or counters directly (preconditions only). */
export async function backdatePost(
postId: string,
fields: { createdDaysAgo?: number; deletedDaysAgo?: number; updatedDaysAgo?: number }
): Promise<void> {
const sql = supportDb()
const id = uuid(postId)
if (fields.createdDaysAgo !== undefined)
await sql`UPDATE posts SET created_at = now() - make_interval(days => ${fields.createdDaysAgo})
WHERE id = ${id}`
if (fields.deletedDaysAgo !== undefined)
await sql`UPDATE posts SET deleted_at = now() - make_interval(days => ${fields.deletedDaysAgo})
WHERE id = ${id}`
if (fields.updatedDaysAgo !== undefined)
await sql`UPDATE posts SET updated_at = now() - make_interval(days => ${fields.updatedDaysAgo})
WHERE id = ${id}`
}

/** The current URL's search param, decoded the router's way (JSON when it parses). */
export function searchParam(page: Page, key: string): unknown {
const raw = new URL(page.url()).searchParams.get(key)
if (raw === null) return undefined
try {
return JSON.parse(raw)
} catch {
return raw
}
}

/** Wait until the inbox shows exactly these marker titles, in any order. */
export async function expectTitlesUnordered(
page: Page,
marker: string,
titles: string[]
): Promise<void> {
await expect
.poll(async () => {
const shown = await page.locator('h3').allInnerTexts()
return shown
.map((t) => t.trim())
.filter((t) => t.includes(marker))
.sort()
})
.toEqual([...titles].sort())
}

/**
* One of the post modal's Manage icon buttons, found by its tooltip (the
* buttons carry no accessible name). Throws when no button has that tooltip.
*/
export async function manageButton(page: Page, tooltip: string): Promise<Locator> {
const buttons = page.getByRole('dialog').getByRole('complementary').getByRole('button')
await expect(buttons.first()).toBeVisible({ timeout: 15_000 })
for (let i = 0; i < 6; i++) {
await buttons.nth(i).hover()
const shown = await page
.getByText(tooltip, { exact: true })
.last()
.waitFor({ state: 'visible', timeout: 1_500 })
.then(() => true)
.catch(() => false)
if (shown) return buttons.nth(i)
}
throw new Error(`No Manage button with the tooltip "${tooltip}"`)
}

/** A manual segment holding these principals (raw uuids). */
export async function makeSegment(
name: string,
principalUuids: string[]
): Promise<{ id: string; name: string }> {
const sql = supportDb()
const id = toUuid(generateId('segment'))
const slug = `${name.toLowerCase().replace(/[^a-z0-9]+/g, '-')}-${id.slice(0, 6)}`
await sql`INSERT INTO segments (id, name, type, slug) VALUES (${id}, ${name}, 'manual', ${slug})`
for (const principal of principalUuids) {
await sql`INSERT INTO user_segments (principal_id, segment_id) VALUES (${principal}, ${id})`
}
return { id: fromUuid('segment', id), name }
}

/** A lowercase word no other post contains (letters only, so search reads it whole). */
export function uniqueWord(): string {
const letters = 'abcdefghijklmnopqrstuvwxyz'
let word = ''
for (let i = 0; i < 10; i++) word += letters[Math.floor(Math.random() * letters.length)]
return `zq${word}`
}

function escapeRegExp(text: string): string {
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
}
Loading
Loading