Skip to content

test(e2e): API REST journeys (posts and votes) - #1167

Merged
mortondev merged 2 commits into
mainfrom
test/product-e2e-api-rest
Nov 20, 2026
Merged

mortondev merged 2 commits into
mainfrom
test/product-e2e-api-rest

Conversation

@mortondev

@mortondev mortondev commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Product-suite e2e journeys for the REST v1 posts and vote routes (sub-area API-R, part 1 of 4). Based on the harness PR #1150; retarget to main once it merges.

Sibling PRs cover the rest of API-R and API-K: feedback taxonomy (comments, moderation, boards, statuses, tags, roadmaps, suggestions, apps), content (changelog, status page, help center, settings, platform), and people plus keys.

Where the specs live

The inventory names tests/api/*.spec.ts, but the product config has no api module folder, so these live in apps/web/e2e/tests/platform/ with the inventory's file names. Helpers: apps/web/e2e/product/api-rest.ts. No shared harness file is changed.

Covered

tests/platform/rest-posts.spec.ts

  • @smoke: API-R-009 (create: 201 shape, auto-vote, author subscription, activity, post.created), API-R-022 (status change: webhook, activity, subscriber email in Mailpit, bell; repeat is a no-op)
  • @core: API-R-001, 004, 010 (only the part both rules agree on), 011, 014, 016, 018, 025, 031, 033, 103 (one test per scope set), 104; quarantined: 026, 027
  • @nightly: API-R-002, 003, 005, 006, 007, 008, 020, 021, 023, 024, 029, 032, 034; quarantined: 012, 013, 028

tests/platform/rest-votes.spec.ts

  • @core: API-R-035, 039
  • @nightly: API-R-037, 038, 040, 041 (validation), 042, 043; quarantined: 041 (unknown voter)

Not pinned:

  • Owner questions: API-R-015 (author override follows role admin, not post.set_author), API-R-019 (plan-cap 402 body), API-R-036 (REST vote needs post.vote_on_behalf, MCP needs none), the default-status half of API-R-010, and the "no post.voted for proxy votes" half of API-R-039.
  • API-R-017: a board with a required custom field refuses every REST post. Listed as an owner question.
  • API-R-030: post move waits for feat(api): add POST /api/v1/posts/{postId}/move #791.

Every test was broken once: wrong expected values plus a wrong error code in expectError. Every test went red.

Quarantined (product bugs, QUARANTINE.md › Product suite: API REST (posts and votes))

Test Root cause Smallest fix
API-R-026 PATCH /posts/:id with {} (or unknown fields only) checks no permission and no scope and returns the full post, so a read:chat key reads any post (routes/api/v1/posts/$postId.ts:31-38, :117) refuse a body with no updatable field, or require post.view_private on every PATCH
API-R-027 tag replace deletes all assignments, then the insert fails on an unknown or repeated id outside a transaction: 500, tags wiped (domains/posts/post.service.ts:480-486) validate and de-duplicate first, then run both in one transaction
API-R-012 create inserts tag ids unchecked: 500 for an unknown or repeated id (post.service.ts:271-276) look the tags up, 404
API-R-013 a soft-deleted status is accepted on create and update (post.service.ts:148, :393-394) add a deletedAt filter
API-R-028 PATCH edits a soft-deleted post and fires status events (post.service.ts:379-383) treat a deleted post as not found
API-R-041 proxy vote for an unknown voter: FK violation, 500 (routes/api/v1/posts/$postId.vote.proxy.ts:43-63) look the principal up, 404

Not reproduced: the inventory's "malformed JSON is a 500" (API-R-020). On this build the routes answer 400 BAD_REQUEST, so API-R-020 is a plain passing test.

Other findings

  • A workspace key on the Admin role has legacy role member. Only the Owner role maps to admin (domains/api-keys/workspace-key-role.ts:50-55). So import mode, authorPrincipalId and backdating never work for an Admin workspace key, only for an admin's personal key or an Owner workspace key. The tests use an admin's personal key for those. This may be an owner question.

Local runs

Fresh database, rest-posts and rest-votes together, --workers=2 --retries=0, three runs in a row: 40 passed and the 6 quarantined tests failed, every run. No flaky results.

CI

PR run 44653618180: product-smoke and product-core (4 shards) pass. All 20 @smoke/@core tests here ran, and none was flaky. Nightly dispatch 44654840949: product-core, product-isolated and product-smoke pass, and none was flaky.

@mortondev mortondev added the run-product-e2e Run the product e2e core suite on this PR label Nov 20, 2026
@mortondev
mortondev force-pushed the test/product-e2e-harness branch from b16d3d9 to aa14deb Compare November 20, 2026 10:20
@mortondev
mortondev changed the base branch from test/product-e2e-harness to main November 20, 2026 10:30
@mortondev
mortondev force-pushed the test/product-e2e-api-rest branch 3 times, most recently from e5c343f to c11cb28 Compare November 20, 2026 11:16
@mortondev
mortondev force-pushed the test/product-e2e-api-rest branch from c11cb28 to 7448bed Compare November 20, 2026 11:31
Product-suite specs for /api/v1/posts and the vote routes: list paging and
filters, reads behind read:feedback and post.view_private, create with its
side effects (auto-vote, author subscription, activity, post.created),
admin overrides and import mode, PATCH per-field gates, delete, merge, the
scope and Contributor matrices, the vote toggle and proxy votes. Six
quarantined tests pin product bugs (QUARANTINE.md, API REST posts and
votes).
Count only this post's webhook deliveries (the webhook is workspace-wide),
search the whole workspace by a word no other post carries, and leave the
order of an unknown sort unpinned.
@mortondev
mortondev force-pushed the test/product-e2e-api-rest branch from 7448bed to aba3607 Compare November 20, 2026 11:41
@mortondev
mortondev merged commit bc4060b into main Nov 20, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-product-e2e Run the product e2e core suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant