Skip to content

test(mail): cover how a request picks the email account (#219) - #244

Merged
juancguerrerodev merged 3 commits into
DojoCodingLabs:mainfrom
saurabhbhoir456:test/mail-accounts-219
Dec 6, 2026
Merged

juancguerrerodev merged 3 commits into
DojoCodingLabs:mainfrom
saurabhbhoir456:test/mail-accounts-219

Conversation

@saurabhbhoir456

@saurabhbhoir456 saurabhbhoir456 commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #219

When someone has more than one email account, Hermit picks the one they meant with resolveAccounts() in
packages/mail/src/accounts.ts (US-MAIL-08): by address, then by label, then by provider, then by part of an address
or label. Neither it nor accountName() had a test that called it directly.

What this PR does

  • Adds packages/mail/test/accounts.test.ts (Vitest, like the other files in packages/mail/test), importing from
    ../src/accounts.ts. Tests only: accounts.ts is unchanged, and the modelText wording is not changed, only what
    it contains is checked.

Tests

  • accountName: an account with a label reads address (label); one without reads just the address.
  • resolveAccounts with no accounts gives ok: false.
  • With accounts and nothing wanted (undefined, "", or a value that is not a string) it gives every account, in
    order.
  • An exact address wins, in any case and with spaces around it.
  • A label matches without accents or case.
  • A provider matches by its id and by its service name in MAIL_SERVICE_NAMES.
  • When a higher tier matches, a lower one is never mixed in.
  • A part of an address or label matches when nothing exact does.
  • No match gives ok: false, and its text names the connected accounts and cuts what was wanted to 100 characters.
  • MemoryMailAccountStore: save replaces by id, get and list return copies, and delete reports whether it
    removed anything.

How to check

pnpm --filter @hermit/mail test
pnpm --filter @hermit/mail test test/accounts.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 #219.

Adds direct tests for how a mail request picks its account.

Vision fit

Principle 3, the model proposes, code decides: account picking is code's tiered matching over the user's words, now pinned by tests.

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 resolver; 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/accounts.test.ts (10/10); 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 merged commit 1d16fe2 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 how a request picks the email account

3 participants