Files
ai-learning-platform/frontend/e2e/navigation.spec.ts
T
yuzhiran-dev 538de50bb1 注册支持用户名/手机号/邮箱 + 镜像站部署脚本 + AI 助手 Tool Calling 重构
- Prisma User 模型新增 username 字段(唯一索引)
- 注册先查重复再创建,返回友好中文提示(非 500)
- 登录支持用户名/手机号/邮箱三种方式
- 前端注册表单增加用户名输入框,预校验 2-20 位格式
- 新增 scripts/deploy.sh:一键构建并部署主站+镜像站+重启后端+重载 Nginx
- 镜像站 www.yuzhiran.com.cn Nginx 配置与主站同步
- AI 助手架构升级:用户端/管理后台均采用完整 Tool Calling 架构
- 新增 UserAiAssistantService(18 工具)+ AiAssistantController
- admin 助手新增 search + mark-all-notifications-read 工具
- 修复注册 500 错误:catch Prisma P2002 → BadRequestException
- Baidu Analytics Script 注入 root layout
2026-06-01 23:14:42 +08:00

113 lines
4.2 KiB
TypeScript
Executable File

import { test, expect } from '@playwright/test';
test.describe('导航与页脚', () => {
test.describe('Header 导航', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test('品牌名称可见', async ({ page }) => {
await expect(page.getByText('宇之然').first()).toBeVisible();
});
test('主导航链接都可见', async ({ page }) => {
const navLinks = ['首页', '专题', '沙盒', '模型', '提示词', '文章', 'AI 工具', '社区'];
for (const link of navLinks) {
const el = page.getByRole('link', { name: link, exact: true });
const count = await el.count();
if (count > 1) {
await expect(el.first()).toBeVisible();
} else if (count === 1) {
await expect(el).toBeVisible();
}
}
});
test('搜索框可见', async ({ page }) => {
const searchInput = page.locator('input[placeholder="搜索..."]');
await expect(searchInput).toBeVisible();
});
test('主题切换按钮可见', async ({ page }) => {
const themeToggle = page.locator('button').filter({ has: page.locator('svg') }).first();
await expect(themeToggle).toBeVisible();
});
test('登录/注册按钮可见', async ({ page }) => {
await expect(page.getByText('登录').first()).toBeVisible();
await expect(page.getByText('注册').first()).toBeVisible();
});
test('点击导航链接可跳转', async ({ page }) => {
const navMap = [
{ label: '专题', url: '/courses' },
{ label: '沙盒', url: '/sandbox' },
{ label: '模型', url: '/models' },
{ label: '提示词', url: '/prompts' },
{ label: 'AI 工具', url: '/tools' },
{ label: '社区', url: '/community' },
{ label: '文章', url: '/contents' },
];
for (const { label, url } of navMap) {
await page.getByRole('link', { name: label }).first().click();
await expect(page).toHaveURL(new RegExp(url));
await page.goBack();
}
});
});
test.describe('Footer 页脚', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test('品牌信息展示', async ({ page }) => {
await expect(page.getByText('让每个人都能用好 AI').first()).toBeVisible();
const footerHeading = page.locator('footer h3');
await expect(footerHeading).toContainText('宇之然 AI');
});
test('导航链接', async ({ page }) => {
await expect(page.getByText('专题').last()).toBeVisible();
await expect(page.getByText('提示词库').last()).toBeVisible();
await expect(page.getByText('AI 工具').last()).toBeVisible();
});
test('关于链接', async ({ page }) => {
await expect(page.getByText('关于我们')).toBeVisible();
await expect(page.getByText('隐私政策')).toBeVisible();
await expect(page.getByText('服务协议').first()).toBeVisible();
await expect(page.getByText('AI 服务协议')).toBeVisible();
});
test('联系方式', async ({ page }) => {
await expect(page.getByText('contact@yuzhiran.com').first()).toBeVisible();
const footerInfo = page.locator('footer li, footer p').filter({ hasText: '北京宇之然科技中心' });
await expect(footerInfo.first()).toBeVisible();
});
test('ICP 备案号链接', async ({ page }) => {
const icpEl = page.locator('footer a').filter({ hasText: /ICP备案|ICP 备案/ });
await expect(icpEl).toBeVisible();
await expect(icpEl).toHaveAttribute('href', 'https://beian.miit.gov.cn/');
});
test('Footer 链接点击跳转正确', async ({ page }) => {
const footerLinks: [string, RegExp][] = [
['专题', /\/courses/],
['关于我们', /\/about/],
['隐私政策', /\/privacy/],
['服务协议', /\/terms/],
['AI 服务协议', /\/ai-agreement/],
];
for (const [text, urlPattern] of footerLinks) {
const link = page.locator('footer a').filter({ hasText: text });
await expect(link.first()).toBeVisible();
await link.first().click();
await expect(page).toHaveURL(urlPattern);
await page.goBack();
}
});
});
});