Skip to content

Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.

TypeScript

test(email-gate): place the envelope test mid-file so sibling branches merge cleanly

zhuangxialied8e3faacbc0a
diff --git a/workers/email-gate/src/index.test.ts b/workers/email-gate/src/index.test.ts
index c5cba38..2d293ff 100644
--- a/workers/email-gate/src/index.test.ts
+++ b/workers/email-gate/src/index.test.ts
@@ -193,43 +193,6 @@ test('email handler throws on upstream 5xx error (triggering SMTP tempfail)', as
}
})
-test('email handler rejects with 550 bounce on 404 no recipient', async () => {
- const { message, rejected } = createFakeMessage()
- const originalFetch = globalThis.fetch
- globalThis.fetch = async () => new Response('Not Found', { status: 404 })
- try {
- await worker.email(message, fakeEnv, fakeCtx)
- assert.deepEqual(rejected, ['No such recipient'])
- } finally {
- globalThis.fetch = originalFetch
- }
-})
-
-test('email handler rejects with 550 bounce on 4xx client errors', async () => {
- const { message, rejected } = createFakeMessage()
- const originalFetch = globalThis.fetch
- globalThis.fetch = async () => new Response('Bad Request', { status: 400 })
- try {
- await worker.email(message, fakeEnv, fakeCtx)
- assert.deepEqual(rejected, ['Upstream 400'])
- } finally {
- globalThis.fetch = originalFetch
- }
-})
-
-test('email handler accepts email on 200 response without setReject', async () => {
- const { message, rejected } = createFakeMessage()
- const originalFetch = globalThis.fetch
- globalThis.fetch = async () => new Response('OK', { status: 200 })
- try {
- await worker.email(message, fakeEnv, fakeCtx)
- assert.deepEqual(rejected, [])
- } finally {
- globalThis.fetch = originalFetch
- }
-})
-
-
/* ===================== the envelope recipient is forwarded ================= */
test('email handler forwards the envelope recipient it admitted the message on', async () => {
@@ -270,3 +233,39 @@ test('email handler forwards the envelope recipient it admitted the message on',
// The visible header is still reported as-is; envelopeTo is additive.
assert.deepEqual((posted as { to?: string[] }).to, ['[email protected]'])
})
+
+test('email handler rejects with 550 bounce on 404 no recipient', async () => {
+ const { message, rejected } = createFakeMessage()
+ const originalFetch = globalThis.fetch
+ globalThis.fetch = async () => new Response('Not Found', { status: 404 })
+ try {
+ await worker.email(message, fakeEnv, fakeCtx)
+ assert.deepEqual(rejected, ['No such recipient'])
+ } finally {
+ globalThis.fetch = originalFetch
+ }
+})
+
+test('email handler rejects with 550 bounce on 4xx client errors', async () => {
+ const { message, rejected } = createFakeMessage()
+ const originalFetch = globalThis.fetch
+ globalThis.fetch = async () => new Response('Bad Request', { status: 400 })
+ try {
+ await worker.email(message, fakeEnv, fakeCtx)
+ assert.deepEqual(rejected, ['Upstream 400'])
+ } finally {
+ globalThis.fetch = originalFetch
+ }
+})
+
+test('email handler accepts email on 200 response without setReject', async () => {
+ const { message, rejected } = createFakeMessage()
+ const originalFetch = globalThis.fetch
+ globalThis.fetch = async () => new Response('OK', { status: 200 })
+ try {
+ await worker.email(message, fakeEnv, fakeCtx)
+ assert.deepEqual(rejected, [])
+ } finally {
+ globalThis.fetch = originalFetch
+ }
+})