Skip to content

Add PG message model tests - #3

Closed
samxu01 wants to merge 1 commit into
mainfrom
codex/add-tests-to-improve-coverage
Closed

samxu01 wants to merge 1 commit into
mainfrom
codex/add-tests-to-improve-coverage

Conversation

@samxu01

@samxu01 samxu01 commented May 28, 2025

Copy link
Copy Markdown
Contributor

Summary

  • add unit tests for pg message model using pg-mem

Testing

  • npm run lint:fix (fails: ESLint couldn't find a config)
  • npm test (fails: jest: not found)

@samxu01 samxu01 closed this May 28, 2025
@samxu01
samxu01 deleted the codex/add-tests-to-improve-coverage branch February 2, 2026 04:34
samxu01 added a commit that referenced this pull request Apr 19, 2026
…+ rate limit

Unit tests mock Mongo queries, the PG pool, and the auth layer — they can't
catch regressions that depend on real Mongoose regex semantics, ObjectId
coercion, or middleware-ordering interactions with the rate limiter. This
integration test exercises the mint endpoint end-to-end against a real
MongoMemoryServer (User, Post, Pod, File, AuditLog) with a mocked PG pool
for the message fan-out path.

Covers the real paths unit tests can't:
- Owner short-circuit on File.uploadedBy
- Public post reference — any authed viewer mints
- Pod-scoped post, viewer not in pod → 403
- Profile picture stored as absolute URL → real substring regex match
  (regression for fix #4)
- PG messages reference file across multiple pods, viewer is in one
  → mint succeeds (regression for fix #3)
- Rate limiter: 31st mint within the window → 429 (regression for fix #1
  — auth must run before mintRateLimit so keyGen sees req.userId)
- Audit log row lands after successful mint

Slots into the existing `INTEGRATION_TEST=true` tier in tests.yml — no new
CI infra, picked up by the existing Test workflow on every PR.

https://claude.ai/code/session_01JGkwSJkDKerKRsnzUe8Mxe
samxu01 added a commit that referenced this pull request May 4, 2026
Fills the human-facing UX for the agent-dm pod type shipped in PR #275.

Gap #1 — Read-only banner + composer disable
Humans with §3.7 read-access (sharing a pod with one of the bots) can VIEW
but not POST in agent-dm rooms. Without this, the composer accepts input
and silently 401s on send. Now: composer is replaced with a soft-toned
banner ("Read-only — you're observing this conversation"). Bot-bot variant
phrases it as "X and Y are talking directly. To engage them, @-mention
either in a shared team pod."

Gap #2 — System event card for "🤝 X and Y started a DM"
The §3.8 announcement post commonly-bot drops in a team pod when two
agents start a DM rendered as raw markdown — including a `[view](/v2/pods
/<id>)` link that opened in a new tab (markdown anchors default to
`target="_blank"`, which is wrong for in-app navigation). Detect by
content shape (no metadata column on PG messages yet), render as a
chrome-light card with router-aware `navigate(...)` button.

Gap #3 — "Between agents · N" sub-section in Private filter
Bot↔bot rooms (where the human is read-only) were mixed in with regular
DMs in the Private filter, hiding the relationship. Override `groupPods`
when filter==='private': split into Pinned, Direct messages, and Between
agents · N — the count doubles as a glanceable "how much agent-to-agent
activity is happening" indicator.

Gap #4 — Empty state copy for fresh agent-dm rooms
Generic "Talk to your team" copy isn't helpful in a 1:1 DM context.
Branch on bot-bot vs human-bot to render appropriate empty-state text
("X and Y haven't talked yet — they'll DM each other when one of them
needs the other's help" vs "No messages yet — this is a private 1:1
conversation").

Design review per CLAUDE.md: no gradients, borders not shadows, one
accent. Token discipline (use --v2-bg-subtle not undefined --v2-surface
-soft). v2-root button.X specificity prefix on the syscard CTA.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant