refactor: 主题系统 → monorepo 五个独立网站
- packages/core: @aidir/core 底座库(src/pages 页面组件体 1:1 镜像路由树 / kit 站点外壳工厂 / content/blog / scripts) - sites/: 5 个独立 Next.js 网站(ai-stack / launchai / the-ai-ledger / devai-tools / findai) - 每站独立 package.json / next.config / tailwind / messages / .env / 构建 - src/app 约 56 个薄路由文件(re-export 底座页面 + 内联路由段配置 revalidate/dynamic) - src/site/brand.tsx 站点配置 + src/site/home.tsx 站点首页(createMarketingLayout / createHomePage 工厂) - generate-site.mjs: 站点生成器(新增网站 = SITES 加条目,零 Core 修改) - start-all-sites.sh: 一键启动 3001-3005 - next-config.mjs: 底座统一 Next 配置工厂(next-intl + MDX + standalone) - 五站共享同一套 PostgreSQL / Better Auth / Admin(设计文档 §42) - 验证: 5 站 build OK / typecheck OK / 55 路由冒烟 200 / 品牌-内容-截图 差异确认 / 登录-投票-重复检测 e2e PASS
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* # 脚本 e2e-interaction
|
||||
* 说明:端到端交互验证 —— 登录 → 投票 → 计数变化 → 退出登录态下投票被拦截。
|
||||
*/
|
||||
import { chromium } from "playwright";
|
||||
|
||||
const BASE = "http://localhost:3001";
|
||||
const results: string[] = [];
|
||||
|
||||
const browser = await chromium.launch();
|
||||
const context = await browser.newContext({ viewport: { width: 1440, height: 900 } });
|
||||
const page = await context.newPage();
|
||||
|
||||
// 1) 登录
|
||||
await page.goto(`${BASE}/login`, { waitUntil: "domcontentloaded" });
|
||||
await page.fill('input[name="email"], input[type="email"]', "alice@demo.dev");
|
||||
await page.fill('input[name="password"], input[type="password"]', "password123");
|
||||
await page.click('button[type="submit"]');
|
||||
await page.waitForURL(/dashboard|\/$/, { timeout: 15000 }).catch(() => {});
|
||||
results.push(`登录后 URL: ${page.url()}`);
|
||||
|
||||
// 2) 打开工具详情页,记录票数
|
||||
await page.goto(`${BASE}/tools/claude`, { waitUntil: "domcontentloaded" });
|
||||
await page.waitForTimeout(1000);
|
||||
const voteButton = page.locator("button", { hasText: /Upvote/ }).first();
|
||||
const before = await voteButton.textContent();
|
||||
results.push(`投票前按钮: ${(before ?? "").trim()}`);
|
||||
|
||||
// 3) 投票
|
||||
await voteButton.click();
|
||||
await page.waitForTimeout(1500);
|
||||
const after = await voteButton.textContent();
|
||||
results.push(`投票后按钮: ${(after ?? "").trim()}`);
|
||||
results.push(`投票生效: ${(before ?? "") !== (after ?? "") ? "PASS" : "FAIL"}`);
|
||||
|
||||
// 4) 写评论
|
||||
try {
|
||||
const hasReviewForm = await page.locator('button:has-text("Write a review")').count();
|
||||
results.push(`找到 Write a review 按钮: ${hasReviewForm}`);
|
||||
if (hasReviewForm > 0) {
|
||||
await page.locator('button:has-text("Write a review")').first().click();
|
||||
await page.waitForTimeout(800);
|
||||
await page.screenshot({ path: "/tmp/aidir-shots/e2e-review-form.png" });
|
||||
// 选 5 星(表单内的大号星级)
|
||||
await page.locator('form button[aria-label="5"]').first().click();
|
||||
await page.locator("form textarea").first().fill("Interactive e2e test review - Claude handles long documents exceptionally well.");
|
||||
await page.locator('form button:has-text("Publish review")').click();
|
||||
await page.waitForTimeout(2000);
|
||||
const reviewVisible = await page.locator("text=Interactive e2e test review").count();
|
||||
results.push(`评论发布: ${reviewVisible > 0 ? "PASS" : "FAIL"}`);
|
||||
}
|
||||
} catch (error) {
|
||||
await page.screenshot({ path: "/tmp/aidir-shots/e2e-debug.png" });
|
||||
results.push(`评论步骤异常: ${String(error).slice(0, 100)}`);
|
||||
}
|
||||
|
||||
// 5) 提交工具(重复检测)
|
||||
await page.goto(`${BASE}/submit`, { waitUntil: "domcontentloaded" });
|
||||
await page.fill('input[placeholder="ChatGPT"]', "ChatGPT");
|
||||
await page.fill('input[type="url"]', "https://chatgpt.com");
|
||||
await page.locator('input[type="url"]').blur();
|
||||
await page.waitForTimeout(1200);
|
||||
const dupVisible = await page.locator("text=already be listed").count();
|
||||
results.push(`重复检测: ${dupVisible > 0 ? "PASS" : "FAIL"}`);
|
||||
|
||||
await browser.close();
|
||||
console.log(results.join("\n"));
|
||||
Reference in New Issue
Block a user