diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 79da92312..12de22ca8 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -59,7 +59,7 @@ jobs: cache: "npm" - name: Cache Playwright browsers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }} diff --git a/.gitignore b/.gitignore index 3bb96bd26..8320e48d4 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,9 @@ logs/ .claude/ .cursor/ .aider* + +# Local MCP server config (may hold personal API keys) +.mcp.json + +# Written by `next dev` +AGENTS.md diff --git a/.mcp.json b/.mcp.json deleted file mode 100644 index a86d7c2c4..000000000 --- a/.mcp.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "mcpServers": { - "context7": { - "command": "npx", - "args": ["-y", "@upstash/context7-mcp"], - "env": { - "CONTEXT7_API_KEY": "ctx7sk-1d829fe1-62b2-4697-b7f4-673ae5047efd" - } - }, - "puppeteer": { - "command": "npx", - "args": ["-y", "puppeteer-mcp-server"], - "env": {} - }, - "next-devtools": { - "command": "npx", - "args": ["-y", "next-devtools-mcp@latest"] - }, - "sequential-thinking": { - "command": "npx", - "args": ["-y", "@modelcontextprotocol/server-sequential-thinking"] - }, - "Sentry": { - "url": "https://mcp.sentry.dev/mcp/assemble-pro/javascript-nextjs" - } - } -} diff --git a/E2E Overview.md b/E2E Overview.md deleted file mode 100644 index ba0146638..000000000 --- a/E2E Overview.md +++ /dev/null @@ -1,36 +0,0 @@ -# End-to-End Testing with Playwright - -To run the end-to-end tests using Playwright, you need to configure your environment and follow these steps: - -### Session and User Setup - -First, you need to add your E2E test user to your locally running database. Do this by running the following script if you haven't already: - -```bash -npm run db:seed -``` - -This will create a user and session for your E2E tests. Details of the E2E user created can be seen in `drizzle/seedE2E.ts`. - -### Running the Tests - -You can run the end-to-end tests using one of the following commands: - -For headless mode: - -```bash -npx playwright test -``` - -For UI mode: - -```bash -npx playwright test --ui -``` - -### Additional E2E constants - -- **E2E_USER_ONE_SESSION_ID**: This is the session token UUID for one E2E user. -- **E2E_USER_TWO_SESSION_ID**: This is the session token UUID for another E2E user. -- **E2E_USER_ONE_ID**: The user ID of one of the E2E users. -- **E2E_USER_TWO_ID**: The user ID of another E2E user. diff --git a/app/(admin)/admin/_client.tsx b/app/(admin)/admin/_client.tsx index 35c33d90a..daf0d6273 100644 --- a/app/(admin)/admin/_client.tsx +++ b/app/(admin)/admin/_client.tsx @@ -12,12 +12,7 @@ import { import { api } from "@/server/trpc/react"; type StatTone = - | "accent" - | "success" - | "warning" - | "danger" - | "info" - | "neutral"; + "accent" | "success" | "warning" | "danger" | "info" | "neutral"; const toneClasses: Record = { accent: "bg-accent/10 text-accent", diff --git a/app/(admin)/admin/moderation/_client.tsx b/app/(admin)/admin/moderation/_client.tsx index 285bcc28e..cbfece7e7 100644 --- a/app/(admin)/admin/moderation/_client.tsx +++ b/app/(admin)/admin/moderation/_client.tsx @@ -122,12 +122,30 @@ const ModerationQueue = () => { }, }); + // System (auto-flagged) reports live in their own table with their own ids, + // so they are dismissed through a separate mutation from member reports. + const { mutate: dismissSystemReport, isPending: isDismissingSystem } = + api.report.dismissSystem.useMutation({ + onSuccess: () => { + toast.success("Report dismissed"); + utils.admin.listReportedPosts.invalidate(); + utils.admin.listFlaggedComments.invalidate(); + utils.report.getCounts.invalidate(); + }, + onError: () => { + toast.error("Failed to dismiss report"); + }, + }); + // Auto-moderation queue (posts awaiting review). const inReview = api.admin.listInReview.useQuery(); - // Live posts that have been flagged by users (open reports on published posts). + // Live posts with open reports, from members or the nightly review. const reportedPosts = api.admin.listReportedPosts.useQuery(); + // Comments flagged by the nightly review. + const flaggedComments = api.admin.listFlaggedComments.useQuery(); + const { mutate: moderatePost, isPending: isModerating } = api.admin.moderatePost.useMutation({ onSuccess: (_data, variables) => { @@ -167,7 +185,10 @@ const ModerationQueue = () => { }; // Dismiss all open reports for a reported-live post (the post stays published). - const handleDismissReportedPost = (reportIds: number[]) => { + const handleDismissReportedPost = ( + reportIds: number[], + systemReportIds: number[], + ) => { reportIds.forEach((reportId) => reviewReport({ reportId, @@ -175,6 +196,7 @@ const ModerationQueue = () => { actionTaken: "Reports dismissed by admin", }), ); + systemReportIds.forEach((reportId) => dismissSystemReport({ reportId })); utils.admin.listReportedPosts.invalidate(); }; @@ -373,7 +395,7 @@ const ModerationQueue = () => { - {/* Reported (live) — published posts users have flagged */} + {/* Reported (live) — published posts flagged by users or the nightly review */}

@@ -427,6 +449,11 @@ const ModerationQueue = () => { {reasonLabels[post.latestReason as ReportReason] ?? post.latestReason} + {post.systemReportIds.length > 0 && ( + + Auto-flagged + + )} {post.latestDetails && ( {post.latestDetails} @@ -457,8 +484,98 @@ const ModerationQueue = () => { +

+ + + ))} + +
+ + {/* Flagged comments — comments the nightly review has auto-flagged */} +
+
+

+ {"// "}flagged comments +

+ + {flaggedComments.data?.length ?? 0} flagged + +
+ + {flaggedComments.isLoading && ( +

Loading…

+ )} + + {!flaggedComments.isLoading && + (flaggedComments.data?.length ?? 0) === 0 && ( +

+ {"// no flagged comments"} +

+ )} + +
+ {flaggedComments.data?.map((comment) => ( +
+
+
+

{comment.body}

+

+ @{comment.authorUsername ?? "unknown"} on{" "} + {comment.parentTitle || "Untitled"} ·{" "} + {getRelativeTime(comment.reportedAt)} + {comment.isDeleted ? " · deleted" : ""} +

+
+ + {reasonLabels[comment.reason as ReportReason] ?? + comment.reason} + + + Auto-flagged + + {comment.details && ( + + {comment.details} + + )} +
+
+
+ {comment.href && ( + + + View + + )} +