Skip to content

test(mail): cover the date, base64, forward and batch helpers (#220) - #245

Merged
juancguerrerodev merged 4 commits into
DojoCodingLabs:mainfrom
saurabhbhoir456:test/mail-mime-helpers-220
Dec 6, 2026
Merged

juancguerrerodev merged 4 commits into
DojoCodingLabs:mainfrom
saurabhbhoir456:test/mail-mime-helpers-220

Conversation

@saurabhbhoir456

@saurabhbhoir456 saurabhbhoir456 commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #220

When Hermit sends, replies or forwards mail, packages/mail/src/mime.ts writes the message and
packages/mail/src/http.ts runs the provider calls. A few small helpers there had no test that called them by name:
mailDate, bytesToBase64, forwardText and inBatches.

What this PR does

  • Adds packages/mail/test/mime-helpers.test.ts (Vitest, like the other files in packages/mail/test). Tests only:
    mime.ts and http.ts are unchanged. buildMime and encodeHeaderText are left out, as they already have tests in
    write.test.ts.

Tests

  • mailDate: a fixed instant gives the RFC 5322 date in UTC, and a single digit day, hour, minute and second show the
    zero padding.
  • bytesToBase64: inputs of 0, 1, 2 and 3 bytes give the right padding; with url = true the result has - and _
    instead of + and / and no =; round trip with base64ToBytes from ../src/text.ts.
  • forwardText: with a note, the note comes first and then a blank line; with a blank note there is no leading blank
    line; a To: line appears only when to has addresses; a line break inside from or subject cannot start a new
    line.
  • inBatches: results keep the order of the input even when later tasks finish first; no more than limit tasks run
    at once (counted in the task); an empty list gives an empty list without calling the task.

How to check

pnpm --filter @hermit/mail test
pnpm --filter @hermit/mail test test/mime-helpers.test.ts
pnpm --filter @hermit/mail typecheck

Keep in mind

  • Tests only. Made-up people and example.com addresses only.

Pull request template

What and why

Closes #220.

Adds named tests for mailDate, bytesToBase64, forwardText and inBatches.

Vision fit

Principle 7, small, typed and tested: the send path's small helpers have tests of their own.

Non-negotiables

  • This keeps every non-negotiable in AGENTS.md as it is.
  • Or it changes one, and this is the accepted RFC: n/a

Checklist

  • It closes one issue, linked above, or it's a small fix (a typo, a broken link, a wrong comment). A feature has an accepted proposal.
  • I wrote the failing test first. It fails without this change and passes with it. Tests were added for the existing helpers; a broken expectation was checked to fail during development.
  • These pass: pnpm check:privacy, pnpm typecheck, pnpm lint, pnpm test and node scripts/guard/check.mjs --patterns scripts/guard/patterns.txt. Gate note: privacy and guard pass on this checkout today; the rest was run per package as listed under AI agents, not as one root gate on this Windows machine, where unrelated pre-existing failures appear in the site badges, the devices table and mobile source scans.
  • No new network call, telemetry, analytics, ads or crash reporting. (A new request in an app adapter is explained below, with its host, skill and risk.)
  • No new dependency, or the reason for each one is below.
  • Every UI string is in packages/copy, in es-419 and en, with matching keys and placeholders, and no em or en dashes.
  • Tests, fixtures and screenshots use made-up data only.

Model path

  • This doesn't touch the model path: packages/model, agent, skills or eval, the prompt, the router, tool descriptions, normalizers, examples or the model file.
  • It does. The eval numbers from before and after are below, run as docs/evals.md says. No held-out case was tuned on.

Screenshots

  • No UI change.
  • UI change. Each changed screen is below, in both themes and both languages, with made-up data.

New dependencies and network calls

None. No new dependency and no new network call.

AI agents

  • No AI agent wrote any part of this.
  • An AI agent helped. Which one, and what it did: Tinsel Alpha, an AI coding agent running in OpenCode, drafted the change and this description and ran the checks below, in a session directed by the author, who reviewed each step's report before it was pushed.
  • I read and ran everything in this pull request, and I can explain it.

What was run: pnpm --filter @hermit/mail exec vitest run test/mime-helpers.test.ts (12/12); full @hermit/mail test at the time; typecheck; eslint.

@juancguerrerodev

Copy link
Copy Markdown
Contributor

Ready to merge once the pull request template is filled in, including the "I read and ran everything" box (details on #234). 🦀

@juancguerrerodev
juancguerrerodev force-pushed the test/mail-mime-helpers-220 branch from c121023 to ffc5577 Compare December 6, 2026 07:57
@juancguerrerodev
juancguerrerodev merged commit ffc5577 into DojoCodingLabs:main Dec 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mail: test the date, base64, forward and batch helpers

3 participants