project-doc-site.spec.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. /** Tests for the documentation website projection adapter. */
  2. import { execFileSync } from 'node:child_process'
  3. import { existsSync, globSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'
  4. import { tmpdir } from 'node:os'
  5. import { basename, join, resolve } from 'node:path'
  6. import { afterEach, describe, expect, it } from 'vitest'
  7. import { docsPages, landingLink, routeLink, sectionSpec, type DocsPage } from '../website/docs.ts'
  8. import {
  9. addProjectionFrontmatter, projectedPageContent, publishableImage, resolveRepositoryRef, rewriteMarkdown,
  10. } from './project-doc-site.ts'
  11. const roots: string[] = []
  12. const repositoryRoot = resolve(import.meta.dirname, '..')
  13. function unexpectedWebsiteMarkdown(files: readonly string[]): string[] {
  14. return files.filter(file => file.endsWith('.md') && file !== 'website/AGENTS.md').sort()
  15. }
  16. afterEach(() => {
  17. for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true })
  18. })
  19. function fixture(): { root: string; pages: DocsPage[] } {
  20. const root = mkdtempSync(join(tmpdir(), 'dsh-doc-site-'))
  21. roots.push(root)
  22. mkdirSync(join(root, 'docs'), { recursive: true })
  23. mkdirSync(join(root, 'packages'), { recursive: true })
  24. writeFileSync(join(root, 'docs/a.md'), '# A\n')
  25. writeFileSync(join(root, 'docs/b.md'), '# B\n')
  26. writeFileSync(join(root, 'docs/x(y).md'), '# Parentheses\n')
  27. writeFileSync(join(root, 'packages/tool.ts'), 'one\ntwo\n')
  28. writeFileSync(join(root, 'packages/logo.svg'), '<svg/>\n')
  29. return {
  30. root,
  31. pages: [
  32. { locale: 'root', contentLocale: 'en-US', source: 'docs/a.md', route: 'a.md', label: 'A', sidebar: 'zh-reference', section: 'Test', order: 1 },
  33. { locale: 'root', contentLocale: 'en-US', source: 'docs/b.md', route: 'reference-root/b.md', label: 'B', sidebar: 'zh-reference', section: 'Test', order: 2 },
  34. { locale: 'en', contentLocale: 'en-US', source: 'docs/a.md', route: 'en/a.md', label: 'A', sidebar: 'en-reference', section: 'Test', order: 1 },
  35. { locale: 'en', contentLocale: 'en-US', source: 'docs/b.md', route: 'en/reference/b.md', label: 'B', sidebar: 'en-reference', section: 'Test', order: 2 },
  36. ],
  37. }
  38. }
  39. describe('website source layout', () => {
  40. it('rejects Markdown outside the subtree instructions', () => {
  41. expect(unexpectedWebsiteMarkdown([
  42. 'website/AGENTS.md',
  43. 'website/docs.ts',
  44. 'website/zh-CN/api/harness/service.md',
  45. ])).toEqual(['website/zh-CN/api/harness/service.md'])
  46. })
  47. it('contains no tracked or unignored documentation copies', () => {
  48. const files = execFileSync(
  49. 'git',
  50. ['ls-files', '--cached', '--others', '--exclude-standard', '--', 'website'],
  51. { cwd: repositoryRoot, encoding: 'utf8' },
  52. ).split('\n').filter(file => file !== '' && existsSync(resolve(repositoryRoot, file)))
  53. expect(
  54. unexpectedWebsiteMarkdown(files),
  55. 'Keep canonical Markdown under docs/ and publish it through website/docs.ts.',
  56. ).toEqual([])
  57. })
  58. })
  59. describe('publishableImage', () => {
  60. it('accepts a regular file inside the repository', () => {
  61. const { root } = fixture()
  62. const real = realpathSync(join(root, 'packages/logo.svg'))
  63. expect(publishableImage(join(root, 'packages/logo.svg'), realpathSync(root))).toBe(real)
  64. })
  65. it('refuses a target whose real path escapes the repository', () => {
  66. // Publication copies the bytes onto the site, so a reference reaching a
  67. // build-machine file must not be treated as an image the repository owns.
  68. const { root } = fixture()
  69. const outside = mkdtempSync(join(tmpdir(), 'dsh-doc-site-outside-'))
  70. roots.push(outside)
  71. writeFileSync(join(outside, 'secret.png'), 'not really a png\n')
  72. symlinkSync(join(outside, 'secret.png'), join(root, 'packages/linked.png'))
  73. expect(publishableImage(join(root, 'packages/linked.png'), realpathSync(root))).toBeUndefined()
  74. expect(publishableImage(join(outside, 'secret.png'), realpathSync(root))).toBeUndefined()
  75. })
  76. it('refuses a directory', () => {
  77. const { root } = fixture()
  78. expect(publishableImage(join(root, 'packages'), realpathSync(root))).toBeUndefined()
  79. })
  80. })
  81. describe('resolveRepositoryRef', () => {
  82. it('defaults to public master instead of a private workflow SHA', () => {
  83. expect(resolveRepositoryRef({ GITHUB_SHA: 'private-sha' })).toBe('master')
  84. })
  85. it('accepts an explicit public repository ref', () => {
  86. expect(resolveRepositoryRef({ DOCS_REPOSITORY_REF: 'public-sha' })).toBe('public-sha')
  87. })
  88. })
  89. describe('rewriteMarkdown', () => {
  90. it('maps published pages and pins unpublished source links', () => {
  91. const { root, pages } = fixture()
  92. const source = '[B](b.md#part) [source](../packages/tool.ts:2) [web](https://example.com)\n'
  93. expect(rewriteMarkdown(source, {
  94. locale: 'en',
  95. sourcePath: 'docs/a.md',
  96. route: 'en/a.md',
  97. pages,
  98. repoRoot: root,
  99. repositoryRef: 'abc123',
  100. })).toBe(
  101. '[B](./reference/b.md#part) '
  102. + '[source](https://github.com/deepseek-ai/deepseek-harness/blob/abc123/packages/tool.ts#L2) '
  103. + '[web](https://example.com)\n',
  104. )
  105. })
  106. it('selects the published target in the current site locale', () => {
  107. const { root, pages } = fixture()
  108. expect(rewriteMarkdown('[B](b.md)\n', {
  109. locale: 'root',
  110. sourcePath: 'docs/a.md',
  111. route: 'a.md',
  112. pages,
  113. repoRoot: root,
  114. repositoryRef: 'abc123',
  115. })).toBe('[B](./reference-root/b.md)\n')
  116. })
  117. it('uses raw GitHub content for unpublished images when nothing places them', () => {
  118. const { root, pages } = fixture()
  119. expect(rewriteMarkdown('![logo](../packages/logo.svg)\n', {
  120. locale: 'en',
  121. sourcePath: 'docs/a.md',
  122. route: 'en/a.md',
  123. pages,
  124. repoRoot: root,
  125. repositoryRef: 'abc123',
  126. })).toBe('![logo](https://raw.githubusercontent.com/deepseek-ai/deepseek-harness/abc123/packages/logo.svg)\n')
  127. })
  128. it('hands an image to the placer and uses the URL it returns', () => {
  129. // A raw GitHub URL cannot serve a private repository, so the site build
  130. // carries images itself; the placer is what puts them there. The stand-in
  131. // derives its URL the way the real one does, so a placer that stopped
  132. // returning the basename would fail here rather than pass on a constant.
  133. const { root, pages } = fixture()
  134. const placed: string[] = []
  135. expect(rewriteMarkdown('![logo](../packages/logo.svg)\n', {
  136. locale: 'en',
  137. sourcePath: 'docs/a.md',
  138. route: 'en/a.md',
  139. pages,
  140. repoRoot: root,
  141. repositoryRef: 'abc123',
  142. placeImage: (absPath) => {
  143. const name = basename(absPath)
  144. placed.push(name)
  145. return `./${name}`
  146. },
  147. })).toBe('![logo](./logo.svg)\n')
  148. expect(placed).toEqual(['logo.svg'])
  149. })
  150. it('keeps a placed image\u2019s query or fragment', () => {
  151. // An SVG view fragment and a Vite query both change what the reference
  152. // means, and the GitHub branch has always carried them.
  153. const { root, pages } = fixture()
  154. expect(rewriteMarkdown('![logo](../packages/logo.svg#view)\n', {
  155. locale: 'en',
  156. sourcePath: 'docs/a.md',
  157. route: 'en/a.md',
  158. pages,
  159. repoRoot: root,
  160. repositoryRef: 'abc123',
  161. placeImage: absPath => `./${basename(absPath)}`,
  162. })).toBe('![logo](./logo.svg#view)\n')
  163. })
  164. it('leaves a published page link to the route even when a placer exists', () => {
  165. const { root, pages } = fixture()
  166. expect(rewriteMarkdown('[B](b.md)\n', {
  167. locale: 'en',
  168. sourcePath: 'docs/a.md',
  169. route: 'en/a.md',
  170. pages,
  171. repoRoot: root,
  172. repositoryRef: 'abc123',
  173. placeImage: () => { throw new Error('a page link must not be placed as an asset') },
  174. })).toBe('[B](./reference/b.md)\n')
  175. })
  176. it('does not rewrite Markdown-looking text inside code fences', () => {
  177. const { root, pages } = fixture()
  178. const source = '```md\n[B](b.md)\n```\n'
  179. expect(rewriteMarkdown(source, {
  180. locale: 'en',
  181. sourcePath: 'docs/a.md',
  182. route: 'en/a.md',
  183. pages,
  184. repoRoot: root,
  185. repositoryRef: 'abc123',
  186. })).toBe(source)
  187. })
  188. it('replaces the destination token without changing repeated titles or escapes', () => {
  189. const { root, pages } = fixture()
  190. const source = '[title](b.md "b.md") [escaped](x\\(y\\).md)\n'
  191. expect(rewriteMarkdown(source, {
  192. locale: 'en',
  193. sourcePath: 'docs/a.md',
  194. route: 'en/a.md',
  195. pages,
  196. repoRoot: root,
  197. repositoryRef: 'abc123',
  198. })).toBe(
  199. '[title](./reference/b.md "b.md") '
  200. + '[escaped](https://github.com/deepseek-ai/deepseek-harness/blob/abc123/docs/x(y).md)\n',
  201. )
  202. })
  203. it('routes a pair switcher across locales while ordinary links stay in locale', () => {
  204. const { root, pages } = fixture()
  205. writeFileSync(join(root, 'docs/a.zh.md'), '# A\n')
  206. const paired = pages.filter(page => page.source !== 'docs/a.md')
  207. paired.push(
  208. {
  209. locale: 'root', contentLocale: 'zh-CN', source: 'docs/a.zh.md', sourceAliases: ['docs/a.md'],
  210. route: 'guide/a.md', label: 'A', sidebar: 'zh-guide', section: 'Test', order: 1,
  211. },
  212. {
  213. locale: 'en', contentLocale: 'en-US', source: 'docs/a.md', sourceAliases: ['docs/a.zh.md'],
  214. route: 'en/guide/a.md', label: 'A', sidebar: 'en-guide', section: 'Test', order: 1,
  215. },
  216. )
  217. expect(rewriteMarkdown('[English](a.md) [B](b.md)\n', {
  218. locale: 'root',
  219. sourcePath: 'docs/a.zh.md',
  220. route: 'guide/a.md',
  221. pages: paired,
  222. repoRoot: root,
  223. repositoryRef: 'abc123',
  224. })).toBe('[English](../en/guide/a.md) [B](../reference-root/b.md)\n')
  225. })
  226. it('fails loud when a relative target is missing', () => {
  227. const { root, pages } = fixture()
  228. expect(() => rewriteMarkdown('[missing](missing.md)\n', {
  229. locale: 'en',
  230. sourcePath: 'docs/a.md',
  231. route: 'en/a.md',
  232. pages,
  233. repoRoot: root,
  234. repositoryRef: 'abc123',
  235. })).toThrow('links to missing path "missing.md"')
  236. })
  237. })
  238. describe('docsPages locale routes', () => {
  239. it('redirects both locale roots to their locale-relative quick-start page', () => {
  240. const homes = docsPages.filter(page => page.sidebar === null)
  241. expect(homes.map(page => page.route).sort()).toEqual(['en/index.md', 'index.md'])
  242. for (const page of homes) {
  243. const source = readFileSync(resolve(repositoryRoot, page.source), 'utf8')
  244. const projected = projectedPageContent(source, page)
  245. expect(projected).toContain('layout: false')
  246. expect(projected).toContain('http-equiv: refresh')
  247. expect(projected).toContain('content: 0; url=./guide/quickstart')
  248. expect(projected).not.toContain('# DeepSeek Harness')
  249. }
  250. })
  251. it('publishes every route in both locales and uses every available Chinese counterpart', () => {
  252. const byRoute = new Map(docsPages.map(page => [page.route, page]))
  253. for (const page of docsPages.filter(page => page.locale === 'root')) {
  254. const counterpart = byRoute.get(`en/${page.route}`)
  255. expect(counterpart, page.route).toBeDefined()
  256. expect(counterpart?.locale).toBe('en')
  257. if (page.contentLocale === 'zh-CN') {
  258. expect(page.source).toMatch(/\.zh\.md$/)
  259. expect(page.contentLocale).toBe('zh-CN')
  260. expect(counterpart?.source).toBe(page.source.replace(/\.zh\.md$/, '.md'))
  261. expect(counterpart?.contentLocale).toBe('en-US')
  262. } else {
  263. expect(counterpart?.source).toBe(page.source)
  264. expect(counterpart?.contentLocale).toBe(page.contentLocale)
  265. const chineseSource = page.source.replace(/\.md$/, '.zh.md')
  266. expect(
  267. existsSync(resolve(repositoryRoot, chineseSource)),
  268. `${page.route} has a Chinese counterpart but projects English`,
  269. ).toBe(false)
  270. }
  271. }
  272. })
  273. it('indexes every subsystem page in both sides of the folder README', () => {
  274. const pages = globSync(join(repositoryRoot, 'docs/subsystems/*.md'))
  275. .map(page => basename(page))
  276. .filter(page => !page.endsWith('.zh.md') && page !== 'README.md')
  277. .sort()
  278. expect(pages.length).toBeGreaterThan(0)
  279. for (const readme of ['README.md', 'README.zh.md']) {
  280. const rows = readFileSync(join(repositoryRoot, 'docs/subsystems', readme), 'utf8')
  281. const missing = pages.filter(page => !rows.includes(`| [${page}](${page}) |`))
  282. expect(missing, `${readme} must carry one table row per subsystem page`).toEqual([])
  283. }
  284. })
  285. it('projects every published subsystem page in Chinese', () => {
  286. const rootPages = docsPages.filter(page => (
  287. page.locale === 'root' && page.route.startsWith('reference/subsystems/')
  288. ))
  289. const translated = rootPages.filter(page => page.contentLocale === 'zh-CN')
  290. const fallbacks = rootPages.filter(page => page.contentLocale === 'en-US')
  291. expect(translated).toHaveLength(43)
  292. expect(translated.every(page => page.source.endsWith('.zh.md'))).toBe(true)
  293. expect(fallbacks).toEqual([])
  294. })
  295. it('publishes the Cordis core API under matching locale structures', () => {
  296. const files = ['context.md', 'events.md', 'fiber.md', 'registry.md', 'service.md']
  297. for (const file of files) {
  298. const root = docsPages.find(page => page.route === `reference/cordis-api/${file}`)
  299. const english = docsPages.find(page => page.route === `en/reference/cordis-api/${file}`)
  300. expect(root?.source).toBe(`docs/cordis-api/${file.replace(/\.md$/, '.zh.md')}`)
  301. expect(root?.contentLocale).toBe('zh-CN')
  302. expect(root?.section).toBe('Cordis API')
  303. expect(english?.source).toBe(`docs/cordis-api/${file}`)
  304. expect(english?.contentLocale).toBe('en-US')
  305. expect(english?.section).toBe('Cordis Core API')
  306. }
  307. })
  308. it('keeps Cordis inherited on the English fallback in both locales', () => {
  309. const pages = docsPages.filter(page => page.route.endsWith('reference/cordis-api/inherited.md'))
  310. expect(pages).toHaveLength(2)
  311. expect(pages.every(page => page.source === 'docs/cordis-api/inherited.md')).toBe(true)
  312. expect(pages.every(page => page.contentLocale === 'en-US')).toBe(true)
  313. })
  314. it('includes persistence event headings in both locale outlines', () => {
  315. const pages = docsPages.filter(page => page.route.endsWith('reference/persistence-catalog.md'))
  316. expect(pages).toHaveLength(2)
  317. expect(pages.map(page => page.source).sort()).toEqual([
  318. 'docs/persistence-catalog.md',
  319. 'docs/persistence-catalog.zh.md',
  320. ])
  321. expect(pages.map(page => page.outline)).toEqual(['deep', 'deep'])
  322. })
  323. it('projects reviewed generated counterparts into root locale routes', () => {
  324. // module-graph, event-producer-consumer, and graph-atlas are paired but intentionally unpublished.
  325. const routes = [
  326. 'reference/capability-seams.md',
  327. 'reference/agent-lifecycle.md',
  328. 'reference/tool-execution-pipeline.md',
  329. 'reference/config-catalog.md',
  330. 'reference/tool-catalog.md',
  331. 'reference/persistence-catalog.md',
  332. 'reference/cordis-api/context.md',
  333. 'reference/cordis-api/events.md',
  334. 'reference/cordis-api/fiber.md',
  335. 'reference/cordis-api/registry.md',
  336. 'reference/cordis-api/service.md',
  337. ]
  338. const pages = routes.map(route => docsPages.find(page => page.route === route))
  339. expect(pages.every(page => page?.contentLocale === 'zh-CN')).toBe(true)
  340. expect(pages.every(page => page?.source.endsWith('.zh.md'))).toBe(true)
  341. })
  342. })
  343. describe('sidebar ordering', () => {
  344. it('places every section a sidebar collection owns', () => {
  345. for (const page of docsPages) {
  346. if (page.sidebar === null) continue
  347. expect(() => sectionSpec(page.locale, page.section), page.route).not.toThrow()
  348. }
  349. })
  350. it('refuses a section with no declared placement', () => {
  351. expect(() => sectionSpec('root', '数据结构'))
  352. .toThrow('Sidebar section "数据结构" has no placement in the root locale.')
  353. })
  354. it('declares placements per locale rather than in one shared list', () => {
  355. // `SDK` labels a group in both locales, so one shared list would have to
  356. // rank it against `入门` and against `Guide` at the same position.
  357. expect(sectionSpec('root', 'SDK').index).toBeGreaterThan(sectionSpec('root', '入门').index)
  358. expect(sectionSpec('en', 'SDK').index).toBeGreaterThan(sectionSpec('en', 'Guide').index)
  359. expect(() => sectionSpec('en', '入门')).toThrow()
  360. expect(() => sectionSpec('root', 'Guide')).toThrow()
  361. })
  362. it('lands every navigation item on a page the manifest publishes', () => {
  363. // The navigation bar named `/guide/` while the manifest published the guide's
  364. // first page at `guide/quickstart.md`, so the item served a 404.
  365. const collections = [
  366. ['root', 'zh-guide'], ['root', 'zh-develop'], ['root', 'zh-reference'],
  367. ['en', 'en-guide'], ['en', 'en-develop'], ['en', 'en-reference'],
  368. ] as const
  369. const published = new Set(docsPages.map(page => routeLink(page.route)))
  370. for (const [locale, collection] of collections) {
  371. expect(published, `${locale}/${collection}`).toContain(landingLink(locale, collection))
  372. }
  373. })
  374. it('collapses the subsystem groups and leaves the smaller ones open', () => {
  375. expect(sectionSpec('root', '执行与工具').collapsed).toBe(true)
  376. expect(sectionSpec('en', 'Execution and tools').collapsed).toBe(true)
  377. expect(sectionSpec('root', '概念').collapsed).toBeUndefined()
  378. })
  379. it('gives each page its own position within a section', () => {
  380. // Sidebar entries sort by order alone, so a shared value leaves the two
  381. // pages ranked by whichever manifest block happens to be concatenated
  382. // first rather than by an intent the manifest states.
  383. const taken = new Map<string, string>()
  384. const collisions: string[] = []
  385. for (const page of docsPages) {
  386. const slot = `${page.locale}/${String(page.sidebar)}/${page.section}#${page.order}`
  387. const holder = taken.get(slot)
  388. if (holder === undefined) taken.set(slot, page.label)
  389. else collisions.push(`${slot}: ${holder} / ${page.label}`)
  390. }
  391. expect(collisions).toEqual([])
  392. })
  393. })
  394. describe('addProjectionFrontmatter', () => {
  395. it('adds frontmatter to an ordinary Markdown page', () => {
  396. expect(addProjectionFrontmatter('# Guide\n', { source: 'docs/guide.md' })).toBe(
  397. '---\neditSource: "docs/guide.md"\n---\n\n# Guide\n',
  398. )
  399. })
  400. it('extends existing VitePress frontmatter', () => {
  401. expect(addProjectionFrontmatter('---\nlayout: home\n---\n', { source: 'docs/index.md' })).toBe(
  402. '---\neditSource: "docs/index.md"\nlayout: home\n---\n',
  403. )
  404. })
  405. it('adds the page-specific outline depth from the publication manifest', () => {
  406. expect(addProjectionFrontmatter('# Catalog\n', {
  407. source: 'docs/catalog.md',
  408. outline: [2, 4],
  409. })).toBe(
  410. '---\neditSource: "docs/catalog.md"\noutline: [2,4]\n---\n\n# Catalog\n',
  411. )
  412. })
  413. })
  414. describe('projectedPageContent', () => {
  415. const page = (sidebar: DocsPage['sidebar']): DocsPage => ({
  416. locale: 'root',
  417. contentLocale: 'zh-CN',
  418. source: 'docs/index.zh.md',
  419. route: 'index.md',
  420. label: 'Home',
  421. sidebar,
  422. section: 'Home',
  423. order: 0,
  424. })
  425. it('omits the source-only body from locale home pages', () => {
  426. expect(projectedPageContent(
  427. '---\nlayout: false\nhead:\n - - meta\n - http-equiv: refresh\n content: 0; url=./guide/quickstart\n---\n\n# Harness\n\n[English](index.md) | 中文\n',
  428. page(null),
  429. )).toBe('---\nlayout: false\nhead:\n - - meta\n - http-equiv: refresh\n content: 0; url=./guide/quickstart\n---\n')
  430. })
  431. it('keeps the full body for ordinary pages', () => {
  432. const markdown = '---\ntitle: Guide\n---\n\n# Guide\n'
  433. expect(projectedPageContent(markdown, page('zh-guide'))).toBe(markdown)
  434. })
  435. it('drops the language switcher the navigation bar already offers', () => {
  436. expect(projectedPageContent('# Guide\n\nEnglish | [中文](./en/guide)\n\nBody.\n', page('zh-guide')))
  437. .toBe('# Guide\n\nBody.\n')
  438. expect(projectedPageContent('# 指南\n\n[English](./en/guide) | 中文\n\n正文。\n', page('zh-guide')))
  439. .toBe('# 指南\n\n正文。\n')
  440. })
  441. it('drops the repository badge every page links from its footer', () => {
  442. const badge = '[![](https://img.shields.io/badge/powered_by-dsh-4D6BFE?style=flat-square)](https://github.com/deepseek-ai/deepseek-harness)'
  443. expect(projectedPageContent(`# Guide\n\nBody.\n\n${badge}\n`, page('zh-guide')))
  444. .toBe('# Guide\n\nBody.\n')
  445. })
  446. it('keeps a switcher-shaped line that is not the page header', () => {
  447. // A tutorial showing the convention must still render the example.
  448. const sample = '# Guide\n\nA\n\nB\n\nC\n\nD\n\nE\n\nEnglish | [中文](./x)\n'
  449. expect(projectedPageContent(sample, page('zh-guide'))).toBe(sample)
  450. })
  451. it('rejects a locale home source without frontmatter', () => {
  452. expect(() => projectedPageContent('# Harness\n', page(null)))
  453. .toThrow('locale home source "docs/index.zh.md" must start with YAML frontmatter')
  454. })
  455. })