Skip to content

Add #341 report-flow integration test#640

Open
julietshen wants to merge 2 commits into
mainfrom
report-flow-integ-test
Open

Add #341 report-flow integration test#640
julietshen wants to merge 2 commits into
mainfrom
report-flow-integ-test

Conversation

@julietshen
Copy link
Copy Markdown
Member

@julietshen julietshen commented May 29, 2026

Summary

Closes #341 (part of the integration-test design in #288).

Submits a report via POST /api/v1/report against a real running stack and asserts the report flows through every system named in the issue:

  • Scylla (item_submission_by_thread) — reported item submission
  • ClickHouse (REPORTING_SERVICE.REPORTS) — analytics row written by ReportingService.submitReport
  • Postgres (manual_review_tool.job_creations) — review queue membership
  • "Simulated" NCMEC: when reportedForReason.csam = true, the report routes through NcmecService.enqueueForHumanReviewIfApplicable, which extracts the content's creator and enqueues the user (not the content). The job_creations.item_id flipping from content → creator is the observable difference from the standard path. The actual cybertip HTTP submission is downstream of a reviewer decision and intentionally out of scope.

Each test provisions its own content item type so item-type cache pollution from a prior test can't mask resolution problems.

Two new polling helpers in server/test/integ/wait.ts:

  • waitForReportInClickHouse — polls REPORTING_SERVICE.REPORTS
  • waitForJobCreationInPostgres — polls manual_review_tool.job_creations (the MRT row is the differentiator for the NCMEC vs. standard path — same table, different item_id)

The NCMEC scenario uses ScalarTypes.IMAGE. isMediaType returns true for IMAGE/AUDIO/VIDEO/MEDIA, and NcmecEnqueueToMrt uses the same generic scalarGetValues handler for all four, so any media-class scalar exercises the same code path. IMAGE keeps the test runnable today; once #632 (MEDIA wiring) lands, MEDIA would work the same way.

Dependency note

Running the integ suite locally on today's main currently fails type-check at services/itemProcessingService/fieldTypeHandlers.ts:83 because the Handlers type requires a MEDIA entry that #632 has not yet merged. This affects all integ tests, not just this one. Once #632 merges, this test should run cleanly via npm run test:integ.

Test plan

  • npm run up && npm run db:update then cd server && npm run test:integ -- report-flow.integ.test.ts and confirm both scenarios pass
  • Verify the standard scenario lands a job_creations row with item_id = content item
  • Verify the CSAM scenario lands a job_creations row with item_id = content creator (the NCMEC enqueue path)

🤖 Generated with Claude Code

Covers issue #341 from the integration test design in #288. Submits a
report via POST /api/v1/report and asserts the report flows through every
system named in the issue:

  - Scylla `item_submission_by_thread` — reported item submission
  - ClickHouse `REPORTING_SERVICE.REPORTS` — analytics row written by
    `ReportingService.submitReport`
  - Postgres `manual_review_tool.job_creations` — review queue membership
  - "Simulated" NCMEC: when `reportedForReason.csam = true`, the report
    routes through `NcmecService.enqueueForHumanReviewIfApplicable`,
    which extracts the content's creator and enqueues the USER instead of
    the content. The `job_creations` row's `item_id` flipping from the
    content item to the creator user is the observable difference from
    the standard path. The actual NCMEC HTTP submission is downstream of
    a reviewer decision and intentionally out of scope.

Each test provisions its own content item type so item-type cache
pollution from a prior test can't mask resolution problems in the
report path.

Supporting changes:

- server/test/integ/wait.ts: adds `waitForReportInClickHouse` (polls
  `REPORTING_SERVICE.REPORTS`) and `waitForJobCreationInPostgres` (polls
  `manual_review_tool.job_creations`). The MRT row is the differentiator
  for the NCMEC vs. standard path — same table, different `item_id`.

The NCMEC scenario uses ScalarTypes.IMAGE; `isMediaType` returns true
for IMAGE/AUDIO/VIDEO/MEDIA and the NCMEC enqueue path
(`NcmecEnqueueToMrt`) uses a single generic `scalarGetValues` handler
for all of them, so any media-class scalar exercises the same path.
IMAGE keeps the test runnable today.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

Warning

Review limit reached

@julietshen, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 38 minutes and 41 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a50d3353-df7b-4bb1-aef3-21a6207b5d1b

📥 Commits

Reviewing files that changed from the base of the PR and between 3290512 and b810ca7.

📒 Files selected for processing (2)
  • server/test/integ/report-flow.integ.test.ts
  • server/test/integ/wait.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch report-flow-integ-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Verified locally with both scenarios green. The afterAll teardown was
failing the suite on a known flake in
`deleteManualReviewQueueForTestsDO_NOT_USE`: it deletes
`manual_review_queues` and `users_and_accessible_queues` inside
`Promise.all`, so the FK delete can race the parent delete and raise a
`users_and_accessible_queues_queue_id_fkey` violation. Letting that
cascade through afterAll turned green tests into a red suite.

Match the runStep pattern from `setupIntegrationServer.shutdown`:
each cleanup runs in its own try/catch, errors are warned and the
remaining steps still execute.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@julietshen julietshen added this to the 1.0 milestone May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report flow integration test

1 participant