stack/apps/backend/src
Mantra e50358710a
fix(tests): use sql.json in onboarding migration test and refresh metrics snapshot (#1420)
## Summary

Two small test-maintenance fixes that came up while running the suite:

- **Onboarding migration test**
(`apps/backend/prisma/migrations/20260420000000_add_project_onboarding_state/tests/default-and-updates.ts`):
switch the JSON insert from `\${JSON.stringify(onboardingState)}::jsonb`
to `\${sql.json(onboardingState)}`. This matches the pattern used by
every other migration test in the repo (see
`20260214000000_fix_trusted_domains_config/tests/*`) and lets the
`postgres` driver handle serialization and parameter binding
consistently rather than relying on a manual `::jsonb` cast.
- **Internal metrics snapshot**
(`apps/e2e/tests/backend/endpoints/api/v1/__snapshots__/internal-metrics.test.ts.snap`):
update `active_users_by_country.AQ` to list `mailbox-2` before
`mailbox-1`. The `should return metrics data with users` test signs in
`mailbox-1` (mailboxes[0]) into AQ first, then later signs `mailbox-2`
(mailboxes[1]) into AQ, so sorted by `last_active_at_millis desc`
`mailbox-2` should come first. The snapshot now matches that ordering.

No production code is touched — both changes are limited to test
fixtures.

## Test plan

- [ ] `pnpm -C apps/backend test run` (migration tests)
- [ ] `pnpm -C apps/e2e test run internal-metrics` (snapshot test)
- [ ] `pnpm lint`
- [ ] `pnpm typecheck`


Made with [Cursor](https://cursor.com)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Tests**
* No user-facing behavior changed; test flows made more robust and less
flaky (migration validation, metrics ingestion polling, CLI expiry
checks, failed-emails digest expectations).
* **API / Documentation**
* CLI auth default expiration reduced from 2 hours to 2 minutes (updated
OpenAPI defaults and related test expectations).
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 10:06:29 -07:00
..
app feat(dashboard): add weekly users metrics for projects (#1412) 2026-05-08 11:00:50 -07:00
auto-migrations Migration tests 2026-02-17 15:58:06 -08:00
lib fix(tests): use sql.json in onboarding migration test and refresh metrics snapshot (#1420) 2026-05-12 10:06:29 -07:00
oauth Improved StackAssertionError error logging 2026-05-07 13:29:01 -07:00
private Update submodules 2026-04-20 19:01:16 -07:00
route-handlers fix team invitation email check + verification code TOCTOU (#1365) 2026-05-04 17:13:03 -07:00
utils Backend fallback (cloud run) (#1306) 2026-04-11 00:57:37 +00:00
analytics.tsx Fix event capture 2024-08-14 12:49:35 -07:00
globals.d.ts Split backend and dashboard (#83) 2024-06-18 15:49:31 +02:00
instrumentation.ts Onboarding app & restricted users (#1069) 2026-01-11 17:22:14 -08:00
polyfills.tsx waitUntil Sentry flush is complete 2026-04-18 22:28:02 -07:00
prisma-client.tsx Fix bigint serialization error on tracing 2026-04-18 14:46:03 -07:00
proxy.tsx External db sync (#1036) 2026-02-05 12:04:31 -08:00
s3.tsx session replays (#1187) 2026-02-16 14:15:17 -08:00
smart-router.tsx Move /api/v1 to /api/latest 2025-02-05 17:24:43 -08:00
stack.tsx Rename STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY to STACK_INTERNAL_PROJECT_SECRET_SERVER_KEY (#1415) 2026-05-06 10:35:08 -07:00