Files
wrong-notebook/e2e/setup-wizard.spec.ts
margrop a6523611b8 feat: 新增管理员安装向导:修改默认密码、配置 AI 渠道、创建第一个错题本
- /setup 改为分步向导,AI 渠道复用设置页表单(未配置时推荐 MiniMax Code),错题本复用创建对话框,后两步可跳过
- 新增 /api/setup:未完成向导且没有错题本时管理员进入应用自动跳转,已在使用的实例升级后不打扰
- 完成状态写入 app-config.json 的 setupCompletedAt,「设置 → 用户管理」可重新运行向导
- AI 配置校验抽到 src/lib/ai-config-validation.ts 供设置页与向导共用
- E2E 准备脚本标记向导已完成,新增重新运行向导用例;同步更新 README、Wiki、安装包说明

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 13:55:44 +08:00

28 lines
1.5 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { ADMIN_PASSWORD } from './helpers';
test('管理员可从设置重新打开安装向导,跳过各步骤后回到首页', async ({ page }) => {
test.setTimeout(60000);
await page.goto('/login');
await page.locator('input[name="email"]').fill('admin@localhost');
await page.locator('input[name="password"]').fill(ADMIN_PASSWORD);
await page.locator('button[type="submit"]').click();
await page.waitForURL('**/', { timeout: 15000 });
// 设置 → 用户管理 → 重新运行安装向导
await page.getByRole('button', { name: /^(设置|Settings)$/ }).click();
await page.getByRole('tab', { name: /用户管理|User Management/ }).click();
await page.getByRole('button', { name: /重新运行安装向导|Run setup wizard again/ }).click();
await page.waitForURL('**/setup');
// 密码已不是默认值,向导从 AI 渠道开始,共 2 步
await expect(page.getByText(/第 1 \/ 2 步|Step 1 of 2/)).toBeVisible();
await expect(page.getByRole('heading', { name: /配置 AI 渠道|Set up an AI provider/ })).toBeVisible();
await page.getByRole('button', { name: /^(跳过|Skip)$/ }).click();
await expect(page.getByRole('heading', { name: /创建第一个错题本|Create your first notebook/ })).toBeVisible();
await page.getByRole('button', { name: /^(完成|Finish)$/ }).click();
await page.waitForURL((url) => url.pathname === '/', { timeout: 15000 });
});