Files
ai-learning-platform/frontend/e2e/homepage.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

68 lines
2.9 KiB
TypeScript
Executable File

import { test, expect } from '@playwright/test';
test.describe('首页 (/)', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test('页面标题正确', async ({ page }) => {
await expect(page).toHaveTitle(/宇之然 AI/);
});
test('Hero 区域渲染', async ({ page }) => {
await expect(page.getByText('免费 AI 知识社区')).toBeVisible();
await expect(page.getByText('让每个人').first()).toBeVisible();
await expect(page.getByText('都能用好 AI').first()).toBeVisible();
await expect(page.getByText('宇之然 AI 是面向大众的 AI 工具与知识社区')).toBeVisible();
});
test('Hero 按钮存在并指向正确链接', async ({ page }) => {
const startBtn = page.getByText('开始探索').first();
await expect(startBtn).toBeVisible();
await expect(startBtn).toHaveAttribute('href', '/courses');
const registerBtn = page.getByText('免费注册').first();
await expect(registerBtn).toBeVisible();
await expect(registerBtn).toHaveAttribute('href', '/auth?tab=register');
});
test('统计数据区域', async ({ page }) => {
await expect(page.getByText('50+').first()).toBeVisible();
await expect(page.getByText('200+').first()).toBeVisible();
await expect(page.getByText('30+').first()).toBeVisible();
await expect(page.getByText('10,000+').first()).toBeVisible();
});
test('特性区域', async ({ page }) => {
await expect(page.getByText('为什么选择宇之然?')).toBeVisible();
await expect(page.getByText('分领域指南').first()).toBeVisible();
await expect(page.getByText('AI 沙盒实战').first()).toBeVisible();
await expect(page.getByText('提示词库').first()).toBeVisible();
await expect(page.getByText('持续更新').first()).toBeVisible();
});
test('热门专题区域', async ({ page }) => {
await expect(page.getByText('热门专题')).toBeVisible();
await expect(page.getByText('AI 通识:零基础入门')).toBeVisible();
await expect(page.getByText('提示词工程从入门到精通')).toBeVisible();
await expect(page.getByText('用 AI 提升 10 倍办公效率')).toBeVisible();
});
test('AI 沙盒预览区域', async ({ page }) => {
await expect(page.getByText('AI 沙盒').first()).toBeVisible();
await expect(page.getByText('在线体验 AI 对话,边学边练')).toBeVisible();
const sandboxLink = page.getByText('打开沙盒').first();
await expect(sandboxLink).toHaveAttribute('href', '/sandbox');
});
test('CTA 区域', async ({ page }) => {
await expect(page.getByText('准备好开启 AI 之旅了吗?')).toBeVisible();
await expect(page.getByText('立即注册,免费探索所有内容')).toBeVisible();
});
test('点击 Hero 开始探索进入课程页', async ({ page }) => {
await page.getByText('开始探索').first().click();
await expect(page).toHaveURL(/\/courses/);
});
});