feat(testing): add vitest suite + guerrilla mail email pool #1

Open
robacheque wants to merge 1 commit from robacheque/resetea.net:feat/testing-vitest into main
First-time contributor

What

Adds a Vitest unit test suite for POST /api/erase and two small fixes
to the mailer that surfaced during testing.

Tests (api/tests/erase.test.js)

18 tests across 5 suites:

  • provider registry — snapshots PROVIDER_DATA from mailer.js to
    catch drift if a provider email, name, or URL changes
  • validation — asserts 400 on missing provider, missing email,
    malformed email, and unknown provider; verifies mailer is never called
  • form-only providers — google and amazon return use_form + valid
    formUrl instead of sending an email
  • email providers — one test per email-accepting provider (10 total),
    derived dynamically from PROVIDER_DATA; asserts 200, status: ok,
    12-char reference, and that sendErasureMail was called once with the
    correct payload
  • sanitization — CRLF sequences in optional fields are stripped
    without erroring

Transport is fully stubbed via require cache — no real emails sent, no
MTA needed.

Mailer fixes

  • Reply-To set to the requester's email so provider replies land
    in their inbox rather than bouncing at privacy@resetea.net
  • Direct transport fallback when sendmail is not available locally
    (dev machines without a local MTA)
## What Adds a Vitest unit test suite for `POST /api/erase` and two small fixes to the mailer that surfaced during testing. ## Tests (`api/tests/erase.test.js`) 18 tests across 5 suites: - **provider registry** — snapshots `PROVIDER_DATA` from `mailer.js` to catch drift if a provider email, name, or URL changes - **validation** — asserts 400 on missing provider, missing email, malformed email, and unknown provider; verifies mailer is never called - **form-only providers** — google and amazon return `use_form` + valid `formUrl` instead of sending an email - **email providers** — one test per email-accepting provider (10 total), derived dynamically from `PROVIDER_DATA`; asserts 200, `status: ok`, 12-char reference, and that `sendErasureMail` was called once with the correct payload - **sanitization** — CRLF sequences in optional fields are stripped without erroring Transport is fully stubbed via require cache — no real emails sent, no MTA needed. ## Mailer fixes - **`Reply-To`** set to the requester's email so provider replies land in their inbox rather than bouncing at `privacy@resetea.net` - **Direct transport fallback** when `sendmail` is not available locally (dev machines without a local MTA)
robacheque added 1 commit 2026-04-17 20:53:36 +00:00
- Vitest unit tests for POST /api/erase: validation, form-only
  providers, all email providers, CRLF sanitization
- Snapshot on PROVIDER_DATA to catch provider config drift
- Mock via require cache to avoid nodemailer/sendmail dependency
- sendErasureMail call assertions (args + call count)
- fetch-test-emails.mjs script to refresh disposable email pool
- mailer: add Reply-To header pointing to requester email
- mailer: fallback to direct transport when sendmail unavailable
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u feat/testing-vitest:robacheque-feat/testing-vitest
git checkout robacheque-feat/testing-vitest

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout main
git merge --no-ff robacheque-feat/testing-vitest
git checkout robacheque-feat/testing-vitest
git rebase main
git checkout main
git merge --ff-only robacheque-feat/testing-vitest
git checkout robacheque-feat/testing-vitest
git rebase main
git checkout main
git merge --no-ff robacheque-feat/testing-vitest
git checkout main
git merge --squash robacheque-feat/testing-vitest
git checkout main
git merge --ff-only robacheque-feat/testing-vitest
git checkout main
git merge robacheque-feat/testing-vitest
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: hacklab/resetea.net#1
No description provided.