Files
Home-Care/hss-home-service/website/tests/pages.spec.ts
comclib c02029a5f3 feat: 初始化居家上门服务系统完整项目代码
- Spring Boot 后端服务 (hss-home-service)
- delivery-miniapp 配送小程序
- website 官网 (Nuxt)
- docs 架构设计文档
- Docker 容器化部署配置

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 09:04:49 +08:00

53 lines
2.3 KiB
TypeScript

import { test, expect } from '@playwright/test'
const pages = [
{ path: '/', title: '首页', seoTitle: '首页 | 智慧医养居家上门服务平台' },
{ path: '/solution', title: '解决方案', seoTitle: '解决方案 | 智慧医养居家上门服务平台' },
{ path: '/capabilities', title: '核心能力', seoTitle: '核心能力 | 智慧医养居家上门服务平台' },
{ path: '/scenarios', title: '应用场景', seoTitle: '应用场景 | 智慧医养居家上门服务平台' },
{ path: '/service-loop', title: '服务闭环', seoTitle: '服务闭环 | 智慧医养居家上门服务平台' },
{ path: '/security', title: '安全合规', seoTitle: '安全合规 | 智慧医养居家上门服务平台' },
{ path: '/resources', title: '资源中心', seoTitle: '资源中心 | 智慧医养居家上门服务平台' },
{ path: '/about', title: '关于我们', seoTitle: '关于我们 | 智慧医养居家上门服务平台' },
{ path: '/contact', title: '联系我们', seoTitle: '联系我们 | 智慧医养居家上门服务平台' },
{ path: '/demo', title: '平台演示', seoTitle: '平台演示 | 智慧医养居家上门服务平台' },
]
for (const p of pages) {
test.describe(p.title, () => {
test('页面可达 HTTP 200', async ({ page }) => {
const res = await page.goto(p.path)
expect(res?.status()).toBe(200)
})
test('SEO title 正确', async ({ page }) => {
await page.goto(p.path)
await expect(page).toHaveTitle(p.seoTitle)
})
test('导航栏存在', async ({ page }) => {
await page.goto(p.path)
await expect(page.locator('header')).toBeVisible()
})
test('页脚存在', async ({ page }) => {
await page.goto(p.path)
await expect(page.locator('footer')).toBeVisible()
})
test('无控制台错误', async ({ page }) => {
const errors: string[] = []
page.on('pageerror', e => errors.push(e.message))
await page.goto(p.path)
await page.waitForTimeout(1000)
expect(errors.filter(e => !e.includes('hydrat'))).toHaveLength(0)
})
test('移动端响应式正常', async ({ page: mobile }) => {
const res = await mobile.goto(p.path)
expect(res?.status()).toBe(200)
await expect(mobile.locator('header')).toBeVisible()
})
})
}