feat(admin): mail preview field with sandboxed HTML and test send
- Add MailPreviewField (POST /mail/preview + /mail/test-send, empty sandbox iframe) - Register mailpreview as valueless/group-labelled; SettingsFormView FORM_VALUES/FORM_LOCALE - Smoke tests for srcdoc, sequence guard, 422 keep-last, and 429 Retry-After Plan 35-03, task 1 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -37,12 +37,17 @@ export const profile = {
|
||||
export interface Reply {
|
||||
status?: number
|
||||
body: unknown
|
||||
/** Extra response headers (for example Retry-After on a 429). */
|
||||
headers?: Record<string, string>
|
||||
}
|
||||
|
||||
export type Route = Reply | ((request: Request) => Reply | Promise<Reply>)
|
||||
|
||||
export function json(status: number, body: unknown): Response {
|
||||
return new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } })
|
||||
export function json(status: number, body: unknown, headers: Record<string, string> = {}): Response {
|
||||
return new Response(JSON.stringify(body), {
|
||||
status,
|
||||
headers: { 'Content-Type': 'application/json', ...headers },
|
||||
})
|
||||
}
|
||||
|
||||
export const notFound = { error: { code: 'not_found', message: 'Not found', details: {} } }
|
||||
@@ -58,7 +63,7 @@ export function mockApi(routes: Record<string, Route>): Request[] {
|
||||
return json(404, notFound)
|
||||
}
|
||||
const reply = typeof route === 'function' ? await route(request.clone()) : route
|
||||
return json(reply.status ?? 200, reply.body)
|
||||
return json(reply.status ?? 200, reply.body, reply.headers)
|
||||
})
|
||||
return calls
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user