| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- /**
- * ================================================================
- * 法务页可达性与结构契约 E2E · TC-L-U01 ~ TC-L-U06
- * ================================================================
- * 需求来源:提交 5a0223b9a「docs(web): add privacy policy and user agreement pages
- * for Xiaomi HealthKit application」新增 `web/privacy.html`、`web/agreement.html`。
- * 小米运动健康(Xiaomi HealthKit)上架审核要求应用提供**公网可直接访问**的
- * 隐私政策与用户协议 URL,且内容需覆盖健康数据收集/授权/撤回等条目。
- *
- * 覆盖缺口背景:该提交入库后(R260 窗口唯一内容变更)仓库内没有任何用例覆盖
- * 这两个页面 —— 属「新增内容零覆盖」。本 spec 补齐,判定两条硬契约:
- * ① **可达性**:`/web/privacy.html`、`/web/agreement.html` 线上返回 200(非 404/302 登录墙);
- * ② **结构完整性**:隐私政策 9 个章节、用户协议 12 个章节齐全,且协议含「健康数据/授权」条款。
- *
- * 只读:仅 GET 页面,不提交任何数据。
- *
- * 运行:
- * LIVE_BASE_URL=http://cfc.iwintrue.com npx playwright test -c playwright.config.live.js --project=legal-pages
- */
- const { test, expect } = require('@playwright/test');
- const BASE = process.env.LIVE_BASE_URL || 'http://cfc.iwintrue.com';
- // [用例编号, 路径, 期望 title 片段, 一级标题, 期望二级章节数]
- const PAGES = [
- ['TC-L-U01', '/web/privacy.html', '隐私政策', '浠艾福隐私政策', 9],
- ['TC-L-U02', '/web/agreement.html', '用户服务协议', '浠艾福用户服务协议', 12],
- ];
- test.describe('法务页 · 可达性与结构契约(小米 HealthKit 上架所需)', () => {
- for (const [tc, path, titlePart, h1Text, h2Count] of PAGES) {
- test(`${tc} ${path} 公网可直接访问(HTTP 200,非登录墙)`, async ({ request }) => {
- const resp = await request.get(`${BASE}${path}`, { timeout: 20000, maxRedirects: 0 });
- // 明确区分「未部署(404)」与「被登录墙拦截(302)」——两者都不满足上架审核要求
- expect(
- resp.status(),
- `${path} 期望 200,实际 ${resp.status()}(404=未部署到生产 / 302=被鉴权墙拦截)`
- ).toBe(200);
- const html = await resp.text();
- expect(html, `${path} 内容不应为空`).not.toHaveLength(0);
- });
- test(`${tc} ${path} 标题与章节结构完整`, async ({ page }) => {
- const resp = await page.goto(`${BASE}${path}`, { waitUntil: 'domcontentloaded', timeout: 60000 });
- const status = resp ? resp.status() : 0;
- // 未部署时以明确的失败信息暴露,而不是抛导航异常
- expect(status, `${path} 加载失败(HTTP ${status}),页面未部署`).toBe(200);
- await expect(page).toHaveTitle(new RegExp(titlePart));
- await expect(page.locator('h1').first()).toHaveText(new RegExp(h1Text));
- const sections = page.locator('h2');
- await expect(
- sections,
- `${path} 章节数不足:期望 ≥${h2Count},实际 ` + String(await sections.count())
- ).toHaveCount(h2Count);
- });
- }
- test('TC-L-U05 用户协议含健康数据授权与撤回条款(HealthKit 审核要点)', async ({ page }) => {
- const resp = await page.goto(`${BASE}/web/agreement.html`, { waitUntil: 'domcontentloaded', timeout: 60000 });
- expect(resp ? resp.status() : 0, '页面未部署,无法校验健康数据条款').toBe(200);
- const body = await page.locator('body').innerText();
- // 审核要求:必须说明健康数据范围、授权方式、撤回途径
- expect(body, '协议缺少「健康数据」条款').toContain('健康数据');
- expect(body, '协议缺少「授权」表述').toContain('授权');
- expect(body, '协议缺少「撤回」表述(授权撤回途径)').toContain('撤回');
- });
- test('TC-L-U06 两个法务页均归属同一主体并可互相跳转或提及', async ({ page }) => {
- const resp = await page.goto(`${BASE}/web/privacy.html`, { waitUntil: 'domcontentloaded', timeout: 60000 });
- expect(resp ? resp.status() : 0, '隐私政策页未部署').toBe(200);
- const body = await page.locator('body').innerText();
- expect(body, '隐私政策未标注运营主体「浠艾福」').toContain('浠艾福');
- });
- });
|