Files
WangShen007 6cd904d460 docs: 交付文档、维护指引与端到端回归
补齐 README、开发计划、维护交接与 E2E 用例,执行最终验收。
2026-10-21 21:40:00 +08:00

32 lines
1.5 KiB
TypeScript

import { test, expect, createArticle, enableHelpCenter, setArticleStatus, unique } from '@e2e'
// Turning the help center on is an org-wide setting, so this runs in the serial
// `org` project. The public site is unauthenticated: exactly what is published,
// nothing else.
test('only published articles are on the public help center @help-center', async ({ adminApi, anonymousPage }) => {
const site = await enableHelpCenter(adminApi)
const code = unique('HC')
const article = await createArticle(adminApi, {
question: `How do I reset my router ${code}?`,
answer: `Hold the reset button for ten seconds. Reference ${code}.`,
})
const articleUrl = `${site}/a/${article.slug}`
// A draft is invisible to the public: not listed, and its URL is not found.
await anonymousPage.goto(site)
await expect(anonymousPage.getByText(code)).toHaveCount(0)
expect((await anonymousPage.request.get(articleUrl)).status()).toBe(404)
await setArticleStatus(adminApi, article.id, 'published')
await anonymousPage.goto(articleUrl)
await expect(anonymousPage.getByRole('heading', { name: `How do I reset my router ${code}?` })).toBeVisible()
await expect(anonymousPage.getByText('Hold the reset button for ten seconds.')).toBeVisible()
await anonymousPage.goto(site)
await expect(anonymousPage.getByText(`How do I reset my router ${code}?`)).toBeVisible()
// Unpublishing takes it down again.
await setArticleStatus(adminApi, article.id, 'draft')
expect((await anonymousPage.request.get(articleUrl)).status()).toBe(404)
})