Files
photo-live/apps/viewer/playwright.config.ts
T
浅念 0fcf18cc5c feat(ov): public read api on replicas with hot sorting
P2 Task 6(ov 公开读 API + viewer 切换):
- ov 装配 PublicOvModule(仅 app-ov.module):/public/albums/{token}、
  /photos、/photos/{id} 三端点同契约读 ov 副本——translations/categories
  自 JSON 列解析(防御性过滤),banner 经 ov 侧 STORAGE_PORT_OV 预签名
  (同本地 MinIO;只读属约定,真实 OSS 只读凭证 P5),viewCount 取
  album_stats 权威累计(无行默认 0;计数端点 Task 8 接线)
- 排序:latest=发布时间 keyset(shared/cursor.ts 同 cn);hot=likeTotal
  desc + photoId desc 决胜,顺序按 `${albumId}|${category}` 短期快照
  (内存 TTL 默认 30s,HOT_SORT_TTL_MS 惰性读取)——计数逐请求现读、
  顺序冻结窗口内一致,偏移游标(base64url 整数)在快照内严格稳定;
  非法 sort 400 VALIDATION_FAILED(cn 不感知该参数)
- 契约:viewCount 放宽为 integer|null(cn null、ov 权威值);
  listPublicPhotos 增 sort 枚举(latest|hot,缺省 latest);
  PhotoPublishedPayload 增 categoryId——补上 Tasks 3/4 管线缺口
  (payloads/publish.service/sync-inbox 投影 + 关联测试随改)
- e2e(services/api/test/public-ov.e2e-spec.ts,7 用例):双入口同进程
  起 cn+ov,cn API 种子→真实发送管线投递;断言相册/列表/单图与 cn
  深等(仅签名 URL 剔除)、banner 真字节、参数矩阵 400/404、hot 排序
  TTL 内快照(计数新/顺序旧)+TTL 过期翻转+偏移翻页、隐藏/下线/紧急
  停用逐态撤下
- viewer 切 ov:API 基址 VITE_API_BASE(缺省 http://127.0.0.1:8081,
  空串=同源网关;Vite 只读 apps/viewer/.env*,根 .env 对前端无效),
  移除 /v1 dev 代理(CORS_ORIGINS 增 127.0.0.1:5175 直连两形);
  playwright webServer 增 dev:ov;e2e 夹具 flushSync(albumId)=cn
  bootstrap 快照 + deliverPendingOnce(sender 新导出)经真实管线投影
  种子,deleteSeededPhoto 改软删让墓碑可同步;14 个 Playwright 全绿
  (journey 管理/staffB 腿仍走 cn 8080)

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-09-18 17:05:56 +08:00

51 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineConfig, devices } from '@playwright/test';
// Task 6 起 e2e 打真实后端:webServer 先等 cn API(8080,仓库根 `pnpm dev:api`
// 构建+启动;已在跑的实例直接复用;journey 管理/上传腿与 flushSync 的
// bootstrap 触发仍走 cn),再等 ov API(8081,`pnpm dev:ov`——P2 Task 6 起
// viewer 观众腿全部切 ov 副本端点),再等 viewer dev(5175,直连
// VITE_API_BASE=ov 8081,无代理)。compose 基础设施(MySQL/MinIO/Redis×2)
// 需预先 `docker compose up -d`(计划约定)。Task 11 起跨端联调:第四个
// webServer 一并等 admin dev(5176,/v1 代理 → 8080,同样复用已在跑的实例)
// ——journey.spec.ts 以绝对 baseURL 驱动 admin 腿。
export default defineConfig({
testDir: './e2e',
timeout: 30_000,
fullyParallel: true,
reporter: [['list']],
use: {
baseURL: 'http://127.0.0.1:5175',
trace: 'on-first-retry',
},
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
webServer: [
{
command: 'pnpm dev:api',
cwd: '../..',
url: 'http://127.0.0.1:8080/v1/health',
reuseExistingServer: true,
timeout: 180_000, // 首次含 tsc 全量构建
},
{
command: 'pnpm dev:ov',
cwd: '../..',
url: 'http://127.0.0.1:8081/v1/health',
reuseExistingServer: true,
timeout: 180_000, // 复用同一构建产物,首次仍可能全量构建
},
{
command: 'pnpm run dev',
url: 'http://127.0.0.1:5175',
reuseExistingServer: true,
timeout: 60_000,
},
{
command: 'pnpm run dev',
cwd: '../admin',
url: 'http://127.0.0.1:5176',
reuseExistingServer: true,
timeout: 120_000, // 首次含模板依赖预构建
},
],
});