Mail relay: docs, agent guide, skills, changelog draft; test against the real service code; starter offers the mail service

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 20:53:38 +01:00
co-authored by Claude Fable 5.2
parent 533f571d4d
commit dd3792cbc7
25 changed files with 991 additions and 167 deletions
+5 -5
View File
@@ -7,7 +7,7 @@
* - each mail says what it is: the test e-mail, a form's two e-mails, Payload's "forgot password";
* - the state routes are for admins; `relay: false` leaves no route and no block; no stored field changed.
*/
import type { Config, Field, Payload } from 'payload'
import type { Field, Payload, SanitizedConfig } from 'payload'
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import os from 'os'
@@ -275,7 +275,7 @@ describe('each mail says what it is', () => {
})
describe('switched off, and what did not change', () => {
const endpoints = (config: Config) => (config.endpoints ?? []).map((e) => `${e.method} ${e.path}`)
const endpoints = (config: SanitizedConfig) => (config.endpoints ?? []).map((e) => `${e.method} ${e.path}`)
const stored = (fields: Field[]): string[] =>
fields.flatMap((f) => {
if (f.type === 'ui') {return []}
@@ -283,7 +283,7 @@ describe('switched off, and what did not change', () => {
const own = 'name' in f && f.name ? [`${f.name}:${f.type}${f.type === 'select' ? `(${(f.options as { value: string }[]).map((o) => (typeof o === 'string' ? o : o.value)).join('|')})` : ''}`] : []
return 'fields' in f && Array.isArray(f.fields) ? [...own, ...stored(f.fields).map((n) => ('name' in f && f.name ? `${f.name}.${n}` : n))] : own
})
const emailTab = (config: Config) => JSON.stringify(config.globals?.find((g) => g.slug === 'site-integrations')?.fields)
const emailTab = (config: SanitizedConfig) => JSON.stringify(config.globals?.find((g) => g.slug === 'site-integrations')?.fields)
test('mail: { relay: false } leaves no route, no state block and no mark on the auth collection', async () => {
const off = await makeConfig({ relay: false }, 'relayoff')
@@ -294,12 +294,12 @@ describe('switched off, and what did not change', () => {
expect(emailTab(off)).not.toContain('MailRelayStatus')
expect(emailTab(off)).not.toContain('Intecion')
expect((off.custom as { iapl: { mail: { relay: unknown } } }).iapl.mail.relay).toBe(false)
const hooks = (config: Config) => config.collections?.find((c) => c.slug === 'users')?.hooks?.beforeOperation?.length ?? 0
const hooks = (config: SanitizedConfig) => config.collections?.find((c) => c.slug === 'users')?.hooks?.beforeOperation?.length ?? 0
expect(hooks(on) - hooks(off)).toBe(1)
})
test('no stored field differs: the same names, types and select values with the service on, off, and as in 1.16', async () => {
const names = (config: Config) => stored(config.globals?.find((g) => g.slug === 'site-integrations')?.fields ?? []).filter((n) => /^(?:email|smtp)/.test(n))
const names = (config: SanitizedConfig) => stored((config.globals?.find((g) => g.slug === 'site-integrations')?.fields ?? [])).filter((n) => /^(?:email|smtp)/.test(n))
const on = names(await makeConfig(undefined, 'fieldson'))
expect(on).toEqual(names(await makeConfig({ relay: false }, 'fieldsoff')))
expect(on).toEqual([