stack/apps/e2e/tests
BilalG1 d14317c787
batch sending (#875)
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->

<!-- ELLIPSIS_HIDDEN -->


----

> [!IMPORTANT]
> Implement batch email rendering and sending with enhanced processing
and error handling.
> 
>   - **Behavior**:
> - Implement batch email rendering and sending in `route.tsx` using
`renderEmailsWithTemplateBatched()` and `sendEmailResendBatched()`.
> - Add per-recipient notification category resolution and unsubscribe
link generation.
> - Support templates from IDs, raw HTML, or drafts with dynamic theme
handling.
> - Enhanced result reporting, including users without primary emails.
>   - **Functions**:
> - Add `renderEmailsWithTemplateBatched()` in `email-rendering.tsx` for
batch email rendering.
> - Add `sendEmailResendBatched()` in `emails.tsx` for batch email
sending.
>     - Add `getChunks()` in `arrays.tsx` to split arrays into chunks.
>   - **Tests**:
> - Add timed waits in `send-email.test.ts` and
`unsubscribe-link.test.ts` to stabilize email delivery checks.
>   - **Dependencies**:
> - Add `@react-email/render` and `resend` to `package.json` for email
rendering and sending.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for ff1dea6c31. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>

----


<!-- ELLIPSIS_HIDDEN -->

<!-- RECURSEML_SUMMARY:START -->
## Review by RecurseML

_🔍 Review performed on
[3c34140..1267879](3c34140aba...1267879cfd)_

| Severity | Location | Issue |
|----------|----------|-------|
| ![Medium](https://img.shields.io/badge/Medium-yellow?style=plastic) |
[apps/e2e/tests/backend/endpoints/api/v1/send-email.test.ts:593](https://github.com/stack-auth/stack-auth/pull/875#discussion_r2317293698)
| Asynchronous wait function not wrapped with runAsynchronously |
| ![Medium](https://img.shields.io/badge/Medium-yellow?style=plastic) |
[apps/e2e/tests/backend/endpoints/api/v1/send-email.test.ts:743](https://github.com/stack-auth/stack-auth/pull/875#discussion_r2317293796)
| Asynchronous wait function not wrapped with runAsynchronously |

<details>
<summary> Files analyzed, no issues (4)</summary>

  • `apps/backend/src/app/api/latest/emails/send-email/route.tsx`
  • `apps/backend/src/lib/email-rendering.tsx`
  • `apps/backend/src/lib/emails.tsx`
  • `packages/stack-shared/src/utils/arrays.tsx`
</details>

<details>
<summary>⏭️ Files skipped (low suspicion) (2)</summary>

  • `apps/backend/package.json`
  • `pnpm-lock.yaml`
</details>

[![Need help? Join our
Discord](https://img.shields.io/badge/Need%20help%3F%20Join%20our%20Discord-5865F2?style=plastic&logo=discord&logoColor=white)](https://discord.gg/n3SsVDAW6U)
<!-- RECURSEML_SUMMARY:END -->

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

## Summary by CodeRabbit

- New Features
- Batch email rendering and sending to multiple recipients with
background processing.
- Per-recipient notification category resolution and unsubscribe link
generation.
- Support for templates from IDs, raw HTML, or drafts with dynamic theme
handling.
  - Enhanced result reporting, including users without primary emails.
- Chores
  - Added dependencies for email rendering and bulk sending.
- Tests
- Stabilized email delivery checks with timed waits across relevant e2e
tests.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
2025-09-11 15:42:51 -07:00
..
backend batch sending (#875) 2025-09-11 15:42:51 -07:00
general Reduce test flakeyness (#517) 2025-03-07 13:34:50 -08:00
js Email Drafts (#849) 2025-09-10 22:57:18 +00:00
global-setup.ts Disallow trailing spaces 2024-07-14 10:35:33 -07:00
globals.d.ts Upgrade backend to Next.js 15 (#360) 2024-12-10 00:11:13 -08:00
helpers.ts Exclude anonymous users from metrics 2025-08-27 11:38:47 -07:00
setup.ts JWKS endpoint now uses base64url 2024-10-11 17:09:24 -07:00
snapshot-serializer.ts Include primary email and display name in JWT 2025-09-09 11:06:47 -07:00