Repository navigation
fix(tests): align postmark reply-one leak regression test with configured inbound domain - #73
Open
detail-app[bot] wants to merge 1 commit into
Conversation
…ured inbound domain
Contributor
🤖 Augment PR SummarySummary: This PR makes the Postmark reply-one regression test load the shared test environment before configuration is imported. 🤖 Was this summary useful? React with 👍 or 👎 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Detail bug report: View on Detail
Bug
The reply-one auto-reply regression test (
tests/testPostmarkReplyOneLeak.ts), added to guard against leaking literalnull/undefinedinto the "you forgot to reply-all" auto-reply body, never actually reached the code path it was meant to lock. It hardcodedINBOUND_DOMAIN = 'labs.example', while the only committed test domain istest.local(tests/_setupEnv.ts/.env.test.example). The postmark handler filters recipients bye.split('@')[1] === config.email.inboundDomain, so the fixture address was filtered out,myToEmailswas empty, and the handler bailed before thesendMailblock — leavingcaptured.htmlundefinedand all 3 subtests failing for the wrong reason. The test also lacked any env bootstrap, crashing on a clean checkout (src/config.tsthrows when required vars are missing).Fix
Made the test match the established convention used by its sibling
tests/testPostmarkEmailSentId.ts:import './_setupEnv';as the first line so required env vars (includingEMAIL_INBOUND_DOMAIN=test.local) are populated beforesrc/config.tsvalidates them.INBOUND_DOMAINfrom'labs.example'to'test.local'so the fixture recipient passes the inbound-domain filter and the handler reaches the reply-one auto-reply path.No production code changed — the guard at
src/email/postmark.ts:80(${project?.event?.emailSignature || ''}) is already correct; this restores the test's ability to actually catch its removal.Testing
npx ts-node --transpile-only tests/testPostmarkReplyOneLeak.ts→ 3/3 pass; with.envmoved aside it still passes 3/3, confirming the test is self-sufficient via the shared harness (no clean-checkout crash).${...emailSignature || ''}→${...emailSignature}insrc/email/postmark.tsmakes subtests 1 and 2 fail on\nnull\n/\nundefined\n(1 pass / 2 fail); restoring the guard returns to 3/3 — proving the suite now locks the guard.src/email/postmark.tswas left unchanged after verification.tests/testPostmarkEmailSentId.tsstill passes 3/3.npx tsc --skipLibCheck --noEmitexits 0.npx eslinton the changed file fails only due to a pre-existing tooling mismatch (pinned@typescript-eslint/parser@3.10.1is incompatible with the installed TypeScript 5.2.2, throwingDeprecationError: 'originalKeywordKind'on every.tsfile, including untouched ones). After loading a compatible parser/plugin, the changed file reports only pre-existing violations (no-explicit-anyon originalas anyscaffolding;no-secretson the unchangedcid12345+es_abc123@literal) — the 2-line fix introduces zero new violations.Automatic Fixes PRs can be configured here.