- 数据模型: vote/review/submission/claim/use_case/audience/collection/event (+tool 冗余统计列) - 社区: 投票(限流+原子toggle+API) / 评论(评分+优缺点+Helpful+聚合回写) / 提交(重复检测+审批发布) / 认领(Owner白名单编辑) - Ranking Engine: trending/popular/most-voted/most-saved/highest-rated/new/editors-choice (纯函数可测) - 发现体系: Use Case + Audience + Collection 三维发现 / /ai-tools-for / /best SEO 页 - Programmatic SEO: 页面生成器 / sitemap 270条 / AggregateRating/FAQPage/Breadcrumb/ItemList schema / alternatives + vs 对比页 - Analytics: event 事件流 + 外链跳转埋点 + /admin/analytics CTR 与搜索词分析 - Admin: submissions/claims/reviews/discovery/vote-audit/analytics 六个新后台 + 仪表盘扩展 - 主题系统: themes registry + 五套站点 (classic/product/editorial/niche/minimal) 构建期注入 - 认证: GitHub OAuth (env门控) + 登录回跳 redirect - i18n: 新增 7 个命名空间中英文案 (546 键一致) - 测试: bun test 32 用例 (ranking/slug/去重/SEO生成器) + Playwright e2e 脚本 - 种子: 14分类/16用例/9受众/40工具/6用户/投票/评论/6合集/7718事件
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
import { chromium } from "playwright";
|
|
import postgres from "postgres";
|
|
|
|
const sql = postgres(process.env.DATABASE_URL || "postgresql://postgres:postgres@127.0.0.1:15433/ai_directory", { prepare: false });
|
|
const count = async () => Number((await sql`SELECT COUNT(*) FROM vote WHERE tool_id='tool_claude'`)[0].count);
|
|
|
|
const browser = await chromium.launch();
|
|
const context = await browser.newContext();
|
|
const page = await context.newPage();
|
|
|
|
// 登录
|
|
await page.goto("http://localhost:3001/login", { waitUntil: "domcontentloaded" });
|
|
await page.fill('input[type="email"]', "bob@demo.dev");
|
|
await page.fill('input[type="password"]', "password123");
|
|
await page.click('button[type="submit"]');
|
|
await page.waitForTimeout(2500);
|
|
|
|
// 记录 → 点击 → 对比
|
|
const before = await count();
|
|
await page.goto("http://localhost:3001/tools/claude", { waitUntil: "domcontentloaded" });
|
|
await page.waitForTimeout(1500);
|
|
const btn = page.locator("button", { hasText: /Upvote|Upvoted/ }).first();
|
|
await btn.click();
|
|
await page.waitForTimeout(2500);
|
|
const after = await count();
|
|
const label = await btn.textContent();
|
|
console.log(`DB votes before=${before} after=${after} | button="${(label ?? "").trim()}"`);
|
|
console.log(before !== after ? "TOGGLE PASS" : "TOGGLE FAIL");
|
|
|
|
// 再点一次恢复
|
|
await btn.click();
|
|
await page.waitForTimeout(2500);
|
|
const restored = await count();
|
|
console.log(`再次点击后 DB=${restored} (${restored === before ? "恢复原状 PASS" : "FAIL"})`);
|
|
|
|
await browser.close();
|
|
await sql.end();
|