/** * 邮件路由的归属:15 条全部进契约,注册表建得起来(字面 / 参数模版互不撞), * 读写都归运营中心(设计稿 §7.2 + 2026-08-26 裁决:设计端没有消费方,不再无故加宽)。 */ import { describe, expect, it } from 'vitest'; import * as contracts from '@contracts'; import { MAIL_ROUTES } from '@contracts'; import { buildRouteRegistry, routesOf } from '../route-registry.ts'; describe('邮件路由契约', () => { it('15 条全在契约命名空间里,注册表能建起来', () => { const all = routesOf(Object.values(contracts)); const registry = buildRouteRegistry(all); expect(MAIL_ROUTES).toHaveLength(15); for (const route of MAIL_ROUTES) { expect(registry.has(route.method, route.path)).toBe(true); } }); it('读写都归 ops', () => { for (const route of MAIL_ROUTES) { expect(route.access).toBe('ops'); } }); it('未存草稿探测与已存账号探测是两条不同的路', () => { const registry = buildRouteRegistry(routesOf(Object.values(contracts))); expect(registry.lookup('POST', '/api/gov/mail/accounts/probe')).toBe('ops'); expect(registry.lookup('POST', '/api/gov/mail/accounts/acc-1/probe')).toBe('ops'); expect(registry.lookup('GET', '/api/gov/mail/inbound/m-1/attachments/0')).toBe('ops'); }); });