Compare commits
1 Commits
dev
..
c4783f83b1
| Author | SHA1 | Date | |
|---|---|---|---|
| c4783f83b1 |
@@ -12,7 +12,7 @@ description: Sync this Next.js frontend with backend API documentation
|
||||
当后端 API 新增、删除、字段结构调整、响应语义变化时,使用本 skill 更新:
|
||||
|
||||
- 网络层
|
||||
- schema / 不可变纯数据
|
||||
- schema / DTO
|
||||
- repository
|
||||
- storage
|
||||
- XState store
|
||||
@@ -22,18 +22,19 @@ description: Sync this Next.js frontend with backend API documentation
|
||||
|
||||
## 当前项目结构
|
||||
|
||||
| 层级 | 路径 | 说明 |
|
||||
| -------------------- | --------------------------------------------------- | ----------------------------------------------- |
|
||||
| API Path | `src/data/services/api/api_path.ts` | 统一维护接口路径 |
|
||||
| API Service | `src/data/services/api/*_api.ts` | 调用 `httpClient` 并解析响应 |
|
||||
| Schema Model | `src/data/schemas/<module>/*.ts` | Zod schema 与不可变纯数据类型,负责解析和归一化 |
|
||||
| Repository Interface | `src/data/repositories/interfaces/i*_repository.ts` | 仓库接口 |
|
||||
| Repository | `src/data/repositories/*_repository.ts` | 业务仓库实现 |
|
||||
| Storage | `src/data/storage/*` | 本地持久化 |
|
||||
| Store | `src/stores/<module>/*` | XState 状态机、actors、helpers、sync |
|
||||
| UI | `src/app/**` | Next.js app router UI |
|
||||
| Mock | `src/data/mock/<module>/**` | 模拟请求 / 响应数据 |
|
||||
| Tests | `**/__tests__/*.test.ts` | schema model、helper、machine transition 测试 |
|
||||
| 层级 | 路径 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| API Path | `src/data/services/api/api_path.ts` | 统一维护接口路径 |
|
||||
| API Service | `src/data/services/api/*_api.ts` | 调用 `httpClient` 并解析响应 |
|
||||
| Schema | `src/data/schemas/<module>/*.ts` | Zod schema,负责防御性解析 |
|
||||
| DTO | `src/data/dto/<module>/*.ts` | DTO class,封装 `fromJson/toJson` |
|
||||
| Repository Interface | `src/data/repositories/interfaces/i*_repository.ts` | 仓库接口 |
|
||||
| Repository | `src/data/repositories/*_repository.ts` | 业务仓库实现 |
|
||||
| Storage | `src/data/storage/*` | 本地持久化 |
|
||||
| Store | `src/stores/<module>/*` | XState 状态机、actors、helpers、sync |
|
||||
| UI | `src/app/**` | Next.js app router UI |
|
||||
| Mock | `src/data/mock/<module>/**` | 模拟请求 / 响应数据 |
|
||||
| Tests | `**/__tests__/*.test.ts` | DTO、helper、machine transition 测试 |
|
||||
|
||||
## 后端文档来源
|
||||
|
||||
@@ -84,16 +85,13 @@ git status --short
|
||||
否则 schema 应尽量防御性解析,例如:
|
||||
|
||||
```ts
|
||||
z.string()
|
||||
.nullable()
|
||||
.transform((v) => v ?? "")
|
||||
.default("");
|
||||
z.string().nullable().transform((v) => v ?? "").default("")
|
||||
```
|
||||
|
||||
项目已有通用 helper:
|
||||
|
||||
```ts
|
||||
src / data / schemas / nullable - defaults.ts;
|
||||
src/data/schemas/nullable-defaults.ts
|
||||
```
|
||||
|
||||
### 3. 更新 API Path
|
||||
@@ -101,7 +99,7 @@ src / data / schemas / nullable - defaults.ts;
|
||||
新增或修改:
|
||||
|
||||
```ts
|
||||
src / data / services / api / api_path.ts;
|
||||
src/data/services/api/api_path.ts
|
||||
```
|
||||
|
||||
示例:
|
||||
@@ -110,7 +108,7 @@ src / data / services / api / api_path.ts;
|
||||
static readonly userEntitlements = `${ApiPath._user}/entitlements`;
|
||||
```
|
||||
|
||||
### 4. 更新 Schema Model
|
||||
### 4. 更新 Schema
|
||||
|
||||
在对应模块下新增或修改:
|
||||
|
||||
@@ -125,35 +123,70 @@ src/data/schemas/<module>/*.ts
|
||||
- 输入类型用 `z.input<typeof Schema>`。
|
||||
- 对后端可能返回 `null` 的字段做防御性处理。
|
||||
- 不要在 schema 中写 UI 逻辑。
|
||||
- Schema 输出必须是纯数据,不要定义 class 或工厂对象。
|
||||
- 对象 Schema 使用 `.readonly()`;已知嵌套对象、数组和 Record 也必须逐层 readonly。
|
||||
- transform 应先完成归一化,再在最终输出应用 `.readonly()`。
|
||||
- 容器默认值必须经过 Schema 解析;使用 `prefault` 或在最外层应用 readonly,不能让 `.default()` 返回未冻结对象。
|
||||
- 后端返回但前端既不读取、也不透传的字段,不要加入 Schema。
|
||||
- 仅用于请求序列化、响应兼容或内部透传的字段直接保留在 Schema 中。
|
||||
- 统一使用 `XxxSchema.parse()` 构造请求与解析响应,不增加 `from()`、`fromJson()` 或 `toJson()` 包装。
|
||||
- 不要再创建独立的数据传输对象层。
|
||||
|
||||
示例:
|
||||
|
||||
```ts
|
||||
export const XxxResponseSchema = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
tags: z
|
||||
.array(z.string())
|
||||
.default(() => [])
|
||||
.readonly(),
|
||||
count: z.number().default(0),
|
||||
})
|
||||
.readonly();
|
||||
export const XxxResponseSchema = z.object({
|
||||
id: z.string(),
|
||||
count: z.number().default(0),
|
||||
});
|
||||
|
||||
export type XxxResponseInput = z.input<typeof XxxResponseSchema>;
|
||||
export type XxxResponseData = z.output<typeof XxxResponseSchema>;
|
||||
export type XxxResponse = XxxResponseData;
|
||||
```
|
||||
|
||||
### 5. 更新 API Service
|
||||
### 5. 更新 DTO
|
||||
|
||||
在对应模块下新增或修改:
|
||||
|
||||
```text
|
||||
src/data/dto/<module>/*.ts
|
||||
```
|
||||
|
||||
要求:
|
||||
|
||||
- DTO class 的 `declare readonly` 只声明前端业务代码会直接访问的字段。
|
||||
- 不要因为后端响应包含某字段,就机械地为它增加 class 属性、嵌套类型或类型别名。
|
||||
- 后端返回但前端既不读取、也不透传的字段,可以不加入 schema 和 DTO。
|
||||
- 仅用于请求序列化、响应兼容或内部透传的字段保留在 schema 中,不添加 class 属性声明。
|
||||
- `Object.assign(this, data)` 会保留 schema 解析后的字段;即使 class 未声明对应属性,`toJson()` 仍可按 schema 正常序列化。
|
||||
- 新增 DTO 字段前先搜索实际调用点;没有直接读取方时默认不声明。
|
||||
|
||||
DTO 统一模式:
|
||||
|
||||
```ts
|
||||
export const XxxResponseSchema = z.object({
|
||||
id: z.string(),
|
||||
// 仅用于内部透传,不需要在 DTO class 中声明。
|
||||
traceId: z.string(),
|
||||
});
|
||||
|
||||
export class XxxResponse {
|
||||
// 业务代码直接读取的字段才公开声明。
|
||||
declare readonly id: string;
|
||||
|
||||
private constructor(input: XxxResponseInput) {
|
||||
const data = XxxResponseSchema.parse(input);
|
||||
Object.assign(this, data);
|
||||
Object.freeze(this);
|
||||
}
|
||||
|
||||
static from(input: XxxResponseInput): XxxResponse {
|
||||
return new XxxResponse(input);
|
||||
}
|
||||
|
||||
static fromJson(json: unknown): XxxResponse {
|
||||
return XxxResponse.from(json as XxxResponseInput);
|
||||
}
|
||||
|
||||
toJson(): XxxResponseData {
|
||||
return XxxResponseSchema.parse(this);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 6. 更新 API Service
|
||||
|
||||
修改:
|
||||
|
||||
@@ -166,9 +199,9 @@ src/data/services/api/<module>_api.ts
|
||||
```ts
|
||||
const env = await httpClient<ApiEnvelope<unknown>>(ApiPath.xxx, {
|
||||
method: "POST",
|
||||
body: request,
|
||||
body: request.toJson(),
|
||||
});
|
||||
return XxxResponseSchema.parse(unwrap(env));
|
||||
return XxxResponse.fromJson(unwrap(env) as Record<string, unknown>);
|
||||
```
|
||||
|
||||
注意:
|
||||
@@ -177,7 +210,7 @@ return XxxResponseSchema.parse(unwrap(env));
|
||||
- 不要在 API 层处理 UI 行为。
|
||||
- multipart 仍使用 `FormData`。
|
||||
|
||||
### 6. 更新 Repository
|
||||
### 7. 更新 Repository
|
||||
|
||||
修改:
|
||||
|
||||
@@ -196,14 +229,14 @@ async getXxx(): Promise<Result<XxxResponse>> {
|
||||
|
||||
Repository 可以做轻量编排,例如:
|
||||
|
||||
- request schema 解析
|
||||
- request DTO 构造
|
||||
- 多接口组合
|
||||
- 本地 storage 同步
|
||||
- 本地模型与接口模型转换
|
||||
- local model 与 DTO 转换
|
||||
|
||||
不要把 React / UI 逻辑放进 repository。
|
||||
|
||||
### 7. 更新 Storage
|
||||
### 8. 更新 Storage
|
||||
|
||||
如果接口影响本地持久化,修改:
|
||||
|
||||
@@ -229,7 +262,7 @@ getEntitlementSnapshot(): Promise<Result<UserEntitlementSnapshotData | null>> {
|
||||
}
|
||||
```
|
||||
|
||||
### 8. 更新 Store / 状态机
|
||||
### 9. 更新 Store / 状态机
|
||||
|
||||
如果接口影响状态流,修改:
|
||||
|
||||
@@ -251,7 +284,7 @@ src/stores/<module>/*-sync.tsx
|
||||
- 页面组件不承担全局监听职责。
|
||||
- 状态机事件应表达业务事实,而不是 UI 操作细节。
|
||||
|
||||
### 9. 更新 UI
|
||||
### 10. 更新 UI
|
||||
|
||||
只有在接口变更影响展示或用户明确要求时,才修改:
|
||||
|
||||
@@ -265,18 +298,19 @@ src/app/**
|
||||
- 不在页面组件里直接写复杂业务编排。
|
||||
- 全局监听逻辑优先放到 `stores/*/*-sync.tsx`。
|
||||
|
||||
### 10. 更新桶文件
|
||||
### 11. 更新桶文件
|
||||
|
||||
如果新增 schema model 或 component,更新对应 `index.ts`:
|
||||
如果新增 schema / DTO / component,更新对应 `index.ts`:
|
||||
|
||||
```text
|
||||
src/data/schemas/<module>/index.ts
|
||||
src/data/dto/<module>/index.ts
|
||||
src/app/**/components/index.ts
|
||||
```
|
||||
|
||||
如果项目使用 barrelsby 生成,不要手动破坏现有导出格式。
|
||||
|
||||
### 11. 更新 Mock 数据
|
||||
### 12. 更新 Mock 数据
|
||||
|
||||
如果新增或调整数据结构,按一个结构一个文件的原则放到:
|
||||
|
||||
@@ -288,11 +322,11 @@ src/data/mock/<module>/websocket-events
|
||||
|
||||
不要把多个结构塞进一个大 JSON。
|
||||
|
||||
### 12. 更新测试
|
||||
### 13. 更新测试
|
||||
|
||||
优先补充:
|
||||
|
||||
- schema model 解析与序列化测试
|
||||
- DTO / schema parse 测试
|
||||
- helper 纯函数测试
|
||||
- XState transition 测试
|
||||
- repository 编排测试(如已有测试基础)
|
||||
@@ -300,11 +334,11 @@ src/data/mock/<module>/websocket-events
|
||||
常见位置:
|
||||
|
||||
```text
|
||||
src/data/schemas/<module>/__tests__/*.test.ts
|
||||
src/data/dto/<module>/__tests__/*.test.ts
|
||||
src/stores/<module>/__tests__/*.test.ts
|
||||
```
|
||||
|
||||
### 13. 验证
|
||||
### 14. 验证
|
||||
|
||||
至少运行:
|
||||
|
||||
@@ -322,17 +356,18 @@ pnpm exec vitest run <related tests>
|
||||
|
||||
1. 文档确认 path / method / payload。
|
||||
2. `api_path.ts` 新增路径。
|
||||
3. 在同一文件新增 readonly schema 与输入/输出类型。
|
||||
4. API service 新增方法。
|
||||
5. repository interface + implementation 新增方法。
|
||||
6. 如需要,接入 store actor / event。
|
||||
7. 补 mock 和测试。
|
||||
8. 运行验证。
|
||||
3. 新增 schema。
|
||||
4. 新增 DTO。
|
||||
5. API service 新增方法。
|
||||
6. repository interface + implementation 新增方法。
|
||||
7. 如需要,接入 store actor / event。
|
||||
8. 补 mock 和测试。
|
||||
9. 运行验证。
|
||||
|
||||
### 修改响应字段
|
||||
|
||||
1. 更新 schema。
|
||||
2. 更新同文件输入/输出类型及相关 parse 调用。
|
||||
2. 更新 DTO declare 字段和 `toJson`。
|
||||
3. 更新 mapper/helper。
|
||||
4. 更新 UI 或状态机依赖字段。
|
||||
5. 更新 mock 和测试。
|
||||
@@ -342,7 +377,7 @@ pnpm exec vitest run <related tests>
|
||||
|
||||
1. 搜索所有引用。
|
||||
2. 删除 API path / API method / repository method。
|
||||
3. 删除 schema model、mock 和测试。
|
||||
3. 删除 DTO/schema/mock/test。
|
||||
4. 更新状态机和 UI 调用。
|
||||
5. 运行 `rg` 确认无残留引用。
|
||||
6. 运行验证。
|
||||
|
||||
@@ -8,8 +8,39 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
quality:
|
||||
name: Quality and Bundle Budgets
|
||||
runs-on: gitea-label
|
||||
container:
|
||||
image: cozsweet-act-runner-node24-docker:latest
|
||||
env:
|
||||
NEXT_TELEMETRY_DISABLED: "1"
|
||||
SENTRY_UPLOAD_SOURCEMAPS: "0"
|
||||
|
||||
steps:
|
||||
- name: Skip quality gate for test branch
|
||||
if: ${{ github.ref == 'refs/heads/test' }}
|
||||
run: echo "Quality gate is disabled for the test branch."
|
||||
|
||||
- name: Checkout
|
||||
if: ${{ github.ref != 'refs/heads/test' }}
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
if: ${{ github.ref != 'refs/heads/test' }}
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Run quality checks
|
||||
if: ${{ github.ref != 'refs/heads/test' }}
|
||||
run: pnpm quality
|
||||
|
||||
- name: Enforce bundle budgets
|
||||
if: ${{ github.ref != 'refs/heads/test' }}
|
||||
run: pnpm perf:bundle:check
|
||||
|
||||
publish:
|
||||
name: Build and Push Docker Image
|
||||
needs: quality
|
||||
runs-on: gitea-label
|
||||
container:
|
||||
image: cozsweet-act-runner-node24-docker:latest
|
||||
@@ -152,9 +183,12 @@ jobs:
|
||||
- name: Deploy image over SSH
|
||||
env:
|
||||
SSH_HOST: ${{ secrets.SSH_HOST }}
|
||||
SSH_USER: ${{ secrets.SSH_USER }}
|
||||
SSH_PORT: ${{ secrets.SSH_PORT }}
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
|
||||
TEST_DEPLOY_DIR: ${{ secrets.TEST_DEPLOY_DIR }}
|
||||
PROD_DEPLOY_DIR: ${{ secrets.PROD_DEPLOY_DIR }}
|
||||
REGISTRY_HOST: ${{ secrets.REGISTRY_HOST }}
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
@@ -163,18 +197,16 @@ jobs:
|
||||
|
||||
case "$DEPLOY_ENV" in
|
||||
test)
|
||||
DEPLOY_ROOT="/home/lzf/apps/cozsweet-web-test"
|
||||
DEPLOY_DIR="${TEST_DEPLOY_DIR:-/opt/cozsweet-web-test}"
|
||||
HOST_PORT="9135"
|
||||
CONTAINER_NAME="cozsweet-web-test"
|
||||
PROJECT_NAME="cozsweet-web-test"
|
||||
SERVER_RETAIN_COUNT="1"
|
||||
;;
|
||||
prod)
|
||||
DEPLOY_ROOT="/home/lzf/apps/cozsweet-web-prod"
|
||||
DEPLOY_DIR="${PROD_DEPLOY_DIR:-/opt/cozsweet-web-prod}"
|
||||
HOST_PORT="9185"
|
||||
CONTAINER_NAME="cozsweet-web-prod"
|
||||
PROJECT_NAME="cozsweet-web-prod"
|
||||
SERVER_RETAIN_COUNT="2"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported deploy env: $DEPLOY_ENV" >&2
|
||||
@@ -182,11 +214,8 @@ jobs:
|
||||
;;
|
||||
esac
|
||||
|
||||
DEPLOY_DIR="$DEPLOY_ROOT/current"
|
||||
DEPLOY_SHARED_DIR="$DEPLOY_ROOT/shared"
|
||||
REMOTE_ENV_FILE="$DEPLOY_SHARED_DIR/$NEXT_ENV_FILE"
|
||||
DEPLOY_HOST="$SSH_HOST"
|
||||
DEPLOY_USER="lzf"
|
||||
DEPLOY_USER="$SSH_USER"
|
||||
DEPLOY_PORT="${SSH_PORT:-22}"
|
||||
DEPLOY_KEY="$SSH_PRIVATE_KEY"
|
||||
DEPLOY_KNOWN_HOSTS="$SSH_KNOWN_HOSTS"
|
||||
@@ -212,19 +241,19 @@ jobs:
|
||||
SSH_OPTS="-i $KEY_FILE -p $DEPLOY_PORT -o IdentitiesOnly=yes"
|
||||
SCP_OPTS="-i $KEY_FILE -P $DEPLOY_PORT -o IdentitiesOnly=yes"
|
||||
|
||||
ssh $SSH_OPTS "$SSH_TARGET" \
|
||||
"mkdir -p '$DEPLOY_DIR' '$DEPLOY_SHARED_DIR' '$DEPLOY_ROOT/releases' '$DEPLOY_ROOT/backups' '$DEPLOY_ROOT/tmp' && chmod 700 '$DEPLOY_SHARED_DIR'"
|
||||
ssh $SSH_OPTS "$SSH_TARGET" "mkdir -p '$DEPLOY_DIR'"
|
||||
scp $SCP_OPTS docker-compose.yml "$SSH_TARGET:$DEPLOY_DIR/docker-compose.yml"
|
||||
scp $SCP_OPTS scripts/server/deploy-docker-image.sh "$SSH_TARGET:$DEPLOY_DIR/deploy-docker-image.sh"
|
||||
scp $SCP_OPTS "$NEXT_ENV_FILE" "$SSH_TARGET:$REMOTE_ENV_FILE"
|
||||
ssh $SSH_OPTS "$SSH_TARGET" "chmod 600 '$REMOTE_ENV_FILE'"
|
||||
scp $SCP_OPTS "$NEXT_ENV_FILE" "$SSH_TARGET:$DEPLOY_DIR/$NEXT_ENV_FILE"
|
||||
|
||||
printf '%s' "$REGISTRY_PASSWORD" \
|
||||
| ssh $SSH_OPTS "$SSH_TARGET" \
|
||||
"docker login '$REGISTRY_HOST' -u '$REGISTRY_USERNAME' --password-stdin"
|
||||
|
||||
SERVER_RETAIN_COUNT="1"
|
||||
|
||||
ssh $SSH_OPTS "$SSH_TARGET" \
|
||||
"cd '$DEPLOY_DIR' && chmod +x ./deploy-docker-image.sh && ./deploy-docker-image.sh '$IMAGE_VERSION_TAG' '$REMOTE_ENV_FILE' '$HOST_PORT' '$CONTAINER_NAME' '$PROJECT_NAME' '$SERVER_RETAIN_COUNT'"
|
||||
"cd '$DEPLOY_DIR' && chmod +x ./deploy-docker-image.sh && ./deploy-docker-image.sh '$IMAGE_VERSION_TAG' '$NEXT_ENV_FILE' '$HOST_PORT' '$CONTAINER_NAME' '$PROJECT_NAME' '$SERVER_RETAIN_COUNT'"
|
||||
|
||||
- name: Purge Cloudflare cache
|
||||
env:
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
name: Deploy frontend to domestic test
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Build and deploy isolated domestic test
|
||||
runs-on: gitea-label
|
||||
container:
|
||||
image: cozsweet-act-runner-node24-docker:latest
|
||||
env:
|
||||
NEXT_TELEMETRY_DISABLED: "1"
|
||||
SENTRY_UPLOAD_SOURCEMAPS: "0"
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Validate domestic SSH configuration
|
||||
env:
|
||||
SSH_HOST: ${{ secrets.DOMESTIC_TEST_SSH_HOST }}
|
||||
SSH_PORT: ${{ secrets.DOMESTIC_TEST_SSH_PORT }}
|
||||
SSH_PRIVATE_KEY_B64: ${{ secrets.DOMESTIC_TEST_SSH_PRIVATE_KEY_B64 }}
|
||||
SSH_KNOWN_HOSTS: ${{ secrets.DOMESTIC_TEST_SSH_KNOWN_HOSTS }}
|
||||
run: |
|
||||
set -eu
|
||||
if [ -z "$SSH_HOST" ] || [ -z "$SSH_PRIVATE_KEY_B64" ] || [ -z "$SSH_KNOWN_HOSTS" ]; then
|
||||
echo "Missing domestic test SSH secrets" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$HOME/.ssh"
|
||||
chmod 700 "$HOME/.ssh"
|
||||
printf '%s' "$SSH_PRIVATE_KEY_B64" | base64 -d > "$HOME/.ssh/domestic_test_deploy_key"
|
||||
printf '%s\n' "$SSH_KNOWN_HOSTS" > "$HOME/.ssh/known_hosts"
|
||||
chmod 600 "$HOME/.ssh/domestic_test_deploy_key" "$HOME/.ssh/known_hosts"
|
||||
|
||||
- name: Prepare domestic test environment
|
||||
env:
|
||||
TEST_ENV_FILE_CONTENT: ${{ secrets.TEST_ENV_FILE }}
|
||||
run: |
|
||||
set -eu
|
||||
if [ -z "$TEST_ENV_FILE_CONTENT" ]; then
|
||||
echo "Missing existing secret: TEST_ENV_FILE" >&2
|
||||
exit 1
|
||||
fi
|
||||
umask 077
|
||||
printf '%s\n' "$TEST_ENV_FILE_CONTENT" > .env.domestic-test
|
||||
|
||||
replace_env() {
|
||||
key="$1"
|
||||
value="$2"
|
||||
awk -v key="$key" -v value="$value" '
|
||||
BEGIN { replaced = 0 }
|
||||
$0 ~ "^" key "=" { print key "=" value; replaced = 1; next }
|
||||
{ print }
|
||||
END { if (!replaced) print key "=" value }
|
||||
' .env.domestic-test > .env.domestic-test.next
|
||||
mv .env.domestic-test.next .env.domestic-test
|
||||
}
|
||||
|
||||
replace_env NEXT_PUBLIC_APP_ENV test
|
||||
replace_env NEXT_PUBLIC_API_BASE_URL https://testapi.banlv-ai.com
|
||||
replace_env NEXT_PUBLIC_WS_BASE_URL wss://testapi.banlv-ai.com/ws
|
||||
replace_env NEXTAUTH_URL http://127.0.0.1:9135
|
||||
replace_env NEXTAUTH_URL_INTERNAL http://127.0.0.1:3000
|
||||
|
||||
grep -Eq '^AUTH_SECRET=.+$' .env.domestic-test
|
||||
grep -Eq '^NEXT_PUBLIC_API_BASE_URL=https://testapi\.banlv-ai\.com/?$' .env.domestic-test
|
||||
grep -Eq '^NEXT_PUBLIC_WS_BASE_URL=wss://testapi\.banlv-ai\.com/ws/?$' .env.domestic-test
|
||||
|
||||
- name: Prepare image metadata
|
||||
run: |
|
||||
set -eu
|
||||
SHORT_SHA="$(git rev-parse --short HEAD)"
|
||||
IMAGE="cozsweet-frontend-domestic-test:test-$SHORT_SHA"
|
||||
ARCHIVE="cozsweet-frontend-domestic-test-$SHORT_SHA.tar.gz"
|
||||
{
|
||||
echo "SHORT_SHA=$SHORT_SHA"
|
||||
echo "IMAGE=$IMAGE"
|
||||
echo "ARCHIVE=$ARCHIVE"
|
||||
} >> "$GITHUB_ENV"
|
||||
|
||||
- name: Run frontend quality checks
|
||||
run: |
|
||||
set -eu
|
||||
pnpm install --frozen-lockfile
|
||||
pnpm lint
|
||||
pnpm typecheck
|
||||
pnpm test:contracts
|
||||
|
||||
- name: Build and archive runtime image
|
||||
run: |
|
||||
set -eu
|
||||
DOCKER_BUILDKIT=1 docker build \
|
||||
--secret id=next_env,src=.env.domestic-test \
|
||||
--build-arg NEXT_ENV_FILE=.env.domestic-test \
|
||||
-t "$IMAGE" \
|
||||
.
|
||||
docker save "$IMAGE" | gzip -1 > "$ARCHIVE"
|
||||
test -s "$ARCHIVE"
|
||||
|
||||
- name: Deploy isolated domestic test container
|
||||
env:
|
||||
SSH_HOST: ${{ secrets.DOMESTIC_TEST_SSH_HOST }}
|
||||
SSH_PORT: ${{ secrets.DOMESTIC_TEST_SSH_PORT }}
|
||||
run: |
|
||||
set -eu
|
||||
DEPLOY_PORT="${SSH_PORT:-22}"
|
||||
KEY_FILE="$HOME/.ssh/domestic_test_deploy_key"
|
||||
SSH_TARGET="lzf@$SSH_HOST"
|
||||
RUN_TOKEN="${GITHUB_RUN_ID:-manual}-${GITHUB_RUN_ATTEMPT:-1}"
|
||||
DEPLOY_ROOT="/home/lzf/apps/cozsweet-web-test"
|
||||
REMOTE_TMP="$DEPLOY_ROOT/tmp/actions-$RUN_TOKEN"
|
||||
REMOTE_ARCHIVE="$REMOTE_TMP/$ARCHIVE"
|
||||
REMOTE_ENV_FILE="$DEPLOY_ROOT/shared/test.env"
|
||||
SSH_OPTS="-i $KEY_FILE -p $DEPLOY_PORT -o BatchMode=yes -o IdentitiesOnly=yes"
|
||||
SCP_OPTS="-i $KEY_FILE -P $DEPLOY_PORT -o BatchMode=yes -o IdentitiesOnly=yes"
|
||||
|
||||
cleanup_remote() {
|
||||
ssh $SSH_OPTS "$SSH_TARGET" \
|
||||
"rm -f '$REMOTE_ARCHIVE' && rmdir '$REMOTE_TMP' 2>/dev/null || true"
|
||||
}
|
||||
trap cleanup_remote EXIT
|
||||
|
||||
ssh $SSH_OPTS "$SSH_TARGET" \
|
||||
"mkdir -p '$DEPLOY_ROOT/current' '$DEPLOY_ROOT/releases/docker' '$DEPLOY_ROOT/shared' '$REMOTE_TMP' && chmod 700 '$DEPLOY_ROOT/shared'"
|
||||
scp $SCP_OPTS scripts/server/deploy-domestic-test-archive.sh \
|
||||
"$SSH_TARGET:$DEPLOY_ROOT/current/deploy-domestic-test-archive.sh"
|
||||
scp $SCP_OPTS .env.domestic-test "$SSH_TARGET:$REMOTE_ENV_FILE"
|
||||
scp $SCP_OPTS "$ARCHIVE" "$SSH_TARGET:$REMOTE_ARCHIVE"
|
||||
ssh $SSH_OPTS "$SSH_TARGET" \
|
||||
"chmod 600 '$REMOTE_ENV_FILE' && chmod 700 '$DEPLOY_ROOT/current/deploy-domestic-test-archive.sh' && '$DEPLOY_ROOT/current/deploy-domestic-test-archive.sh' '$REMOTE_ARCHIVE' '$IMAGE' '$REMOTE_ENV_FILE' 9135"
|
||||
|
||||
- name: Cleanup runner artifacts
|
||||
if: always()
|
||||
run: |
|
||||
rm -f .env.domestic-test .env.domestic-test.next "${ARCHIVE:-}" "$HOME/.ssh/domestic_test_deploy_key"
|
||||
@@ -6,12 +6,10 @@ ENV PNPM_HOME=/pnpm
|
||||
ENV PNPM_STORE_PATH=/pnpm/store
|
||||
ENV PATH=$PNPM_HOME:$PATH
|
||||
|
||||
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
||||
|
||||
RUN apk add --no-cache libc6-compat \
|
||||
&& npm install --global "pnpm@10.30.3" --registry="$NPM_REGISTRY" \
|
||||
&& pnpm config set store-dir "$PNPM_STORE_PATH" \
|
||||
&& pnpm config set registry "$NPM_REGISTRY"
|
||||
&& corepack enable \
|
||||
&& corepack prepare pnpm@10.30.3 --activate \
|
||||
&& pnpm config set store-dir "$PNPM_STORE_PATH"
|
||||
|
||||
FROM base AS deps
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
|
||||
@@ -1,403 +0,0 @@
|
||||
# 虚拟礼物商品与付款后文案 API
|
||||
|
||||
## 一、用途
|
||||
|
||||
前端按当前角色一次获取全部启用的礼物品类和商品,在本地完成品类切换与商品筛选。页面不得写死咖啡、鲜花、服装等品类,也不得根据 `planId` 推算名称、图片或价格。付款成功后,前端使用订单号获取稳定的角色感谢文案。
|
||||
|
||||
## 三、推荐接入流程
|
||||
|
||||
1. 当前角色确定后,只请求一次 `GET /api/payment/gift-products?characterId=<CHARACTER_ID>`。
|
||||
2. 使用 `data.categories` 渲染品类栏,使用 `data.plans` 保存完整商品目录。
|
||||
3. 用户切换品类时只在前端按 `product.category` 本地筛选,不再请求后端。
|
||||
4. 使用商品自身的 `planName`、`description`、`imageUrl`、`amountCents` 和 `currency` 渲染通用商品卡片。
|
||||
5. 用户选择商品后,使用该商品原始 `planId` 创建订单。
|
||||
6. 用户切换商品时清除旧 `orderId`、`clientSecret` 和支付组件状态,再创建新订单。
|
||||
7. Stripe 使用本次订单返回的 `payParams.clientSecret` 挂载 Payment Element。
|
||||
8. 每 3 至 5 秒轮询订单状态,直到状态变成 `paid`、`failed` 或 `expired`。
|
||||
9. 状态为 `paid` 后调用 `POST /api/payment/tip-message`,展示 `data.message`。
|
||||
|
||||
> `amountCents`、`currency` 和 `planId` 必须来自同一条商品数据。后端下单时会再次按 `planId` 校验真实价格,前端展示值不得作为收费依据。
|
||||
|
||||
---
|
||||
|
||||
## 四、一次获取完整礼物目录
|
||||
|
||||
### 4.1 请求
|
||||
|
||||
```http
|
||||
GET /api/payment/gift-products?characterId=elio
|
||||
```
|
||||
|
||||
- 完整地址:`https://proapi.banlv-ai.com/api/payment/gift-products`
|
||||
- 兼容别名:`GET /api/payment/tip-plans`
|
||||
- 登录鉴权:不需要
|
||||
- 请求格式:Query String
|
||||
|
||||
### 4.2 查询参数
|
||||
|
||||
| 字段 | 类型 | 必填 | 可空 | 示例 | 说明 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| `characterId` | string | 前端必传 | 否 | `elio` | 当前收礼角色 ID。后端仍兼容省略,但多角色前端不得省略。 |
|
||||
| `category` | string | 否 | 否 | `coffee` | 兼容旧的按品类懒加载方式。新版前端首屏不传此字段。 |
|
||||
|
||||
### 4.3 请求示例
|
||||
|
||||
```bash
|
||||
curl 'https://proapi.banlv-ai.com/api/payment/gift-products?characterId=elio'
|
||||
```
|
||||
|
||||
### 4.4 成功响应
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"success": true,
|
||||
"data": {
|
||||
"characterId": "elio",
|
||||
"categories": [
|
||||
{
|
||||
"category": "coffee",
|
||||
"name": "Coffee",
|
||||
"productCount": 3,
|
||||
"imageUrl": null
|
||||
},
|
||||
{
|
||||
"category": "flowers",
|
||||
"name": "Flowers",
|
||||
"productCount": 2,
|
||||
"imageUrl": "https://example.com/flowers.jpg"
|
||||
}
|
||||
],
|
||||
"plans": [
|
||||
{
|
||||
"planId": "tip_coffee_usd_4_99",
|
||||
"planName": "Velvet Espresso",
|
||||
"orderType": "tip",
|
||||
"tipType": "coffee_small",
|
||||
"category": "coffee",
|
||||
"characterId": "elio",
|
||||
"description": "Buy Elio a small coffee",
|
||||
"imageUrl": null,
|
||||
"amountCents": 499,
|
||||
"currency": "USD",
|
||||
"autoRenew": false,
|
||||
"isFirstRechargeOffer": false,
|
||||
"firstRechargeDiscountPercent": 0,
|
||||
"promotionType": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 4.5 响应字段
|
||||
|
||||
| 字段 | 类型 | 可空 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `data.characterId` | string | 是 | 本次查询的角色;省略请求参数时为 `null`。 |
|
||||
| `data.categories` | array | 否 | 当前结果中的品类,顺序与 Manager 商品排序一致。 |
|
||||
| `categories[].category` | string | 否 | 稳定品类值,只用于关联和筛选。 |
|
||||
| `categories[].name` | string | 否 | 品类展示名称。 |
|
||||
| `categories[].productCount` | number(整数) | 否 | 当前品类中的启用商品数量。 |
|
||||
| `categories[].imageUrl` | string | 是 | 该品类第一张可用商品图;没有图片时为 `null`。 |
|
||||
| `data.plans` | array | 否 | 当前角色全部启用商品;没有商品时为空数组。 |
|
||||
| `plans[].planId` | string | 否 | 商品唯一标识,创建订单时必须原样传回。 |
|
||||
| `plans[].planName` | string | 否 | 商品展示名称。 |
|
||||
| `plans[].orderType` | string enum | 否 | 礼物固定为 `tip`。 |
|
||||
| `plans[].tipType` | string | 否 | 支付成功事件使用的礼物细分类型。 |
|
||||
| `plans[].category` | string | 否 | 所属品类,与 `categories[].category` 对应。 |
|
||||
| `plans[].characterId` | string | 否 | 收礼角色 ID。 |
|
||||
| `plans[].description` | string | 否 | 商品说明,可能为空字符串。 |
|
||||
| `plans[].imageUrl` | string | 是 | 完整公开图片 URL;没有图片时为 `null`。 |
|
||||
| `plans[].amountCents` | number(整数) | 否 | 展示金额的百分之一;USD 下 `499` 表示 `$4.99`。 |
|
||||
| `plans[].currency` | string | 否 | 三位大写币种代码,例如 `USD`。 |
|
||||
| `plans[].autoRenew` | boolean | 否 | 礼物固定为 `false`。 |
|
||||
| `plans[].isFirstRechargeOffer` | boolean | 否 | 礼物固定为 `false`。 |
|
||||
| `plans[].firstRechargeDiscountPercent` | number(整数) | 否 | 礼物固定为 `0`。 |
|
||||
| `plans[].promotionType` | string | 是 | 礼物没有促销时为 `null`。 |
|
||||
|
||||
## 五、前端通用品类与商品显示逻辑
|
||||
|
||||
### 5.1 建议类型
|
||||
|
||||
```ts
|
||||
interface GiftCategory {
|
||||
category: string;
|
||||
name: string;
|
||||
productCount: number;
|
||||
imageUrl: string | null;
|
||||
}
|
||||
|
||||
interface GiftProduct {
|
||||
planId: string;
|
||||
planName: string;
|
||||
orderType: "tip";
|
||||
tipType: string;
|
||||
category: string;
|
||||
characterId: string;
|
||||
description: string;
|
||||
imageUrl: string | null;
|
||||
amountCents: number;
|
||||
currency: string;
|
||||
autoRenew: false;
|
||||
}
|
||||
|
||||
interface GiftCatalog {
|
||||
characterId: string | null;
|
||||
categories: GiftCategory[];
|
||||
plans: GiftProduct[];
|
||||
}
|
||||
```
|
||||
|
||||
### 5.2 状态和筛选
|
||||
|
||||
```ts
|
||||
const [catalog, setCatalog] = useState<GiftCatalog | null>(null);
|
||||
const [selectedCategory, setSelectedCategory] = useState<string | null>(null);
|
||||
const [selectedPlanId, setSelectedPlanId] = useState<string | null>(null);
|
||||
|
||||
const visibleProducts = (catalog?.plans ?? []).filter(
|
||||
product => product.category === selectedCategory,
|
||||
);
|
||||
```
|
||||
|
||||
- 角色变化时重新请求,并以 `characterId` 作为缓存键,不能复用另一个角色的目录。
|
||||
- 请求完成后默认选择 `categories[0].category`;深链指定的品类存在时优先选择深链值。
|
||||
- 切换品类只更新 `selectedCategory`,不请求第二个接口。
|
||||
- 只有一个品类时可以隐藏品类切换栏。
|
||||
- 新增未知品类时仍使用同一套通用商品卡片,禁止编写 `if (category === "coffee")` 一类业务分支。
|
||||
- 商品图片优先级:`product.imageUrl` → 当前 `category.imageUrl` → 通用礼物占位图。
|
||||
- 商品名称和说明使用 `planName`、`description`;不要使用前端本地咖啡常量覆盖。
|
||||
- 价格使用 `Intl.NumberFormat`,金额为 `amountCents / 100`。
|
||||
|
||||
```ts
|
||||
const displayPrice = new Intl.NumberFormat("en-US", {
|
||||
style: "currency",
|
||||
currency: product.currency,
|
||||
}).format(product.amountCents / 100);
|
||||
```
|
||||
|
||||
### 5.3 页面状态
|
||||
|
||||
| 状态 | 前端行为 |
|
||||
| --- | --- |
|
||||
| 加载中 | 显示稳定尺寸的商品骨架,不显示旧角色缓存。 |
|
||||
| `categories=[]`、`plans=[]` | 显示“该角色暂时没有可用礼物”,不要回退到写死咖啡。 |
|
||||
| 某品类没有商品 | 自动切换到第一个有商品的品类;全部为空时显示空状态。 |
|
||||
| `imageUrl=null` | 使用品类图或通用占位图。 |
|
||||
| 请求失败 | 显示重试操作,不使用可能过期的价格创建订单。 |
|
||||
| 角色切换 | 取消旧请求,清空品类、商品、选中商品、订单和 Stripe 状态。 |
|
||||
|
||||
### 5.4 兼容接口
|
||||
|
||||
- `GET /api/payment/gift-categories` 保留给只需要品类的旧客户端,新版前端主流程不调用。
|
||||
- `GET /api/payment/gift-products?characterId=elio&category=coffee` 仍支持按品类过滤,适用于未来商品数很大时懒加载。
|
||||
- `GET /api/payment/tip-plans` 与 `/gift-products` 返回同一协议,旧前端继续读取 `data.plans` 不受影响。
|
||||
- 新增的 `data.characterId` 和 `data.categories` 是向后兼容字段。
|
||||
|
||||
---
|
||||
|
||||
## 六、创建礼物支付订单
|
||||
|
||||
### 6.1 请求
|
||||
|
||||
```http
|
||||
POST /api/payment/create-order
|
||||
```
|
||||
|
||||
- 完整地址:`https://proapi.banlv-ai.com/api/payment/create-order`
|
||||
- 登录鉴权:需要
|
||||
- Header:`Authorization: Bearer <USER_TOKEN>`
|
||||
- Content-Type:`application/json`
|
||||
|
||||
### 6.2 请求字段
|
||||
|
||||
| 字段 | 类型 | 必填 | 可空 | 示例 | 说明 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| `planId` | string | 是 | 否 | `tip_coffee_usd_4_99` | 必须使用本次商品接口返回的原始值。 |
|
||||
| `payChannel` | enum string | 是 | 否 | `stripe` | 可选值:`stripe`、`ezpay`。 |
|
||||
| `autoRenew` | boolean | 是 | 否 | `false` | 礼物是一次性付款,固定发送 `false`。 |
|
||||
| `recipientCharacterId` | string | 否 | 否 | `elio` | 可省略;省略时使用商品所属角色。传入其他角色会被拒绝。 |
|
||||
|
||||
### 6.3 请求示例
|
||||
|
||||
```bash
|
||||
curl -X POST 'https://proapi.banlv-ai.com/api/payment/create-order' \
|
||||
-H 'Authorization: Bearer <USER_TOKEN>' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"planId": "tip_coffee_usd_4_99",
|
||||
"payChannel": "stripe",
|
||||
"autoRenew": false,
|
||||
"recipientCharacterId": "elio"
|
||||
}'
|
||||
```
|
||||
|
||||
### 6.4 Stripe 成功响应
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"success": true,
|
||||
"data": {
|
||||
"orderId": "pay_xxx",
|
||||
"payParams": {
|
||||
"clientSecret": "<STRIPE_CLIENT_SECRET>",
|
||||
"provider": "stripe",
|
||||
"automaticRenewal": false,
|
||||
"firstChargeAmountCents": 499,
|
||||
"renewalAmountCents": null
|
||||
},
|
||||
"expiresAt": "2026-07-20T10:30:00+00:00",
|
||||
"expiresInSeconds": 1800
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 6.5 Stripe 前端处理要求
|
||||
|
||||
- 使用 `data.payParams.clientSecret` 挂载 Stripe Payment Element。
|
||||
- `firstChargeAmountCents` 应与所选商品的 `amountCents` 一致,可用于提交支付前的防错校验。
|
||||
- 用户切换商品或重新创建订单后,必须销毁旧 Payment Element,并使用新的 `orderId + clientSecret` 重新挂载。
|
||||
- 不要复用上一件商品的 `clientSecret`,否则页面商品名称、显示价格和实际 PaymentIntent 可能不属于同一订单。
|
||||
- 礼物不会增加积分或 VIP,不参加首充折扣,也不会自动续费。
|
||||
|
||||
EzPay 响应可能在 `payParams` 中返回 `cashierUrl` 或 `payData`,前端按对应支付渠道处理。
|
||||
|
||||
---
|
||||
|
||||
## 七、轮询订单状态
|
||||
|
||||
### 7.1 请求
|
||||
|
||||
```http
|
||||
GET /api/payment/order-status?order_id=<ORDER_ID>
|
||||
```
|
||||
|
||||
- 完整地址:`https://proapi.banlv-ai.com/api/payment/order-status`
|
||||
- 登录鉴权:需要,必须与创建订单的用户一致
|
||||
- Header:`Authorization: Bearer <USER_TOKEN>`
|
||||
- 查询字段兼容性说明:当前字段名是 `order_id`,不是 `orderId`
|
||||
|
||||
### 7.2 请求示例
|
||||
|
||||
```bash
|
||||
curl 'https://proapi.banlv-ai.com/api/payment/order-status?order_id=<ORDER_ID>' \
|
||||
-H 'Authorization: Bearer <USER_TOKEN>'
|
||||
```
|
||||
|
||||
### 7.3 关键响应字段
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"success": true,
|
||||
"data": {
|
||||
"orderId": "pay_xxx",
|
||||
"status": "paid",
|
||||
"orderType": "tip",
|
||||
"planId": "tip_coffee_usd_4_99",
|
||||
"creditsAdded": 0
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| 字段 | 类型 | 可空 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `orderId` | string | 否 | 当前订单号。 |
|
||||
| `status` | enum string | 否 | `pending`、`paid`、`failed` 或 `expired`。 |
|
||||
| `orderType` | string | 否 | 礼物订单为 `tip`。 |
|
||||
| `planId` | string | 是 | 当前订单对应的商品 `planId`。 |
|
||||
| `creditsAdded` | number(整数) | 否 | 礼物订单固定为 `0`。 |
|
||||
|
||||
建议每 3 至 5 秒轮询一次;出现 `paid`、`failed` 或 `expired` 后立即停止。
|
||||
|
||||
---
|
||||
|
||||
## 八、获取付款后感谢文案
|
||||
|
||||
### 8.1 请求
|
||||
|
||||
```http
|
||||
POST /api/payment/tip-message
|
||||
```
|
||||
|
||||
仅在订单状态已经变为 `paid` 后调用。
|
||||
|
||||
- 完整地址:`https://proapi.banlv-ai.com/api/payment/tip-message`
|
||||
- 登录鉴权:需要,必须是订单所属用户
|
||||
- Header:`Authorization: Bearer <USER_TOKEN>`
|
||||
- Content-Type:`application/json`
|
||||
|
||||
### 8.2 请求字段
|
||||
|
||||
| 字段 | 类型 | 必填 | 可空 | 示例 | 说明 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| `orderId` | string | 是 | 否 | `pay_xxx` | 当前用户已经支付成功的礼物订单号。 |
|
||||
|
||||
### 8.3 请求示例
|
||||
|
||||
```bash
|
||||
curl -X POST 'https://proapi.banlv-ai.com/api/payment/tip-message' \
|
||||
-H 'Authorization: Bearer <USER_TOKEN>' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"orderId":"<PAID_ORDER_ID>"}'
|
||||
```
|
||||
|
||||
### 8.4 成功响应
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"success": true,
|
||||
"data": {
|
||||
"orderId": "pay_xxx",
|
||||
"characterId": "elio",
|
||||
"planId": "tip_coffee_usd_4_99",
|
||||
"productName": "Velvet Espresso",
|
||||
"tipCount": 1,
|
||||
"poolIndex": 37,
|
||||
"message": "This is the 1st time you've sent me \"Velvet Espresso\". You have a knack for making me smile."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 8.5 响应字段
|
||||
|
||||
| 字段 | 类型 | 可空 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `orderId` | string | 否 | 已支付订单号。 |
|
||||
| `characterId` | string | 否 | 收礼角色 ID。 |
|
||||
| `planId` | string | 否 | 本次实际支付商品的 `planId`。 |
|
||||
| `productName` | string | 否 | 本次实际支付商品名称。 |
|
||||
| `tipCount` | number(整数) | 否 | 当前用户对同一 `planId` 的成功支付次数。 |
|
||||
| `poolIndex` | number(整数) | 否 | 本次选中的预生成文案下标,范围为 `0` 至 `99`。 |
|
||||
| `message` | string | 否 | 可直接展示的完整英文文案。 |
|
||||
|
||||
每个角色在 Manager 中预先保存正好 100 条英文感谢语。后端使用 `characterId + orderId` 稳定选择一条,因此同一个 `orderId` 重复请求时,`poolIndex` 和 `message` 保持一致。该接口不会在请求时调用 AI。
|
||||
|
||||
---
|
||||
|
||||
## 十、前端验收步骤
|
||||
|
||||
1. 在预发请求 Elio 的品类,确认页面根据接口返回结果渲染,没有写死咖啡品类。
|
||||
2. 请求选中品类的商品,确认商品名称、`planId`、图片、`amountCents` 和币种全部来自接口。
|
||||
3. 分别选择 `$4.99`、`$9.99` 商品,确认创建订单请求发送的是对应商品自己的 `planId`。
|
||||
4. 创建订单后校验 `payParams.firstChargeAmountCents === product.amountCents`;不一致时阻止支付并重新创建订单。
|
||||
5. 切换商品后确认旧 Stripe Payment Element 已销毁,新的组件使用新 `clientSecret`。
|
||||
6. 使用预发测试账号完成一笔允许的支付,轮询状态直到 `paid`。
|
||||
7. 连续两次调用付款后文案接口,确认同一订单返回内容完全一致。
|
||||
8. 再次购买同一商品,确认 `tipCount` 增加 1。
|
||||
9. 确认礼物付款后没有增加积分、VIP 或自动续费。
|
||||
|
||||
## 十一、注意事项
|
||||
|
||||
- 前端不要缓存并跨商品复用 `orderId`、`clientSecret` 或 `payParams`。
|
||||
- `planId` 是商品身份,`amountCents` 是商品价格;二者必须来自同一次商品接口响应。
|
||||
- 品类或商品为空时展示空状态,不要回退到写死的旧咖啡商品。
|
||||
- `imageUrl=null` 是合法结果,应显示本地占位图。
|
||||
- 本接口没有新增数据库迁移,也没有改变现有公开字段命名。
|
||||
@@ -12,6 +12,12 @@
|
||||
"./src/data/repositories",
|
||||
"./src/data/repositories/interfaces",
|
||||
"./src/data/services/api",
|
||||
"./src/data/dto/auth",
|
||||
"./src/data/dto/chat",
|
||||
"./src/data/dto/feedback",
|
||||
"./src/data/dto/feedback/response",
|
||||
"./src/data/dto/metrics",
|
||||
"./src/data/dto/user",
|
||||
"./src/data/schemas/auth",
|
||||
"./src/data/schemas/auth/request",
|
||||
"./src/data/schemas/auth/response",
|
||||
@@ -25,9 +31,9 @@
|
||||
"./src/data/schemas/payment",
|
||||
"./src/data/schemas/payment/request",
|
||||
"./src/data/schemas/payment/response",
|
||||
"./src/data/schemas/private-zone",
|
||||
"./src/data/schemas/private-zone/request",
|
||||
"./src/data/schemas/private-zone/response",
|
||||
"./src/data/schemas/private-room",
|
||||
"./src/data/schemas/private-room/request",
|
||||
"./src/data/schemas/private-room/response",
|
||||
"./src/data/schemas/user",
|
||||
"./src/data/storage/app",
|
||||
"./src/data/storage/auth",
|
||||
|
||||
@@ -0,0 +1,496 @@
|
||||
# 前端锁消息解锁 API 接入文档
|
||||
|
||||
## 1. 文档状态
|
||||
|
||||
本文档描述 `POST /api/chat/unlock-private` 与 `GET /api/chat/history` 的最新接口协议,覆盖后端已有锁消息和前端临时创建锁消息两种场景。
|
||||
|
||||
当前协议已经实现并通过自动化测试。前端联调前可通过目标环境的 `/openapi.json` 确认 `UnlockPrivateRequest` 已包含 `messageId`、`lockType` 和 `clientLockId`。
|
||||
|
||||
`unlock-private` 响应已收敛为紧凑结构。历史兼容别名不再返回,前端必须使用本文列出的标准 camelCase 字段。
|
||||
|
||||
环境地址:
|
||||
|
||||
| 环境 | API Base URL |
|
||||
| --- | --- |
|
||||
| test 测试环境 | `https://testapi.banlv-ai.com` |
|
||||
| pro 预发环境 | `https://proapi.banlv-ai.com` |
|
||||
| production 生产环境 | `https://api.banlv-ai.com` |
|
||||
|
||||
## 2. 功能目标
|
||||
|
||||
前端可以先展示一条本地锁消息。用户点击解锁时,即使该消息还没有后端 `messageId`,后端也会创建对应的聊天记录,并根据余额决定是否生成真实内容。
|
||||
|
||||
核心规则:
|
||||
|
||||
1. 余额不足时不生成真实语音、图片或私密内容,不扣积分,但会保存锁消息并返回真实 `messageId`。
|
||||
2. 用户充值后,前端使用同一个 `clientLockId` 再次解锁,后端更新原消息,不新增另一条聊天记录。
|
||||
3. 成功扣积分并持久化解锁后,`history` 才返回解锁状态。
|
||||
4. 刷新页面不会自动解锁。未扣积分、未消耗免费私密额度时,`history` 仍返回 `locked=true`。
|
||||
5. 前端只能使用 `unlocked` 或 `lockDetail.locked` 判断锁状态,不能根据 URL 是否为空判断。
|
||||
|
||||
## 3. 身份认证
|
||||
|
||||
两个接口都使用当前聊天用户的登录 Token:
|
||||
|
||||
```http
|
||||
Authorization: Bearer <TOKEN>
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
前端不得保存或传递 Supabase service key。
|
||||
|
||||
## 4. 解锁接口
|
||||
|
||||
### 4.1 请求地址
|
||||
|
||||
```http
|
||||
POST <API_BASE_URL>/api/chat/unlock-private
|
||||
```
|
||||
|
||||
生产环境完整地址:
|
||||
|
||||
```http
|
||||
POST https://api.banlv-ai.com/api/chat/unlock-private
|
||||
```
|
||||
|
||||
### 4.2 请求参数
|
||||
|
||||
请求体为 JSON:
|
||||
|
||||
```json
|
||||
{
|
||||
"messageId": "可选,有就传",
|
||||
"lockType": "voice_message",
|
||||
"clientLockId": "前端生成的唯一ID,可选但强烈建议"
|
||||
}
|
||||
```
|
||||
|
||||
| 字段 | 类型 | 是否必填 | 示例 | 说明 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `messageId` | string | 否 | `"9a43..."` | 后端真实消息 ID。已有消息时传;前端临时锁消息首次解锁时可以不传。 |
|
||||
| `lockType` | string | 临时锁消息必填 | `"voice_message"` | 锁类型。没有有效 `messageId` 时必须传。 |
|
||||
| `clientLockId` | string | 否,强烈建议 | `"fb_voice_3737_001"` | 前端锁卡片唯一 ID,用于充值后重试、刷新找回和避免重复创建。 |
|
||||
|
||||
`lockType` 支持以下值:
|
||||
|
||||
| 标准值 | 兼容别名 | 积分价格 |
|
||||
| --- | --- | ---: |
|
||||
| `voice_message` | `voice`、`audio` | 20 |
|
||||
| `image_paywall` | `image`、`photo`、`picture` | 40 |
|
||||
| `private_message` | `private`、`private_topic`、`private_room` | 10 |
|
||||
|
||||
建议前端只使用标准值。
|
||||
|
||||
### 4.3 `clientLockId` 生成规则
|
||||
|
||||
前端在创建锁卡片时生成一次,之后不得改变:
|
||||
|
||||
```ts
|
||||
const clientLockId = crypto.randomUUID();
|
||||
```
|
||||
|
||||
同一条锁消息在以下场景中必须继续使用同一个值:
|
||||
|
||||
- 第一次点击解锁;
|
||||
- 余额不足后进入充值;
|
||||
- 充值成功后重新点击解锁;
|
||||
- 网络超时后重试;
|
||||
- 前端重新渲染同一条本地锁卡片。
|
||||
|
||||
首次响应拿到后端 `messageId` 后,前端应同时保存 `messageId` 和 `clientLockId`。
|
||||
|
||||
### 4.4 最小请求示例
|
||||
|
||||
解锁已有后端消息:
|
||||
|
||||
```bash
|
||||
curl -X POST 'https://api.banlv-ai.com/api/chat/unlock-private' \
|
||||
-H 'Authorization: Bearer <TOKEN>' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"messageId":"<MESSAGE_ID>"}'
|
||||
```
|
||||
|
||||
解锁前端临时语音锁消息:
|
||||
|
||||
```bash
|
||||
curl -X POST 'https://api.banlv-ai.com/api/chat/unlock-private' \
|
||||
-H 'Authorization: Bearer <TOKEN>' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"lockType":"voice_message",
|
||||
"clientLockId":"codex_test_voice_001"
|
||||
}'
|
||||
```
|
||||
|
||||
充值后建议把三个字段都传回:
|
||||
|
||||
```json
|
||||
{
|
||||
"messageId": "<FIRST_RESPONSE_MESSAGE_ID>",
|
||||
"lockType": "voice_message",
|
||||
"clientLockId": "codex_test_voice_001"
|
||||
}
|
||||
```
|
||||
|
||||
## 5. 统一响应结构
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"success": true,
|
||||
"data": {}
|
||||
}
|
||||
```
|
||||
|
||||
业务解锁失败通常也返回 HTTP 200。前端必须读取 `data.unlocked` 和 `data.reason`,不能只检查 HTTP 状态或顶层 `success`。
|
||||
|
||||
重要字段:
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `unlocked` | boolean | 本次操作后是否已真实解锁。 |
|
||||
| `reason` | string/null | 本次操作结果原因。 |
|
||||
| `messageId` | string | 后端真实消息 ID。首次临时锁请求后也会返回。 |
|
||||
| `clientLockId` | string/null | 后端识别到的前端锁 ID。 |
|
||||
| `lockType` | string/null | 规范化后的锁类型。 |
|
||||
| `content` | string/null | 当前消息文字;私密内容未解锁时可以为 `null`。 |
|
||||
| `type` | string | `text` 或 `voice`。 |
|
||||
| `audioUrl` | string | 锁定语音为空字符串,成功解锁后是完整 URL。 |
|
||||
| `image.url` | string/null | 图片完整 URL;是否展示仍由 `lockDetail.locked` 决定。 |
|
||||
| `creditBalance` | number/null | 操作后的当前积分。 |
|
||||
| `creditsCharged` | number | 本次实际扣除积分;失败或免费额度解锁为 0。 |
|
||||
| `requiredCredits` | number | 当前锁类型需要的积分。 |
|
||||
| `shortfallCredits` | number | 余额不足时还差多少积分。 |
|
||||
| `lockDetail.locked` | boolean | 前端锁卡片的最终展示开关。 |
|
||||
| `lockDetail.showContent` | boolean | 是否允许展示文字内容。 |
|
||||
| `lockDetail.showUpgrade` | boolean | 是否展示充值入口。 |
|
||||
| `lockDetail.reason` | string/null | 锁定原因。 |
|
||||
|
||||
以下重复或与解锁无关的字段已经删除:`message_id`、`messageType`、`reply`、`response`、`audio_url`、`displayMessage`、`localizedMessage`、`paywallTriggered`、`showUpgrade`、`timestamp`、`isGuest`、亲密度字段以及 `blocked` 系列字段。
|
||||
|
||||
## 6. 余额不足
|
||||
|
||||
请求:
|
||||
|
||||
```json
|
||||
{
|
||||
"lockType": "voice_message",
|
||||
"clientLockId": "fb_voice_37370387172559600_001"
|
||||
}
|
||||
```
|
||||
|
||||
代表性响应:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"success": true,
|
||||
"data": {
|
||||
"unlocked": false,
|
||||
"reason": "insufficient_credits",
|
||||
"type": "voice",
|
||||
"messageId": "<BACKEND_MESSAGE_ID>",
|
||||
"clientLockId": "fb_voice_37370387172559600_001",
|
||||
"lockType": "voice_message",
|
||||
"content": "I left a voice message for you. Unlock it to listen.",
|
||||
"audioUrl": "",
|
||||
"creditBalance": 5,
|
||||
"creditsCharged": 0,
|
||||
"requiredCredits": 20,
|
||||
"shortfallCredits": 15,
|
||||
"lockDetail": {
|
||||
"locked": true,
|
||||
"showContent": true,
|
||||
"showUpgrade": true,
|
||||
"reason": "voice_message",
|
||||
"detail": {
|
||||
"messageId": "<BACKEND_MESSAGE_ID>",
|
||||
"clientLockId": "fb_voice_37370387172559600_001",
|
||||
"lockType": "voice_message",
|
||||
"requiredCredits": 20
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
前端处理:
|
||||
|
||||
1. 使用返回的 `messageId` 替换本地临时消息 ID。
|
||||
2. 保留原 `clientLockId`。
|
||||
3. 保持锁定状态并打开充值页面。
|
||||
4. 充值完成后再次调用解锁接口。
|
||||
5. 请求期间禁用解锁按钮,避免用户连续点击。
|
||||
|
||||
## 7. 解锁成功
|
||||
|
||||
### 7.1 语音成功
|
||||
|
||||
后端先确认并扣除 20 积分,然后生成真实文字和语音,更新同一条聊天记录:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"success": true,
|
||||
"data": {
|
||||
"unlocked": true,
|
||||
"reason": "ok",
|
||||
"type": "voice",
|
||||
"messageId": "<BACKEND_MESSAGE_ID>",
|
||||
"clientLockId": "fb_voice_37370387172559600_001",
|
||||
"lockType": "voice_message",
|
||||
"content": "I made this voice just for you.",
|
||||
"audioUrl": "https://api.banlv-ai.com/audio/<FILE>.mp3",
|
||||
"creditBalance": 10,
|
||||
"creditsCharged": 20,
|
||||
"requiredCredits": 20,
|
||||
"shortfallCredits": 0,
|
||||
"lockDetail": {
|
||||
"locked": false,
|
||||
"showContent": true,
|
||||
"showUpgrade": false
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
前端收到后直接用本次响应替换锁卡片,播放地址读取 `data.audioUrl`。
|
||||
|
||||
### 7.2 图片成功
|
||||
|
||||
```json
|
||||
{
|
||||
"unlocked": true,
|
||||
"reason": "ok",
|
||||
"messageId": "<BACKEND_MESSAGE_ID>",
|
||||
"clientLockId": "fb_image_001",
|
||||
"lockType": "image_paywall",
|
||||
"image": {
|
||||
"type": "elio_schedule",
|
||||
"url": "https://dbapi.banlv-ai.com/storage/v1/object/public/<PATH>"
|
||||
},
|
||||
"creditBalance": 60,
|
||||
"creditsCharged": 40,
|
||||
"requiredCredits": 40,
|
||||
"lockDetail": {
|
||||
"locked": false,
|
||||
"showContent": true,
|
||||
"showUpgrade": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
图片读取 `data.image.url`。后端已有图片锁消息可能在锁定时也返回真实 URL,因为 URL 本身不作为解锁凭证;前端仍必须根据 `lockDetail.locked` 遮挡或禁止查看。
|
||||
|
||||
前端临时创建、尚未确定图片内容的锁消息,在成功扣积分前可能没有图片 URL;成功后后端选择图片并返回 URL。
|
||||
|
||||
### 7.3 私密文本成功
|
||||
|
||||
前端临时私密消息按 10 积分生成并解锁:
|
||||
|
||||
```json
|
||||
{
|
||||
"unlocked": true,
|
||||
"reason": "ok",
|
||||
"messageId": "<BACKEND_MESSAGE_ID>",
|
||||
"clientLockId": "fb_private_001",
|
||||
"lockType": "private_message",
|
||||
"content": "<REAL_PRIVATE_REPLY>",
|
||||
"creditsCharged": 10,
|
||||
"requiredCredits": 10,
|
||||
"lockDetail": {
|
||||
"locked": false,
|
||||
"showContent": true,
|
||||
"showUpgrade": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
已有后端私密文本仍优先使用每日免费私密额度:登录用户默认每天 2 条,游客默认每天 1 条。成功消耗免费额度后也会持久解锁,但 `creditsCharged=0`。
|
||||
|
||||
## 8. History 接口
|
||||
|
||||
### 8.1 请求
|
||||
|
||||
```http
|
||||
GET <API_BASE_URL>/api/chat/history?limit=50&offset=0
|
||||
Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
```bash
|
||||
curl 'https://api.banlv-ai.com/api/chat/history?limit=50&offset=0' \
|
||||
-H 'Authorization: Bearer <TOKEN>'
|
||||
```
|
||||
|
||||
`limit=1&offset=0` 返回最新的一条数据库聊天记录展开后的消息;接口最终按聊天展示顺序返回 `data.messages`。
|
||||
|
||||
### 8.2 锁定消息示例
|
||||
|
||||
```json
|
||||
{
|
||||
"role": "assistant",
|
||||
"type": "voice",
|
||||
"content": "I left a voice message for you. Unlock it to listen.",
|
||||
"id": "<BACKEND_MESSAGE_ID>",
|
||||
"created_at": "2026-07-13T08:00:00+00:00",
|
||||
"audioUrl": null,
|
||||
"image": {
|
||||
"type": null,
|
||||
"url": null
|
||||
},
|
||||
"lockDetail": {
|
||||
"locked": true,
|
||||
"showContent": true,
|
||||
"showUpgrade": true,
|
||||
"reason": "voice_message",
|
||||
"detail": {
|
||||
"messageId": "<BACKEND_MESSAGE_ID>",
|
||||
"clientLockId": "fb_voice_37370387172559600_001",
|
||||
"lockType": "voice_message",
|
||||
"requiredCredits": 20
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 8.3 前端展示规则
|
||||
|
||||
```ts
|
||||
const locked = message.lockDetail?.locked === true;
|
||||
const showText = message.lockDetail?.showContent !== false;
|
||||
|
||||
if (locked) {
|
||||
// 展示锁卡片、遮罩或解锁按钮
|
||||
} else {
|
||||
// 展示真实内容
|
||||
}
|
||||
```
|
||||
|
||||
各类型规则:
|
||||
|
||||
| 状态 | `lockDetail.locked` | URL/内容行为 |
|
||||
| --- | ---: | --- |
|
||||
| 锁定语音 | `true` | `audioUrl=null`,不能播放。 |
|
||||
| 已解锁语音 | `false` | `audioUrl` 是完整可播放 URL。 |
|
||||
| 锁定图片 | `true` | `image.url` 可能有值,也可能为空;必须遮挡。 |
|
||||
| 已解锁图片 | `false` | 使用完整 `image.url` 展示。 |
|
||||
| 锁定私密文本 | `true` | 根据 `showContent` 决定是否显示 `content`。 |
|
||||
| 已解锁私密文本 | `false` | 展示完整 `content`。 |
|
||||
|
||||
## 9. 推荐 TypeScript 类型
|
||||
|
||||
```ts
|
||||
type LockType = "voice_message" | "image_paywall" | "private_message";
|
||||
|
||||
interface UnlockPrivateRequest {
|
||||
messageId?: string;
|
||||
lockType?: LockType;
|
||||
clientLockId?: string;
|
||||
}
|
||||
|
||||
interface LockDetail {
|
||||
locked: boolean;
|
||||
showContent: boolean;
|
||||
showUpgrade: boolean;
|
||||
reason?: string | null;
|
||||
hint?: string | null;
|
||||
actionLabel?: string | null;
|
||||
detail?: {
|
||||
messageId?: string;
|
||||
clientLockId?: string;
|
||||
lockType?: LockType;
|
||||
requiredCredits?: number;
|
||||
refundedCredits?: number;
|
||||
} | null;
|
||||
}
|
||||
|
||||
interface UnlockPrivateData {
|
||||
unlocked: boolean;
|
||||
reason?: string | null;
|
||||
messageId: string;
|
||||
clientLockId?: string | null;
|
||||
lockType?: LockType | null;
|
||||
type: "text" | "voice";
|
||||
content?: string | null;
|
||||
audioUrl: string;
|
||||
image: {
|
||||
type?: string | null;
|
||||
url?: string | null;
|
||||
};
|
||||
creditBalance?: number | null;
|
||||
creditsCharged: number;
|
||||
requiredCredits: number;
|
||||
shortfallCredits: number;
|
||||
lockDetail: LockDetail;
|
||||
}
|
||||
```
|
||||
|
||||
## 10. 异常与前端处理
|
||||
|
||||
| `data.reason` | 含义 | 前端处理 |
|
||||
| --- | --- | --- |
|
||||
| `ok` | 成功扣费并解锁 | 用响应替换锁卡片。 |
|
||||
| `not_locked` | 消息已经不是锁定状态 | 直接按已解锁内容展示,不再扣费。 |
|
||||
| `insufficient_credits` | 积分不足 | 保存返回的 `messageId`,保持锁定并进入充值。 |
|
||||
| `content_generation_failed` | 临时锁内容生成失败 | 后端尝试退回本次积分;保持锁定,允许稍后重试。 |
|
||||
| `voice_generation_failed` | 已有语音消息生成失败 | 未扣积分,保持锁定并允许重试。 |
|
||||
| `quota_exhausted` | 已有私密文本每日免费额度用完 | 展示 `lockDetail.hint`。 |
|
||||
| `invalid_lock_type` | `lockType` 不支持 | 记录前端错误并停止请求。 |
|
||||
| `not_found` | 消息不存在且没有有效 `lockType` | 禁用当前解锁按钮或重新同步 history。 |
|
||||
|
||||
认证失败会返回 HTTP 401。请求字段类型不合法可能返回 HTTP 422。
|
||||
|
||||
## 11. 前端完整流程
|
||||
|
||||
```text
|
||||
创建本地锁卡片并生成 clientLockId
|
||||
-> 用户点击解锁
|
||||
-> POST /api/chat/unlock-private
|
||||
-> unlocked=true:替换卡片并展示真实内容
|
||||
-> insufficient_credits:保存 messageId,打开充值
|
||||
-> 充值成功
|
||||
-> 使用相同 messageId + lockType + clientLockId 重试
|
||||
-> unlocked=true:替换卡片
|
||||
-> 页面刷新
|
||||
-> GET /api/chat/history
|
||||
-> 只按 lockDetail.locked 恢复锁定或解锁状态
|
||||
```
|
||||
|
||||
## 12. 测试方法
|
||||
|
||||
必须使用测试账号,不要用真实付费用户验证扣费。
|
||||
|
||||
1. 准备余额低于 20 的测试账号。
|
||||
2. 不传 `messageId`,使用唯一 `clientLockId` 请求 `voice_message`。
|
||||
3. 确认 `unlocked=false`、`creditsCharged=0`,并取得非空 `messageId`。
|
||||
4. 调用 history,确认同一 `messageId` 存在且 `locked=true`、`audioUrl=null`。
|
||||
5. 给测试账号增加到至少 20 积分。
|
||||
6. 使用相同 `messageId`、`lockType`、`clientLockId` 再次请求。
|
||||
7. 确认 `unlocked=true`、`creditsCharged=20`、`audioUrl` 非空。
|
||||
8. 再次调用 history,确认同一消息 `locked=false` 且 `audioUrl` 非空。
|
||||
9. 对图片 40 积分和私密文本 10 积分重复验证。
|
||||
10. 测试结束后记录测试账号积分变化;生成的聊天记录会保留在 history 中,没有自动清理接口。
|
||||
|
||||
后端自动化测试:
|
||||
|
||||
```powershell
|
||||
.\.venv\Scripts\python.exe -m pytest tests\test_private_unlock.py -q
|
||||
```
|
||||
|
||||
当前结果:`20 passed`;私密解锁、图片 paywall、私密相册和私密空间相关回归共 `48 passed`。
|
||||
|
||||
## 13. 兼容性与回滚
|
||||
|
||||
- 已有前端继续只传 `messageId` 的调用方式保持兼容。
|
||||
- 请求参数保持兼容:已有前端继续只传 `messageId` 仍可使用。
|
||||
- 响应字段有收敛:旧别名不再返回,前端需要按第 5、9 节使用标准字段。
|
||||
- 本次功能不需要数据库迁移,通过现有 `chat_messages` 和解锁记录保存状态。
|
||||
- 如果上线后需要回滚,只回滚本次后端路由和 schema 代码即可;已生成的聊天记录可保留,不影响旧 history 读取。
|
||||
- 上线前需将代码提交并推送到目标环境对应分支:`test`、`pro` 或 `main`,再部署对应环境。
|
||||
|
||||
## 14. Needs confirmation
|
||||
|
||||
- `https://api.cozsweet.com` 是否继续作为生产 API 别名,不在本次代码和环境配置中确认;本文统一使用正式生产地址 `https://api.banlv-ai.com`。
|
||||
@@ -1,328 +0,0 @@
|
||||
# CozSweet 多角色聊天权威协议
|
||||
|
||||
## 1. 状态与范围
|
||||
|
||||
本文是前端仓库中多角色目录、聊天、解锁、缓存隔离及关联业务的唯一人工维护协议。旧的单角色迁移方案和独立锁媒体协议已删除,不再作为实现或联调依据。
|
||||
|
||||
协议描述当前前端已经执行的行为,不描述尚未落地的后端迁移步骤。字段和路径由下列机器可验证入口约束:
|
||||
|
||||
| 边界 | 实现位置 |
|
||||
| --- | --- |
|
||||
| API 路径与方法 | `src/data/services/api/api_contract.json` |
|
||||
| 请求与响应字段 | `src/data/schemas/character`、`src/data/schemas/chat` |
|
||||
| 角色 ID、slug 与本地资源 | `src/data/constants/character.ts` |
|
||||
| Chat UI 消息身份 | `src/stores/chat/ui-message.ts` |
|
||||
| 本地缓存身份 | `src/data/repositories/chat_cache_identity.ts`、`src/lib/chat/chat_cache_keys.ts` |
|
||||
|
||||
如本文与上述实现发生差异,修改代码时必须在同一变更中更新本文,不能新增第二份并行协议。
|
||||
|
||||
## 2. 角色目录与路由
|
||||
|
||||
### 2.1 角色身份
|
||||
|
||||
`id` 是 API、状态机、缓存和数据归属使用的稳定业务身份;`slug` 只用于 URL。
|
||||
|
||||
| `id` | `slug` | 展示名称 |
|
||||
| --- | --- | --- |
|
||||
| `elio` | `elio` | Elio Silvestri |
|
||||
| `maya-tan` | `maya` | Maya Tan |
|
||||
| `nayeli-cervantes` | `nayeli` | Nayeli Cervantes |
|
||||
|
||||
不得向业务 API 发送 slug、展示名称、`@handle` 或旧 ID。旧 ID `character_elio`、`character_maya`、`character_nayeli` 仅用于本地持久化数据迁移。
|
||||
|
||||
### 2.2 角色目录接口
|
||||
|
||||
```http
|
||||
GET <API_BASE_URL>/api/characters?capability=chat
|
||||
Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
标准响应数据:
|
||||
|
||||
```json
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"id": "maya-tan",
|
||||
"displayName": "Maya Tan",
|
||||
"isActive": true,
|
||||
"capabilities": {
|
||||
"chat": true,
|
||||
"privateContent": true
|
||||
},
|
||||
"sortOrder": 20
|
||||
}
|
||||
],
|
||||
"defaultCharacterId": "elio"
|
||||
}
|
||||
```
|
||||
|
||||
前端只接纳同时满足以下条件的角色:
|
||||
|
||||
1. `id` 存在于本地资源目录;
|
||||
2. `isActive=true`;
|
||||
3. `capabilities.chat=true`。
|
||||
|
||||
服务端目录决定角色是否可聊天及排序;本地目录继续提供 slug、图片、文案和 Tip 能力。`privateZone` 只有在本地能力和服务端 `privateContent` 同时开启时可用。
|
||||
|
||||
远端目录返回前,生产环境只使用 Elio 作为临时目录;非生产环境可使用完整本地目录。远端目录加载成功后,以合并结果为准。
|
||||
|
||||
### 2.3 页面路由
|
||||
|
||||
```text
|
||||
/characters/{slug}/splash
|
||||
/characters/{slug}/chat
|
||||
/characters/{slug}/private-zone
|
||||
/characters/{slug}/tip
|
||||
```
|
||||
|
||||
当前 Splash 是角色详情入口,不是全角色列表页。以下旧地址保留为默认角色重定向,并原样保留查询参数:
|
||||
|
||||
```text
|
||||
/splash -> /characters/elio/splash
|
||||
/chat -> /characters/elio/chat
|
||||
/private-zone -> /characters/elio/private-zone
|
||||
/tip -> /characters/elio/tip
|
||||
```
|
||||
|
||||
Chat Provider 以 `characterId` 为边界,路由角色变化时创建新的 Actor。Private Zone 的角色边界由 [Private Zone 权威协议](./FRONTEND_PRIVATE_ZONE_API.md) 定义。
|
||||
|
||||
## 3. Chat HTTP 协议
|
||||
|
||||
### 3.1 发送消息
|
||||
|
||||
```http
|
||||
POST <API_BASE_URL>/api/chat/send
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"characterId": "maya-tan",
|
||||
"message": "Hello Maya",
|
||||
"useWebSocket": false
|
||||
}
|
||||
```
|
||||
|
||||
请求规则:
|
||||
|
||||
- `characterId` 必填;
|
||||
- `message` 最大 4000 字符;
|
||||
- `message` 与 `imageId`、`imageThumbUrl`、`imageMediumUrl`、`imageOriginalUrl` 至少一项有效;
|
||||
- 图片请求可附带 `imageWidth`、`imageHeight`;
|
||||
- `useWebSocket` 缺失时按 `false` 处理。
|
||||
|
||||
前端使用的响应字段为:
|
||||
|
||||
```text
|
||||
reply, audioUrl, messageId, isGuest, timestamp, image, lockDetail,
|
||||
canSendMessage, creditBalance, creditsCharged, requiredCredits,
|
||||
shortfallCredits
|
||||
```
|
||||
|
||||
`messageId` 是后端消息身份,不是 React key。锁状态只读取 `lockDetail.locked` 和 `lockDetail.reason`。
|
||||
|
||||
### 3.2 获取历史
|
||||
|
||||
```http
|
||||
GET <API_BASE_URL>/api/chat/history?characterId=maya-tan&limit=50&offset=0
|
||||
Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
| Query | 必填 | 规则 |
|
||||
| --- | --- | --- |
|
||||
| `characterId` | 是 | 角色业务 ID |
|
||||
| `limit` | 否 | 前端默认 50 |
|
||||
| `offset` | 否 | 前端默认 0 |
|
||||
|
||||
响应数据包含 `messages`、`total`、`limit`、`offset`,并可包含当前私密额度快照。消息字段:
|
||||
|
||||
```text
|
||||
role, type, content, id, createdAt/created_at, audioUrl, image, lockDetail
|
||||
```
|
||||
|
||||
前端兼容 `createdAt` 和 `created_at` 输入,解析后统一为 `createdAt`。缺失的可空载荷会由 Schema 归一化,业务组件不直接读取原始 envelope。
|
||||
|
||||
本地快照可先进入可渲染状态;网络历史随后覆盖缓存并更新 UI。网络同步期间新增的乐观消息按 `displayId` 保留。向上拉取更早页面时也按 `displayId` 去重。
|
||||
|
||||
### 3.3 最新消息预览
|
||||
|
||||
```http
|
||||
GET <API_BASE_URL>/api/chat/previews
|
||||
Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"characterId": "elio",
|
||||
"message": {
|
||||
"id": "<MESSAGE_ID>",
|
||||
"role": "assistant",
|
||||
"type": "text",
|
||||
"content": "How was your day?"
|
||||
}
|
||||
},
|
||||
{
|
||||
"characterId": "maya-tan",
|
||||
"message": null
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
接口可用时,Splash 以批量结果更新各角色预览;接口失败时,当前角色可回退到 `history?limit=1&offset=0`。预览缓存仍使用角色会话身份隔离。
|
||||
|
||||
## 4. 解锁协议
|
||||
|
||||
### 4.1 解锁单条消息
|
||||
|
||||
```http
|
||||
POST <API_BASE_URL>/api/chat/unlock-private
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
已有后端消息:
|
||||
|
||||
```json
|
||||
{
|
||||
"characterId": "maya-tan",
|
||||
"messageId": "<MESSAGE_ID>"
|
||||
}
|
||||
```
|
||||
|
||||
前端 Promotion 锁卡片:
|
||||
|
||||
```json
|
||||
{
|
||||
"characterId": "maya-tan",
|
||||
"lockType": "voice_message",
|
||||
"clientLockId": "<STABLE_CLIENT_LOCK_ID>"
|
||||
}
|
||||
```
|
||||
|
||||
请求必须包含 `characterId`,并至少包含 `messageId` 或 `lockType`。标准 `lockType` 为:
|
||||
|
||||
```text
|
||||
voice_message
|
||||
image_paywall
|
||||
private_message
|
||||
```
|
||||
|
||||
前端解析的响应字段:
|
||||
|
||||
```text
|
||||
unlocked, content, messageId, clientLockId, lockType, audioUrl, image,
|
||||
reason, creditBalance, creditsCharged, requiredCredits, shortfallCredits
|
||||
```
|
||||
|
||||
处理规则:
|
||||
|
||||
1. `unlocked=true` 时更新内容、音频、图片和锁状态;
|
||||
2. `unlocked=false` 时保持锁定,并根据 `reason` 决定是否打开支付流程;
|
||||
3. `reason=not_found` 不打开支付流程;
|
||||
4. 响应 `messageId` 只写入 `remoteId`,不得替换 `displayId`;
|
||||
5. Promotion 重试继续使用同一个 `clientLockId`;
|
||||
6. 跨支付、登录和图片 Overlay 恢复时同时保存显示身份与后端身份。
|
||||
|
||||
### 4.2 解锁当前角色历史
|
||||
|
||||
```http
|
||||
POST <API_BASE_URL>/api/chat/unlock-history
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer <TOKEN>
|
||||
|
||||
{"characterId":"maya-tan"}
|
||||
```
|
||||
|
||||
请求和返回消息都限定当前角色。前端完成解锁后重新读取该角色历史,不复用其他角色 Actor 的消息。
|
||||
|
||||
### 4.3 角色错误
|
||||
|
||||
前端识别以下后端错误码:
|
||||
|
||||
| 错误码 | 前端行为 |
|
||||
| --- | --- |
|
||||
| `CHARACTER_DISABLED` | 禁止继续发送并刷新角色目录 |
|
||||
| `CHARACTER_NOT_FOUND` | 清理待恢复导航、刷新目录并返回默认角色 |
|
||||
| `CHARACTER_MISMATCH` | 不进入支付,刷新当前角色历史 |
|
||||
| `CHARACTER_STATE_UNAVAILABLE` | 保留会话并提示稍后重试 |
|
||||
|
||||
任何角色错误都不得在前端回退为另一个角色的历史。
|
||||
|
||||
## 5. UI 消息身份协议
|
||||
|
||||
网络字段继续使用 `messageId`;前端 UI 严格区分三种身份:
|
||||
|
||||
| 字段 | 用途 | 是否稳定 |
|
||||
| --- | --- | --- |
|
||||
| `displayId` | React key、DOM 定位、Overlay URL、解锁目标 | 消息生命周期内必须稳定 |
|
||||
| `remoteId` | 后端 `messageId`、媒体缓存、解锁 API | 后端返回后可补充 |
|
||||
| `clientId` | 乐观发送消息或无后端 ID 的回复 | 创建时生成 |
|
||||
|
||||
标准 `displayId`:
|
||||
|
||||
```text
|
||||
历史消息 server:{encodedRemoteId}:{assistant|user}
|
||||
同角色重复 ID server:{encodedRemoteId}:{role}:{occurrence}
|
||||
无后端 ID 历史 legacy:{stableHash}
|
||||
乐观文本 client:message:{uuid}
|
||||
乐观图片 client:image:{uuid}
|
||||
无 ID 回复 client:reply:{uuid}
|
||||
错误提示 client:error:{uuid}
|
||||
空会话问候语 greeting:{characterId}
|
||||
Promotion promotion:{clientLockId}
|
||||
```
|
||||
|
||||
同一个后端 ID 可能同时出现在 user 和 assistant 记录中,因此不得直接使用 `remoteId` 作为 React key。解锁前后 `displayId` 不变;图片 Overlay 始终写入 `displayId`,但读取时兼容旧的 `remoteId` URL。
|
||||
|
||||
## 6. 本地缓存与会话隔离
|
||||
|
||||
缓存 owner 规则:
|
||||
|
||||
```text
|
||||
正式用户或已有用户 ID 的会话 user:{userId}
|
||||
没有用户 ID 的 Guest 会话 device:{deviceId}
|
||||
```
|
||||
|
||||
正式账号缺少持久化用户 ID 时跳过 Chat 缓存,不得回退到设备级或匿名缓存。
|
||||
|
||||
消息和媒体共同使用会话键:
|
||||
|
||||
```text
|
||||
conversationKey = {ownerKey}::character:{encodeURIComponent(characterId)}
|
||||
```
|
||||
|
||||
媒体键在该会话下继续包含后端消息 ID 和媒体类型:
|
||||
|
||||
```text
|
||||
{conversationKey}:{remoteId}:{image|audio}
|
||||
```
|
||||
|
||||
旧的无角色 owner key 迁移到 Elio;包含旧角色 ID 的 key 迁移到当前后端 ID。迁移是幂等的,不能覆盖已经存在的当前命名空间数据。
|
||||
|
||||
切换用户、Guest/正式账号或角色时,不得复用前一个 `conversationKey`。切换角色会销毁旧 Chat Actor;请求取消信号会阻止旧响应写入新角色状态。
|
||||
|
||||
## 7. 关联业务边界
|
||||
|
||||
- Private Zone 的相册、解锁、Gallery 和支付回跳由 [Private Zone 权威协议](./FRONTEND_PRIVATE_ZONE_API.md) 定义。
|
||||
- Tip 的角色归属、订单轮询和支付回跳由 [Payment 权威协议](./FRONTEND_PAYMENT_API.md) 定义;Chat 只保存解锁所需的原角色回跳地址。
|
||||
- 登录、支付和解锁回跳保存原角色动态 URL,不能降级为通用 `/chat`。
|
||||
- Analytics 可以使用 `characterId`,聊天正文不属于路由或身份协议的一部分。
|
||||
|
||||
## 8. 变更验收
|
||||
|
||||
协议相关变更至少验证:
|
||||
|
||||
1. Character、Chat、Storage、Navigation 和 Payment 的 TypeScript 类型检查;
|
||||
2. `src/data/services/api/__tests__/multi_character_api.test.ts`;
|
||||
3. `src/stores/chat/__tests__`;
|
||||
4. `src/data/storage/chat/__tests__` 与 `src/data/storage/navigation/__tests__`;
|
||||
5. `src/app/chat/__tests__` 及 Chat 组件测试;
|
||||
6. 同一用户的不同角色、Guest 与正式账号、账号切换后的历史和媒体均不串联;
|
||||
7. 快速切换角色时,旧请求不能覆盖新 Actor;
|
||||
8. 动态 URL、旧地址重定向、登录和支付回跳恢复正确角色;
|
||||
9. 解锁后 `displayId` 不变,`remoteId` 可从响应补齐。
|
||||
@@ -1,292 +0,0 @@
|
||||
# CozSweet Payment 权威协议
|
||||
|
||||
## 1. 状态与范围
|
||||
|
||||
本文是前端仓库中 VIP、Top-up、Tip、支付渠道、订单轮询和支付回跳的唯一人工维护协议。旧的 Tip 成功结果扩展文档已删除,不再单独定义 Payment 行为。
|
||||
|
||||
协议描述当前前端实际执行的行为。字段和状态由以下机器可验证入口约束:
|
||||
|
||||
| 边界 | 实现位置 |
|
||||
| --- | --- |
|
||||
| API 路径与方法 | `src/data/services/api/api_contract.json` |
|
||||
| 请求与响应字段 | `src/data/schemas/payment` |
|
||||
| API 调用 | `src/data/services/api/payment_api.ts` |
|
||||
| Payment 状态机 | `src/stores/payment` |
|
||||
| 支付拉起与回跳 | `src/app/_hooks/use-payment-launch-flow.ts`、`src/lib/payment` |
|
||||
| Subscription 页面 | `src/app/subscription` |
|
||||
| Tip 页面 | `src/app/tip` |
|
||||
|
||||
修改上述实现时必须在同一变更中更新本文,不能再新增按支付页面或支付渠道拆分的并行协议。
|
||||
|
||||
## 2. API 总览
|
||||
|
||||
| 方法 | 路径 | 用途 |
|
||||
| --- | --- | --- |
|
||||
| `GET` | `/api/payment/plans` | VIP 与 Top-up 套餐目录 |
|
||||
| `GET` | `/api/payment/gift-products?characterId={id}` | 当前角色的完整礼物目录 |
|
||||
| `POST` | `/api/payment/create-order` | 创建 VIP、Top-up 或 Tip 订单 |
|
||||
| `GET` | `/api/payment/order-status?order_id={id}` | 查询订单状态 |
|
||||
| `POST` | `/api/payment/tip-message` | 获取已支付礼物订单的稳定感谢文案 |
|
||||
|
||||
所有响应先由通用 envelope 解包,再进入 Payment Schema。页面和状态机不直接读取原始 envelope。
|
||||
|
||||
## 3. 套餐目录
|
||||
|
||||
### 3.1 默认套餐
|
||||
|
||||
```http
|
||||
GET <API_BASE_URL>/api/payment/plans
|
||||
Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
响应数据:
|
||||
|
||||
```json
|
||||
{
|
||||
"isFirstRecharge": true,
|
||||
"firstRechargeOffer": {
|
||||
"enabled": true,
|
||||
"type": "topup",
|
||||
"discountPercent": 50
|
||||
},
|
||||
"plans": []
|
||||
}
|
||||
```
|
||||
|
||||
`plans[]` 的标准字段:
|
||||
|
||||
```text
|
||||
planId, planName, orderType, vipDays, dolAmount, creditBalance,
|
||||
amountCents, originalAmountCents, dailyPriceCents, currency,
|
||||
isFirstRechargeOffer, mostPopular, firstRechargeDiscountPercent,
|
||||
promotionType
|
||||
```
|
||||
|
||||
默认目录写入本地套餐缓存。Payment Actor 启动时先读缓存;有缓存则先渲染并后台刷新,没有缓存则直接请求网络。
|
||||
|
||||
支付成功后会清除默认套餐缓存、刷新用户权益,并在当前 Actor 中消费首充展示状态。服务端下一次目录响应仍是最终权威结果。
|
||||
|
||||
### 3.2 Gift Products 目录
|
||||
|
||||
```http
|
||||
GET <API_BASE_URL>/api/payment/gift-products?characterId=elio
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"characterId": "elio",
|
||||
"categories": [
|
||||
{
|
||||
"category": "coffee",
|
||||
"name": "Coffee",
|
||||
"productCount": 1,
|
||||
"imageUrl": null
|
||||
}
|
||||
],
|
||||
"plans": [
|
||||
{
|
||||
"planId": "tip_coffee_usd_4_99",
|
||||
"planName": "Velvet Espresso",
|
||||
"orderType": "tip",
|
||||
"tipType": "coffee_small",
|
||||
"category": "coffee",
|
||||
"characterId": "elio",
|
||||
"description": "Buy Elio a small coffee",
|
||||
"imageUrl": null,
|
||||
"amountCents": 499,
|
||||
"currency": "USD",
|
||||
"autoRenew": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
目录不需要登录,也不写入默认套餐缓存。前端必须传当前角色 ID,一次读取 `categories` 和全部 `plans`;当前 Tip 页面固定使用第一分类,并按商品原始顺序默认选择第一件商品,不展示分类切换栏。
|
||||
|
||||
名称、说明、图片、金额、币种和 `planId` 全部来自同一条商品数据。状态机把当前分类商品映射为 `PaymentPlan` 以复用 Checkout 和埋点,同时保留完整 Gift Product 供 UI 展示。目录为空或请求失败时禁止创建订单,不回退到本地固定商品或价格。
|
||||
|
||||
## 4. 创建订单
|
||||
|
||||
```http
|
||||
POST <API_BASE_URL>/api/payment/create-order
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
标准请求:
|
||||
|
||||
```json
|
||||
{
|
||||
"planId": "tip_coffee_usd_4_99",
|
||||
"payChannel": "stripe",
|
||||
"autoRenew": false,
|
||||
"recipientCharacterId": "maya-tan"
|
||||
}
|
||||
```
|
||||
|
||||
| 字段 | 规则 |
|
||||
| --- | --- |
|
||||
| `planId` | 必须来自当前 Actor 已加载的目录 |
|
||||
| `payChannel` | `stripe` 或 `ezpay` |
|
||||
| `autoRenew` | Tip 和一次性 Top-up 为 `false`;VIP 根据套餐和用户选择决定 |
|
||||
| `recipientCharacterId` | Schema 可选;当前 Tip 页面必传角色业务 ID,VIP 和 Top-up 不传 |
|
||||
|
||||
Payment Actor 只有在 `selectedPlanId` 非空且用户已同意协议时创建订单。套餐加载、创建和轮询期间页面会禁用重复提交;Tip 在 paid 状态展示成功页,Subscription 在 paid 状态展示成功 Dialog,随后通过 reset 明确开始下一笔订单。
|
||||
|
||||
创建订单响应统一归一化为:
|
||||
|
||||
```ts
|
||||
interface CreatePaymentOrderResponse {
|
||||
orderId: string;
|
||||
payParams: Record<string, unknown>;
|
||||
}
|
||||
```
|
||||
|
||||
后端可以把支付 URL 放在 `payParams`,也可以使用以下顶层兼容字段;Schema 会把非空值合并进 `payParams`:
|
||||
|
||||
```text
|
||||
cashierUrl/cashier_url
|
||||
checkoutUrl/checkout_url
|
||||
paymentUrl/payment_url
|
||||
approvalUrl/approval_url
|
||||
redirectUrl/redirect_url
|
||||
url
|
||||
```
|
||||
|
||||
## 5. 支付渠道与拉起方式
|
||||
|
||||
### 5.1 渠道选择
|
||||
|
||||
| 环境与地区 | 行为 |
|
||||
| --- | --- |
|
||||
| 生产环境、菲律宾 | 可选择 Stripe 或 Ezpay,默认 Ezpay |
|
||||
| 生产环境、其他地区 | 强制 Stripe,不展示渠道选择器 |
|
||||
| 非生产环境 | 允许选择两个渠道;菲律宾默认 Ezpay,其他地区默认 Stripe |
|
||||
|
||||
当生产环境不允许选择渠道时,URL 中请求的 `payChannel` 不生效。
|
||||
|
||||
### 5.2 Stripe
|
||||
|
||||
`payParams.clientSecret` 或 `payParams.client_secret` 存在,且 provider 未声明为非 Stripe 时,前端动态加载嵌入式 Stripe Dialog。
|
||||
|
||||
关闭尚未支付的 Stripe Dialog 会重置当前订单状态;确认支付后隐藏 Dialog,并继续由 Payment Actor 轮询订单状态。
|
||||
|
||||
### 5.3 Ezpay 与其他跳转支付
|
||||
|
||||
`payParams.provider="ezpay"` 且存在支付 URL 时:
|
||||
|
||||
- 生产环境先保存待恢复订单,然后直接跳转外部支付页;
|
||||
- 非生产环境先显示确认 Dialog,确认后保存并跳转;
|
||||
- 待恢复订单保存失败时不得离开当前页面。
|
||||
|
||||
存在支付 URL 但 provider 不是 Ezpay 时,前端直接设置 `window.location.href`。既没有 Stripe client secret 也没有支付 URL 时,订单进入失败状态并展示参数错误。
|
||||
|
||||
## 6. 订单状态轮询
|
||||
|
||||
```http
|
||||
GET <API_BASE_URL>/api/payment/order-status?order_id=<ORDER_ID>
|
||||
Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
响应数据:
|
||||
|
||||
```json
|
||||
{
|
||||
"orderId": "tip_order_123",
|
||||
"status": "paid",
|
||||
"orderType": "tip",
|
||||
"planId": "tip_coffee_usd_4_99",
|
||||
"creditsAdded": 0
|
||||
}
|
||||
```
|
||||
|
||||
| 字段 | 前端规则 |
|
||||
| --- | --- |
|
||||
| `status` | 只接受 `pending`、`paid`、`failed`、`expired` |
|
||||
| `planId` | 可为 `null` |
|
||||
| `creditsAdded` | 整数;Tip 固定为 `0` |
|
||||
|
||||
状态机创建订单或恢复订单后立即查询一次。`pending` 每 4 秒再次查询,最长持续 5 分钟:
|
||||
|
||||
- `paid`:进入最终成功状态并停止轮询;
|
||||
- `failed`:进入失败状态并停止轮询;
|
||||
- `expired`:进入订单过期状态、销毁旧支付参数并停止轮询;
|
||||
- 超过 5 分钟:本地标记为失败并显示超时错误;
|
||||
- 查询请求本身失败:进入失败状态,不在当前 Actor 中自动重试。
|
||||
|
||||
## 7. 外部支付回跳
|
||||
|
||||
只有 Ezpay 跳转需要持久化 `PendingPaymentOrder`:
|
||||
|
||||
```text
|
||||
orderId
|
||||
payChannel = ezpay
|
||||
subscriptionType = vip | topup | tip
|
||||
giftCategory(仅 Tip,可空)
|
||||
giftPlanId(仅 Tip,可空)
|
||||
returnTo = chat | private-zone | profile(可选)
|
||||
characterSlug(可选)
|
||||
createdAt
|
||||
```
|
||||
|
||||
`/subscription/return` 读取该记录并恢复到对应入口:
|
||||
|
||||
```text
|
||||
VIP / Top-up -> /subscription?type=...&payChannel=ezpay&paymentReturn=1
|
||||
Tip -> /characters/{slug}/tip?category=...&planId=...&payChannel=ezpay&paymentReturn=1
|
||||
```
|
||||
|
||||
恢复页面只接受与当前 `paymentType` 相同的待处理订单。带有 `paymentReturn=1` 时派发 `PaymentReturned` 并继续轮询;普通进入支付页时会清理同类型的旧待处理订单。订单进入 paid、failed 或 expired 后清理持久化记录。缺少 Gift 字段的旧记录由最新目录默认选择第一件商品,不再读取 `coffee_type`。
|
||||
|
||||
无效或未知 `characterSlug` 回退到默认角色 slug。有效角色回跳必须保留原角色,不能统一返回 Elio。`returnTo=private-zone` 的最终页面行为由 [Private Zone 权威协议](./FRONTEND_PRIVATE_ZONE_API.md) 定义。
|
||||
|
||||
## 8. 成功后的跨域同步
|
||||
|
||||
`PaymentSuccessSync` 在每个订单首次进入 paid 时:
|
||||
|
||||
1. 消费当前 Actor 的首充展示状态;
|
||||
2. 清除默认套餐缓存;
|
||||
3. 派发 `UserFetch` 刷新积分、VIP 和权益。
|
||||
|
||||
Chat 路由额外挂载 `ChatPaymentSuccessSync`。如果当前角色没有待恢复的单消息解锁,它会派发 `ChatPaymentSucceeded`,由 Chat 决定是否展示历史解锁提示;存在待恢复单消息解锁时,由原解锁流程接管。
|
||||
|
||||
Subscription 显示成功 Dialog,关闭后根据 `returnTo` 和原角色 slug 返回。Tip 直接显示角色成功页,重置后可以再次创建订单。
|
||||
|
||||
## 9. Tip 成功结果
|
||||
|
||||
Tip 订单进入 paid 后调用:
|
||||
|
||||
```http
|
||||
POST <API_BASE_URL>/api/payment/tip-message
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer <TOKEN>
|
||||
|
||||
{"orderId":"pay_xxx"}
|
||||
```
|
||||
|
||||
响应包含 `orderId`、`characterId`、`planId`、`productName`、`tipCount`、`poolIndex` 和可直接展示的完整 `message`。`tipCount` 表示当前付款身份对同一商品的累计成功次数。
|
||||
|
||||
Tip 成功页在文案加载期间立即确认支付成功。`tipCount=1` 时展示固定首次咖啡文案并忽略后端 `message`;大于 1 时按纯文本直接展示 `message`。接口失败时展示本地通用感谢语和 Retry,重试只重新请求 Tip Message,不重复轮询订单或创建订单。
|
||||
|
||||
## 10. Provider 与状态边界
|
||||
|
||||
- `/subscription` 使用独立 Payment Actor;
|
||||
- `/characters/{slug}/tip` 使用以 `characterId` 为 key 的 Payment Actor;
|
||||
- Chat 路由使用角色级 Payment Actor,以便支付成功桥接当前 Chat;
|
||||
- 切换角色或离开对应 Provider 后,不得把旧订单状态显示到另一个角色页面;
|
||||
- Payment Actor 只根据订单状态接口判断最终结果,不根据支付 Dialog 或外部跳转本身推断已扣款。
|
||||
|
||||
## 11. 变更验收
|
||||
|
||||
Payment 协议相关变更至少验证:
|
||||
|
||||
1. `src/data/services/api/__tests__/payment_api.test.ts`;
|
||||
2. `src/data/repositories/__tests__/payment_repository.test.ts`;
|
||||
3. `src/stores/payment/__tests__`;
|
||||
4. `src/lib/payment/__tests__`;
|
||||
5. `src/app/_hooks/__tests__` 中的 Payment 流程测试;
|
||||
6. `src/app/subscription/__tests__` 与 `src/app/tip/__tests__`;
|
||||
7. Stripe、Ezpay、paid、failed、expired、timeout 和回跳恢复路径;
|
||||
8. Tip 创建订单携带当前角色 ID,VIP/Top-up 不携带;
|
||||
9. Tip Message 成功、失败和重试不重复创建订单;
|
||||
10. 支付成功后用户权益、套餐缓存和 Chat 解锁协调结果正确。
|
||||
@@ -1,241 +0,0 @@
|
||||
# CozSweet Private Zone 权威协议
|
||||
|
||||
## 1. 状态与范围
|
||||
|
||||
本文是前端仓库中角色私密空间、相册列表、相册解锁、Gallery 和积分不足导航的唯一人工维护协议。
|
||||
|
||||
协议描述当前前端实际执行的行为。字段和状态由以下机器可验证入口约束:
|
||||
|
||||
| 边界 | 实现位置 |
|
||||
| --- | --- |
|
||||
| API 路径与方法 | `src/data/services/api/api_contract.json` |
|
||||
| 请求与响应字段 | `src/data/schemas/private-zone` |
|
||||
| API 与 Repository | `src/data/services/api/private_zone_api.ts`、`src/data/repositories/private_zone_repository.ts` |
|
||||
| Private Zone 状态机 | `src/stores/private-zone` |
|
||||
| 页面、Gallery 与导航 | `src/app/private-zone` |
|
||||
| 角色 Provider | `src/providers/private-zone-route-provider.tsx` |
|
||||
|
||||
修改上述实现时必须在同一变更中更新本文,不能再新增按相册列表、解锁或 Gallery 拆分的并行协议。
|
||||
|
||||
## 2. 角色与路由边界
|
||||
|
||||
标准路由:
|
||||
|
||||
```text
|
||||
/characters/{characterSlug}/private-zone
|
||||
```
|
||||
|
||||
旧地址保留为默认角色重定向,并保留查询参数:
|
||||
|
||||
```text
|
||||
/private-zone -> /characters/elio/private-zone
|
||||
```
|
||||
|
||||
URL 使用角色 `slug`,API 和 Actor 使用角色业务 `id`:
|
||||
|
||||
| `id` | `slug` |
|
||||
| --- | --- |
|
||||
| `elio` | `elio` |
|
||||
| `maya-tan` | `maya` |
|
||||
| `nayeli-cervantes` | `nayeli` |
|
||||
|
||||
角色必须同时存在于本地目录且 `capabilities.privateZone=true`。该能力由本地配置和角色目录响应的 `privateContent` 共同决定;能力关闭或 slug 未知时路由返回 Not Found。
|
||||
|
||||
`PrivateZoneProvider` 以 `characterId` 为输入和 React key。切换角色会销毁旧 Actor 并创建空状态,不能复用上一角色的相册、余额或解锁请求。
|
||||
|
||||
## 3. 相册列表
|
||||
|
||||
```http
|
||||
GET <API_BASE_URL>/api/private-zone/albums?characterId=maya-tan&limit=20
|
||||
Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
| Query | 必填 | 前端规则 |
|
||||
| --- | --- | --- |
|
||||
| `characterId` | 是 | 当前角色业务 ID |
|
||||
| `limit` | 否 | 当前固定为 20 |
|
||||
|
||||
前端当前只加载第一页,不实现 Private Zone 分页,也不把相册列表写入本地缓存。初始化、手动刷新或登录身份变化时重新请求网络。
|
||||
|
||||
标准响应数据:
|
||||
|
||||
```json
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"albumId": "album-1",
|
||||
"title": "A quiet afternoon",
|
||||
"content": "I saved these for you.",
|
||||
"previewText": "Unlock to view",
|
||||
"imageCount": 3,
|
||||
"images": [
|
||||
{
|
||||
"url": "https://example.com/private/cover.jpg",
|
||||
"locked": true,
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"locked": true,
|
||||
"unlocked": false,
|
||||
"unlockCost": 40,
|
||||
"publishedAt": "2026-07-20T09:00:00Z",
|
||||
"lockDetail": {
|
||||
"locked": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"creditBalance": 20
|
||||
}
|
||||
```
|
||||
|
||||
前端将缺失或非法的可空字段按 Schema 默认值归一化。页面不直接读取原始响应 envelope。
|
||||
|
||||
相册只要满足任意条件即视为锁定:
|
||||
|
||||
```ts
|
||||
album.locked || !album.unlocked || album.lockDetail.locked
|
||||
```
|
||||
|
||||
因此不能只根据图片 URL 是否存在判断已解锁。锁定相册允许存在封面 URL,但只能显示锁定预览,不能打开 Gallery。
|
||||
|
||||
## 4. 解锁相册
|
||||
|
||||
### 4.1 请求
|
||||
|
||||
用户点击锁定相册后,前端先展示确认 Dialog。只有待确认 `albumId` 仍存在于当前 Actor 的 `items` 中,才会发起请求。
|
||||
|
||||
```http
|
||||
POST <API_BASE_URL>/api/private-zone/albums/{albumId}/unlock
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"expectedCost": 40
|
||||
}
|
||||
```
|
||||
|
||||
`albumId` 来自当前角色列表;请求 body 只发送用户确认时看到的 `expectedCost`,不重复发送 `characterId`。后端通过 `albumId` 确定相册与角色归属。
|
||||
|
||||
### 4.2 响应
|
||||
|
||||
```json
|
||||
{
|
||||
"albumId": "album-1",
|
||||
"locked": false,
|
||||
"unlocked": true,
|
||||
"reason": "ok",
|
||||
"unlockCost": 40,
|
||||
"requiredCredits": 40,
|
||||
"creditBalance": 60,
|
||||
"shortfallCredits": 0,
|
||||
"images": [
|
||||
{
|
||||
"url": "https://example.com/private/photo-1.jpg",
|
||||
"locked": false,
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
前端识别的标准 reason:
|
||||
|
||||
```text
|
||||
ok
|
||||
already_unlocked
|
||||
insufficient_credits
|
||||
cost_changed
|
||||
unlock_in_progress
|
||||
deduct_failed
|
||||
persist_failed_refunded
|
||||
not_found
|
||||
```
|
||||
|
||||
Schema 同时允许未知字符串,未知失败原因使用通用错误文案。
|
||||
|
||||
### 4.3 状态机处理
|
||||
|
||||
| 条件 | 行为 |
|
||||
| --- | --- |
|
||||
| `unlocked=true` 且 `locked=false` | 更新相册、余额和图片;增加成功 nonce;刷新用户权益 |
|
||||
| `reason=insufficient_credits` | 更新相册与余额,生成 Paywall 请求 |
|
||||
| `reason=cost_changed` | 清除确认状态、展示价格变化错误并重新加载列表 |
|
||||
| `reason=not_found` | 从当前列表移除相册并展示错误 |
|
||||
| 其他业务失败 | 使用响应补丁更新相册,并展示对应或通用错误 |
|
||||
| 请求异常 | 保留列表,清除进行中状态并展示异常信息 |
|
||||
|
||||
响应补丁只替换匹配 `albumId` 的相册:
|
||||
|
||||
- `locked`、`unlocked` 使用响应值;
|
||||
- 非零 `unlockCost` 更新当前价格,否则保留列表价格;
|
||||
- 非空 `images` 更新图片,否则保留列表图片;
|
||||
- `lockDetail.locked` 与响应 `locked` 对齐。
|
||||
|
||||
解锁请求进行期间确认按钮保持禁用,避免同一个 Actor 重复提交。
|
||||
|
||||
## 5. 身份与支付导航
|
||||
|
||||
Private Zone 初始化会复用 Guest 登录引导。Auth 尚未初始化或正在加载时不请求列表;`notLoggedIn` 完成 Guest bootstrap 后再进入列表加载。Guest 和正式用户都可以读取后端允许的相册列表。
|
||||
|
||||
积分不足生成 Paywall 请求后:
|
||||
|
||||
| 当前身份 | 导航 |
|
||||
| --- | --- |
|
||||
| Guest 或 Not Logged In | 打开 Auth,redirect 为当前角色 Private Zone |
|
||||
| 已认证用户 | 打开 Top-up,`returnTo=private-zone`,保留当前角色来源 |
|
||||
|
||||
Paywall 导航发起后立即消费当前请求,避免 React 重渲染重复导航。支付回跳和订单恢复遵循 [Payment 权威协议](./FRONTEND_PAYMENT_API.md)。
|
||||
|
||||
解锁成功后 `unlockSuccessNonce` 递增,页面桥接到 `UserFetch`,刷新当前积分和权益。Private Zone 不自行修改 User Store 余额。
|
||||
|
||||
## 6. Gallery URL 协议
|
||||
|
||||
解锁相册使用查询参数打开页内 Gallery:
|
||||
|
||||
```text
|
||||
/characters/{slug}/private-zone?album={albumId}&image={zeroBasedIndex}
|
||||
```
|
||||
|
||||
解析规则:
|
||||
|
||||
- `album` 必须是非空字符串;
|
||||
- `image` 必须是大于等于 0 的整数,缺失时使用 0;
|
||||
- 相册必须仍在当前角色列表中;
|
||||
- 相册必须已解锁;
|
||||
- 对应图片必须存在非空 URL。
|
||||
|
||||
任一条件不满足时,页面通过 replace 删除 `album` 和 `image`,并保留其他查询参数。
|
||||
|
||||
页面内点击九宫格缩略图时,Gallery 从该图片的后端数组原始索引打开。关闭操作优先使用浏览器 back;直接刷新或外部分享 Gallery URL 时,关闭操作使用 replace 返回当前角色 Private Zone。
|
||||
|
||||
Gallery 只浏览 `locked=false` 且 URL 非空的图片,但 URL 中的 `image` 仍使用原始数组索引。横向拖动时图片跟随指针,达到视口宽度 18%(最低 56px),或达到 0.45px/ms 且至少移动 24px 时切换;首尾越界拖动使用 0.28 阻尼且不循环。松手后使用 240ms 横向吸附动画,键盘方向键和左右按钮复用相同切换逻辑。Escape 关闭;`prefers-reduced-motion` 下取消吸附过渡。
|
||||
|
||||
## 7. UI 与数据边界
|
||||
|
||||
- React key 使用稳定 `albumId`;
|
||||
- 卡片图片数量优先使用 `imageCount`,为 0 时回退到 `images.length`;
|
||||
- 锁定相册显示模糊封面、角色头像、锁标识、图片数量和 `View collection` 入口;卡片不展示视频数量或积分价格,解锁价格只在确认 Dialog 中展示;
|
||||
- 解锁相册过滤锁定或空 URL 图片,并保留剩余图片的原始数组索引;
|
||||
- 1 张图片显示 4:5 大图,2/4 张使用两列,其余使用三列正方形九宫格;
|
||||
- 超过 9 张时卡片显示前九张,末格显示 `+N`,Gallery 仍可浏览全部有效图片;
|
||||
- Gallery 只挂载当前图片和相邻图片,避免多图相册同时解码全部原图;
|
||||
- `creditBalance` 是当前列表/解锁响应快照,不替代 User Store 权益;
|
||||
- Private Zone 不使用 Chat 的 `conversationKey`、消息缓存或媒体缓存;
|
||||
- Private Zone 不持有 Payment Actor,Top-up 通过路由级导航进入独立 Payment Provider。
|
||||
|
||||
## 8. 变更验收
|
||||
|
||||
Private Zone 协议相关变更至少验证:
|
||||
|
||||
1. `src/data/schemas/private-zone/__tests__`;
|
||||
2. `src/data/services/api/__tests__/multi_character_api.test.ts` 中的 Private Zone 请求;
|
||||
3. `src/stores/private-zone/__tests__`;
|
||||
4. `src/app/private-zone/__tests__` 与组件测试;
|
||||
5. Elio、Maya、Nayeli 列表互不串联;
|
||||
6. 登录身份变化会刷新当前角色列表;
|
||||
7. 成功、余额不足、价格变化、重复解锁、退款失败和 not found 分支;
|
||||
8. Auth、Top-up 和支付成功后返回原角色;
|
||||
9. 锁定相册不能通过 Gallery URL 绕过;
|
||||
10. 切换角色后旧 Actor 的相册与解锁状态不再可见。
|
||||
@@ -1,30 +0,0 @@
|
||||
# 前端 API 契约检查
|
||||
|
||||
本仓库只包含 Next.js 前端,Python 后端仍在独立项目中维护。前端实际调用的
|
||||
HTTP method 与 path 统一记录在
|
||||
`src/data/services/api/api_contract.json`,`ApiPath` 与 OpenAPI 检查共同消费这份清单。
|
||||
|
||||
## 本地检查
|
||||
|
||||
传入 Python 后端生成的 OpenAPI JSON 文件或 URL:
|
||||
|
||||
```bash
|
||||
pnpm contract:check ../backend/openapi.json
|
||||
pnpm contract:check https://backend.example.com/openapi.json
|
||||
```
|
||||
|
||||
也可以使用环境变量:
|
||||
|
||||
```bash
|
||||
BACKEND_OPENAPI_SOURCE=https://backend.example.com/openapi.json pnpm contract:check
|
||||
```
|
||||
|
||||
检查会验证前端依赖的每个 method/path 是否仍由后端公开。路径参数名称不同
|
||||
(例如 `{albumId}` 与 `{album_id}`)不会产生误报。字段级兼容仍由前端 Zod
|
||||
Schema Model 测试负责,避免仅凭 OpenAPI 生成代码覆盖现有防御性解析规则。
|
||||
|
||||
## CI 配置
|
||||
|
||||
在 Gitea Actions Secrets 中配置 `BACKEND_OPENAPI_SOURCE` 后,CI 会比较目标
|
||||
Python 后端的实时 OpenAPI。未配置时 CI 会明确记录跳过原因,本地的比较器测试
|
||||
仍会随 `pnpm quality` 执行。
|
||||
@@ -8,14 +8,14 @@
|
||||
|
||||
| Workflow | 触发时机 | 职责 |
|
||||
| --- | --- | --- |
|
||||
| `.gitea/workflows/ci.yml` | `dev`、`main`、`test` push / PR | 安装依赖、执行完整质量检查、Python 后端 OpenAPI 差异检查、移动端 smoke,并校验 bundle 预算 |
|
||||
| `.gitea/workflows/ci.yml` | `dev`、`main`、`test` push / PR | 安装依赖、Lint、单元测试、Next.js 构建 |
|
||||
| `.gitea/workflows/docker-image.yml` | `main`、`test` push / 手动触发 | 构建 Docker 镜像、推送到镜像仓库,并通过 SSH 部署 |
|
||||
|
||||
这样可以避免所有开发分支都发布镜像,并确保生产镜像通过发布门禁。
|
||||
|
||||
`main` 分支发布前会执行 Docker workflow 内的完整质量和 bundle 门禁。`test`
|
||||
分支为快速部署测试环境,会跳过完整质量检查,但仍必须通过 bundle 预算;独立的
|
||||
`ci.yml` 会同时执行完整检查并提供测试结果。
|
||||
`main` 分支发布前会执行 Docker workflow 内的质量和 bundle 门禁。`test`
|
||||
分支为快速部署测试环境,会跳过该门禁;独立的 `ci.yml` 仍会照常执行测试分支检查,
|
||||
但不会阻塞测试镜像构建与部署。
|
||||
|
||||
## 必需 Secrets
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
| `REGISTRY_PACKAGE_NAME` | `cozsweet-web` | 可选;Registry 镜像名不含 owner 或包名不一致时用于指定 package name |
|
||||
| `TEST_ENV_FILE` | `.env.local` 的完整内容 | 测试环境构建期环境变量 |
|
||||
| `PRODUCTION_ENV_FILE` | `.env.production` 的完整内容 | 生产环境构建期环境变量 |
|
||||
| `BACKEND_OPENAPI_SOURCE` | `https://api.example.com/openapi.json` | 可选;CI 用于检查 Python 后端是否仍公开前端依赖的 method/path |
|
||||
|
||||
Next.js 的 `NEXT_PUBLIC_*` 会在构建期固化到产物中,因此测试环境和生产环境会分别构建镜像。
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# 外部入口接入说明
|
||||
|
||||
Facebook 等外部应用统一通过 `/external-entry` 进入本应用。入口先保存外部身份和短期业务意图,再跳转到对应角色页面并清理地址栏中的入口查询参数。
|
||||
外部应用通过 `/external-entry` 进入本应用。
|
||||
|
||||
| 环境 | APP HOST |
|
||||
| --- | --- |
|
||||
| 预发环境 `pre` | `frontend-test.banlv-ai.com` |
|
||||
| 正式环境 `production` | `cozsweet.com` |
|
||||
| 测试环境 | `frontend-test.banlv-ai.com` |
|
||||
| 正式环境 | `cozsweet.com` |
|
||||
|
||||
入口格式:
|
||||
|
||||
@@ -13,78 +13,67 @@ Facebook 等外部应用统一通过 `/external-entry` 进入本应用。入口
|
||||
https://<APP_HOST>/external-entry?<参数>
|
||||
```
|
||||
|
||||
## 当前 Facebook 业务入口
|
||||
## 可选参数
|
||||
|
||||
当前正式投放固定为 4 类入口乘以 3 个角色,共 12 条链接。Facebook 业务名称与应用页面的对应关系如下:
|
||||
|
||||
| Facebook 入口 | 参数组合 | 落地行为 |
|
||||
| --- | --- | --- |
|
||||
| 私密空间 | `target=chat` | 进入普通聊天页,不插入任何锁定内容。 |
|
||||
| 语音 | `target=chat&mode=promotion&promotion_type=voice` | 进入聊天页,并插入一条待解锁语音。 |
|
||||
| 图片包 | `target=private-zone` | 进入角色的 `private-zone` 图片空间。 |
|
||||
| 帮忙买咖啡 | `target=tip` | 进入角色的咖啡打赏页。 |
|
||||
|
||||
每条正式链接还必须显式传入:
|
||||
|
||||
- `character=elio`、`character=maya` 或 `character=nayeli`;
|
||||
- `psid=<PSID>`,其中 `<PSID>` 必须由 Facebook 发送端替换为当前用户经过 URL 编码的 Page-scoped User ID。
|
||||
|
||||
完整的 12 条正式发送模板见 [Facebook 12 条外部入口链接清单](./links.md)。
|
||||
|
||||
## 参数说明
|
||||
所有参数均为可选参数。
|
||||
|
||||
| 参数 | 可选值或格式 | 用途 |
|
||||
| --- | --- | --- |
|
||||
| `target` | `chat`、`tip`、`private-zone` | 指定进入的页面;不传或值无效时进入聊天页。 |
|
||||
| `character` | `elio`、`maya`、`nayeli` | 指定角色;不传或值无效时使用 Elio。正式投放链接必须显式传入。 |
|
||||
| `psid` | string | Facebook Page-scoped User ID。Facebook 正式投放链接必须动态传入。 |
|
||||
| `target` | `chat`、`tip`、`private-room` | 指定进入的页面;不传或值无效时进入聊天页。 |
|
||||
| `psid` | string | 传入 Facebook Page-scoped User ID。 |
|
||||
| `mode` | `promotion` | 开启聊天促销模式。 |
|
||||
| `promotion_type` | `voice`、`image`、`private` | 指定促销消息类型,仅与 `mode=promotion` 一起使用。 |
|
||||
|
||||
`mode=promotion` 只有在 `target=chat` 且同时提供有效的 `promotion_type` 时生效。当前 12 条正式投放链接只使用 `promotion_type=voice`;`image` 和 `private` 保留为兼容能力,不属于本次业务清单。
|
||||
|
||||
## 四类发送模板
|
||||
|
||||
发送前必须把 `<CHARACTER>` 替换为角色值,把 `<PSID>` 替换为当前 Facebook 用户的真实 PSID;不得把占位符原样发送给用户。
|
||||
|
||||
私密空间(普通聊天):
|
||||
|
||||
```text
|
||||
https://<APP_HOST>/external-entry?target=chat&character=<CHARACTER>&psid=<PSID>
|
||||
```
|
||||
|
||||
语音:
|
||||
|
||||
```text
|
||||
https://<APP_HOST>/external-entry?target=chat&character=<CHARACTER>&mode=promotion&promotion_type=voice&psid=<PSID>
|
||||
```
|
||||
|
||||
图片包:
|
||||
|
||||
```text
|
||||
https://<APP_HOST>/external-entry?target=private-zone&character=<CHARACTER>&psid=<PSID>
|
||||
```
|
||||
|
||||
帮忙买咖啡:
|
||||
|
||||
```text
|
||||
https://<APP_HOST>/external-entry?target=tip&character=<CHARACTER>&psid=<PSID>
|
||||
```
|
||||
`mode=promotion` 只有在 `target=chat` 且同时提供有效的 `promotion_type` 时生效。
|
||||
|
||||
## PSID 与登录状态流程
|
||||
|
||||
`psid` 可以和任意有效入口参数组合使用。应用会先保存 PSID,再执行登录状态判断和 Facebook Identity 绑定。详细流程见 [PSID 与登录状态流程图](./psid-login-flow.md)。
|
||||
PSID 保存、登录状态判断和 Facebook Identity 绑定逻辑见 [PSID 与登录状态流程图](./psid-login-flow.md)。
|
||||
|
||||
所有参数值都必须进行 URL 编码。入口中禁止传递登录 Token、Page Access Token、App Secret 或其他秘密。
|
||||
## 使用示例
|
||||
|
||||
## 兼容说明
|
||||
普通聊天:
|
||||
|
||||
- 历史参数 `target=private-room` 继续兼容进入 `private-zone`,但不得用于新投放链接。
|
||||
- `private_zone` 等其他拼写仍按无效目标处理并回退聊天页。
|
||||
- `promotion_type=image` 和 `promotion_type=private` 继续由现有代码支持,但不计入当前 12 条 Facebook 业务链接。
|
||||
- 无效或缺失的 `character` 继续回退 Elio;正式投放模板始终显式传入角色,不能依赖回退。
|
||||
```text
|
||||
https://<APP_HOST>/external-entry?target=chat
|
||||
```
|
||||
|
||||
## 调试与正式清单
|
||||
携带 PSID 进入聊天,示例 PSID 为 `27511427698460020`:
|
||||
|
||||
- [本地调试链接清单](./debug-links.md)
|
||||
- [Facebook 12 条外部入口链接清单](./links.md)
|
||||
```text
|
||||
https://<APP_HOST>/external-entry?target=chat&psid=27511427698460020
|
||||
```
|
||||
|
||||
语音促销聊天:
|
||||
|
||||
```text
|
||||
https://<APP_HOST>/external-entry?target=chat&mode=promotion&promotion_type=voice
|
||||
```
|
||||
|
||||
图片促销聊天:
|
||||
|
||||
```text
|
||||
https://<APP_HOST>/external-entry?target=chat&mode=promotion&promotion_type=image
|
||||
```
|
||||
|
||||
私密文本促销聊天:
|
||||
|
||||
```text
|
||||
https://<APP_HOST>/external-entry?target=chat&mode=promotion&promotion_type=private
|
||||
```
|
||||
|
||||
咖啡打赏:
|
||||
|
||||
```text
|
||||
https://<APP_HOST>/external-entry?target=tip
|
||||
```
|
||||
|
||||
私密空间:
|
||||
|
||||
```text
|
||||
https://<APP_HOST>/external-entry?target=private-room
|
||||
```
|
||||
|
||||
`psid` 可以与任意 `target` 或聊天促销参数组合使用。参数值需要进行 URL 编码,不要在入口中传递登录 Token、Page Access Token 或 App Secret。
|
||||
|
||||
测试环境和正式环境的完整可点击示例见 [外部入口链接清单](./links.md)。
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
# 外部入口本地调试链接清单
|
||||
|
||||
[返回外部入口接入说明](./README.md)
|
||||
|
||||
启动本地应用后,可以直接点击以下链接进行调试。根网址为 `http://localhost:3000`,PSID 示例统一使用 `27511427698460020`。
|
||||
|
||||
## 默认入口
|
||||
|
||||
| 入口 | 链接 |
|
||||
| --- | --- |
|
||||
| 默认入口(Elio 聊天) | [打开默认入口](http://localhost:3000/external-entry) |
|
||||
| 普通聊天 | [打开普通聊天](http://localhost:3000/external-entry?target=chat) |
|
||||
| 携带 PSID 的聊天 | [打开 PSID 聊天示例](http://localhost:3000/external-entry?target=chat&psid=27511427698460020) |
|
||||
|
||||
## 角色聊天
|
||||
|
||||
| 角色 | 链接 |
|
||||
| --- | --- |
|
||||
| Elio | [打开 Elio 聊天](http://localhost:3000/external-entry?target=chat&character=elio) |
|
||||
| Maya | [打开 Maya 聊天](http://localhost:3000/external-entry?target=chat&character=maya) |
|
||||
| Nayeli | [打开 Nayeli 聊天](http://localhost:3000/external-entry?target=chat&character=nayeli) |
|
||||
|
||||
## 聊天促销
|
||||
|
||||
| 促销类型 | 链接 |
|
||||
| --- | --- |
|
||||
| 语音促销 | [打开语音促销](http://localhost:3000/external-entry?target=chat&mode=promotion&promotion_type=voice) |
|
||||
| 图片促销 | [打开图片促销](http://localhost:3000/external-entry?target=chat&mode=promotion&promotion_type=image) |
|
||||
| 私密文本促销 | [打开私密文本促销](http://localhost:3000/external-entry?target=chat&mode=promotion&promotion_type=private) |
|
||||
|
||||
## 咖啡打赏
|
||||
|
||||
| 角色 | 链接 |
|
||||
| --- | --- |
|
||||
| Elio | [打开 Elio 咖啡打赏](http://localhost:3000/external-entry?target=tip&character=elio) |
|
||||
| Maya | [打开 Maya 咖啡打赏](http://localhost:3000/external-entry?target=tip&character=maya) |
|
||||
| Nayeli | [打开 Nayeli 咖啡打赏](http://localhost:3000/external-entry?target=tip&character=nayeli) |
|
||||
|
||||
## 私密空间
|
||||
|
||||
| 角色 | 链接 |
|
||||
| --- | --- |
|
||||
| Elio | [打开 Elio 私密空间](http://localhost:3000/external-entry?target=private-zone&character=elio) |
|
||||
| Maya | [打开 Maya 私密空间](http://localhost:3000/external-entry?target=private-zone&character=maya) |
|
||||
| Nayeli | [打开 Nayeli 私密空间](http://localhost:3000/external-entry?target=private-zone&character=nayeli) |
|
||||
|
||||
如需为其他入口携带 PSID,在链接末尾追加 `&psid=27511427698460020`。对于不带查询参数的默认入口,请改为追加 `?psid=27511427698460020`。
|
||||
@@ -1,52 +1,31 @@
|
||||
# Facebook 12 条外部入口链接清单
|
||||
# 外部入口链接清单
|
||||
|
||||
本清单是 Facebook 正式投放的唯一业务链接清单,共 4 类入口乘以 3 个角色,合计 12 条模板。
|
||||
[返回外部入口接入说明](./README.md)
|
||||
|
||||
## 发送规则
|
||||
以下链接可以直接点击打开。PSID 示例统一使用 `27511427698460020`。
|
||||
|
||||
- 发送前必须把每条模板中的 `<PSID>` 替换为当前用户经过 URL 编码的 Facebook Page-scoped User ID;不得把占位符原样发送。
|
||||
- 每条链接都显式传入 `character`,不得依赖缺省角色回退。
|
||||
- Facebook 业务名称“私密空间”进入普通聊天页;业务名称“图片包”才进入应用的 `private-zone`。
|
||||
- 不要在入口中传递登录 Token、Page Access Token、App Secret 或其他秘密。
|
||||
- 以下模板包含占位符,替换真实 PSID 后才能直接发送或点击。
|
||||
## 测试环境
|
||||
|
||||
## 正式投放模板
|
||||
| 入口 | 链接 |
|
||||
| --- | --- |
|
||||
| 普通聊天 | [打开普通聊天](https://frontend-test.banlv-ai.com/external-entry?target=chat) |
|
||||
| 携带 PSID 的聊天 | [打开 PSID 聊天示例](https://frontend-test.banlv-ai.com/external-entry?target=chat&psid=27511427698460020) |
|
||||
| 语音促销 | [打开语音促销](https://frontend-test.banlv-ai.com/external-entry?target=chat&mode=promotion&promotion_type=voice) |
|
||||
| 图片促销 | [打开图片促销](https://frontend-test.banlv-ai.com/external-entry?target=chat&mode=promotion&promotion_type=image) |
|
||||
| 私密文本促销 | [打开私密文本促销](https://frontend-test.banlv-ai.com/external-entry?target=chat&mode=promotion&promotion_type=private) |
|
||||
| 咖啡打赏 | [打开咖啡打赏](https://frontend-test.banlv-ai.com/external-entry?target=tip) |
|
||||
| 私密空间 | [打开私密空间](https://frontend-test.banlv-ai.com/external-entry?target=private-room) |
|
||||
|
||||
| 编号 | Facebook 入口 | 角色 | 发送模板 | 预期落地与页面状态 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 1 | 私密空间 | Elio | `https://cozsweet.com/external-entry?target=chat&character=elio&psid=<PSID>` | `/characters/elio/chat`,不显示促销锁卡 |
|
||||
| 2 | 私密空间 | Maya | `https://cozsweet.com/external-entry?target=chat&character=maya&psid=<PSID>` | `/characters/maya/chat`,不显示促销锁卡 |
|
||||
| 3 | 私密空间 | Nayeli | `https://cozsweet.com/external-entry?target=chat&character=nayeli&psid=<PSID>` | `/characters/nayeli/chat`,不显示促销锁卡 |
|
||||
| 4 | 语音 | Elio | `https://cozsweet.com/external-entry?target=chat&character=elio&mode=promotion&promotion_type=voice&psid=<PSID>` | `/characters/elio/chat`,显示一条锁定语音 |
|
||||
| 5 | 语音 | Maya | `https://cozsweet.com/external-entry?target=chat&character=maya&mode=promotion&promotion_type=voice&psid=<PSID>` | `/characters/maya/chat`,显示一条锁定语音 |
|
||||
| 6 | 语音 | Nayeli | `https://cozsweet.com/external-entry?target=chat&character=nayeli&mode=promotion&promotion_type=voice&psid=<PSID>` | `/characters/nayeli/chat`,显示一条锁定语音 |
|
||||
| 7 | 图片包 | Elio | `https://cozsweet.com/external-entry?target=private-zone&character=elio&psid=<PSID>` | `/characters/elio/private-zone` |
|
||||
| 8 | 图片包 | Maya | `https://cozsweet.com/external-entry?target=private-zone&character=maya&psid=<PSID>` | `/characters/maya/private-zone` |
|
||||
| 9 | 图片包 | Nayeli | `https://cozsweet.com/external-entry?target=private-zone&character=nayeli&psid=<PSID>` | `/characters/nayeli/private-zone` |
|
||||
| 10 | 帮忙买咖啡 | Elio | `https://cozsweet.com/external-entry?target=tip&character=elio&psid=<PSID>` | `/characters/elio/tip` |
|
||||
| 11 | 帮忙买咖啡 | Maya | `https://cozsweet.com/external-entry?target=tip&character=maya&psid=<PSID>` | `/characters/maya/tip` |
|
||||
| 12 | 帮忙买咖啡 | Nayeli | `https://cozsweet.com/external-entry?target=tip&character=nayeli&psid=<PSID>` | `/characters/nayeli/tip` |
|
||||
## 正式环境
|
||||
|
||||
## 预发验证
|
||||
| 入口 | 链接 |
|
||||
| --- | --- |
|
||||
| 普通聊天 | [打开普通聊天](https://cozsweet.com/external-entry?target=chat) |
|
||||
| 携带 PSID 的聊天 | [打开 PSID 聊天示例](https://cozsweet.com/external-entry?target=chat&psid=27511427698460020) |
|
||||
| 语音促销 | [打开语音促销](https://cozsweet.com/external-entry?target=chat&mode=promotion&promotion_type=voice) |
|
||||
| 图片促销 | [打开图片促销](https://cozsweet.com/external-entry?target=chat&mode=promotion&promotion_type=image) |
|
||||
| 私密文本促销 | [打开私密文本促销](https://cozsweet.com/external-entry?target=chat&mode=promotion&promotion_type=private) |
|
||||
| 咖啡打赏 | [打开咖啡打赏](https://cozsweet.com/external-entry?target=tip) |
|
||||
| 私密空间 | [打开私密空间](https://cozsweet.com/external-entry?target=private-room) |
|
||||
|
||||
预发验证不维护第二套业务清单。将上述 12 条模板的主机统一替换为 `frontend-test.banlv-ai.com`,其余路径和参数保持不变:
|
||||
|
||||
```text
|
||||
https://frontend-test.banlv-ai.com/external-entry?<与正式模板相同的查询参数>
|
||||
```
|
||||
|
||||
预发环境是 `pre`,不是正式环境。预发验证通过不代表已经更新 `cozsweet.com` 或获得生产发布批准。
|
||||
|
||||
## 验收判断
|
||||
|
||||
- 最终浏览器地址必须是表格中的预期页面,且不再保留 `/external-entry` 的查询参数。
|
||||
- `<PSID>` 替换后的真实值必须由应用保存。
|
||||
- “私密空间”只进入普通聊天,不得出现锁定语音、锁定图片或私密文本促销卡。
|
||||
- “语音”进入聊天后必须只注入一条锁定语音。
|
||||
- “图片包”和“帮忙买咖啡”必须分别进入对应角色的 `private-zone` 与 `tip`,不能串到其他角色。
|
||||
|
||||
## 不属于当前 12 条清单的兼容能力
|
||||
|
||||
- 历史 `target=private-room` 继续兼容,但不得创建新的投放链接。
|
||||
- `promotion_type=image`、`promotion_type=private` 和独立 PSID 示例不属于当前正式业务清单。
|
||||
- 兼容能力的保留不改变本页“只有 12 条正式投放模板”的口径。
|
||||
如需在其他入口携带 PSID,在链接末尾追加 `&psid=27511427698460020`。
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
# Private Zone 全链路改名联调说明
|
||||
|
||||
- 日期:2026-07-22
|
||||
- 目标环境:本地、`pre`、生产
|
||||
- 当前状态:已验证
|
||||
|
||||
## 1. 目标
|
||||
|
||||
原功能名称存在拼写错误。本次将前端、unified 后端、Manager、数据库、埋点和文档中的正式命名统一为 `Private Zone`,并同步切换页面路由、API 路径和公开枚举值。
|
||||
|
||||
## 2. 环境地址
|
||||
|
||||
| 环境 | 前端 | API Base URL |
|
||||
| --- | --- | --- |
|
||||
| `pre` | `https://frontend-test.banlv-ai.com` | `https://proapi.banlv-ai.com` |
|
||||
| 生产 | `https://cozsweet.com` | `https://api.banlv-ai.com` |
|
||||
|
||||
## 3. 前端影响
|
||||
|
||||
前端已完成以下修改:
|
||||
|
||||
- 页面路由统一为 `/private-zone` 和 `/characters/{characterSlug}/private-zone`。
|
||||
- 外部入口参数统一为 `target=private-zone`。
|
||||
- 支付回跳参数统一为 `returnTo=private-zone`。
|
||||
- 类型、Repository、API client、XState actor、Provider 和资源目录统一使用 `privateZone`、`PrivateZone`、`private-zone` 或 `private_zone`。
|
||||
- 埋点键统一为 `navigation.private_zone`、`chat.open_private_zone_from_avatar` 等新名称。
|
||||
- 角色能力字段统一为 `capabilities.privateZone`。
|
||||
|
||||
旧页面和旧查询参数不再作为正式入口保留。发布时必须让前后端属于同一个发布批次。
|
||||
|
||||
## 4. API 变更清单
|
||||
|
||||
所有接口都使用 `Authorization: Bearer <TOKEN>`,响应继续使用现有统一 envelope。请求与响应中未列出的业务字段保持原类型和含义。
|
||||
|
||||
| 方法 | 新路径 | 用途 |
|
||||
| --- | --- | --- |
|
||||
| `GET` | `/api/private-zone/albums` | 查询付费图片包 |
|
||||
| `POST` | `/api/private-zone/albums/{albumId}/unlock` | 解锁图片包 |
|
||||
| `GET` | `/api/private-zone/moments` | 查询朋友圈式内容 |
|
||||
| `POST` | `/api/private-zone/moments/{momentId}/unlock` | 解锁单条内容 |
|
||||
| `GET` | `/api/private-zone/config` | 查询当前角色和用户解锁配置 |
|
||||
| `GET` | `/api/private-zone/diaries` | 查询关系日记 |
|
||||
| `POST` | `/api/private-zone/diaries/{diaryId}/seen` | 标记关系日记已读 |
|
||||
| `POST` | `/api/private-zone/diaries/{diaryId}/unlock` | 解锁关系日记 |
|
||||
|
||||
### 4.1 图片包列表
|
||||
|
||||
```http
|
||||
GET /api/private-zone/albums?characterId=elio&limit=20
|
||||
Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
| 字段 | 位置 | 类型 | 必填 | 可为 `null` | 说明 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| `characterId` | query | string | 是 | 否 | 角色 ID |
|
||||
| `limit` | query | integer | 否 | 否 | `1-50`,默认 `20` |
|
||||
| `cursor` | query | string | 否 | 是 | 分页游标 |
|
||||
|
||||
调用示例:
|
||||
|
||||
```bash
|
||||
curl 'https://proapi.banlv-ai.com/api/private-zone/albums?characterId=elio&limit=20' \
|
||||
-H 'Authorization: Bearer <TOKEN>'
|
||||
```
|
||||
|
||||
### 4.2 解锁图片包
|
||||
|
||||
```http
|
||||
POST /api/private-zone/albums/{albumId}/unlock
|
||||
Authorization: Bearer <TOKEN>
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
| 字段 | 位置 | 类型 | 必填 | 可为 `null` | 说明 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| `albumId` | path | string | 是 | 否 | 图片包 ID |
|
||||
| `expectedCost` | body | integer | 否 | 是 | 前端确认价格;与后端价格不一致时拒绝解锁 |
|
||||
|
||||
```bash
|
||||
curl -X POST 'https://proapi.banlv-ai.com/api/private-zone/albums/<ALBUM_ID>/unlock' \
|
||||
-H 'Authorization: Bearer <TOKEN>' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"expectedCost":320}'
|
||||
```
|
||||
|
||||
### 4.3 Moments 内容与解锁
|
||||
|
||||
```http
|
||||
GET /api/private-zone/moments?characterId=elio&limit=20
|
||||
POST /api/private-zone/moments/{momentId}/unlock
|
||||
```
|
||||
|
||||
解锁请求体与图片包一致,`expectedCost` 为可选整数。响应中的正式分类值同步改为:
|
||||
|
||||
```json
|
||||
{
|
||||
"lockDetail": {
|
||||
"type": "private_zone_moment",
|
||||
"reason": "private_zone_moment"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 5. 其他公开值
|
||||
|
||||
| 使用位置 | 新值 | 类型 |
|
||||
| --- | --- | --- |
|
||||
| `/api/chat/unlock-private` 的 `lockType` 别名 | `private_zone` | string enum |
|
||||
| 日程导入 `contentType` 别名 | `private_zone` | string enum,归一化为 `paid_content` |
|
||||
| 外部入口 `target` | `private-zone` | string enum |
|
||||
| 支付回跳 `returnTo` | `private-zone` | string enum |
|
||||
| 锁定详情分类 | `private_zone_moment` | string enum |
|
||||
|
||||
## 6. 数据库迁移
|
||||
|
||||
因为 `pre` 与生产当前共用 `https://dbapi.banlv-ai.com`,预发部署前先执行 unified 仓库中的临时桥接脚本:
|
||||
|
||||
```text
|
||||
database/private-zone-bridge.sql
|
||||
```
|
||||
|
||||
桥接脚本会创建新表并在切换窗口内保持新旧解锁写入双向同步。生产前后端全部切换完成后,再执行最终迁移:
|
||||
|
||||
```text
|
||||
database/private-zone-migration.sql
|
||||
```
|
||||
|
||||
迁移会在同一事务中完成:
|
||||
|
||||
- 将历史解锁表无损重命名;新旧表同时存在时先合并再删除旧表。
|
||||
- 重命名关联约束、索引、策略和触发器。
|
||||
- 合并 `users.preferences` 中历史解锁键,防止已解锁内容重新锁定。
|
||||
- 把 `credit_ledger` 历史分类迁移到 `private_zone` 和 `private_zone_moment`。
|
||||
- 定向迁移历史埋点键、页面 URL 和系统媒体路径,不改写用户聊天正文。
|
||||
- 删除切换窗口使用的双写触发器和函数。
|
||||
- 支持重复执行。
|
||||
|
||||
## 7. 兼容性与发布顺序
|
||||
|
||||
这是破坏性命名修正,不保留旧 API、旧页面路由或旧公开枚举作为正式兼容层。必须按以下顺序发布:
|
||||
|
||||
1. 备份数据库并记录当前 unified、前端和 Manager 版本。
|
||||
2. 执行 `database/private-zone-bridge.sql`,确认新旧表双向写入一致。
|
||||
3. 部署 unified `pre`,验证所有 `/api/private-zone/*` 接口。
|
||||
4. 部署前端 `pre`,验证页面、外部入口、解锁和支付回跳。
|
||||
5. Manager 更新后验证积分用途显示为新分类。
|
||||
6. `pre` 验证通过后,先启动新生产后端并临时配置旧 API 到新 API 的 Nginx 转发。
|
||||
7. 切换生产后端,再部署同批次生产前端;确认新前端只调用 `/api/private-zone/*`。
|
||||
8. 删除临时 Nginx 转发,执行 `database/private-zone-migration.sql` 清理旧数据库对象。
|
||||
|
||||
## 8. 错误与界面状态
|
||||
|
||||
- `401`:Token 缺失或无效,前端进入现有登录恢复流程。
|
||||
- `403`:游客访问仅注册用户可用的关系日记操作,展示现有注册引导。
|
||||
- `404`:角色、图片包、内容或日记不存在,展示现有空状态或失效提示。
|
||||
- `409`:`expectedCost` 与后端价格不同,刷新列表后重新确认。
|
||||
- `402` 或业务余额不足错误:进入现有充值流程,并使用 `returnTo=private-zone` 返回原角色页面。
|
||||
- 网络失败:不修改本地解锁状态,保留重试入口。
|
||||
|
||||
## 9. 验收用例
|
||||
|
||||
1. `/characters/elio/private-zone`、Maya 和 Nayeli 对应页面均可打开。
|
||||
2. `GET /api/private-zone/albums` 返回当前角色内容,角色之间不混用。
|
||||
3. 已解锁历史记录在迁移后保持解锁状态,不重复扣积分。
|
||||
4. 新解锁成功后刷新页面仍为已解锁状态。
|
||||
5. 积分不足进入充值页后,回跳到原角色 `/private-zone` 页面。
|
||||
6. `target=private-zone&character=nayeli` 进入 Nayeli 对应页面。
|
||||
7. Manager 的积分用途不再出现旧分类。
|
||||
8. 三个仓库执行旧命名残留扫描,结果为 `0`。
|
||||
|
||||
## 10. 当前测试证据
|
||||
|
||||
- unified:`316 passed`。
|
||||
- 前端:TypeScript 类型检查通过;Vitest `639 passed`;ESLint 通过;契约测试 `4 passed`;生产构建通过并生成三个角色的 `/private-zone` 页面。
|
||||
- Manager:`75 passed`。
|
||||
- PostgreSQL 16 临时库:升级、重复升级、回滚和再次升级全部通过;历史解锁、偏好键、积分账本、埋点、媒体路径和数据库对象名均通过断言,临时容器已删除。
|
||||
- `pre`:unified `71da49b` 和前端 `35939e7` 已验证;新 API 已注册 `8` 条 `/api/private-zone/*` 路径,旧 API 路径数量为 `0`;新页面返回 `200`,旧页面返回 `404`。
|
||||
- 生产:unified 镜像 `ai-boyfriend-unified:prod-20260722-71da49b`(镜像 ID `sha256:755ef5741856d83d7d808e7df8ee259b6fa5fb94fe333b523ee280ed1d5f674b`)和前端镜像 `prod-35939e7` 已健康运行;Manager 当前版本为 `6eea005`。
|
||||
- 生产接口:测试账号调用 `GET https://api.banlv-ai.com/api/private-zone/config?characterId=elio` 返回 `200`,`success=true`;旧版 API 路径在所有公开 API 入口均返回 `404`。
|
||||
- 生产数据库:最终迁移已执行,旧表、桥接函数、桥接触发器、旧偏好键、旧积分分类和旧埋点值的残留数量均为 `0`。
|
||||
|
||||
## 11. 回滚影响
|
||||
|
||||
最终迁移执行前可直接恢复旧应用,桥接表会保留双向一致的数据。最终迁移执行后,回滚必须同时执行 unified 仓库中的 `database/private-zone-rollback.sql`。回滚前应停止写入,先保存切换后的新增解锁记录,再执行逆向迁移并恢复旧应用版本。不得只恢复前端或只恢复 unified。
|
||||
|
||||
## 12. 待确认事项
|
||||
|
||||
- 无。
|
||||
@@ -1,6 +1,6 @@
|
||||
# Performance baseline
|
||||
|
||||
Baseline date: 2026-07-16
|
||||
Baseline date: 2026-07-15
|
||||
|
||||
Next.js: 16.2.7 (Turbopack)
|
||||
|
||||
@@ -30,10 +30,10 @@ Compressed sizes below are Turbopack module estimates. `Eager` is the route's sy
|
||||
|
||||
| Route | Direct-import baseline | Current eager baseline | Change | Current async baseline |
|
||||
| --- | ---: | ---: | ---: | ---: |
|
||||
| `/splash` | 646.2 KiB | 600.6 KiB | -45.6 KiB | 49.2 KiB |
|
||||
| `/chat` | 669.8 KiB | 641.1 KiB | -28.7 KiB | 49.6 KiB |
|
||||
| `/subscription` | 658.4 KiB | 618.0 KiB | -40.4 KiB | 20.6 KiB |
|
||||
| `/tip` | 651.6 KiB | 611.8 KiB | -39.8 KiB | 20.6 KiB |
|
||||
| `/splash` | 646.2 KiB | 599.7 KiB | -46.5 KiB | 49.2 KiB |
|
||||
| `/chat` | 669.8 KiB | 637.8 KiB | -32.0 KiB | 49.6 KiB |
|
||||
| `/subscription` | 658.4 KiB | 616.9 KiB | -41.5 KiB | 20.6 KiB |
|
||||
| `/tip` | 651.6 KiB | 610.9 KiB | -40.7 KiB | 20.6 KiB |
|
||||
|
||||
The earlier direct-import pass replaced root `@/utils` and `@/data/storage`
|
||||
barrel imports with symbol-level module paths. The current Client-boundary pass
|
||||
@@ -42,10 +42,6 @@ provider imports, and loads the Dexie-backed chat repository through a dynamic
|
||||
import. UA Parser remains an intentional eager dependency because the app still
|
||||
requires its general browser, OS, and device detection behavior.
|
||||
|
||||
The 2026-07-16 verification also prevents runtime imports from the root
|
||||
repository and storage barrels. This keeps unrelated repositories from turning
|
||||
the intentionally async Dexie path eager when a new feature is added.
|
||||
|
||||
Module loading baseline:
|
||||
|
||||
| Module | Before | Baseline |
|
||||
|
||||
@@ -13,7 +13,6 @@ This project uses Playwright for end-to-end tests.
|
||||
```bash
|
||||
pnpm test:e2e
|
||||
pnpm test:e2e:chrome
|
||||
pnpm test:e2e:mobile-smoke
|
||||
pnpm test:e2e:real
|
||||
pnpm test:e2e:prod
|
||||
```
|
||||
@@ -26,10 +25,6 @@ pnpm exec playwright install chromium
|
||||
|
||||
For local development on macOS, `pnpm test:e2e:chrome` can reuse the installed Google Chrome.
|
||||
|
||||
`pnpm test:e2e:mobile-smoke` runs the critical authentication, logout, token
|
||||
refresh and paid-image unlock paths with the Pixel 7 profile. CI runs this tier
|
||||
on every pull request and `dev` / `test` / `main` push.
|
||||
|
||||
## Environment overrides
|
||||
|
||||
```bash
|
||||
@@ -40,6 +35,6 @@ pnpm test:e2e:real
|
||||
|
||||
```bash
|
||||
PLAYWRIGHT_BASE_URL=https://cozsweet.com \
|
||||
E2E_API_BASE_URL=https://api.banlv-ai.com \
|
||||
E2E_API_BASE_URL=https://proapi.banlv-ai.com \
|
||||
pnpm test:e2e:prod
|
||||
```
|
||||
|
||||
@@ -2,7 +2,6 @@ import type { Page } from "@playwright/test";
|
||||
|
||||
import { registerAuthMocks } from "./api/auth";
|
||||
import { registerChatMocks } from "./api/chat";
|
||||
import { registerCharacterMocks } from "./api/character";
|
||||
import { registerPaymentMocks } from "./api/payment";
|
||||
import { registerUserMocks } from "./api/user";
|
||||
|
||||
@@ -12,7 +11,7 @@ export interface MockCoreApisOptions {
|
||||
paidImageFlow?: boolean;
|
||||
paidImageInsufficientCreditsFlow?: boolean;
|
||||
paidVoiceInsufficientCreditsFlow?: boolean;
|
||||
topUpHandoffFlow?: boolean;
|
||||
psidLoginFlow?: boolean;
|
||||
}
|
||||
|
||||
export async function mockCoreApis(page: Page, options: MockCoreApisOptions = {}) {
|
||||
@@ -22,16 +21,15 @@ export async function mockCoreApis(page: Page, options: MockCoreApisOptions = {}
|
||||
paidImageFlow: options.paidImageFlow ?? false,
|
||||
paidImageInsufficientCreditsFlow: options.paidImageInsufficientCreditsFlow ?? false,
|
||||
paidVoiceInsufficientCreditsFlow: options.paidVoiceInsufficientCreditsFlow ?? false,
|
||||
topUpHandoffFlow: options.topUpHandoffFlow ?? false,
|
||||
psidLoginFlow: options.psidLoginFlow ?? false,
|
||||
};
|
||||
const chatState = { hasExpiredChatSend: false, paidImageRequested: false, paidImageUnlocked: false };
|
||||
|
||||
await registerAuthMocks(page, {
|
||||
chatSendTokenRefreshFlow: chatOptions.chatSendTokenRefreshFlow,
|
||||
isChatSendTokenExpired: () => chatState.hasExpiredChatSend,
|
||||
topUpHandoffFlow: chatOptions.topUpHandoffFlow,
|
||||
psidLoginFlow: chatOptions.psidLoginFlow,
|
||||
});
|
||||
await registerCharacterMocks(page);
|
||||
await registerUserMocks(page);
|
||||
await registerChatMocks(page, chatOptions, chatState);
|
||||
await registerPaymentMocks(page);
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
|
||||
import { apiEnvelope } from "../data/common";
|
||||
import { emailLoginResponse, guestLoginResponse, refreshedEmailLoginResponse, refreshedGuestLoginResponse, topUpHandoffResponse } from "../data/auth";
|
||||
import { emailLoginResponse, guestLoginResponse, psidLoginResponse, refreshedEmailLoginResponse, refreshedGuestLoginResponse } from "../data/auth";
|
||||
|
||||
export interface AuthMockState {
|
||||
chatSendTokenRefreshFlow: boolean;
|
||||
isChatSendTokenExpired: () => boolean;
|
||||
topUpHandoffFlow: boolean;
|
||||
psidLoginFlow: boolean;
|
||||
}
|
||||
|
||||
export async function registerAuthMocks(page: Page, state: AuthMockState) {
|
||||
await page.route("**/api/auth/handoff/topup/consume", async (route) => {
|
||||
if (!state.topUpHandoffFlow) {
|
||||
await page.route("**/api/auth/login/facebook/psid", async (route) => {
|
||||
if (!state.psidLoginFlow) {
|
||||
await route.continue();
|
||||
return;
|
||||
}
|
||||
await route.fulfill({ json: apiEnvelope(topUpHandoffResponse) });
|
||||
|
||||
await route.fulfill({ json: apiEnvelope(psidLoginResponse) });
|
||||
});
|
||||
|
||||
await page.route("**/api/auth/guest", async (route) => {
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
|
||||
import { apiEnvelope } from "../data/common";
|
||||
import { chatCharactersResponse } from "../data/character";
|
||||
|
||||
export async function registerCharacterMocks(page: Page) {
|
||||
await page.route(/\/api\/characters(?:\?.*)?$/, async (route) => {
|
||||
await route.fulfill({ json: apiEnvelope(chatCharactersResponse) });
|
||||
});
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
|
||||
import { apiEnvelope } from "../data/common";
|
||||
import { chatSendResponse, createChatSendResponse, createPaidImageHistoryResponse, createWeeklyLimitChatSendResponse, emptyChatHistoryResponse, emptyChatPreviewsResponse, insufficientCreditsUnlockImageResponse, insufficientCreditsUnlockVoiceResponse, paidImageChatSendResponse, paidImageUnlockHistoryResponse, paidVoiceHistoryResponse } from "../data/chat";
|
||||
import { chatSendResponse, createChatSendResponse, createPaidImageHistoryResponse, createWeeklyLimitChatSendResponse, emptyChatHistoryResponse, insufficientCreditsUnlockImageResponse, insufficientCreditsUnlockVoiceResponse, paidImageChatSendResponse, paidImageUnlockHistoryResponse, paidVoiceHistoryResponse } from "../data/chat";
|
||||
|
||||
export interface ChatMockOptions {
|
||||
chatLimitTriggerAt?: number;
|
||||
@@ -20,23 +20,6 @@ export interface ChatMockState {
|
||||
export async function registerChatMocks(page: Page, options: ChatMockOptions, state: ChatMockState) {
|
||||
let sendCount = 0;
|
||||
|
||||
await page.route("**/api/chat/opening-message", async (route) => {
|
||||
const body = route.request().postDataJSON() as {
|
||||
openingMessage?: unknown;
|
||||
} | undefined;
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
messageId: "mock-opening-message",
|
||||
created: true,
|
||||
openingMessage:
|
||||
typeof body?.openingMessage === "string"
|
||||
? body.openingMessage
|
||||
: "Hello",
|
||||
createdAt: "2026-07-23T00:00:00Z",
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/chat/history**", async (route) => {
|
||||
const response = options.paidVoiceInsufficientCreditsFlow
|
||||
? paidVoiceHistoryResponse
|
||||
@@ -48,10 +31,6 @@ export async function registerChatMocks(page: Page, options: ChatMockOptions, st
|
||||
await route.fulfill({ json: apiEnvelope(response) });
|
||||
});
|
||||
|
||||
await page.route("**/api/chat/previews", async (route) => {
|
||||
await route.fulfill({ json: apiEnvelope(emptyChatPreviewsResponse) });
|
||||
});
|
||||
|
||||
await page.route("**/api/chat/send", async (route) => {
|
||||
sendCount += 1;
|
||||
const requestBody = route.request().postDataJSON() as { message?: unknown } | undefined;
|
||||
@@ -61,35 +40,7 @@ export async function registerChatMocks(page: Page, options: ChatMockOptions, st
|
||||
await route.fulfill({ status: 401, json: { message: "expired" } });
|
||||
return;
|
||||
}
|
||||
const response = message.includes("discount offer test")
|
||||
? {
|
||||
...chatSendResponse,
|
||||
reply: "I know you're thinking carefully about the price.",
|
||||
messageId: "discount-action-message",
|
||||
commercialAction: {
|
||||
actionId: "13ec8a10-58d7-4d24-b66b-8db5699a1aa8",
|
||||
type: "discountOffer",
|
||||
copy: "Want me to ask for my best private offer?",
|
||||
ctaLabel: "Yes, ask for me",
|
||||
target: "discountConsent",
|
||||
ruleId: "discount_after_price_objection",
|
||||
},
|
||||
}
|
||||
: message.includes("private album offer test")
|
||||
? {
|
||||
...chatSendResponse,
|
||||
reply: "You always know how to make me smile.",
|
||||
messageId: "commercial-action-message",
|
||||
commercialAction: {
|
||||
actionId: "commercial-action-1",
|
||||
type: "privateAlbumOffer",
|
||||
copy: "There are more private photos waiting for you.",
|
||||
ctaLabel: "Open private zone",
|
||||
target: "privateZone",
|
||||
ruleId: "private_album_after_appearance_praise",
|
||||
},
|
||||
}
|
||||
: options.paidImageFlow && message.includes("给我发图片")
|
||||
const response = options.paidImageFlow && message.includes("给我发图片")
|
||||
? paidImageChatSendResponse
|
||||
: options.chatLimitTriggerAt != null && sendCount >= options.chatLimitTriggerAt
|
||||
? createWeeklyLimitChatSendResponse(sendCount, options.chatLimitTriggerAt)
|
||||
|
||||
@@ -4,16 +4,6 @@ import { apiEnvelope } from "../data/common";
|
||||
import { createPaymentOrderResponse, paidPaymentOrderStatusResponse, paymentPlansResponse, tipPaymentPlansResponse, vipStatusResponse } from "../data/payment";
|
||||
|
||||
export async function registerPaymentMocks(page: Page) {
|
||||
await page.route("**/api/payment/commercial-offers/*/accept", async (route) => route.fulfill({ json: apiEnvelope({
|
||||
commercialOfferId: "13ec8a10-58d7-4d24-b66b-8db5699a1aa8",
|
||||
planId: "vip_annual",
|
||||
subscriptionType: "vip",
|
||||
discountPercent: 30,
|
||||
pricePercent: 70,
|
||||
expiresAt: "2026-07-24T08:00:00+00:00",
|
||||
message: "I got it for you.",
|
||||
promotionType: "commercial_seven_discount",
|
||||
}) }));
|
||||
await page.route("**/api/payment/plans**", async (route) => route.fulfill({ json: apiEnvelope(paymentPlansResponse) }));
|
||||
await page.route("**/api/payment/tip-plans**", async (route) => route.fulfill({ json: apiEnvelope(tipPaymentPlansResponse) }));
|
||||
await page.route("**/api/payment/create-order", async (route) => route.fulfill({ json: apiEnvelope(createPaymentOrderResponse) }));
|
||||
|
||||
@@ -50,16 +50,14 @@ export const refreshedEmailLoginResponse = {
|
||||
refreshToken: "e2e-refreshed-email-refresh-token",
|
||||
};
|
||||
|
||||
export const topUpHandoffResponse = {
|
||||
token: "e2e-messenger-token",
|
||||
refreshToken: "e2e-messenger-refresh-token",
|
||||
loginStatus: "facebookMessenger",
|
||||
merged: false,
|
||||
user: {
|
||||
...e2eEmailUser,
|
||||
id: "user_e2e_messenger",
|
||||
username: "E2E Messenger User",
|
||||
email: "messenger_hash@messenger.cozsweet.invalid",
|
||||
loginProvider: "facebook_messenger",
|
||||
},
|
||||
export const psidLoginResponse = {
|
||||
token: "e2e-psid-guest-token",
|
||||
refreshToken: "",
|
||||
matchedBy: "psid",
|
||||
fbAsid: "",
|
||||
fbPsid: "e2e-facebook-psid",
|
||||
hasCompleteFacebookIdentity: false,
|
||||
isGuest: true,
|
||||
user: e2eUser,
|
||||
userId: e2eUser.id,
|
||||
};
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
export const chatCharactersResponse = {
|
||||
items: [
|
||||
{
|
||||
id: "elio",
|
||||
displayName: "Elio Silvestri",
|
||||
isActive: true,
|
||||
capabilities: { chat: true, privateContent: true },
|
||||
sortOrder: 10,
|
||||
},
|
||||
{
|
||||
id: "maya-tan",
|
||||
displayName: "Maya Tan",
|
||||
isActive: true,
|
||||
capabilities: { chat: true, privateContent: true },
|
||||
sortOrder: 20,
|
||||
},
|
||||
{
|
||||
id: "nayeli-cervantes",
|
||||
displayName: "Nayeli Cervantes",
|
||||
isActive: true,
|
||||
capabilities: { chat: true, privateContent: true },
|
||||
sortOrder: 30,
|
||||
},
|
||||
],
|
||||
defaultCharacterId: "elio",
|
||||
};
|
||||
@@ -9,8 +9,6 @@ export const emptyChatHistoryResponse = {
|
||||
privateCanViewFree: false,
|
||||
};
|
||||
|
||||
export const emptyChatPreviewsResponse = { items: [] };
|
||||
|
||||
export const chatSendResponse = {
|
||||
reply: "Hello from the E2E boyfriend.",
|
||||
audioUrl: "",
|
||||
@@ -66,7 +64,6 @@ export function createWeeklyLimitChatSendResponse(
|
||||
}
|
||||
|
||||
export const paidImageMessageId = "msg_photo_paywall_001";
|
||||
export const paidImageDisplayMessageId = `server:${paidImageMessageId}:assistant`;
|
||||
export const paidImageUrl =
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=";
|
||||
export const paidImageChatSendResponse = {
|
||||
@@ -75,13 +72,13 @@ export const paidImageChatSendResponse = {
|
||||
messageId: paidImageMessageId,
|
||||
isGuest: true,
|
||||
timestamp: 1_782_180_725_000,
|
||||
image: { type: "elio_schedule", url: null },
|
||||
image: { type: "elio_schedule", url: paidImageUrl },
|
||||
lockDetail: { locked: true, showContent: true, showUpgrade: true, reason: "image", hint: "Activate VIP to unlock the full photo.", detail: null },
|
||||
};
|
||||
|
||||
export function createPaidImageHistoryResponse(unlocked: boolean) {
|
||||
return {
|
||||
messages: [{ role: "assistant", type: "image", content: unlocked ? "" : paidImageChatSendResponse.reply, id: paidImageMessageId, created_at: "2026-06-30T00:00:00.000Z", audioUrl: null, image: { type: "elio_schedule", url: unlocked ? paidImageUrl : null }, lockDetail: unlocked ? { locked: false, showContent: true, showUpgrade: false, reason: null, hint: null, detail: null } : paidImageChatSendResponse.lockDetail }],
|
||||
messages: [{ role: "assistant", type: "image", content: unlocked ? "" : paidImageChatSendResponse.reply, id: paidImageMessageId, created_at: "2026-06-30T00:00:00.000Z", audioUrl: null, image: { type: "elio_schedule", url: paidImageUrl }, lockDetail: unlocked ? { locked: false, showContent: true, showUpgrade: false, reason: null, hint: null, detail: null } : paidImageChatSendResponse.lockDetail }],
|
||||
total: 1, limit: 50, offset: 0, isVip: unlocked, privateFreeLimit: 0, privateUsedToday: 0, privateCanViewFree: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,11 +10,5 @@ export const tipPaymentPlansResponse = { plans: [
|
||||
] };
|
||||
export const paymentOrderId = "order_e2e_vip_monthly";
|
||||
export const createPaymentOrderResponse = { orderId: paymentOrderId, payParams: { provider: "stripe", clientSecret: "pi_e2e_secret_mock" } };
|
||||
export const paidPaymentOrderStatusResponse = {
|
||||
orderId: paymentOrderId,
|
||||
status: "paid",
|
||||
orderType: "vip_monthly",
|
||||
planId: "vip_monthly",
|
||||
creditsAdded: 0,
|
||||
};
|
||||
export const paidPaymentOrderStatusResponse = { orderId: paymentOrderId, status: "paid", orderType: "vip_monthly", planId: "vip_monthly" };
|
||||
export const vipStatusResponse = { isVip: false, expiresAt: null };
|
||||
|
||||
@@ -8,13 +8,6 @@ export const e2eEmailCredentials = {
|
||||
};
|
||||
|
||||
export const splashStartChatButtonName = "Start Chatting";
|
||||
export const defaultCharacterSlug = "elio";
|
||||
export const defaultCharacterSplashPath = `/characters/${defaultCharacterSlug}/splash`;
|
||||
export const defaultCharacterChatPath = `/characters/${defaultCharacterSlug}/chat`;
|
||||
export const defaultCharacterProfilePath = `/profile?returnTo=%2Fcharacters%2F${defaultCharacterSlug}%2Fchat`;
|
||||
export const defaultCharacterChatUrl = new RegExp(
|
||||
`/characters/${defaultCharacterSlug}/chat(?:\\?.*)?$`,
|
||||
);
|
||||
|
||||
export function getSplashStartChatButton(page: Page) {
|
||||
return page.getByRole("button", { name: splashStartChatButtonName });
|
||||
@@ -31,11 +24,8 @@ export async function setEmailSessionStorage(page: Page) {
|
||||
}
|
||||
|
||||
export async function seedEmailSession(page: Page) {
|
||||
await page.goto(defaultCharacterSplashPath);
|
||||
await page.goto("/splash");
|
||||
await setEmailSessionStorage(page);
|
||||
await page.reload();
|
||||
// Let the root auth provider hydrate the seeded session before navigation.
|
||||
await page.waitForTimeout(750);
|
||||
}
|
||||
|
||||
export async function switchToEmailSignIn(page: Page) {
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import { expect, type BrowserContext, type Page } from "@playwright/test";
|
||||
|
||||
import {
|
||||
defaultCharacterChatPath,
|
||||
defaultCharacterChatUrl,
|
||||
defaultCharacterSplashPath,
|
||||
seedEmailSession,
|
||||
} from "./auth";
|
||||
import { seedEmailSession } from "./auth";
|
||||
|
||||
export async function clearBrowserState(context: BrowserContext, page: Page, baseURL?: string) {
|
||||
await context.clearCookies();
|
||||
@@ -17,17 +12,13 @@ export async function clearBrowserState(context: BrowserContext, page: Page, bas
|
||||
}
|
||||
|
||||
export async function enterChatFromSplash(page: Page, options: { expectedUrl?: RegExp; timeout?: number; waitUntil?: "commit" | "domcontentloaded" | "load" | "networkidle" } = {}) {
|
||||
const {
|
||||
expectedUrl = defaultCharacterChatUrl,
|
||||
timeout = 10_000,
|
||||
waitUntil,
|
||||
} = options;
|
||||
await page.goto(defaultCharacterSplashPath, { waitUntil });
|
||||
const { expectedUrl = /\/chat$/, timeout = 10_000, waitUntil } = options;
|
||||
await page.goto("/splash", { waitUntil });
|
||||
const startChatButton = page.getByRole("button", { name: "Start Chatting" });
|
||||
await expect(startChatButton).toBeVisible({ timeout });
|
||||
await expect(startChatButton).toBeEnabled();
|
||||
for (let attempt = 0; attempt < 3; attempt += 1) {
|
||||
await startChatButton.click({ timeout: 3_000 }).catch(() => {});
|
||||
await startChatButton.click();
|
||||
try { await expect(page).toHaveURL(expectedUrl, { timeout: 3_000 }); return; } catch { await page.waitForTimeout(500); }
|
||||
}
|
||||
await expect(page).toHaveURL(expectedUrl, { timeout });
|
||||
@@ -42,7 +33,9 @@ export async function dismissChatInterruptions(page: Page) {
|
||||
|
||||
export async function signInWithEmailAndOpenChat(page: Page) {
|
||||
await seedEmailSession(page);
|
||||
await page.goto(defaultCharacterChatPath);
|
||||
const historyResponsePromise = page.waitForResponse("**/api/chat/history**");
|
||||
await page.goto("/chat");
|
||||
await historyResponsePromise;
|
||||
await dismissChatInterruptions(page);
|
||||
await expect(page.getByRole("textbox", { name: "Message" })).toBeEnabled({ timeout: 20_000 });
|
||||
}
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
import { expect, type Page } from "@playwright/test";
|
||||
|
||||
export async function completeVipPayment(page: Page) {
|
||||
const checkoutButton = page.getByRole("button", { name: "Pay and Top Up" });
|
||||
await expect(checkoutButton).toBeDisabled();
|
||||
await page.getByRole("button", { name: /Monthly,/i }).click();
|
||||
const renewalDialog = page.getByRole("dialog", {
|
||||
name: "Automatic Renewal Confirmation",
|
||||
});
|
||||
await expect(renewalDialog).toBeVisible();
|
||||
await renewalDialog.getByRole("button", { name: "Confirm" }).click();
|
||||
await expect(checkoutButton).toBeEnabled();
|
||||
|
||||
const createOrderRequestPromise = page.waitForRequest("**/api/payment/create-order");
|
||||
const orderStatusRequestPromise = page.waitForRequest("**/api/payment/order-status**");
|
||||
await checkoutButton.click();
|
||||
await page.getByRole("button", { name: /Pay and Activ/i }).click();
|
||||
const createOrderRequest = await createOrderRequestPromise;
|
||||
expect(createOrderRequest.postDataJSON()).toMatchObject({ planId: "vip_monthly", payChannel: "stripe" });
|
||||
await orderStatusRequestPromise;
|
||||
|
||||
@@ -3,7 +3,6 @@ import { expect, test } from "@playwright/test";
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import {
|
||||
clearBrowserState,
|
||||
defaultCharacterChatUrl,
|
||||
enterChatFromSplash,
|
||||
submitEmailLogin,
|
||||
switchToEmailSignIn,
|
||||
@@ -25,11 +24,9 @@ test("user can email login from other sign-in options and return to chat", async
|
||||
await expect(page).toHaveURL(/\/auth(?:\?.*)?$/);
|
||||
|
||||
await switchToEmailSignIn(page);
|
||||
const loginRequest = await submitEmailLogin(page, {
|
||||
expectedUrl: defaultCharacterChatUrl,
|
||||
});
|
||||
const loginRequest = await submitEmailLogin(page, { expectedUrl: /\/chat$/ });
|
||||
expect(["desktop", "android"]).toContain(loginRequest?.postDataJSON().platform);
|
||||
|
||||
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Save CozSweet" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Menu" })).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import {
|
||||
clearBrowserState,
|
||||
defaultCharacterProfilePath,
|
||||
defaultCharacterSplashPath,
|
||||
defaultCharacterChatUrl,
|
||||
enterChatFromSplash,
|
||||
getSplashStartChatButton,
|
||||
submitEmailLogin,
|
||||
switchToEmailSignIn,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page);
|
||||
});
|
||||
|
||||
test("user can log out from the profile after email login", async ({
|
||||
page,
|
||||
}) => {
|
||||
await enterChatFromSplash(page);
|
||||
await page
|
||||
.getByRole("button", { name: "Sign up to unlock more features" })
|
||||
.click();
|
||||
await expect(page).toHaveURL(/\/auth(?:\?.*)?$/);
|
||||
await switchToEmailSignIn(page);
|
||||
await submitEmailLogin(page, { expectedUrl: defaultCharacterChatUrl });
|
||||
await page.getByRole("link", { name: "Back to home" }).click();
|
||||
await expect(page).toHaveURL(
|
||||
new RegExp(defaultCharacterSplashPath.replace("?", "\\?") + "$"),
|
||||
);
|
||||
|
||||
await page.getByRole("button", { name: "Menu" }).click();
|
||||
await expect(page).toHaveURL(
|
||||
new RegExp(defaultCharacterProfilePath.replace("?", "\\?") + "$"),
|
||||
);
|
||||
|
||||
const logoutRequestPromise = page.waitForRequest("**/api/auth/logout");
|
||||
await page.getByRole("button", { name: /Log out/i }).click();
|
||||
|
||||
const logoutRequest = await logoutRequestPromise;
|
||||
expect(logoutRequest.method()).toBe("POST");
|
||||
|
||||
await expect(page).toHaveURL(new RegExp(`${defaultCharacterSplashPath}$`));
|
||||
await expect(getSplashStartChatButton(page)).toBeVisible();
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import {
|
||||
clearBrowserState,
|
||||
getSplashStartChatButton,
|
||||
signInWithEmailAndOpenChat,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page);
|
||||
});
|
||||
|
||||
test("user can log out from the sidebar after email login", async ({
|
||||
page,
|
||||
}) => {
|
||||
await signInWithEmailAndOpenChat(page);
|
||||
await expect(page.getByRole("button", { name: "Menu" })).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Menu" }).click();
|
||||
await expect(page).toHaveURL(/\/sidebar$/);
|
||||
|
||||
const logoutRequestPromise = page.waitForRequest("**/api/auth/logout");
|
||||
await page.getByRole("button", { name: /Log out/i }).click();
|
||||
|
||||
const logoutRequest = await logoutRequestPromise;
|
||||
expect(logoutRequest.method()).toBe("POST");
|
||||
|
||||
await expect(page).toHaveURL(/\/splash$/);
|
||||
await expect(getSplashStartChatButton(page)).toBeVisible();
|
||||
});
|
||||
@@ -3,72 +3,44 @@ import { expect, test } from "@playwright/test";
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import { clearBrowserState } from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const handoffToken = "e2e-handoff-token-that-is-at-least-32-characters";
|
||||
const psid = "e2e-facebook-psid";
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page, { topUpHandoffFlow: true });
|
||||
await mockCoreApis(page, { psidLoginFlow: true });
|
||||
});
|
||||
|
||||
test("user consumes a top-up handoff and opens credit packages as a formal Messenger user", async ({
|
||||
test("user enters from an external PSID link and becomes a guest", async ({
|
||||
page,
|
||||
}) => {
|
||||
const handoffRequestPromise = page.waitForRequest(
|
||||
"**/api/auth/handoff/topup/consume",
|
||||
const psidLoginRequestPromise = page.waitForRequest(
|
||||
"**/api/auth/login/facebook/psid",
|
||||
);
|
||||
|
||||
await page.goto(
|
||||
`/external-entry?target=topup&handoffToken=${encodeURIComponent(handoffToken)}`,
|
||||
);
|
||||
await page.goto(`/external-entry?target=chat&psid=${psid}`);
|
||||
|
||||
const handoffRequest = await handoffRequestPromise;
|
||||
expect(handoffRequest.method()).toBe("POST");
|
||||
expect(handoffRequest.postDataJSON()).toEqual({ handoffToken });
|
||||
const psidLoginRequest = await psidLoginRequestPromise;
|
||||
expect(psidLoginRequest.method()).toBe("POST");
|
||||
expect(psidLoginRequest.postDataJSON()).toMatchObject({
|
||||
psid,
|
||||
bindToGuest: true,
|
||||
});
|
||||
expect(psidLoginRequest.postDataJSON().deviceId).toEqual(expect.any(String));
|
||||
|
||||
await expect(page).toHaveURL("/subscription?type=topup");
|
||||
await expect(
|
||||
page.getByRole("button", { name: /Pay and Top Up/i }),
|
||||
).toBeVisible();
|
||||
await expect(page).toHaveURL(/\/chat$/);
|
||||
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();
|
||||
|
||||
await expect
|
||||
.poll(() =>
|
||||
page.evaluate(() => ({
|
||||
loginProvider: localStorage.getItem("cozsweet:login_provider"),
|
||||
loginToken: localStorage.getItem("cozsweet:login_token"),
|
||||
refreshToken: localStorage.getItem("cozsweet:refresh_token"),
|
||||
guestToken: localStorage.getItem("cozsweet:guest_token"),
|
||||
psid: localStorage.getItem("cozsweet:psid"),
|
||||
})),
|
||||
)
|
||||
.toMatchObject({
|
||||
loginProvider: "facebookMessenger",
|
||||
loginToken: "e2e-messenger-token",
|
||||
refreshToken: "e2e-messenger-refresh-token",
|
||||
loginProvider: "guest",
|
||||
guestToken: "e2e-psid-guest-token",
|
||||
psid,
|
||||
});
|
||||
});
|
||||
|
||||
test("invalid top-up handoff does not log in and is removed from the URL", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.route("**/api/auth/handoff/topup/consume", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 410,
|
||||
json: {
|
||||
detail: {
|
||||
code: "HANDOFF_EXPIRED",
|
||||
message: "充值链接已过期",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto(
|
||||
`/external-entry?target=topup&handoffToken=${encodeURIComponent(handoffToken)}`,
|
||||
);
|
||||
|
||||
await expect(page).toHaveURL("/external-entry?target=topup");
|
||||
await expect(
|
||||
page.getByText(/invalid or has expired/i),
|
||||
).toBeVisible();
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => localStorage.getItem("cozsweet:login_provider")))
|
||||
.not.toBe("facebookMessenger");
|
||||
});
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import {
|
||||
clearBrowserState,
|
||||
defaultCharacterProfilePath,
|
||||
dismissChatInterruptions,
|
||||
enterChatFromSplash,
|
||||
submitEmailLogin,
|
||||
switchToEmailSignIn,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const characters = [
|
||||
{ slug: "elio", displayName: "Elio Silvestri" },
|
||||
{ slug: "maya", displayName: "Maya Tan" },
|
||||
{ slug: "nayeli", displayName: "Nayeli Cervantes" },
|
||||
] as const;
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page);
|
||||
});
|
||||
|
||||
test("guest user avatar returns to Profile after sign-in", async ({
|
||||
page,
|
||||
}) => {
|
||||
await enterChatFromSplash(page, { timeout: 30_000 });
|
||||
await sendMessage(page, "Open my profile");
|
||||
|
||||
await page.getByRole("button", { name: "Open profile" }).click();
|
||||
|
||||
await expect(page).toHaveURL(/\/auth\?redirect=/);
|
||||
expect(new URL(page.url()).searchParams.get("redirect")).toBe(
|
||||
defaultCharacterProfilePath,
|
||||
);
|
||||
await switchToEmailSignIn(page);
|
||||
await submitEmailLogin(page, {
|
||||
expectedUrl: new RegExp(
|
||||
`${defaultCharacterProfilePath.replace("?", "\\?")}$`,
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
for (const character of characters) {
|
||||
test(`${character.displayName} avatar opens the matching Private Zone`, async ({
|
||||
page,
|
||||
}) => {
|
||||
await enterCharacterChat(page, character.slug);
|
||||
await sendMessage(page, `Hello ${character.displayName}`);
|
||||
|
||||
await page
|
||||
.getByRole("button", {
|
||||
name: `Open ${character.displayName}'s private zone`,
|
||||
})
|
||||
.last()
|
||||
.click();
|
||||
|
||||
await expect(page).toHaveURL(
|
||||
new RegExp(`/characters/${character.slug}/private-zone(?:\\?.*)?$`),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async function enterCharacterChat(page: Page, characterSlug: string) {
|
||||
const chatPath = `/characters/${characterSlug}/chat`;
|
||||
|
||||
await page.goto(`/characters/${characterSlug}/splash`);
|
||||
await page.getByRole("button", { name: "Start Chatting" }).click();
|
||||
await expect(page).toHaveURL(new RegExp(`${chatPath}(?:\\?.*)?$`));
|
||||
await dismissChatInterruptions(page);
|
||||
await expect(page.getByRole("textbox", { name: "Message" })).toBeEnabled({
|
||||
timeout: 20_000,
|
||||
});
|
||||
}
|
||||
|
||||
async function sendMessage(page: Page, message: string) {
|
||||
await dismissChatInterruptions(page);
|
||||
const messageInput = page.getByRole("textbox", { name: "Message" });
|
||||
|
||||
await expect(messageInput).toBeEnabled({ timeout: 20_000 });
|
||||
await messageInput.fill(message);
|
||||
await messageInput.press("Enter");
|
||||
await expect(page.getByRole("button", { name: "Open profile" })).toBeVisible({
|
||||
timeout: 10_000,
|
||||
});
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import {
|
||||
clearBrowserState,
|
||||
completeVipPayment,
|
||||
defaultCharacterChatUrl,
|
||||
dismissChatInterruptions,
|
||||
enterChatFromSplash,
|
||||
expectAuthRedirectToVipChatSubscription,
|
||||
@@ -30,9 +29,9 @@ test("guest uses the shared chat limit top-up flow", async ({ page }) => {
|
||||
await dismissChatInterruptions(page);
|
||||
|
||||
const messageInput = page.getByRole("textbox", { name: "Message" });
|
||||
const quantityLimitBanner = page.getByTestId(
|
||||
"chat-insufficient-credits-banner",
|
||||
);
|
||||
const quantityLimitBanner = page
|
||||
.getByRole("status")
|
||||
.filter({ hasText: "Insufficient credits" });
|
||||
let limitTriggeredAt: number | null = null;
|
||||
let completedSendCount = 0;
|
||||
|
||||
@@ -80,7 +79,9 @@ test("guest uses the shared chat limit top-up flow", async ({ page }) => {
|
||||
expect(limitTriggeredAt).toBe(mockedLimitTriggerAt);
|
||||
|
||||
await expect(quantityLimitBanner).toBeVisible();
|
||||
await expect(quantityLimitBanner.getByText("Out of Daily Free Chats")).toBeVisible();
|
||||
await expect(
|
||||
quantityLimitBanner.getByText("Free chats refresh every day."),
|
||||
).toBeVisible();
|
||||
const topUpButton = quantityLimitBanner.getByRole("button", {
|
||||
name: "Top up credits to continue",
|
||||
});
|
||||
@@ -96,7 +97,7 @@ test("guest uses the shared chat limit top-up flow", async ({ page }) => {
|
||||
|
||||
await completeVipPayment(page);
|
||||
|
||||
await expect(page).toHaveURL(defaultCharacterChatUrl);
|
||||
await expect(page).toHaveURL(/\/chat$/);
|
||||
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();
|
||||
});
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@ import { expect, test, type Request } from "@playwright/test";
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import {
|
||||
clearBrowserState,
|
||||
enterChatFromSplash,
|
||||
setEmailSessionStorage,
|
||||
signInWithEmailAndOpenChat,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
@@ -24,8 +23,7 @@ test("chat send refreshes an expired token, retries the request, and renders the
|
||||
}
|
||||
});
|
||||
|
||||
await enterChatFromSplash(page);
|
||||
await setEmailSessionStorage(page);
|
||||
await signInWithEmailAndOpenChat(page);
|
||||
|
||||
const message = "token refresh retry test";
|
||||
const messageInput = page.getByRole("textbox", { name: "Message" });
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import {
|
||||
clearBrowserState,
|
||||
enterChatFromSplash,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page);
|
||||
});
|
||||
|
||||
test("renders a backend commercial action and opens the private zone", async ({
|
||||
page,
|
||||
}) => {
|
||||
await enterChatFromSplash(page);
|
||||
|
||||
const input = page.getByRole("textbox", { name: "Message" });
|
||||
await expect(input).toBeEnabled();
|
||||
await input.fill("private album offer test");
|
||||
await input.press("Enter");
|
||||
|
||||
const offer = page.getByLabel("Open private zone");
|
||||
await expect(offer).toContainText(
|
||||
"There are more private photos waiting for you.",
|
||||
);
|
||||
await offer.getByRole("button", { name: "Open private zone" }).click();
|
||||
|
||||
await expect(page).toHaveURL(/\/characters\/elio\/private-zone$/);
|
||||
});
|
||||
|
||||
test("asks for consent before opening a user-bound discount plan", async ({
|
||||
page,
|
||||
}) => {
|
||||
await enterChatFromSplash(page);
|
||||
|
||||
const input = page.getByRole("textbox", { name: "Message" });
|
||||
await input.fill("discount offer test");
|
||||
await input.press("Enter");
|
||||
|
||||
const offer = page.getByLabel("Yes, ask for me");
|
||||
await expect(offer).toContainText("Want me to ask for my best private offer?");
|
||||
await offer.getByRole("button", { name: "Yes, ask for me" }).click();
|
||||
|
||||
await expect(page).toHaveURL(
|
||||
/\/subscription\?type=vip.*planId=vip_annual.*commercialOfferId=13ec8a10/,
|
||||
);
|
||||
});
|
||||
@@ -1,201 +0,0 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import { apiEnvelope } from "@e2e/fixtures/data/common";
|
||||
import { clearBrowserState } from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const testPsid = "e2e-facebook-psid-27511427698460020";
|
||||
|
||||
const characters = [
|
||||
{
|
||||
id: "elio",
|
||||
slug: "elio",
|
||||
displayName: "Elio Silvestri",
|
||||
shortName: "Elio",
|
||||
},
|
||||
{
|
||||
id: "maya-tan",
|
||||
slug: "maya",
|
||||
displayName: "Maya Tan",
|
||||
shortName: "Maya",
|
||||
},
|
||||
{
|
||||
id: "nayeli-cervantes",
|
||||
slug: "nayeli",
|
||||
displayName: "Nayeli Cervantes",
|
||||
shortName: "Nayeli",
|
||||
},
|
||||
] as const;
|
||||
|
||||
type Character = (typeof characters)[number];
|
||||
type EntryKind = "private-space" | "voice" | "image-pack" | "coffee";
|
||||
|
||||
interface FacebookEntryCase {
|
||||
character: Character;
|
||||
kind: EntryKind;
|
||||
target: "chat" | "private-zone" | "tip";
|
||||
expectedPath: string;
|
||||
promotionType?: "voice";
|
||||
}
|
||||
|
||||
const entryCases: FacebookEntryCase[] = characters.flatMap((character) => [
|
||||
{
|
||||
character,
|
||||
kind: "private-space",
|
||||
target: "chat",
|
||||
expectedPath: `/characters/${character.slug}/chat`,
|
||||
},
|
||||
{
|
||||
character,
|
||||
kind: "voice",
|
||||
target: "chat",
|
||||
expectedPath: `/characters/${character.slug}/chat`,
|
||||
promotionType: "voice",
|
||||
},
|
||||
{
|
||||
character,
|
||||
kind: "image-pack",
|
||||
target: "private-zone",
|
||||
expectedPath: `/characters/${character.slug}/private-zone`,
|
||||
},
|
||||
{
|
||||
character,
|
||||
kind: "coffee",
|
||||
target: "tip",
|
||||
expectedPath: `/characters/${character.slug}/tip`,
|
||||
},
|
||||
]);
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page);
|
||||
await registerEntryPageMocks(page);
|
||||
});
|
||||
|
||||
for (const entryCase of entryCases) {
|
||||
test(`${entryCase.character.displayName} opens Facebook ${entryCase.kind} entry`, async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto(buildEntryUrl(entryCase));
|
||||
|
||||
await expect(page).toHaveURL(entryCase.expectedPath, { timeout: 20_000 });
|
||||
await expect
|
||||
.poll(() =>
|
||||
page.evaluate(() => localStorage.getItem("cozsweet:psid")),
|
||||
)
|
||||
.toBe(testPsid);
|
||||
|
||||
if (entryCase.kind === "private-space") {
|
||||
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Unlock voice message" }),
|
||||
).toHaveCount(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (entryCase.kind === "voice") {
|
||||
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Unlock voice message" }),
|
||||
).toHaveCount(1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (entryCase.kind === "image-pack") {
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Private albums" }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByText(entryCase.character.displayName).last(),
|
||||
).toBeVisible();
|
||||
return;
|
||||
}
|
||||
|
||||
await expect(
|
||||
page.getByRole("heading", {
|
||||
name: `Buy ${entryCase.character.shortName} a coffee`,
|
||||
}),
|
||||
).toBeVisible();
|
||||
});
|
||||
}
|
||||
|
||||
function buildEntryUrl(entryCase: FacebookEntryCase): string {
|
||||
const params = new URLSearchParams({
|
||||
target: entryCase.target,
|
||||
character: entryCase.character.slug,
|
||||
psid: testPsid,
|
||||
});
|
||||
if (entryCase.promotionType) {
|
||||
params.set("mode", "promotion");
|
||||
params.set("promotion_type", entryCase.promotionType);
|
||||
}
|
||||
return `/external-entry?${params.toString()}`;
|
||||
}
|
||||
|
||||
async function registerEntryPageMocks(page: Page): Promise<void> {
|
||||
await page.route("**/api/private-zone/posts**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const characterId = url.searchParams.get("characterId") ?? "elio";
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
characterId,
|
||||
items: [],
|
||||
nextCursor: null,
|
||||
hasMore: false,
|
||||
creditBalance: 1000,
|
||||
currency: "credits",
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/private-zone/albums**", async (route) => {
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
creditBalance: 1000,
|
||||
pendingImageCount: 0,
|
||||
hasIncompleteContent: false,
|
||||
items: [],
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/payment/gift-products**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const characterId = url.searchParams.get("characterId") ?? "elio";
|
||||
const planPrefix =
|
||||
characterId === "elio"
|
||||
? "tip"
|
||||
: `tip_${characterId.replaceAll("-", "_")}`;
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
characterId,
|
||||
categories: [
|
||||
{
|
||||
category: "coffee",
|
||||
name: "Coffee",
|
||||
productCount: 1,
|
||||
imageUrl: null,
|
||||
},
|
||||
],
|
||||
plans: [
|
||||
{
|
||||
planId: `${planPrefix}_coffee_usd_4_99`,
|
||||
planName: "Small Coffee",
|
||||
orderType: "tip",
|
||||
tipType: "coffee_small",
|
||||
category: "coffee",
|
||||
characterId,
|
||||
description: "A character-scoped coffee gift",
|
||||
imageUrl: null,
|
||||
amountCents: 499,
|
||||
currency: "USD",
|
||||
autoRenew: false,
|
||||
isFirstRechargeOffer: false,
|
||||
firstRechargeDiscountPercent: 0,
|
||||
promotionType: null,
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import {
|
||||
clearBrowserState,
|
||||
completeVipPayment,
|
||||
defaultCharacterChatUrl,
|
||||
expectInsufficientCreditsDialog,
|
||||
expectVipChatSubscriptionUrl,
|
||||
setEmailSessionStorage,
|
||||
submitEmailLogin,
|
||||
switchToEmailSignIn,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
@@ -24,7 +24,7 @@ test("guest unlocks a promoted image through email login and top-up", async ({
|
||||
await page.goto(
|
||||
"/external-entry?target=chat&mode=promotion&promotion_type=image",
|
||||
);
|
||||
await expect(page).toHaveURL(defaultCharacterChatUrl);
|
||||
await expect(page).toHaveURL(/\/chat$/);
|
||||
|
||||
const unlockButton = page.getByRole("button", {
|
||||
name: "Unlock private image",
|
||||
@@ -35,10 +35,13 @@ test("guest unlocks a promoted image through email login and top-up", async ({
|
||||
await expect(page).toHaveURL(/\/auth\?redirect=/);
|
||||
|
||||
await switchToEmailSignIn(page);
|
||||
await submitEmailLogin(page, { expectedUrl: /\/chat$/ });
|
||||
|
||||
await setEmailSessionStorage(page);
|
||||
const unlockRequestPromise = page.waitForRequest(
|
||||
"**/api/chat/unlock-private",
|
||||
);
|
||||
await submitEmailLogin(page, { expectedUrl: defaultCharacterChatUrl });
|
||||
await page.reload();
|
||||
|
||||
const unlockRequest = await unlockRequestPromise;
|
||||
expect(unlockRequest.method()).toBe("POST");
|
||||
@@ -54,6 +57,6 @@ test("guest unlocks a promoted image through email login and top-up", async ({
|
||||
await expectVipChatSubscriptionUrl(page);
|
||||
await completeVipPayment(page);
|
||||
|
||||
await expect(page).toHaveURL(defaultCharacterChatUrl);
|
||||
await expect(page).toHaveURL(/\/chat$/);
|
||||
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -1,206 +0,0 @@
|
||||
import path from "node:path";
|
||||
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import { apiEnvelope } from "@e2e/fixtures/data/common";
|
||||
import { e2eEmailUser } from "@e2e/fixtures/data/auth";
|
||||
import { chatCharactersResponse } from "@e2e/fixtures/data/character";
|
||||
import {
|
||||
emptyChatHistoryResponse,
|
||||
emptyChatPreviewsResponse,
|
||||
} from "@e2e/fixtures/data/chat";
|
||||
import { paymentPlansResponse } from "@e2e/fixtures/data/payment";
|
||||
import { userEntitlementsResponse } from "@e2e/fixtures/data/user";
|
||||
import {
|
||||
defaultCharacterChatPath,
|
||||
defaultCharacterSplashPath,
|
||||
seedEmailSession,
|
||||
} from "@e2e/fixtures/helpers/auth";
|
||||
|
||||
const previewDirectory = path.join(
|
||||
process.cwd(),
|
||||
".codex",
|
||||
"artifacts",
|
||||
"frontend-preview",
|
||||
"2026-07-22",
|
||||
"favorite-menu",
|
||||
);
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await registerFavoriteMenuMocks(page);
|
||||
});
|
||||
|
||||
test("favorite entry and three-tab Menu navigation render on the real pages", async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
const mobile = testInfo.project.name.includes("mobile");
|
||||
await page.setViewportSize(
|
||||
mobile ? { width: 390, height: 844 } : { width: 1440, height: 900 },
|
||||
);
|
||||
const browserErrors = collectBrowserErrors(page);
|
||||
|
||||
await seedEmailSession(page);
|
||||
await page.goto(defaultCharacterChatPath);
|
||||
|
||||
await expect(page.getByRole("button", { name: "Save CozSweet" })).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: /First recharge offer, 50% off/i }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Profile" })).toHaveCount(0);
|
||||
await savePreview(page, `${mobile ? "mobile" : "desktop"}-chat.png`);
|
||||
|
||||
await page.goto(defaultCharacterSplashPath);
|
||||
await expect(page.getByRole("button", { name: "Save CozSweet" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Menu" })).toBeVisible();
|
||||
const navigation = page.getByRole("navigation", {
|
||||
name: "Primary navigation",
|
||||
});
|
||||
await expect(navigation).toContainText("Chat");
|
||||
await expect(navigation).toContainText("Private Zone");
|
||||
await expect(navigation).toContainText("Menu");
|
||||
await savePreview(page, `${mobile ? "mobile" : "desktop"}-splash.png`);
|
||||
|
||||
await page.goto("/characters/elio/private-zone");
|
||||
await expect(page.getByRole("button", { name: "Save CozSweet" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Menu" })).toBeVisible();
|
||||
await savePreview(
|
||||
page,
|
||||
`${mobile ? "mobile" : "desktop"}-private-zone.png`,
|
||||
);
|
||||
|
||||
await page.getByRole("button", { name: "Menu" }).click();
|
||||
await expect(page.getByRole("heading", { name: "Menu" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Save CozSweet" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Menu" })).toHaveAttribute(
|
||||
"aria-current",
|
||||
"page",
|
||||
);
|
||||
await savePreview(page, `${mobile ? "mobile" : "desktop"}-menu.png`);
|
||||
|
||||
if (mobile) {
|
||||
await page.evaluate(() => {
|
||||
localStorage.setItem("cozsweet:favorite_entry", "1");
|
||||
});
|
||||
await page.goto(defaultCharacterChatPath);
|
||||
await expect(page.getByRole("button", { name: "Download" })).toBeVisible();
|
||||
await savePreview(page, "mobile-android-external-chat-download.png");
|
||||
|
||||
await page.addInitScript(() => {
|
||||
Object.defineProperty(navigator, "userAgent", {
|
||||
configurable: true,
|
||||
value:
|
||||
"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1",
|
||||
});
|
||||
});
|
||||
await page.goto(defaultCharacterChatPath);
|
||||
const iosDownload = page.getByRole("button", { name: "Download" });
|
||||
await expect(iosDownload).toBeVisible();
|
||||
await iosDownload.click();
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Add CozSweet to Home Screen" }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByRole("dialog")).toContainText(
|
||||
"In Safari, tap the Share button, then choose “Add to Home Screen”.",
|
||||
);
|
||||
await savePreview(page, "mobile-ios-external-chat-download.png");
|
||||
}
|
||||
|
||||
expect(browserErrors.filter(isFeatureRuntimeError)).toEqual([]);
|
||||
});
|
||||
|
||||
async function registerFavoriteMenuMocks(page: Page): Promise<void> {
|
||||
await mockCoreApis(page);
|
||||
await page.route("**/api/payment/plans**", async (route) => {
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
...paymentPlansResponse,
|
||||
isFirstRecharge: true,
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.route("**/api/private-zone/albums**", async (route) => {
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({ items: [], creditBalance: 80 }),
|
||||
});
|
||||
});
|
||||
await page.context().route("**/api/**", async (route) => {
|
||||
const pathname = new URL(route.request().url()).pathname;
|
||||
if (pathname === "/api/auth/session") {
|
||||
await route.fulfill({
|
||||
json: {
|
||||
expires: "2099-12-31T23:59:59.000Z",
|
||||
user: { email: null, image: null, name: null },
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (pathname === "/api/characters") {
|
||||
await route.fulfill({ json: apiEnvelope(chatCharactersResponse) });
|
||||
return;
|
||||
}
|
||||
if (pathname === "/api/user/profile") {
|
||||
await route.fulfill({ json: apiEnvelope(e2eEmailUser) });
|
||||
return;
|
||||
}
|
||||
if (pathname === "/api/user/entitlements") {
|
||||
await route.fulfill({ json: apiEnvelope(userEntitlementsResponse) });
|
||||
return;
|
||||
}
|
||||
if (pathname === "/api/chat/history") {
|
||||
await route.fulfill({ json: apiEnvelope(emptyChatHistoryResponse) });
|
||||
return;
|
||||
}
|
||||
if (pathname === "/api/chat/previews") {
|
||||
await route.fulfill({ json: apiEnvelope(emptyChatPreviewsResponse) });
|
||||
return;
|
||||
}
|
||||
if (pathname === "/api/payment/plans") {
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
...paymentPlansResponse,
|
||||
isFirstRecharge: true,
|
||||
}),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (pathname === "/api/payment/vip-status") {
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({ isVip: false, expiresAt: null }),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (pathname === "/api/private-zone/albums") {
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({ items: [], creditBalance: 80 }),
|
||||
});
|
||||
return;
|
||||
}
|
||||
await route.fallback();
|
||||
});
|
||||
}
|
||||
|
||||
function collectBrowserErrors(page: Page): string[] {
|
||||
const errors: string[] = [];
|
||||
page.on("pageerror", (error) => errors.push(error.message));
|
||||
page.on("console", (message) => {
|
||||
if (message.type() === "error") errors.push(message.text());
|
||||
});
|
||||
return errors;
|
||||
}
|
||||
|
||||
function isFeatureRuntimeError(message: string): boolean {
|
||||
const isKnownLocalPreviewDependencyError =
|
||||
message.includes("[ApiLoggingInterceptor]") ||
|
||||
message.includes("[next-auth][error][CLIENT_FETCH_ERROR]") ||
|
||||
message.includes("[Result] Result.wrap caught exception");
|
||||
return !isKnownLocalPreviewDependencyError;
|
||||
}
|
||||
|
||||
async function savePreview(page: Page, fileName: string): Promise<void> {
|
||||
if (process.env.FRONTEND_PREVIEW_SCREENSHOTS !== "1") return;
|
||||
await page.screenshot({
|
||||
path: path.join(previewDirectory, fileName),
|
||||
animations: "disabled",
|
||||
});
|
||||
}
|
||||
@@ -1,264 +0,0 @@
|
||||
import path from "node:path";
|
||||
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import { apiEnvelope } from "@e2e/fixtures/data/common";
|
||||
import { clearBrowserState } from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const characters = [
|
||||
{
|
||||
id: "elio",
|
||||
slug: "elio",
|
||||
displayName: "Elio Silvestri",
|
||||
shortName: "Elio",
|
||||
cover: "elio.png",
|
||||
splashCover: "elio.png",
|
||||
},
|
||||
{
|
||||
id: "maya-tan",
|
||||
slug: "maya",
|
||||
displayName: "Maya Tan",
|
||||
shortName: "Maya",
|
||||
cover: "maya.webp",
|
||||
splashCover: "maya-home.webp",
|
||||
},
|
||||
{
|
||||
id: "nayeli-cervantes",
|
||||
slug: "nayeli",
|
||||
displayName: "Nayeli Cervantes",
|
||||
shortName: "Nayeli",
|
||||
cover: "nayeli.webp",
|
||||
splashCover: "nayeli.webp",
|
||||
},
|
||||
] as const;
|
||||
|
||||
const previewDirectory = path.join(
|
||||
process.cwd(),
|
||||
".codex",
|
||||
"artifacts",
|
||||
"frontend-preview",
|
||||
"2026-07-22",
|
||||
"multi-role-commercial",
|
||||
);
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page);
|
||||
await registerMultiRoleCommercialMocks(page);
|
||||
});
|
||||
|
||||
for (const character of characters) {
|
||||
test(`${character.displayName} homepage renders its assigned cover`, async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
const mobile = testInfo.project.name.includes("mobile");
|
||||
await page.setViewportSize(
|
||||
mobile ? { width: 390, height: 844 } : { width: 1440, height: 900 },
|
||||
);
|
||||
|
||||
await page.goto(`/characters/${character.slug}/splash`);
|
||||
|
||||
const cover = page.locator(`img[src*="${character.splashCover}"]`);
|
||||
await expect(cover).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("navigation", { name: "Primary navigation" }),
|
||||
).toContainText("Private Zone");
|
||||
await expect
|
||||
.poll(() =>
|
||||
cover.evaluate((image: HTMLImageElement) =>
|
||||
image.complete ? image.naturalWidth : 0,
|
||||
),
|
||||
)
|
||||
.toBeGreaterThan(0);
|
||||
|
||||
if (
|
||||
process.env.FRONTEND_PREVIEW_SCREENSHOTS === "1" &&
|
||||
character.id !== "elio"
|
||||
) {
|
||||
await page.screenshot({
|
||||
path: path.join(
|
||||
previewDirectory,
|
||||
`${character.slug}-${mobile ? "mobile-390x844" : "desktop-1440x900"}.png`,
|
||||
),
|
||||
animations: "disabled",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test(`${character.displayName} can open a character-scoped Private Zone`, async ({
|
||||
page,
|
||||
}) => {
|
||||
const momentsRequest = page.waitForRequest((request) => {
|
||||
const url = new URL(request.url());
|
||||
return (
|
||||
url.pathname === "/api/private-zone/posts" &&
|
||||
url.searchParams.get("characterId") === character.id
|
||||
);
|
||||
});
|
||||
const albumRequest = page.waitForRequest((request) => {
|
||||
const url = new URL(request.url());
|
||||
return (
|
||||
url.pathname === "/api/private-zone/albums" &&
|
||||
url.searchParams.get("characterId") === character.id
|
||||
);
|
||||
});
|
||||
|
||||
await page.goto(`/characters/${character.slug}/private-zone`);
|
||||
|
||||
await Promise.all([momentsRequest, albumRequest]);
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Private albums" }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByRole("tab")).toHaveText(["Albums", "Moments"]);
|
||||
await expect(page.getByRole("tab", { name: "Albums" })).toHaveAttribute(
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
await expect(page.getByText(character.displayName).last()).toBeVisible();
|
||||
const albumButton = page.getByRole("button", {
|
||||
name: `View locked collection with 8 images from ${character.displayName}`,
|
||||
});
|
||||
if (character.id === "maya-tan") {
|
||||
await expect(albumButton).toHaveCount(0);
|
||||
await expect(page.getByRole("button", { name: "Refresh" })).toHaveCount(0);
|
||||
await expect(page.getByText("No private albums yet.")).toHaveCount(0);
|
||||
} else {
|
||||
await expect(albumButton).toBeVisible();
|
||||
}
|
||||
});
|
||||
|
||||
test(`${character.displayName} receives a character-scoped Tip catalog`, async ({
|
||||
page,
|
||||
}) => {
|
||||
const catalogRequest = page.waitForRequest((request) => {
|
||||
const url = new URL(request.url());
|
||||
return (
|
||||
url.pathname === "/api/payment/gift-products" &&
|
||||
url.searchParams.get("characterId") === character.id
|
||||
);
|
||||
});
|
||||
|
||||
await page.goto(`/characters/${character.slug}/tip`);
|
||||
|
||||
await catalogRequest;
|
||||
await expect(
|
||||
page.getByRole("heading", { name: `Buy ${character.shortName} a coffee` }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByRole("radio", { name: /Small Coffee/ })).toBeChecked();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Order and Buy" }),
|
||||
).toBeEnabled();
|
||||
await expect(
|
||||
page.getByText("This character does not have any gifts available yet."),
|
||||
).toHaveCount(0);
|
||||
});
|
||||
}
|
||||
|
||||
test("a real Private Zone request failure still offers Retry", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.route("**/api/private-zone/albums**", async (route) => {
|
||||
await route.fulfill({ status: 503, json: { message: "Albums unavailable" } });
|
||||
});
|
||||
|
||||
await page.goto("/characters/maya/private-zone");
|
||||
|
||||
await expect(page.getByRole("button", { name: "Retry" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Refresh" })).toHaveCount(0);
|
||||
});
|
||||
|
||||
async function registerMultiRoleCommercialMocks(page: Page): Promise<void> {
|
||||
await page.route("**/api/private-zone/posts**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const characterId = url.searchParams.get("characterId") ?? "elio";
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
characterId,
|
||||
items: [],
|
||||
nextCursor: null,
|
||||
hasMore: false,
|
||||
creditBalance: 1000,
|
||||
currency: "credits",
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/private-zone/albums**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const characterId = url.searchParams.get("characterId") ?? "elio";
|
||||
const character =
|
||||
characters.find((candidate) => candidate.id === characterId) ?? characters[0];
|
||||
|
||||
const hasCompleteAlbum = character.id !== "maya-tan";
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
creditBalance: 1000,
|
||||
pendingImageCount: hasCompleteAlbum ? 0 : 7,
|
||||
hasIncompleteContent: !hasCompleteAlbum,
|
||||
items: hasCompleteAlbum ? [
|
||||
{
|
||||
albumId: `album-${character.id}`,
|
||||
title: `${character.shortName} private photos`,
|
||||
content: null,
|
||||
previewText: "Unlock this private album",
|
||||
imageCount: 8,
|
||||
images: [
|
||||
{
|
||||
url: `/images/private-zone/banner/${character.slug}.png`,
|
||||
locked: true,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
locked: true,
|
||||
unlocked: false,
|
||||
unlockCost: 320,
|
||||
publishedAt: "2026-07-22T10:00:00+08:00",
|
||||
lockDetail: { locked: true },
|
||||
},
|
||||
] : [],
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/payment/gift-products**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const characterId = url.searchParams.get("characterId") ?? "elio";
|
||||
const planPrefix =
|
||||
characterId === "elio"
|
||||
? "tip"
|
||||
: `tip_${characterId.replaceAll("-", "_")}`;
|
||||
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
characterId,
|
||||
categories: [
|
||||
{
|
||||
category: "coffee",
|
||||
name: "Coffee",
|
||||
productCount: 1,
|
||||
imageUrl: null,
|
||||
},
|
||||
],
|
||||
plans: [
|
||||
{
|
||||
planId: `${planPrefix}_coffee_usd_4_99`,
|
||||
planName: "Small Coffee",
|
||||
orderType: "tip",
|
||||
tipType: "coffee_small",
|
||||
category: "coffee",
|
||||
characterId,
|
||||
description: "A character-scoped coffee gift",
|
||||
imageUrl: null,
|
||||
amountCents: 499,
|
||||
currency: "USD",
|
||||
autoRenew: false,
|
||||
isFirstRechargeOffer: false,
|
||||
firstRechargeDiscountPercent: 0,
|
||||
promotionType: null,
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,24 +1,23 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import { apiEnvelope } from "@e2e/fixtures/data/common";
|
||||
import { createPaidImageHistoryResponse } from "@e2e/fixtures/data/chat";
|
||||
import {
|
||||
paidImageDisplayMessageId,
|
||||
paidImageMessageId,
|
||||
} from "@e2e/fixtures/test-data";
|
||||
import { paidImageMessageId } from "@e2e/fixtures/test-data";
|
||||
import {
|
||||
clearBrowserState,
|
||||
completeVipPayment,
|
||||
defaultCharacterChatPath,
|
||||
dismissChatInterruptions,
|
||||
enterChatFromSplash,
|
||||
expectInsufficientCreditsDialog,
|
||||
expectVipChatSubscriptionUrl,
|
||||
setEmailSessionStorage,
|
||||
submitEmailLogin,
|
||||
switchToEmailSignIn,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const paidImageOverlayUrl = new RegExp(
|
||||
`/chat\\?image=${paidImageMessageId}$`,
|
||||
);
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page, {
|
||||
@@ -44,27 +43,38 @@ test("guest can unlock a paid image after email login and subscription payment",
|
||||
message: "给我发图片",
|
||||
});
|
||||
|
||||
const lockedImageCard = page.getByRole("group", {
|
||||
name: "Locked private image",
|
||||
const paidImageButton = page.getByRole("button", {
|
||||
name: "Open image in fullscreen",
|
||||
}).last();
|
||||
await expect(lockedImageCard).toBeVisible();
|
||||
await expect(lockedImageCard.locator("img")).toHaveCount(0);
|
||||
await lockedImageCard
|
||||
.getByRole("button", { name: "Unlock private image" })
|
||||
await expect(paidImageButton).toBeVisible();
|
||||
|
||||
await paidImageButton.click();
|
||||
await expect(page).toHaveURL(paidImageOverlayUrl);
|
||||
|
||||
const lockedImageDialog = page.getByRole("dialog", {
|
||||
name: "Locked fullscreen image",
|
||||
});
|
||||
await expect(lockedImageDialog).toBeVisible();
|
||||
|
||||
await lockedImageDialog
|
||||
.getByRole("button", { name: "Unlock high-definition large image" })
|
||||
.click();
|
||||
|
||||
await expect(page).toHaveURL(/\/auth\?redirect=/);
|
||||
expect(new URL(page.url()).searchParams.get("redirect")).toBe(
|
||||
defaultCharacterChatPath,
|
||||
`/chat?image=${paidImageMessageId}`,
|
||||
);
|
||||
|
||||
await switchToEmailSignIn(page);
|
||||
await submitEmailLogin(page, {
|
||||
expectedUrl: paidImageOverlayUrl,
|
||||
});
|
||||
|
||||
await setEmailSessionStorage(page);
|
||||
const unlockRequestPromise = page.waitForRequest(
|
||||
"**/api/chat/unlock-private",
|
||||
);
|
||||
await submitEmailLogin(page, {
|
||||
expectedUrl: new RegExp(`${defaultCharacterChatPath}$`),
|
||||
});
|
||||
await page.goto(`/chat?image=${paidImageMessageId}`);
|
||||
|
||||
const unlockRequest = await unlockRequestPromise;
|
||||
expect(unlockRequest.postDataJSON()).toMatchObject({
|
||||
@@ -79,46 +89,7 @@ test("guest can unlock a paid image after email login and subscription payment",
|
||||
await expectVipChatSubscriptionUrl(page);
|
||||
await completeVipPayment(page);
|
||||
|
||||
await expect(page).toHaveURL(
|
||||
new RegExp(
|
||||
`${defaultCharacterChatPath}(?:\\?image=${encodeURIComponent(paidImageDisplayMessageId)})?$`,
|
||||
),
|
||||
);
|
||||
expect(new URL(page.url()).pathname).toBe(defaultCharacterChatPath);
|
||||
await expect(page).toHaveURL(/\/chat(?:\?image=msg_photo_paywall_001)?$/);
|
||||
expect(new URL(page.url()).pathname).toBe("/chat");
|
||||
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("fullscreen image closes from its back button, the image, and browser history Back", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.route("**/api/chat/history**", async (route) => {
|
||||
await route.fulfill({
|
||||
json: apiEnvelope(createPaidImageHistoryResponse(true)),
|
||||
});
|
||||
});
|
||||
await enterChatFromSplash(page);
|
||||
await dismissChatInterruptions(page);
|
||||
|
||||
const imageButton = page.getByRole("button", {
|
||||
name: "Open image in fullscreen",
|
||||
});
|
||||
const imageDialog = page.getByRole("dialog", { name: "Fullscreen image" });
|
||||
|
||||
await imageButton.click();
|
||||
await expect(imageDialog).toBeVisible();
|
||||
await imageDialog.getByRole("button", { name: "Back" }).click();
|
||||
await expect(imageDialog).toHaveCount(0);
|
||||
await expect(page).toHaveURL(defaultCharacterChatPath);
|
||||
|
||||
await imageButton.click();
|
||||
await expect(imageDialog).toBeVisible();
|
||||
await imageDialog.locator("img").click();
|
||||
await expect(imageDialog).toHaveCount(0);
|
||||
await expect(page).toHaveURL(defaultCharacterChatPath);
|
||||
|
||||
await imageButton.click();
|
||||
await expect(imageDialog).toBeVisible();
|
||||
await page.goBack();
|
||||
await expect(imageDialog).toHaveCount(0);
|
||||
await expect(page).toHaveURL(defaultCharacterChatPath);
|
||||
});
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
import { stripePaymentDialogStyles } from "@/app/_components/payment/stripe-payment-dialog.styles";
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
|
||||
const viewports = [
|
||||
{ width: 390, height: 844 },
|
||||
{ width: 405, height: 797 },
|
||||
{ width: 540, height: 900 },
|
||||
] as const;
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await mockCoreApis(page);
|
||||
});
|
||||
|
||||
for (const viewport of viewports) {
|
||||
test(`payment portal stays viewport-bound at ${viewport.width}x${viewport.height}`, async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize(viewport);
|
||||
await page.goto("/subscription?type=topup", {
|
||||
waitUntil: "domcontentloaded",
|
||||
});
|
||||
|
||||
await mountPaymentPanel(page, 180);
|
||||
await expectViewportScrim(page, viewport);
|
||||
await expectCenteredShortPanel(page, viewport);
|
||||
|
||||
await mountPaymentPanel(page, 1_200);
|
||||
await expectViewportScrim(page, viewport);
|
||||
await expectScrollableTallPanel(page, viewport);
|
||||
});
|
||||
}
|
||||
|
||||
async function mountPaymentPanel(page: Page, contentHeight: number) {
|
||||
await page.evaluate(
|
||||
({ dialogClassName, overlayClassName, requestedContentHeight }) => {
|
||||
document.querySelector('[data-testid="payment-layout-overlay"]')?.remove();
|
||||
document.querySelector('[data-testid="transformed-checkout-host"]')?.remove();
|
||||
|
||||
const transformedCheckoutHost = document.createElement("div");
|
||||
transformedCheckoutHost.dataset.testid = "transformed-checkout-host";
|
||||
transformedCheckoutHost.style.transform = "translateX(50%)";
|
||||
document.body.appendChild(transformedCheckoutHost);
|
||||
|
||||
const overlay = document.createElement("div");
|
||||
overlay.dataset.testid = "payment-layout-overlay";
|
||||
overlay.className = overlayClassName;
|
||||
|
||||
const panel = document.createElement("div");
|
||||
panel.dataset.testid = "payment-layout-panel";
|
||||
panel.className = dialogClassName;
|
||||
|
||||
const content = document.createElement("div");
|
||||
content.style.height = `${requestedContentHeight}px`;
|
||||
content.textContent = "Complete payment";
|
||||
panel.appendChild(content);
|
||||
overlay.appendChild(panel);
|
||||
|
||||
// Mirrors ModalPortal: the overlay must be a body child, never a child of
|
||||
// the transformed checkout host that triggered it.
|
||||
document.body.appendChild(overlay);
|
||||
},
|
||||
{
|
||||
dialogClassName: stripePaymentDialogStyles.dialog,
|
||||
overlayClassName: stripePaymentDialogStyles.overlay,
|
||||
requestedContentHeight: contentHeight,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async function expectViewportScrim(
|
||||
page: Page,
|
||||
viewport: { width: number; height: number },
|
||||
) {
|
||||
const overlay = page.getByTestId("payment-layout-overlay");
|
||||
await expect(overlay).toBeVisible();
|
||||
const box = await overlay.boundingBox();
|
||||
|
||||
expect(box).not.toBeNull();
|
||||
expect(box?.x).toBeCloseTo(0, 0);
|
||||
expect(box?.y).toBeCloseTo(0, 0);
|
||||
expect(box?.width).toBeCloseTo(viewport.width, 0);
|
||||
expect(box?.height).toBeCloseTo(viewport.height, 0);
|
||||
await expect(overlay.evaluate((node) => node.parentElement === document.body))
|
||||
.resolves.toBe(true);
|
||||
}
|
||||
|
||||
async function expectCenteredShortPanel(
|
||||
page: Page,
|
||||
viewport: { width: number; height: number },
|
||||
) {
|
||||
const panel = page.getByTestId("payment-layout-panel");
|
||||
const box = await panel.boundingBox();
|
||||
|
||||
expect(box).not.toBeNull();
|
||||
expect(box?.y ?? 0).toBeGreaterThan(100);
|
||||
expect(Math.abs((box?.y ?? 0) * 2 + (box?.height ?? 0) - viewport.height))
|
||||
.toBeLessThanOrEqual(2);
|
||||
}
|
||||
|
||||
async function expectScrollableTallPanel(
|
||||
page: Page,
|
||||
viewport: { width: number; height: number },
|
||||
) {
|
||||
const panel = page.getByTestId("payment-layout-panel");
|
||||
const box = await panel.boundingBox();
|
||||
const scrollMetrics = await panel.evaluate((node) => ({
|
||||
clientHeight: node.clientHeight,
|
||||
scrollHeight: node.scrollHeight,
|
||||
}));
|
||||
|
||||
expect(box).not.toBeNull();
|
||||
expect(box?.y ?? 0).toBeGreaterThanOrEqual(15);
|
||||
expect(box?.y ?? 100).toBeLessThanOrEqual(25);
|
||||
expect((box?.y ?? 0) + (box?.height ?? 0))
|
||||
.toBeLessThanOrEqual(viewport.height - 15);
|
||||
expect(scrollMetrics.scrollHeight).toBeGreaterThan(scrollMetrics.clientHeight);
|
||||
}
|
||||
@@ -1,422 +0,0 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import { apiEnvelope } from "@e2e/fixtures/data/common";
|
||||
import { e2eEmailUser } from "@e2e/fixtures/data/user";
|
||||
import {
|
||||
clearBrowserState,
|
||||
seedEmailSession,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const idrPlans = {
|
||||
plans: [
|
||||
{
|
||||
planId: "vip_monthly",
|
||||
planName: "Monthly",
|
||||
orderType: "vip_monthly",
|
||||
amountCents: 19_590_000,
|
||||
originalAmountCents: 19_590_000,
|
||||
dailyPriceCents: 653_000,
|
||||
currency: "IDR",
|
||||
vipDays: 30,
|
||||
dolAmount: null,
|
||||
creditBalance: 3_000,
|
||||
},
|
||||
{
|
||||
planId: "dol_1000",
|
||||
planName: "1,000 Credits",
|
||||
orderType: "dol",
|
||||
amountCents: 8_890_000,
|
||||
originalAmountCents: null,
|
||||
dailyPriceCents: null,
|
||||
currency: "IDR",
|
||||
vipDays: null,
|
||||
dolAmount: 1_000,
|
||||
creditBalance: 1_000,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const idrGiftCatalog = {
|
||||
characterId: "elio",
|
||||
categories: [
|
||||
{
|
||||
category: "coffee",
|
||||
name: "Coffee",
|
||||
productCount: 1,
|
||||
imageUrl: null,
|
||||
},
|
||||
],
|
||||
plans: [
|
||||
{
|
||||
planId: "tip_coffee_usd_4_99",
|
||||
planName: "Velvet Espresso",
|
||||
orderType: "tip",
|
||||
tipType: "coffee_small",
|
||||
category: "coffee",
|
||||
characterId: "elio",
|
||||
description: "Buy Elio a Velvet Espresso",
|
||||
imageUrl: null,
|
||||
amountCents: 8_929_900,
|
||||
currency: "IDR",
|
||||
autoRenew: false,
|
||||
isFirstRechargeOffer: false,
|
||||
firstRechargeDiscountPercent: 0,
|
||||
promotionType: null,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
async function registerIndonesiaPaymentMocks(page: Page) {
|
||||
const orderStatuses = new Map<string, "pending" | "paid">();
|
||||
const orderPlans = new Map<string, { planId: string; orderType: string }>();
|
||||
let createOrderCount = 0;
|
||||
|
||||
await page.route("**/api/user/profile", async (route) => {
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({ ...e2eEmailUser, countryCode: "ID" }),
|
||||
});
|
||||
});
|
||||
await page.route("**/api/payment/plans**", async (route) => {
|
||||
await route.fulfill({ json: apiEnvelope(idrPlans) });
|
||||
});
|
||||
await page.route("**/api/payment/gift-products**", async (route) => {
|
||||
await route.fulfill({ json: apiEnvelope(idrGiftCatalog) });
|
||||
});
|
||||
await page.route("**/api/payment/create-order", async (route) => {
|
||||
createOrderCount += 1;
|
||||
const body = route.request().postDataJSON() as {
|
||||
planId: string;
|
||||
payChannel: "ezpay" | "stripe";
|
||||
};
|
||||
const plan =
|
||||
idrPlans.plans.find((item) => item.planId === body.planId) ??
|
||||
idrGiftCatalog.plans.find((item) => item.planId === body.planId);
|
||||
const orderId = `order_${body.payChannel}_${body.planId}`;
|
||||
orderStatuses.set(orderId, "pending");
|
||||
orderPlans.set(orderId, {
|
||||
planId: body.planId,
|
||||
orderType: plan?.orderType ?? "dol",
|
||||
});
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
orderId,
|
||||
payParams:
|
||||
body.payChannel === "stripe"
|
||||
? {
|
||||
provider: "stripe",
|
||||
clientSecret: "pi_e2e_secret_mock",
|
||||
}
|
||||
: {
|
||||
provider: "ezpay",
|
||||
countryCode: "ID",
|
||||
channelCode: "ID_QRIS_DYNAMIC_QR",
|
||||
channelType: "QR",
|
||||
payData: "00020101021226670016COM.NOBUBANK.WWW",
|
||||
firstChargeAmountCents: plan?.amountCents ?? 0,
|
||||
currency: "IDR",
|
||||
},
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.route("**/api/payment/order-status**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const orderId = url.searchParams.get("order_id") ?? "";
|
||||
const plan = orderPlans.get(orderId);
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
orderId,
|
||||
status: orderStatuses.get(orderId) ?? "pending",
|
||||
orderType: plan?.orderType ?? "dol",
|
||||
planId: plan?.planId ?? null,
|
||||
creditsAdded: 0,
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.route("**/api/payment/tip-message", async (route) => {
|
||||
const body = route.request().postDataJSON() as { orderId: string };
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
orderId: body.orderId,
|
||||
characterId: "elio",
|
||||
planId: "tip_coffee_usd_4_99",
|
||||
productName: "Velvet Espresso",
|
||||
tipCount: 1,
|
||||
poolIndex: 0,
|
||||
message: "Thank you. Your gift made me smile.",
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
getCreateOrderCount() {
|
||||
return createOrderCount;
|
||||
},
|
||||
markPaid(orderId: string) {
|
||||
orderStatuses.set(orderId, "paid");
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async function prepareIndonesiaUser(page: Page) {
|
||||
await seedEmailSession(page);
|
||||
await page.evaluate(() => {
|
||||
const rawUser = localStorage.getItem("cozsweet:user");
|
||||
const user = rawUser ? JSON.parse(rawUser) : {};
|
||||
localStorage.setItem(
|
||||
"cozsweet:user",
|
||||
JSON.stringify({ ...user, countryCode: "ID" }),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async function expectQrisOrder(
|
||||
page: Page,
|
||||
buttonName: RegExp,
|
||||
planId: string,
|
||||
formattedAmount: RegExp,
|
||||
) {
|
||||
const requestPromise = page.waitForRequest("**/api/payment/create-order");
|
||||
await page.getByRole("button", { name: buttonName }).click();
|
||||
const request = await requestPromise;
|
||||
expect(request.postDataJSON()).toMatchObject({
|
||||
planId,
|
||||
payChannel: "ezpay",
|
||||
recipientCharacterId: "elio",
|
||||
});
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Scan to pay with QRIS" });
|
||||
await expect(dialog).toBeVisible();
|
||||
await expect(dialog).toContainText(formattedAmount);
|
||||
await expect(dialog).toContainText("Waiting for payment");
|
||||
await expect(
|
||||
dialog.getByRole("img", { name: "QRIS payment QR code" }),
|
||||
).toBeVisible();
|
||||
return `order_ezpay_${planId}`;
|
||||
}
|
||||
|
||||
async function expectCheckoutButtonLayout(page: Page) {
|
||||
const viewport = page.viewportSize();
|
||||
const checkoutBox = await page
|
||||
.getByRole("button", { name: "Pay and Top Up" })
|
||||
.boundingBox();
|
||||
const stripeBox = await page.getByRole("button", { name: "Stripe" }).boundingBox();
|
||||
expect(viewport).not.toBeNull();
|
||||
expect(checkoutBox).not.toBeNull();
|
||||
expect(stripeBox).not.toBeNull();
|
||||
if (!viewport || !checkoutBox || !stripeBox) return;
|
||||
expect(checkoutBox.y + checkoutBox.height).toBeLessThanOrEqual(viewport.height);
|
||||
expect(stripeBox.y + stripeBox.height).toBeLessThanOrEqual(checkoutBox.y);
|
||||
}
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page);
|
||||
});
|
||||
|
||||
test("Indonesia VIP defaults to QRIS and completes after status polling", async ({
|
||||
page,
|
||||
}) => {
|
||||
const payment = await registerIndonesiaPaymentMocks(page);
|
||||
await prepareIndonesiaUser(page);
|
||||
await page.goto("/subscription?type=vip&character=elio");
|
||||
|
||||
await expect(page.getByText("Choose who you want to support")).toHaveCount(0);
|
||||
await expect(page.getByText("Supporting Elio")).toHaveCount(0);
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Elio", exact: true }),
|
||||
).toHaveCount(0);
|
||||
|
||||
await expect(page.getByRole("button", { name: "QRIS" })).toHaveAttribute(
|
||||
"aria-pressed",
|
||||
"true",
|
||||
);
|
||||
const checkoutButton = page.getByRole("button", { name: "Pay and Top Up" });
|
||||
await expect(checkoutButton).toBeDisabled();
|
||||
await expectCheckoutButtonLayout(page);
|
||||
|
||||
await page.getByRole("button", { name: /Monthly, 195900 IDR/i }).click();
|
||||
const renewalDialog = page.getByRole("dialog", {
|
||||
name: "Automatic Renewal Confirmation",
|
||||
});
|
||||
await expect(renewalDialog).toBeVisible();
|
||||
expect(payment.getCreateOrderCount()).toBe(0);
|
||||
|
||||
await renewalDialog.getByRole("button", { name: "Confirm" }).click();
|
||||
await expect(renewalDialog).toBeHidden();
|
||||
await expect(checkoutButton).toBeEnabled();
|
||||
expect(payment.getCreateOrderCount()).toBe(0);
|
||||
|
||||
const orderId = await expectQrisOrder(
|
||||
page,
|
||||
/Pay and Top Up/i,
|
||||
"vip_monthly",
|
||||
/Rp\s*195[.,]900/,
|
||||
);
|
||||
expect(payment.getCreateOrderCount()).toBe(1);
|
||||
payment.markPaid(orderId);
|
||||
|
||||
const success = page.getByRole("alertdialog", { name: "Payment successful" });
|
||||
await expect(success).toBeVisible({ timeout: 10_000 });
|
||||
await expect(
|
||||
page.getByRole("dialog", { name: "Scan to pay with QRIS" }),
|
||||
).toBeHidden();
|
||||
});
|
||||
|
||||
test("Indonesia credit top-up uses QRIS display cents", async ({ page }) => {
|
||||
const payment = await registerIndonesiaPaymentMocks(page);
|
||||
await prepareIndonesiaUser(page);
|
||||
await page.goto("/subscription?type=topup&character=elio");
|
||||
await expect(page.getByText("Supporting Elio")).toHaveCount(0);
|
||||
await expectCheckoutButtonLayout(page);
|
||||
|
||||
const orderId = await expectQrisOrder(
|
||||
page,
|
||||
/Pay and Top Up/i,
|
||||
"dol_1000",
|
||||
/Rp\s*88[.,]900/,
|
||||
);
|
||||
payment.markPaid(orderId);
|
||||
|
||||
await expect(
|
||||
page.getByRole("alertdialog", { name: "Payment successful" }),
|
||||
).toBeVisible({ timeout: 10_000 });
|
||||
});
|
||||
|
||||
test("closing QRIS restores payment selection and allows switching to Stripe", async ({
|
||||
page,
|
||||
}) => {
|
||||
const payment = await registerIndonesiaPaymentMocks(page);
|
||||
await prepareIndonesiaUser(page);
|
||||
await page.goto("/subscription?type=topup&character=elio");
|
||||
|
||||
await expectQrisOrder(
|
||||
page,
|
||||
/Pay and Top Up/i,
|
||||
"dol_1000",
|
||||
/Rp\s*88[.,]900/,
|
||||
);
|
||||
const dialog = page.getByRole("dialog", { name: "Scan to pay with QRIS" });
|
||||
await dialog.getByRole("button", { name: "Close" }).click();
|
||||
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect(page.getByRole("button", { name: "Stripe" })).toBeEnabled();
|
||||
await page.getByRole("button", { name: "Stripe" }).click();
|
||||
await expect(page.getByRole("button", { name: "Stripe" })).toHaveAttribute(
|
||||
"aria-pressed",
|
||||
"true",
|
||||
);
|
||||
await expect(page.getByRole("button", { name: "Pay and Top Up" })).toBeEnabled();
|
||||
expect(payment.getCreateOrderCount()).toBe(1);
|
||||
});
|
||||
|
||||
test("closing QRIS allows switching to Stripe and creating a Stripe order", async ({
|
||||
page,
|
||||
}) => {
|
||||
const payment = await registerIndonesiaPaymentMocks(page);
|
||||
await prepareIndonesiaUser(page);
|
||||
await page.goto("/subscription?type=topup&character=elio");
|
||||
|
||||
await expectQrisOrder(
|
||||
page,
|
||||
/Pay and Top Up/i,
|
||||
"dol_1000",
|
||||
/Rp\s*88[.,]900/,
|
||||
);
|
||||
const dialog = page.getByRole("dialog", { name: "Scan to pay with QRIS" });
|
||||
await dialog.getByRole("button", { name: "Close" }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
|
||||
const stripeButton = page.getByRole("button", {
|
||||
name: "Stripe",
|
||||
exact: true,
|
||||
});
|
||||
await expect(stripeButton).toBeEnabled();
|
||||
await stripeButton.click();
|
||||
await expect(stripeButton).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Resume QRIS payment" }),
|
||||
).toHaveCount(0);
|
||||
|
||||
const stripeRequestPromise = page.waitForRequest(
|
||||
"**/api/payment/create-order",
|
||||
);
|
||||
await page.getByRole("button", { name: "Pay and Top Up" }).click();
|
||||
const stripeRequest = await stripeRequestPromise;
|
||||
expect(stripeRequest.postDataJSON()).toMatchObject({
|
||||
planId: "dol_1000",
|
||||
payChannel: "stripe",
|
||||
recipientCharacterId: "elio",
|
||||
});
|
||||
expect(payment.getCreateOrderCount()).toBe(2);
|
||||
});
|
||||
|
||||
test("payment issue submits Other to the feedback API without creating an order", async ({
|
||||
page,
|
||||
}) => {
|
||||
const payment = await registerIndonesiaPaymentMocks(page);
|
||||
await prepareIndonesiaUser(page);
|
||||
let feedbackBody = "";
|
||||
let idempotencyKey = "";
|
||||
await page.route("**/api/feedback", async (route) => {
|
||||
feedbackBody = route.request().postData() ?? "";
|
||||
idempotencyKey = route.request().headers()["idempotency-key"] ?? "";
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({ feedbackId: "feedback-payment-1", duplicate: false }),
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto("/subscription?type=topup&character=elio");
|
||||
await page.getByRole("button", { name: "Payment issue?" }).click();
|
||||
const dialog = page.getByRole("dialog", {
|
||||
name: "What problem did you encounter?",
|
||||
});
|
||||
await expect(dialog).toBeVisible();
|
||||
await dialog.getByRole("radio", { name: "Other" }).check();
|
||||
await dialog
|
||||
.getByLabel("Please describe the issue")
|
||||
.fill("QRIS did not open correctly.");
|
||||
await dialog.getByRole("button", { name: "Submit" }).click();
|
||||
|
||||
await expect(page.getByRole("status")).toHaveText(
|
||||
"Thanks. Your payment issue has been submitted.",
|
||||
);
|
||||
await expect(dialog).toBeHidden();
|
||||
expect(payment.getCreateOrderCount()).toBe(0);
|
||||
expect(idempotencyKey).toMatch(/^payment_feedback_[A-Za-z0-9_-]+$/);
|
||||
expect(feedbackBody).toContain('name="category"');
|
||||
expect(feedbackBody).toContain("payment");
|
||||
expect(feedbackBody).toContain(
|
||||
"Payment issue: Other\r\nDetails: QRIS did not open correctly.",
|
||||
);
|
||||
expect(feedbackBody).toContain('name="context"');
|
||||
expect(feedbackBody).toContain('"paymentIssueReason":"other"');
|
||||
expect(feedbackBody).toContain('"characterId":"elio"');
|
||||
});
|
||||
|
||||
test("Indonesia gift checkout keeps IDR price through QRIS and thank-you flow", async ({
|
||||
page,
|
||||
}) => {
|
||||
const payment = await registerIndonesiaPaymentMocks(page);
|
||||
await prepareIndonesiaUser(page);
|
||||
await page.goto("/characters/elio/tip");
|
||||
|
||||
await expect(page.getByText(/IDR\s*89[.,]299/)).toBeVisible();
|
||||
await expectQrisOrder(
|
||||
page,
|
||||
/Order and Buy/i,
|
||||
"tip_coffee_usd_4_99",
|
||||
/Rp\s*89[.,]299/,
|
||||
);
|
||||
const dialog = page.getByRole("dialog", { name: "Scan to pay with QRIS" });
|
||||
await dialog.getByRole("button", { name: "Close" }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
|
||||
await expect(page.getByRole("button", { name: "Stripe" })).toBeEnabled();
|
||||
await page.getByRole("button", { name: "Stripe" }).click();
|
||||
await expect(page.getByRole("button", { name: "Stripe" })).toHaveAttribute(
|
||||
"aria-pressed",
|
||||
"true",
|
||||
);
|
||||
expect(payment.getCreateOrderCount()).toBe(1);
|
||||
});
|
||||
@@ -1,153 +0,0 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import { apiEnvelope } from "@e2e/fixtures/data/common";
|
||||
import { e2eEmailUser } from "@e2e/fixtures/data/user";
|
||||
import {
|
||||
clearBrowserState,
|
||||
seedEmailSession,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const phpPlans = {
|
||||
plans: [
|
||||
{
|
||||
planId: "dol_1000",
|
||||
planName: "1,000 Credits",
|
||||
orderType: "dol",
|
||||
amountCents: 49_990,
|
||||
originalAmountCents: 74_990,
|
||||
dailyPriceCents: null,
|
||||
currency: "PHP",
|
||||
vipDays: null,
|
||||
dolAmount: 1_000,
|
||||
creditBalance: 1_000,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
async function registerPhilippinesPaymentMocks(
|
||||
page: Page,
|
||||
response: "hosted" | "qr",
|
||||
) {
|
||||
let createOrderCount = 0;
|
||||
|
||||
await page.route("**/api/user/profile", async (route) => {
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({ ...e2eEmailUser, countryCode: "PH" }),
|
||||
});
|
||||
});
|
||||
await page.route("**/api/payment/plans**", async (route) => {
|
||||
await route.fulfill({ json: apiEnvelope(phpPlans) });
|
||||
});
|
||||
await page.route("**/api/payment/create-order", async (route) => {
|
||||
createOrderCount += 1;
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
orderId: `order_gcash_${response}`,
|
||||
payParams: {
|
||||
provider: "ezpay",
|
||||
countryCode: "PH",
|
||||
channelCode: "PH_QRPH_DYNAMIC",
|
||||
channelType: "QR",
|
||||
payData: "000201010212ph-qr-payload",
|
||||
...(response === "hosted"
|
||||
? { cashierUrl: "https://pay.example/gcash-hosted" }
|
||||
: {}),
|
||||
firstChargeAmountCents: 49_990,
|
||||
currency: "PHP",
|
||||
},
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.route("**/api/payment/order-status**", async (route) => {
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
orderId: `order_gcash_${response}`,
|
||||
status: "pending",
|
||||
orderType: "dol",
|
||||
planId: "dol_1000",
|
||||
creditsAdded: 0,
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
getCreateOrderCount: () => createOrderCount,
|
||||
};
|
||||
}
|
||||
|
||||
async function preparePhilippinesUser(page: Page) {
|
||||
await seedEmailSession(page);
|
||||
await page.evaluate(() => {
|
||||
const rawUser = localStorage.getItem("cozsweet:user");
|
||||
const user = rawUser ? JSON.parse(rawUser) : {};
|
||||
localStorage.setItem(
|
||||
"cozsweet:user",
|
||||
JSON.stringify({ ...user, countryCode: "PH" }),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page);
|
||||
});
|
||||
|
||||
test("Philippines checkout prefers the hosted GCash URL even for a QR response", async ({
|
||||
page,
|
||||
}) => {
|
||||
const payment = await registerPhilippinesPaymentMocks(page, "hosted");
|
||||
await preparePhilippinesUser(page);
|
||||
await page.goto("/subscription?type=topup&character=elio");
|
||||
|
||||
await expect(page.getByRole("button", { name: "GCash" })).toHaveAttribute(
|
||||
"aria-pressed",
|
||||
"true",
|
||||
);
|
||||
await page.getByRole("button", { name: "Pay and Top Up" }).click();
|
||||
|
||||
await expect(
|
||||
page.getByRole("alertdialog", { name: "Continue to payment?" }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("dialog", { name: "Pay with GCash / QR Ph" }),
|
||||
).toHaveCount(0);
|
||||
await expect(
|
||||
page.getByRole("dialog", { name: "Scan to pay with QRIS" }),
|
||||
).toHaveCount(0);
|
||||
expect(payment.getCreateOrderCount()).toBe(1);
|
||||
|
||||
await page.getByRole("button", { name: "Cancel" }).click();
|
||||
await expect(page.getByRole("button", { name: "Stripe" })).toBeEnabled();
|
||||
expect(payment.getCreateOrderCount()).toBe(1);
|
||||
});
|
||||
|
||||
test("Philippines QR-only fallback is labeled GCash / QR Ph and can switch to Stripe", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
const payment = await registerPhilippinesPaymentMocks(page, "qr");
|
||||
await preparePhilippinesUser(page);
|
||||
await page.goto("/subscription?type=topup&character=elio");
|
||||
|
||||
await page.getByRole("button", { name: "Pay and Top Up" }).click();
|
||||
const dialog = page.getByRole("dialog", {
|
||||
name: "Pay with GCash / QR Ph",
|
||||
});
|
||||
await expect(dialog).toBeVisible();
|
||||
await expect(dialog).toContainText(/₱\s*499\.90/);
|
||||
await expect(dialog).not.toContainText("QRIS");
|
||||
await expect(
|
||||
dialog.getByRole("img", { name: "GCash / QR Ph payment QR code" }),
|
||||
).toBeVisible();
|
||||
|
||||
await dialog.getByRole("button", { name: "Close" }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect(page.getByRole("button", { name: "Stripe" })).toBeEnabled();
|
||||
await page.getByRole("button", { name: "Stripe" }).click();
|
||||
await expect(page.getByRole("button", { name: "Stripe" })).toHaveAttribute(
|
||||
"aria-pressed",
|
||||
"true",
|
||||
);
|
||||
expect(payment.getCreateOrderCount()).toBe(1);
|
||||
});
|
||||
@@ -1,164 +0,0 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import { apiEnvelope } from "@e2e/fixtures/data/common";
|
||||
import {
|
||||
clearBrowserState,
|
||||
seedEmailSession,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const postId = "11111111-1111-1111-1111-111111111111";
|
||||
let unlocked = false;
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
unlocked = false;
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page);
|
||||
await registerPrivateZoneVideoMocks(page);
|
||||
});
|
||||
|
||||
test("Private Zone defaults to Albums and reveals video after switching to Moments", async ({
|
||||
page,
|
||||
}) => {
|
||||
await seedEmailSession(page);
|
||||
|
||||
const listRequest = page.waitForRequest((request) => {
|
||||
const url = new URL(request.url());
|
||||
return (
|
||||
url.pathname === "/api/private-zone/posts" &&
|
||||
url.searchParams.get("characterId") === "maya-tan"
|
||||
);
|
||||
});
|
||||
await page.goto("/characters/maya/private-zone");
|
||||
await listRequest;
|
||||
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Private albums" }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByText("Maya archive")).toBeVisible();
|
||||
await page.getByRole("tab", { name: "Moments" }).click();
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Private moments" }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByText("Only for you.")).toBeVisible();
|
||||
await expect(page.locator("video")).toHaveCount(0);
|
||||
|
||||
await page.getByRole("button", { name: "Unlock for 100 credits" }).click();
|
||||
const dialog = page.getByRole("alertdialog");
|
||||
await expect(dialog).toContainText("100 credits");
|
||||
const unlockRequest = page.waitForRequest(
|
||||
`**/api/private-zone/posts/${postId}/unlock`,
|
||||
);
|
||||
await dialog.getByRole("button", { name: "Unlock", exact: true }).click();
|
||||
expect((await unlockRequest).postDataJSON()).toEqual({ expectedCost: 100 });
|
||||
|
||||
const video = page.locator("video");
|
||||
await expect(video).toHaveCount(1);
|
||||
await expect(video.locator("source")).toHaveAttribute("src", /video\.mp4/);
|
||||
await expect(page.getByRole("alertdialog")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("Albums render first and Moments remain available behind the second tab", async ({ page }) => {
|
||||
await seedEmailSession(page);
|
||||
await page.goto("/characters/maya/private-zone");
|
||||
|
||||
const tabs = page.getByRole("tab");
|
||||
await expect(tabs).toHaveText(["Albums", "Moments"]);
|
||||
await expect(page.getByRole("tab", { name: "Albums" })).toHaveAttribute(
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Private albums" }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByText("Maya archive")).toBeVisible();
|
||||
|
||||
await page.getByRole("tab", { name: "Moments" }).click();
|
||||
await expect(page.getByRole("tab", { name: "Moments" })).toHaveAttribute(
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Private moments" }),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
async function registerPrivateZoneVideoMocks(page: Page): Promise<void> {
|
||||
await page.route("**/api/private-zone/posts**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
characterId: url.searchParams.get("characterId") ?? "maya-tan",
|
||||
items: [videoPost(unlocked)],
|
||||
nextCursor: null,
|
||||
hasMore: false,
|
||||
creditBalance: unlocked ? 150 : 250,
|
||||
currency: "credits",
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
// Playwright evaluates page routes in reverse registration order. Register
|
||||
// the specific mutation last so the broader list route cannot intercept it.
|
||||
await page.route("**/api/private-zone/posts/*/unlock", async (route) => {
|
||||
unlocked = true;
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
postId,
|
||||
reason: "ok",
|
||||
unlocked: true,
|
||||
creditsCharged: 100,
|
||||
requiredCredits: 100,
|
||||
currentCredits: 150,
|
||||
shortfallCredits: 0,
|
||||
creditBalance: 150,
|
||||
post: videoPost(true),
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/private-zone/albums**", async (route) => {
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
items: [
|
||||
{
|
||||
albumId: "album-maya",
|
||||
title: "Maya archive",
|
||||
content: null,
|
||||
previewText: "Private photos",
|
||||
imageCount: 1,
|
||||
images: [{ url: "/images/private-zone/banner/maya.png", locked: true, index: 0 }],
|
||||
locked: true,
|
||||
unlocked: false,
|
||||
unlockCost: 80,
|
||||
publishedAt: "2026-07-24T10:00:00+00:00",
|
||||
lockDetail: { locked: true },
|
||||
},
|
||||
],
|
||||
creditBalance: 250,
|
||||
pendingImageCount: 0,
|
||||
hasIncompleteContent: false,
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function videoPost(isUnlocked: boolean) {
|
||||
return {
|
||||
postId,
|
||||
characterId: "maya-tan",
|
||||
caption: "Only for you.",
|
||||
posterUrl: "/images/private-zone/banner/maya.png",
|
||||
mediaType: "video",
|
||||
videoUrl: isUnlocked ? "/test-video.mp4?token=short" : null,
|
||||
videoMimeType: "video/mp4",
|
||||
videoSizeBytes: 1024,
|
||||
durationSeconds: 18,
|
||||
unlockCostCredits: 100,
|
||||
currency: "credits",
|
||||
locked: !isUnlocked,
|
||||
unlocked: isUnlocked,
|
||||
availableForNewUnlock: true,
|
||||
publishedAt: "2026-07-24T10:00:00+00:00",
|
||||
};
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import {
|
||||
paidImageMessageId,
|
||||
} from "@e2e/fixtures/test-data";
|
||||
import { paidImageMessageId } from "@e2e/fixtures/test-data";
|
||||
import {
|
||||
clearBrowserState,
|
||||
dismissChatInterruptions,
|
||||
@@ -12,6 +10,10 @@ import {
|
||||
signInWithEmailAndOpenChat,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const paidImageOverlayUrl = new RegExp(
|
||||
`/chat\\?image=${paidImageMessageId}$`,
|
||||
);
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page, {
|
||||
@@ -19,23 +21,30 @@ test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
});
|
||||
});
|
||||
|
||||
test("user sees insufficient credits when unlocking from the locked image card and can navigate to subscription", async ({
|
||||
test("user sees insufficient credits when unlocking a paid image from fullscreen and can navigate to subscription", async ({
|
||||
page,
|
||||
}) => {
|
||||
await signInWithEmailAndOpenChat(page);
|
||||
await dismissChatInterruptions(page);
|
||||
|
||||
const lockedImageCard = page.getByRole("group", {
|
||||
name: "Locked private image",
|
||||
const paidImageButton = page.getByRole("button", {
|
||||
name: "Open image in fullscreen",
|
||||
}).last();
|
||||
await expect(lockedImageCard).toBeVisible({ timeout: 10_000 });
|
||||
await expect(lockedImageCard.locator("img")).toHaveCount(0);
|
||||
await expect(paidImageButton).toBeVisible({ timeout: 10_000 });
|
||||
|
||||
await paidImageButton.click();
|
||||
await expect(page).toHaveURL(paidImageOverlayUrl);
|
||||
|
||||
const lockedImageDialog = page.getByRole("dialog", {
|
||||
name: "Locked fullscreen image",
|
||||
});
|
||||
await expect(lockedImageDialog).toBeVisible();
|
||||
|
||||
const unlockRequestPromise = page.waitForRequest(
|
||||
"**/api/chat/unlock-private",
|
||||
);
|
||||
await lockedImageCard
|
||||
.getByRole("button", { name: "Unlock private image" })
|
||||
await lockedImageDialog
|
||||
.getByRole("button", { name: "Unlock high-definition large image" })
|
||||
.click();
|
||||
|
||||
const unlockRequest = await unlockRequestPromise;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import {
|
||||
defaultCharacterChatUrl,
|
||||
enterChatFromSplash,
|
||||
submitEmailLogin,
|
||||
switchToEmailSignIn,
|
||||
@@ -20,7 +19,7 @@ test.describe("pre-release email login smoke", () => {
|
||||
page,
|
||||
}) => {
|
||||
await enterChatFromSplash(page, {
|
||||
expectedUrl: defaultCharacterChatUrl,
|
||||
expectedUrl: /\/chat(?:\?.*)?$/,
|
||||
timeout: 20_000,
|
||||
waitUntil: "domcontentloaded",
|
||||
});
|
||||
@@ -37,12 +36,12 @@ test.describe("pre-release email login smoke", () => {
|
||||
|
||||
await switchToEmailSignIn(page);
|
||||
await submitEmailLogin(page, {
|
||||
expectedUrl: defaultCharacterChatUrl,
|
||||
expectedUrl: /\/chat(?:\?.*)?$/,
|
||||
waitForRequest: false,
|
||||
urlTimeout: 20_000,
|
||||
});
|
||||
|
||||
await expect(page.getByRole("button", { name: "Profile" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Menu" })).toBeVisible();
|
||||
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
import { expect, test, type Locator, type Page } from "@playwright/test";
|
||||
|
||||
import {
|
||||
defaultCharacterChatUrl,
|
||||
dismissChatInterruptions,
|
||||
enterChatFromSplash,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const preReleaseHost = "frontend-test.banlv-ai.com";
|
||||
const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? "";
|
||||
|
||||
test.describe("pre-release multi-message lock types", () => {
|
||||
test.setTimeout(120_000);
|
||||
test.skip(
|
||||
!baseURL.includes(preReleaseHost),
|
||||
`Run this test only with PLAYWRIGHT_BASE_URL pointing at ${preReleaseHost}.`,
|
||||
);
|
||||
|
||||
test("returns locked image, locked voice, then unlocked text", async ({
|
||||
page,
|
||||
}) => {
|
||||
await enterChatFromSplash(page, {
|
||||
expectedUrl: defaultCharacterChatUrl,
|
||||
timeout: 20_000,
|
||||
waitUntil: "domcontentloaded",
|
||||
});
|
||||
await dismissChatInterruptions(page);
|
||||
|
||||
const messageInput = page.getByRole("textbox", { name: "Message" });
|
||||
await expect(messageInput).toBeEnabled({ timeout: 30_000 });
|
||||
|
||||
let aiMessageCount = await page
|
||||
.locator('[aria-label="AI message"]')
|
||||
.count();
|
||||
|
||||
const imageReply = await sendMessageAndWaitForAiReply(
|
||||
page,
|
||||
messageInput,
|
||||
"发个图片",
|
||||
aiMessageCount,
|
||||
);
|
||||
aiMessageCount += 1;
|
||||
await expect(
|
||||
imageReply.getByRole("button", { name: "Open image in fullscreen" }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
imageReply
|
||||
.getByRole("button", { name: "Open image in fullscreen" })
|
||||
.locator("img"),
|
||||
).toHaveClass(/blur-sm/);
|
||||
|
||||
const voiceReply = await sendMessageAndWaitForAiReply(
|
||||
page,
|
||||
messageInput,
|
||||
"发送语音",
|
||||
aiMessageCount,
|
||||
);
|
||||
aiMessageCount += 1;
|
||||
await expect(
|
||||
voiceReply.getByRole("button", { name: "Unlock voice message" }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
voiceReply.getByRole("button", { name: "Play voice message" }),
|
||||
).toBeDisabled();
|
||||
|
||||
const textReply = await sendMessageAndWaitForAiReply(
|
||||
page,
|
||||
messageInput,
|
||||
"你好",
|
||||
aiMessageCount,
|
||||
);
|
||||
await expect(
|
||||
textReply.getByRole("button", { name: "Unlock voice message" }),
|
||||
).toHaveCount(0);
|
||||
await expect(
|
||||
textReply.getByRole("group", { name: "Locked private image" }),
|
||||
).toHaveCount(0);
|
||||
await expect(textReply.getByRole("button", { name: /Unlock/ })).toHaveCount(0);
|
||||
await expect(textReply).toContainText(/\S/);
|
||||
});
|
||||
});
|
||||
|
||||
async function sendMessageAndWaitForAiReply(
|
||||
page: Page,
|
||||
messageInput: Locator,
|
||||
message: string,
|
||||
previousAiMessageCount: number,
|
||||
): Promise<Locator> {
|
||||
const aiMessages = page.locator('[aria-label="AI message"]');
|
||||
const sendRequestPromise = page.waitForRequest("**/api/chat/send");
|
||||
|
||||
await messageInput.fill(message);
|
||||
await messageInput.press("Enter");
|
||||
|
||||
const sendRequest = await sendRequestPromise;
|
||||
expect(sendRequest.postDataJSON()).toMatchObject({ message });
|
||||
|
||||
await expect
|
||||
.poll(() => aiMessages.count(), { timeout: 60_000 })
|
||||
.toBeGreaterThan(previousAiMessageCount);
|
||||
const latestReply = aiMessages.last();
|
||||
await expect(latestReply).toBeVisible();
|
||||
return latestReply;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
# Server-only deploy configuration.
|
||||
# Copy this file to .deploy.env on the deployment server when you want the
|
||||
# post-receive hook to pull CI-built images instead of building locally.
|
||||
|
||||
# build: build Docker image on the deployment server.
|
||||
# pull: pull Docker image from registry and restart the container.
|
||||
COZSWEET_DEPLOY_IMAGE_SOURCE=pull
|
||||
|
||||
# Full image repository without tag.
|
||||
# Example:
|
||||
# COZSWEET_REGISTRY_IMAGE=gitea.banlv-ai.com/admin/cozsweet-web
|
||||
COZSWEET_REGISTRY_IMAGE=gitea.banlv-ai.com/admin/cozsweet-web
|
||||
|
||||
# Optional. Defaults to <deploy_env>-<short_sha>, for example:
|
||||
# - test-abc1234 on test branch
|
||||
# - prod-abc1234 on main branch
|
||||
#
|
||||
# You may set this to test-latest or prod-latest for latest-tag deploys.
|
||||
# COZSWEET_REMOTE_IMAGE_TAG=
|
||||
@@ -32,8 +32,8 @@ AUTH_SECRET=PinzhujxR/qMPrY7bAor8qQlwmmy1tJJCex9Tomhk2c=
|
||||
# 第三方 OAuth
|
||||
AUTH_GOOGLE_ID=351948560061-isubggf6eahfii9n0stpf2qu3haralro.apps.googleusercontent.com
|
||||
AUTH_GOOGLE_SECRET=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
|
||||
AUTH_FACEBOOK_ID=3346658785491798
|
||||
AUTH_FACEBOOK_SECRET=11afd29e30d53d55f069ec2e63f5b61c
|
||||
AUTH_FACEBOOK_ID=26934819589512827
|
||||
AUTH_FACEBOOK_SECRET=004b1a9384b3433e153992e5edcef4ad
|
||||
|
||||
# Cloudflare CDN(test / production 部署后刷缓存用)
|
||||
CF_ZONE_ID=b1b6bfb7795667609c8e7f418af0156b
|
||||
|
||||
@@ -5,7 +5,6 @@ NEXTAUTH_URL=https://frontend-test.banlv-ai.com
|
||||
NEXTAUTH_URL_INTERNAL=http://localhost:3000
|
||||
NEXT_PUBLIC_API_BASE_URL=https://proapi.banlv-ai.com
|
||||
NEXT_PUBLIC_WS_BASE_URL=wss://proapi.banlv-ai.com/ws
|
||||
NEXT_PUBLIC_ENABLE_VOICE_CALL=false
|
||||
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_51Te8ybEJDtUGxQHo0UMySJ2hW0vVryynzllmIUI3UQdQCFgxNLci0Jmm2lQkRsTaIP7C7IQlFzfFyBJ5rOhr1ML800G8P8DF5R
|
||||
|
||||
NEXT_PUBLIC_API_CONNECT_TIMEOUT=30000
|
||||
@@ -26,8 +25,8 @@ AUTH_SECRET=rKGeHQ/8tKPoh12Kiedil5zHuj9ZfPA0NwY9bgwRqkE=
|
||||
# 第三方 OAuth
|
||||
AUTH_GOOGLE_ID=351948560061-isubggf6eahfii9n0stpf2qu3haralro.apps.googleusercontent.com
|
||||
AUTH_GOOGLE_SECRET=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
|
||||
AUTH_FACEBOOK_ID=3346658785491798
|
||||
AUTH_FACEBOOK_SECRET=11afd29e30d53d55f069ec2e63f5b61c
|
||||
AUTH_FACEBOOK_ID=26934819589512827
|
||||
AUTH_FACEBOOK_SECRET=004b1a9384b3433e153992e5edcef4ad
|
||||
|
||||
# Cloudflare CDN(test / production 部署后刷缓存用)
|
||||
CF_ZONE_ID=b1b6bfb7795667609c8e7f418af0156b
|
||||
|
||||
@@ -10,7 +10,6 @@ NEXT_PUBLIC_API_BASE_URL=https://api.banlv-ai.com
|
||||
|
||||
# WebSocket URL(生产环境)
|
||||
NEXT_PUBLIC_WS_BASE_URL=wss://api.banlv-ai.com/ws
|
||||
NEXT_PUBLIC_ENABLE_VOICE_CALL=false
|
||||
|
||||
# Stripe 支付(publishable key 可暴露在浏览器端)
|
||||
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_51Te8ybEJDtUGxQHouKlEMfMuCZWifzlhBIReeKvANOtyCXS4zL0SMTWJXiFHPKz7azpF6OnIKXUPFSLs82fevVjr00w1bw5mvl
|
||||
@@ -35,8 +34,8 @@ AUTH_SECRET=XypsCWoLCNmwOaq4taIMJHe4+cU9YZBaYN4VMTtmSik=
|
||||
# 第三方 OAuth
|
||||
AUTH_GOOGLE_ID=351948560061-isubggf6eahfii9n0stpf2qu3haralro.apps.googleusercontent.com
|
||||
AUTH_GOOGLE_SECRET=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
|
||||
AUTH_FACEBOOK_ID=3346658785491798
|
||||
AUTH_FACEBOOK_SECRET=11afd29e30d53d55f069ec2e63f5b61c
|
||||
AUTH_FACEBOOK_ID=26934819589512827
|
||||
AUTH_FACEBOOK_SECRET=004b1a9384b3433e153992e5edcef4ad
|
||||
|
||||
# Cloudflare CDN(test / production 部署后刷缓存用)
|
||||
CF_ZONE_ID=b1b6bfb7795667609c8e7f418af0156b
|
||||
|
||||
@@ -5,28 +5,6 @@ import nextTs from "eslint-config-next/typescript";
|
||||
const eslintConfig = defineConfig([
|
||||
...nextVitals,
|
||||
...nextTs,
|
||||
{
|
||||
files: ["src/**/*.{ts,tsx}"],
|
||||
rules: {
|
||||
"no-restricted-imports": [
|
||||
"error",
|
||||
{
|
||||
paths: [
|
||||
{
|
||||
name: "@/data/repositories",
|
||||
message:
|
||||
"Import the concrete repository module so unrelated browser storage stays out of the client graph.",
|
||||
},
|
||||
{
|
||||
name: "@/data/storage",
|
||||
message:
|
||||
"Import the concrete storage module so unrelated persistence code stays out of the client graph.",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/app/**/*.{ts,tsx}"],
|
||||
ignores: ["src/app/api/**", "src/app/**/route.ts"],
|
||||
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 35 KiB |
@@ -2,14 +2,9 @@ import { withSentryConfig } from "@sentry/nextjs";
|
||||
import type { NextConfig } from "next";
|
||||
import { withSerwist } from "@serwist/turbopack";
|
||||
|
||||
import { LEGACY_GLOBAL_ROUTE_REDIRECTS } from "./src/router/legacy-global-route-redirects";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
// Docker runs the traced runtime emitted to `.next/standalone`.
|
||||
output: "standalone",
|
||||
async redirects() {
|
||||
return [...LEGACY_GLOBAL_ROUTE_REDIRECTS];
|
||||
},
|
||||
images: {
|
||||
remotePatterns: [
|
||||
{
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
"name": "cozsweet-frontend-nextjs",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@10.30.3",
|
||||
"engines": {
|
||||
"node": "24.x"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
@@ -17,7 +13,7 @@
|
||||
"lint": "eslint",
|
||||
"lint:fix": "eslint --fix",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"quality": "pnpm lint && pnpm typecheck && pnpm test && pnpm test:contracts",
|
||||
"quality": "pnpm lint && pnpm typecheck && pnpm test",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"test:ui": "vitest --ui",
|
||||
@@ -25,11 +21,8 @@
|
||||
"test:e2e:chrome": "PLAYWRIGHT_USE_SYSTEM_CHROME=1 playwright test --project=mock-chromium",
|
||||
"test:e2e:headed": "playwright test --project=mock-chromium --headed",
|
||||
"test:e2e:ui": "playwright test --ui",
|
||||
"test:e2e:mobile-smoke": "playwright test --project=mock-mobile-chrome e2e/specs/mock/auth/email-login-from-other-options.spec.ts e2e/specs/mock/auth/logout-from-profile.spec.ts e2e/specs/mock/chat/chat-send-token-refresh-retry.spec.ts e2e/specs/mock/unlock-message/image-unlock-insufficient-credits.spec.ts",
|
||||
"test:e2e:real": "E2E_REAL_BACKEND=1 PLAYWRIGHT_BASE_URL=${PLAYWRIGHT_BASE_URL:-https://frontend-test.banlv-ai.com} E2E_API_BASE_URL=${E2E_API_BASE_URL:-https://proapi.banlv-ai.com} playwright test --project=real-backend",
|
||||
"test:e2e:prod": "E2E_REAL_BACKEND=1 PLAYWRIGHT_BASE_URL=${PLAYWRIGHT_BASE_URL:-https://cozsweet.com} E2E_API_BASE_URL=${E2E_API_BASE_URL:-https://api.banlv-ai.com} playwright test --project=prod-smoke",
|
||||
"contract:check": "node scripts/contracts/check-openapi.mjs",
|
||||
"test:contracts": "node --test scripts/contracts/__tests__/*.test.mjs",
|
||||
"test:e2e:prod": "E2E_REAL_BACKEND=1 PLAYWRIGHT_BASE_URL=${PLAYWRIGHT_BASE_URL:-https://cozsweet.com} E2E_API_BASE_URL=${E2E_API_BASE_URL:-https://proapi.banlv-ai.com} playwright test --project=prod-smoke",
|
||||
"perf:bundle": "next experimental-analyze --output && node scripts/performance/report-bundle.mjs",
|
||||
"perf:bundle:check": "PERF_BUNDLE_ENFORCE=1 pnpm perf:bundle",
|
||||
"perf:vitals": "node scripts/performance/collect-web-vitals.mjs",
|
||||
@@ -44,13 +37,12 @@
|
||||
"@xstate/react": "^5",
|
||||
"classnames": "^2.5.1",
|
||||
"dexie": "^4.4.3",
|
||||
"esbuild": "^0.28.0",
|
||||
"esbuild": "^0.25.0",
|
||||
"lucide-react": "^1.18.0",
|
||||
"next": "16.2.7",
|
||||
"next-auth": "^4.24.14",
|
||||
"ofetch": "^1.5.1",
|
||||
"pino": "^10.3.1",
|
||||
"qrcode.react": "^4.2.0",
|
||||
"react": "19.2.4",
|
||||
"react-dom": "19.2.4",
|
||||
"react-icons": "^5.6.0",
|
||||
@@ -63,7 +55,7 @@
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.61.1",
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@types/node": "^24",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"@vitest/coverage-v8": "^4.1.8",
|
||||
@@ -71,7 +63,6 @@
|
||||
"barrelsby": "^2.8.1",
|
||||
"eslint": "^9",
|
||||
"eslint-config-next": "16.2.7",
|
||||
"fake-indexeddb": "^6.2.5",
|
||||
"jsdom": "^29.1.1",
|
||||
"tailwindcss": "^4",
|
||||
"typescript": "^5",
|
||||
|
||||
@@ -12,10 +12,7 @@ export default defineConfig({
|
||||
fullyParallel: true,
|
||||
forbidOnly: Boolean(process.env.CI),
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
// Next.js dev + Turbopack can return incomplete module payloads when the
|
||||
// local mock suite compiles many routes concurrently. Keep this tier
|
||||
// deterministic locally as well as in CI.
|
||||
workers: 1,
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
reporter: process.env.CI
|
||||
? [["list"], ["html", { open: "never" }]]
|
||||
: [["list"], ["html", { open: "never" }]],
|
||||
@@ -30,9 +27,6 @@ export default defineConfig({
|
||||
? {
|
||||
command: "pnpm dev -H 127.0.0.1 -p 3000",
|
||||
url: baseURL,
|
||||
env: {
|
||||
E2E_DISABLE_SERVICE_WORKER: "1",
|
||||
},
|
||||
reuseExistingServer: !process.env.CI,
|
||||
timeout: 120_000,
|
||||
}
|
||||
|
||||
@@ -13,10 +13,10 @@ importers:
|
||||
version: 5.2.0
|
||||
'@sentry/nextjs':
|
||||
specifier: ^10.61.0
|
||||
version: 10.61.0(@opentelemetry/core@2.8.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.8.0(@opentelemetry/api@1.9.1))(next@16.2.7(@babel/core@7.29.7)(@opentelemetry/api@1.9.1)(@playwright/test@1.61.1)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react@19.2.4)(webpack@5.108.0(esbuild@0.28.1))
|
||||
version: 10.61.0(@opentelemetry/core@2.8.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.8.0(@opentelemetry/api@1.9.1))(next@16.2.7(@babel/core@7.29.7)(@opentelemetry/api@1.9.1)(@playwright/test@1.61.1)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react@19.2.4)(webpack@5.108.0(esbuild@0.25.12))
|
||||
'@serwist/turbopack':
|
||||
specifier: ^9.0.0
|
||||
version: 9.5.11(esbuild@0.28.1)(next@16.2.7(@babel/core@7.29.7)(@opentelemetry/api@1.9.1)(@playwright/test@1.61.1)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react@19.2.4)(typescript@5.9.3)
|
||||
version: 9.5.11(esbuild@0.25.12)(next@16.2.7(@babel/core@7.29.7)(@opentelemetry/api@1.9.1)(@playwright/test@1.61.1)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react@19.2.4)(typescript@5.9.3)
|
||||
'@stripe/react-stripe-js':
|
||||
specifier: ^6.6.0
|
||||
version: 6.6.0(@stripe/stripe-js@9.8.0)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
|
||||
@@ -33,8 +33,8 @@ importers:
|
||||
specifier: ^4.4.3
|
||||
version: 4.4.3
|
||||
esbuild:
|
||||
specifier: ^0.28.0
|
||||
version: 0.28.1
|
||||
specifier: ^0.25.0
|
||||
version: 0.25.12
|
||||
lucide-react:
|
||||
specifier: ^1.18.0
|
||||
version: 1.18.0(react@19.2.4)
|
||||
@@ -50,9 +50,6 @@ importers:
|
||||
pino:
|
||||
specifier: ^10.3.1
|
||||
version: 10.3.1
|
||||
qrcode.react:
|
||||
specifier: ^4.2.0
|
||||
version: 4.2.0(react@19.2.4)
|
||||
react:
|
||||
specifier: 19.2.4
|
||||
version: 19.2.4
|
||||
@@ -85,8 +82,8 @@ importers:
|
||||
specifier: ^4
|
||||
version: 4.3.0
|
||||
'@types/node':
|
||||
specifier: ^24
|
||||
version: 24.13.3
|
||||
specifier: ^20
|
||||
version: 20.19.41
|
||||
'@types/react':
|
||||
specifier: ^19
|
||||
version: 19.2.16
|
||||
@@ -108,9 +105,6 @@ importers:
|
||||
eslint-config-next:
|
||||
specifier: 16.2.7
|
||||
version: 16.2.7(@typescript-eslint/parser@8.60.1(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3)
|
||||
fake-indexeddb:
|
||||
specifier: ^6.2.5
|
||||
version: 6.2.5
|
||||
jsdom:
|
||||
specifier: ^29.1.1
|
||||
version: 29.1.1
|
||||
@@ -122,7 +116,7 @@ importers:
|
||||
version: 5.9.3
|
||||
vitest:
|
||||
specifier: ^4.1.8
|
||||
version: 4.1.8(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(@vitest/coverage-v8@4.1.8)(@vitest/ui@4.1.8)(jsdom@29.1.1)(vite@8.0.16(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0))
|
||||
version: 4.1.8(@opentelemetry/api@1.9.1)(@types/node@20.19.41)(@vitest/coverage-v8@4.1.8)(@vitest/ui@4.1.8)(jsdom@29.1.1)(vite@8.0.16(@types/node@20.19.41)(esbuild@0.25.12)(jiti@2.7.0)(terser@5.48.0))
|
||||
|
||||
packages:
|
||||
|
||||
@@ -280,158 +274,158 @@ packages:
|
||||
'@emnapi/wasi-threads@1.2.1':
|
||||
resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==}
|
||||
|
||||
'@esbuild/aix-ppc64@0.28.1':
|
||||
resolution: {integrity: sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==}
|
||||
'@esbuild/aix-ppc64@0.25.12':
|
||||
resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [ppc64]
|
||||
os: [aix]
|
||||
|
||||
'@esbuild/android-arm64@0.28.1':
|
||||
resolution: {integrity: sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==}
|
||||
'@esbuild/android-arm64@0.25.12':
|
||||
resolution: {integrity: sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@esbuild/android-arm@0.28.1':
|
||||
resolution: {integrity: sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==}
|
||||
'@esbuild/android-arm@0.25.12':
|
||||
resolution: {integrity: sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
|
||||
'@esbuild/android-x64@0.28.1':
|
||||
resolution: {integrity: sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==}
|
||||
'@esbuild/android-x64@0.25.12':
|
||||
resolution: {integrity: sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [android]
|
||||
|
||||
'@esbuild/darwin-arm64@0.28.1':
|
||||
resolution: {integrity: sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==}
|
||||
'@esbuild/darwin-arm64@0.25.12':
|
||||
resolution: {integrity: sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@esbuild/darwin-x64@0.28.1':
|
||||
resolution: {integrity: sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==}
|
||||
'@esbuild/darwin-x64@0.25.12':
|
||||
resolution: {integrity: sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@esbuild/freebsd-arm64@0.28.1':
|
||||
resolution: {integrity: sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==}
|
||||
'@esbuild/freebsd-arm64@0.25.12':
|
||||
resolution: {integrity: sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [freebsd]
|
||||
|
||||
'@esbuild/freebsd-x64@0.28.1':
|
||||
resolution: {integrity: sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==}
|
||||
'@esbuild/freebsd-x64@0.25.12':
|
||||
resolution: {integrity: sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@esbuild/linux-arm64@0.28.1':
|
||||
resolution: {integrity: sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==}
|
||||
'@esbuild/linux-arm64@0.25.12':
|
||||
resolution: {integrity: sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-arm@0.28.1':
|
||||
resolution: {integrity: sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==}
|
||||
'@esbuild/linux-arm@0.25.12':
|
||||
resolution: {integrity: sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-ia32@0.28.1':
|
||||
resolution: {integrity: sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==}
|
||||
'@esbuild/linux-ia32@0.25.12':
|
||||
resolution: {integrity: sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [ia32]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-loong64@0.28.1':
|
||||
resolution: {integrity: sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==}
|
||||
'@esbuild/linux-loong64@0.25.12':
|
||||
resolution: {integrity: sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-mips64el@0.28.1':
|
||||
resolution: {integrity: sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==}
|
||||
'@esbuild/linux-mips64el@0.25.12':
|
||||
resolution: {integrity: sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [mips64el]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-ppc64@0.28.1':
|
||||
resolution: {integrity: sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==}
|
||||
'@esbuild/linux-ppc64@0.25.12':
|
||||
resolution: {integrity: sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-riscv64@0.28.1':
|
||||
resolution: {integrity: sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==}
|
||||
'@esbuild/linux-riscv64@0.25.12':
|
||||
resolution: {integrity: sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-s390x@0.28.1':
|
||||
resolution: {integrity: sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==}
|
||||
'@esbuild/linux-s390x@0.25.12':
|
||||
resolution: {integrity: sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-x64@0.28.1':
|
||||
resolution: {integrity: sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==}
|
||||
'@esbuild/linux-x64@0.25.12':
|
||||
resolution: {integrity: sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/netbsd-arm64@0.28.1':
|
||||
resolution: {integrity: sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==}
|
||||
'@esbuild/netbsd-arm64@0.25.12':
|
||||
resolution: {integrity: sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [netbsd]
|
||||
|
||||
'@esbuild/netbsd-x64@0.28.1':
|
||||
resolution: {integrity: sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==}
|
||||
'@esbuild/netbsd-x64@0.25.12':
|
||||
resolution: {integrity: sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [netbsd]
|
||||
|
||||
'@esbuild/openbsd-arm64@0.28.1':
|
||||
resolution: {integrity: sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==}
|
||||
'@esbuild/openbsd-arm64@0.25.12':
|
||||
resolution: {integrity: sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [openbsd]
|
||||
|
||||
'@esbuild/openbsd-x64@0.28.1':
|
||||
resolution: {integrity: sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==}
|
||||
'@esbuild/openbsd-x64@0.25.12':
|
||||
resolution: {integrity: sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [openbsd]
|
||||
|
||||
'@esbuild/openharmony-arm64@0.28.1':
|
||||
resolution: {integrity: sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==}
|
||||
'@esbuild/openharmony-arm64@0.25.12':
|
||||
resolution: {integrity: sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [openharmony]
|
||||
|
||||
'@esbuild/sunos-x64@0.28.1':
|
||||
resolution: {integrity: sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==}
|
||||
'@esbuild/sunos-x64@0.25.12':
|
||||
resolution: {integrity: sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [sunos]
|
||||
|
||||
'@esbuild/win32-arm64@0.28.1':
|
||||
resolution: {integrity: sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==}
|
||||
'@esbuild/win32-arm64@0.25.12':
|
||||
resolution: {integrity: sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@esbuild/win32-ia32@0.28.1':
|
||||
resolution: {integrity: sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==}
|
||||
'@esbuild/win32-ia32@0.25.12':
|
||||
resolution: {integrity: sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
|
||||
'@esbuild/win32-x64@0.28.1':
|
||||
resolution: {integrity: sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==}
|
||||
'@esbuild/win32-x64@0.25.12':
|
||||
resolution: {integrity: sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
@@ -1477,8 +1471,8 @@ packages:
|
||||
'@types/json5@0.0.29':
|
||||
resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==}
|
||||
|
||||
'@types/node@24.13.3':
|
||||
resolution: {integrity: sha512-Dh8vAsV36ig5wa9OX4pXvMc9D3Veibfw2wix0CUwYODLD8nkj9UsLjASr49nPg+2eKzxhBV+v7L8pXvT4e639Q==}
|
||||
'@types/node@20.19.41':
|
||||
resolution: {integrity: sha512-ECymXOukMnOoVkC2bb1Vc/w/836DXncOg5m8Xj1RH7xSHZJWNYY6Zh7EH477vcnD5egKNNfy2RpNOmuChhFPgQ==}
|
||||
|
||||
'@types/react-dom@19.2.3':
|
||||
resolution: {integrity: sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==}
|
||||
@@ -2186,8 +2180,8 @@ packages:
|
||||
resolution: {integrity: sha512-w+5mJ3GuFL+NjVtJlvydShqE1eN3h3PbI7/5LAsYJP/2qtuMXjfL2LpHSRqo4b4eSF5K/DH1JXKUAHSB2UW50g==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
esbuild@0.28.1:
|
||||
resolution: {integrity: sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==}
|
||||
esbuild@0.25.12:
|
||||
resolution: {integrity: sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
@@ -2345,10 +2339,6 @@ packages:
|
||||
resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
fake-indexeddb@6.2.5:
|
||||
resolution: {integrity: sha512-CGnyrvbhPlWYMngksqrSSUT1BAVP49dZocrHuK0SvtR0D5TMs5wP0o3j7jexDJW01KSadjBp1M/71o/KR3nD1w==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
fast-deep-equal@3.1.3:
|
||||
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
|
||||
|
||||
@@ -3293,11 +3283,6 @@ packages:
|
||||
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
qrcode.react@4.2.0:
|
||||
resolution: {integrity: sha512-QpgqWi8rD9DsS9EP3z7BT+5lY5SFhsqGjpgW5DY/i3mK4M9DTBNz3ErMi8BWYEfI3L0d8GIbGmcdFAS1uIRGjA==}
|
||||
peerDependencies:
|
||||
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
||||
|
||||
queue-microtask@1.2.3:
|
||||
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
|
||||
|
||||
@@ -3731,8 +3716,8 @@ packages:
|
||||
uncrypto@0.1.3:
|
||||
resolution: {integrity: sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q==}
|
||||
|
||||
undici-types@7.18.2:
|
||||
resolution: {integrity: sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==}
|
||||
undici-types@6.21.0:
|
||||
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
|
||||
|
||||
undici@7.27.2:
|
||||
resolution: {integrity: sha512-uZsKNuzQxDMUY6M3pIMvy5tvlGmtq8XJ2oLAkfRKGNu+1VQAIvLy2xIVG5ATZl5wDXl/tddByAWCizRbOme+TA==}
|
||||
@@ -4235,82 +4220,82 @@ snapshots:
|
||||
tslib: 2.8.1
|
||||
optional: true
|
||||
|
||||
'@esbuild/aix-ppc64@0.28.1':
|
||||
'@esbuild/aix-ppc64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-arm64@0.28.1':
|
||||
'@esbuild/android-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-arm@0.28.1':
|
||||
'@esbuild/android-arm@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-x64@0.28.1':
|
||||
'@esbuild/android-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/darwin-arm64@0.28.1':
|
||||
'@esbuild/darwin-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/darwin-x64@0.28.1':
|
||||
'@esbuild/darwin-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/freebsd-arm64@0.28.1':
|
||||
'@esbuild/freebsd-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/freebsd-x64@0.28.1':
|
||||
'@esbuild/freebsd-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-arm64@0.28.1':
|
||||
'@esbuild/linux-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-arm@0.28.1':
|
||||
'@esbuild/linux-arm@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-ia32@0.28.1':
|
||||
'@esbuild/linux-ia32@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-loong64@0.28.1':
|
||||
'@esbuild/linux-loong64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-mips64el@0.28.1':
|
||||
'@esbuild/linux-mips64el@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-ppc64@0.28.1':
|
||||
'@esbuild/linux-ppc64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-riscv64@0.28.1':
|
||||
'@esbuild/linux-riscv64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-s390x@0.28.1':
|
||||
'@esbuild/linux-s390x@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-x64@0.28.1':
|
||||
'@esbuild/linux-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/netbsd-arm64@0.28.1':
|
||||
'@esbuild/netbsd-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/netbsd-x64@0.28.1':
|
||||
'@esbuild/netbsd-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/openbsd-arm64@0.28.1':
|
||||
'@esbuild/openbsd-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/openbsd-x64@0.28.1':
|
||||
'@esbuild/openbsd-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/openharmony-arm64@0.28.1':
|
||||
'@esbuild/openharmony-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/sunos-x64@0.28.1':
|
||||
'@esbuild/sunos-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-arm64@0.28.1':
|
||||
'@esbuild/win32-arm64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-ia32@0.28.1':
|
||||
'@esbuild/win32-ia32@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-x64@0.28.1':
|
||||
'@esbuild/win32-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@eslint-community/eslint-utils@4.9.1(eslint@9.39.4(jiti@2.7.0))':
|
||||
@@ -4825,7 +4810,7 @@ snapshots:
|
||||
dependencies:
|
||||
'@sentry/core': 10.61.0
|
||||
|
||||
'@sentry/nextjs@10.61.0(@opentelemetry/core@2.8.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.8.0(@opentelemetry/api@1.9.1))(next@16.2.7(@babel/core@7.29.7)(@opentelemetry/api@1.9.1)(@playwright/test@1.61.1)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react@19.2.4)(webpack@5.108.0(esbuild@0.28.1))':
|
||||
'@sentry/nextjs@10.61.0(@opentelemetry/core@2.8.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.8.0(@opentelemetry/api@1.9.1))(next@16.2.7(@babel/core@7.29.7)(@opentelemetry/api@1.9.1)(@playwright/test@1.61.1)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react@19.2.4)(webpack@5.108.0(esbuild@0.25.12))':
|
||||
dependencies:
|
||||
'@opentelemetry/api': 1.9.1
|
||||
'@rollup/plugin-commonjs': 28.0.1(rollup@4.62.2)
|
||||
@@ -4837,7 +4822,7 @@ snapshots:
|
||||
'@sentry/opentelemetry': 10.61.0(@opentelemetry/api@1.9.1)(@opentelemetry/core@2.8.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.8.0(@opentelemetry/api@1.9.1))
|
||||
'@sentry/react': 10.61.0(react@19.2.4)
|
||||
'@sentry/vercel-edge': 10.61.0
|
||||
'@sentry/webpack-plugin': 5.3.0(webpack@5.108.0(esbuild@0.28.1))
|
||||
'@sentry/webpack-plugin': 5.3.0(webpack@5.108.0(esbuild@0.25.12))
|
||||
next: 16.2.7(@babel/core@7.29.7)(@opentelemetry/api@1.9.1)(@playwright/test@1.61.1)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
|
||||
rollup: 4.62.2
|
||||
stacktrace-parser: 0.1.11
|
||||
@@ -4918,10 +4903,10 @@ snapshots:
|
||||
'@opentelemetry/api': 1.9.1
|
||||
'@sentry/core': 10.61.0
|
||||
|
||||
'@sentry/webpack-plugin@5.3.0(webpack@5.108.0(esbuild@0.28.1))':
|
||||
'@sentry/webpack-plugin@5.3.0(webpack@5.108.0(esbuild@0.25.12))':
|
||||
dependencies:
|
||||
'@sentry/bundler-plugin-core': 5.3.0
|
||||
webpack: 5.108.0(esbuild@0.28.1)
|
||||
webpack: 5.108.0(esbuild@0.25.12)
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- supports-color
|
||||
@@ -4940,7 +4925,7 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- browserslist
|
||||
|
||||
'@serwist/turbopack@9.5.11(esbuild@0.28.1)(next@16.2.7(@babel/core@7.29.7)(@opentelemetry/api@1.9.1)(@playwright/test@1.61.1)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react@19.2.4)(typescript@5.9.3)':
|
||||
'@serwist/turbopack@9.5.11(esbuild@0.25.12)(next@16.2.7(@babel/core@7.29.7)(@opentelemetry/api@1.9.1)(@playwright/test@1.61.1)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react@19.2.4)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@serwist/build': 9.5.11(browserslist@4.28.2)(typescript@5.9.3)
|
||||
'@serwist/utils': 9.5.11(browserslist@4.28.2)
|
||||
@@ -4954,7 +4939,7 @@ snapshots:
|
||||
serwist: 9.5.11(browserslist@4.28.2)(typescript@5.9.3)
|
||||
zod: 4.4.1
|
||||
optionalDependencies:
|
||||
esbuild: 0.28.1
|
||||
esbuild: 0.25.12
|
||||
typescript: 5.9.3
|
||||
transitivePeerDependencies:
|
||||
- '@swc/helpers'
|
||||
@@ -5134,9 +5119,9 @@ snapshots:
|
||||
|
||||
'@types/json5@0.0.29': {}
|
||||
|
||||
'@types/node@24.13.3':
|
||||
'@types/node@20.19.41':
|
||||
dependencies:
|
||||
undici-types: 7.18.2
|
||||
undici-types: 6.21.0
|
||||
|
||||
'@types/react-dom@19.2.3(@types/react@19.2.16)':
|
||||
dependencies:
|
||||
@@ -5327,7 +5312,7 @@ snapshots:
|
||||
obug: 2.1.2
|
||||
std-env: 4.1.0
|
||||
tinyrainbow: 3.1.0
|
||||
vitest: 4.1.8(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(@vitest/coverage-v8@4.1.8)(@vitest/ui@4.1.8)(jsdom@29.1.1)(vite@8.0.16(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0))
|
||||
vitest: 4.1.8(@opentelemetry/api@1.9.1)(@types/node@20.19.41)(@vitest/coverage-v8@4.1.8)(@vitest/ui@4.1.8)(jsdom@29.1.1)(vite@8.0.16(@types/node@20.19.41)(esbuild@0.25.12)(jiti@2.7.0)(terser@5.48.0))
|
||||
|
||||
'@vitest/expect@4.1.8':
|
||||
dependencies:
|
||||
@@ -5338,13 +5323,13 @@ snapshots:
|
||||
chai: 6.2.2
|
||||
tinyrainbow: 3.1.0
|
||||
|
||||
'@vitest/mocker@4.1.8(vite@8.0.16(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0))':
|
||||
'@vitest/mocker@4.1.8(vite@8.0.16(@types/node@20.19.41)(esbuild@0.25.12)(jiti@2.7.0)(terser@5.48.0))':
|
||||
dependencies:
|
||||
'@vitest/spy': 4.1.8
|
||||
estree-walker: 3.0.3
|
||||
magic-string: 0.30.21
|
||||
optionalDependencies:
|
||||
vite: 8.0.16(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)
|
||||
vite: 8.0.16(@types/node@20.19.41)(esbuild@0.25.12)(jiti@2.7.0)(terser@5.48.0)
|
||||
|
||||
'@vitest/pretty-format@4.1.8':
|
||||
dependencies:
|
||||
@@ -5373,7 +5358,7 @@ snapshots:
|
||||
sirv: 3.0.2
|
||||
tinyglobby: 0.2.17
|
||||
tinyrainbow: 3.1.0
|
||||
vitest: 4.1.8(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(@vitest/coverage-v8@4.1.8)(@vitest/ui@4.1.8)(jsdom@29.1.1)(vite@8.0.16(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0))
|
||||
vitest: 4.1.8(@opentelemetry/api@1.9.1)(@types/node@20.19.41)(@vitest/coverage-v8@4.1.8)(@vitest/ui@4.1.8)(jsdom@29.1.1)(vite@8.0.16(@types/node@20.19.41)(esbuild@0.25.12)(jiti@2.7.0)(terser@5.48.0))
|
||||
|
||||
'@vitest/utils@4.1.8':
|
||||
dependencies:
|
||||
@@ -5951,34 +5936,34 @@ snapshots:
|
||||
is-date-object: 1.1.0
|
||||
is-symbol: 1.1.1
|
||||
|
||||
esbuild@0.28.1:
|
||||
esbuild@0.25.12:
|
||||
optionalDependencies:
|
||||
'@esbuild/aix-ppc64': 0.28.1
|
||||
'@esbuild/android-arm': 0.28.1
|
||||
'@esbuild/android-arm64': 0.28.1
|
||||
'@esbuild/android-x64': 0.28.1
|
||||
'@esbuild/darwin-arm64': 0.28.1
|
||||
'@esbuild/darwin-x64': 0.28.1
|
||||
'@esbuild/freebsd-arm64': 0.28.1
|
||||
'@esbuild/freebsd-x64': 0.28.1
|
||||
'@esbuild/linux-arm': 0.28.1
|
||||
'@esbuild/linux-arm64': 0.28.1
|
||||
'@esbuild/linux-ia32': 0.28.1
|
||||
'@esbuild/linux-loong64': 0.28.1
|
||||
'@esbuild/linux-mips64el': 0.28.1
|
||||
'@esbuild/linux-ppc64': 0.28.1
|
||||
'@esbuild/linux-riscv64': 0.28.1
|
||||
'@esbuild/linux-s390x': 0.28.1
|
||||
'@esbuild/linux-x64': 0.28.1
|
||||
'@esbuild/netbsd-arm64': 0.28.1
|
||||
'@esbuild/netbsd-x64': 0.28.1
|
||||
'@esbuild/openbsd-arm64': 0.28.1
|
||||
'@esbuild/openbsd-x64': 0.28.1
|
||||
'@esbuild/openharmony-arm64': 0.28.1
|
||||
'@esbuild/sunos-x64': 0.28.1
|
||||
'@esbuild/win32-arm64': 0.28.1
|
||||
'@esbuild/win32-ia32': 0.28.1
|
||||
'@esbuild/win32-x64': 0.28.1
|
||||
'@esbuild/aix-ppc64': 0.25.12
|
||||
'@esbuild/android-arm': 0.25.12
|
||||
'@esbuild/android-arm64': 0.25.12
|
||||
'@esbuild/android-x64': 0.25.12
|
||||
'@esbuild/darwin-arm64': 0.25.12
|
||||
'@esbuild/darwin-x64': 0.25.12
|
||||
'@esbuild/freebsd-arm64': 0.25.12
|
||||
'@esbuild/freebsd-x64': 0.25.12
|
||||
'@esbuild/linux-arm': 0.25.12
|
||||
'@esbuild/linux-arm64': 0.25.12
|
||||
'@esbuild/linux-ia32': 0.25.12
|
||||
'@esbuild/linux-loong64': 0.25.12
|
||||
'@esbuild/linux-mips64el': 0.25.12
|
||||
'@esbuild/linux-ppc64': 0.25.12
|
||||
'@esbuild/linux-riscv64': 0.25.12
|
||||
'@esbuild/linux-s390x': 0.25.12
|
||||
'@esbuild/linux-x64': 0.25.12
|
||||
'@esbuild/netbsd-arm64': 0.25.12
|
||||
'@esbuild/netbsd-x64': 0.25.12
|
||||
'@esbuild/openbsd-arm64': 0.25.12
|
||||
'@esbuild/openbsd-x64': 0.25.12
|
||||
'@esbuild/openharmony-arm64': 0.25.12
|
||||
'@esbuild/sunos-x64': 0.25.12
|
||||
'@esbuild/win32-arm64': 0.25.12
|
||||
'@esbuild/win32-ia32': 0.25.12
|
||||
'@esbuild/win32-x64': 0.25.12
|
||||
|
||||
escalade@3.2.0: {}
|
||||
|
||||
@@ -6208,8 +6193,6 @@ snapshots:
|
||||
|
||||
expect-type@1.3.0: {}
|
||||
|
||||
fake-indexeddb@6.2.5: {}
|
||||
|
||||
fast-deep-equal@3.1.3: {}
|
||||
|
||||
fast-glob@3.3.1:
|
||||
@@ -6585,7 +6568,7 @@ snapshots:
|
||||
|
||||
jest-worker@27.5.1:
|
||||
dependencies:
|
||||
'@types/node': 24.13.3
|
||||
'@types/node': 20.19.41
|
||||
merge-stream: 2.0.0
|
||||
supports-color: 8.1.1
|
||||
|
||||
@@ -6799,15 +6782,15 @@ snapshots:
|
||||
|
||||
minimist@1.2.8: {}
|
||||
|
||||
minimizer-webpack-plugin@5.6.1(esbuild@0.28.1)(webpack@5.108.0(esbuild@0.28.1)):
|
||||
minimizer-webpack-plugin@5.6.1(esbuild@0.25.12)(webpack@5.108.0(esbuild@0.25.12)):
|
||||
dependencies:
|
||||
'@jridgewell/trace-mapping': 0.3.31
|
||||
jest-worker: 27.5.1
|
||||
schema-utils: 4.3.3
|
||||
terser: 5.48.0
|
||||
webpack: 5.108.0(esbuild@0.28.1)
|
||||
webpack: 5.108.0(esbuild@0.25.12)
|
||||
optionalDependencies:
|
||||
esbuild: 0.28.1
|
||||
esbuild: 0.25.12
|
||||
|
||||
minipass@7.1.3: {}
|
||||
|
||||
@@ -7093,10 +7076,6 @@ snapshots:
|
||||
|
||||
punycode@2.3.1: {}
|
||||
|
||||
qrcode.react@4.2.0(react@19.2.4):
|
||||
dependencies:
|
||||
react: 19.2.4
|
||||
|
||||
queue-microtask@1.2.3: {}
|
||||
|
||||
quick-format-unescaped@4.0.4: {}
|
||||
@@ -7640,7 +7619,7 @@ snapshots:
|
||||
|
||||
uncrypto@0.1.3: {}
|
||||
|
||||
undici-types@7.18.2: {}
|
||||
undici-types@6.21.0: {}
|
||||
|
||||
undici@7.27.2: {}
|
||||
|
||||
@@ -7704,7 +7683,7 @@ snapshots:
|
||||
|
||||
uuid@8.3.2: {}
|
||||
|
||||
vite@8.0.16(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0):
|
||||
vite@8.0.16(@types/node@20.19.41)(esbuild@0.25.12)(jiti@2.7.0)(terser@5.48.0):
|
||||
dependencies:
|
||||
lightningcss: 1.32.0
|
||||
picomatch: 4.0.4
|
||||
@@ -7712,16 +7691,16 @@ snapshots:
|
||||
rolldown: 1.0.3
|
||||
tinyglobby: 0.2.17
|
||||
optionalDependencies:
|
||||
'@types/node': 24.13.3
|
||||
esbuild: 0.28.1
|
||||
'@types/node': 20.19.41
|
||||
esbuild: 0.25.12
|
||||
fsevents: 2.3.3
|
||||
jiti: 2.7.0
|
||||
terser: 5.48.0
|
||||
|
||||
vitest@4.1.8(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(@vitest/coverage-v8@4.1.8)(@vitest/ui@4.1.8)(jsdom@29.1.1)(vite@8.0.16(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)):
|
||||
vitest@4.1.8(@opentelemetry/api@1.9.1)(@types/node@20.19.41)(@vitest/coverage-v8@4.1.8)(@vitest/ui@4.1.8)(jsdom@29.1.1)(vite@8.0.16(@types/node@20.19.41)(esbuild@0.25.12)(jiti@2.7.0)(terser@5.48.0)):
|
||||
dependencies:
|
||||
'@vitest/expect': 4.1.8
|
||||
'@vitest/mocker': 4.1.8(vite@8.0.16(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0))
|
||||
'@vitest/mocker': 4.1.8(vite@8.0.16(@types/node@20.19.41)(esbuild@0.25.12)(jiti@2.7.0)(terser@5.48.0))
|
||||
'@vitest/pretty-format': 4.1.8
|
||||
'@vitest/runner': 4.1.8
|
||||
'@vitest/snapshot': 4.1.8
|
||||
@@ -7738,11 +7717,11 @@ snapshots:
|
||||
tinyexec: 1.2.4
|
||||
tinyglobby: 0.2.17
|
||||
tinyrainbow: 3.1.0
|
||||
vite: 8.0.16(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)
|
||||
vite: 8.0.16(@types/node@20.19.41)(esbuild@0.25.12)(jiti@2.7.0)(terser@5.48.0)
|
||||
why-is-node-running: 2.3.0
|
||||
optionalDependencies:
|
||||
'@opentelemetry/api': 1.9.1
|
||||
'@types/node': 24.13.3
|
||||
'@types/node': 20.19.41
|
||||
'@vitest/coverage-v8': 4.1.8(vitest@4.1.8)
|
||||
'@vitest/ui': 4.1.8(vitest@4.1.8)
|
||||
jsdom: 29.1.1
|
||||
@@ -7765,7 +7744,7 @@ snapshots:
|
||||
|
||||
webpack-sources@3.5.0: {}
|
||||
|
||||
webpack@5.108.0(esbuild@0.28.1):
|
||||
webpack@5.108.0(esbuild@0.25.12):
|
||||
dependencies:
|
||||
'@types/estree': 1.0.9
|
||||
'@types/json-schema': 7.0.15
|
||||
@@ -7783,7 +7762,7 @@ snapshots:
|
||||
graceful-fs: 4.2.11
|
||||
loader-runner: 4.3.2
|
||||
mime-db: 1.54.0
|
||||
minimizer-webpack-plugin: 5.6.1(esbuild@0.28.1)(webpack@5.108.0(esbuild@0.28.1))
|
||||
minimizer-webpack-plugin: 5.6.1(esbuild@0.25.12)(webpack@5.108.0(esbuild@0.25.12))
|
||||
neo-async: 2.6.2
|
||||
schema-utils: 4.3.3
|
||||
tapable: 2.3.3
|
||||
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 97 KiB |
|
Before Width: | Height: | Size: 217 KiB |
|
Before Width: | Height: | Size: 179 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 482 KiB |
|
Before Width: | Height: | Size: 581 KiB |
|
Before Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
Before Width: | Height: | Size: 814 KiB |
|
Before Width: | Height: | Size: 652 KiB |
|
Before Width: | Height: | Size: 907 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 351 KiB After Width: | Height: | Size: 351 KiB |
|
Before Width: | Height: | Size: 577 KiB After Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 342 KiB After Width: | Height: | Size: 2.1 MiB |
|
After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 490 KiB |
@@ -11,13 +11,13 @@
|
||||
"lang": "en",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/images/icons/Icon-192.png?v=20260724",
|
||||
"src": "/images/icons/Icon-192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "/images/icons/Icon-512.png?v=20260724",
|
||||
"src": "/images/icons/Icon-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
const workflowUrl = new URL(
|
||||
"../../../.gitea/workflows/domestic-test.yml",
|
||||
import.meta.url,
|
||||
);
|
||||
const deployScriptUrl = new URL(
|
||||
"../../server/deploy-domestic-test-archive.sh",
|
||||
import.meta.url,
|
||||
);
|
||||
|
||||
test("domestic frontend workflow is manual and registry-free", async () => {
|
||||
const workflow = await readFile(workflowUrl, "utf8");
|
||||
|
||||
assert.match(workflow, /workflow_dispatch:/);
|
||||
assert.doesNotMatch(workflow, /\bpush:/);
|
||||
assert.doesNotMatch(workflow, /REGISTRY_IMAGE/);
|
||||
assert.match(workflow, /docker save/);
|
||||
assert.match(workflow, /DOMESTIC_TEST_SSH_PRIVATE_KEY_B64/);
|
||||
assert.match(workflow, /base64 -d/);
|
||||
});
|
||||
|
||||
test("domestic frontend workflow pins the China test API and isolated port", async () => {
|
||||
const workflow = await readFile(workflowUrl, "utf8");
|
||||
const deployScript = await readFile(deployScriptUrl, "utf8");
|
||||
|
||||
assert.match(workflow, /https:\/\/testapi\.banlv-ai\.com/);
|
||||
assert.match(workflow, /wss:\/\/testapi\.banlv-ai\.com\/ws/);
|
||||
assert.match(workflow, /9135/);
|
||||
assert.match(deployScript, /127\.0\.0\.1:\$HOST_PORT/);
|
||||
assert.match(deployScript, /cozsweet-frontend-domestic-test/);
|
||||
});
|
||||
@@ -1,68 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
|
||||
import {
|
||||
findMissingOperations,
|
||||
normalizePath,
|
||||
} from "../openapi-contract.mjs";
|
||||
|
||||
describe("OpenAPI contract comparison", () => {
|
||||
it("accepts matching paths and methods", () => {
|
||||
const missing = findMissingOperations(
|
||||
{
|
||||
chatHistory: { method: "get", path: "/api/chat/history" },
|
||||
unlockAlbum: {
|
||||
method: "post",
|
||||
path: "/api/private-zone/albums/{albumId}/unlock",
|
||||
},
|
||||
},
|
||||
{
|
||||
paths: {
|
||||
"/api/chat/history": { get: {} },
|
||||
"/api/private-zone/albums/{album_id}/unlock/": { post: {} },
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
assert.deepEqual(missing, []);
|
||||
});
|
||||
|
||||
it("reports missing paths and methods with operation ids", () => {
|
||||
const missing = findMissingOperations(
|
||||
{
|
||||
chatHistory: { method: "get", path: "/api/chat/history" },
|
||||
chatSend: { method: "post", path: "/api/chat/send" },
|
||||
},
|
||||
{ paths: { "/api/chat/history": { post: {} } } },
|
||||
);
|
||||
|
||||
assert.deepEqual(missing, [
|
||||
{
|
||||
operationId: "chatHistory",
|
||||
method: "get",
|
||||
path: "/api/chat/history",
|
||||
reason: "method is missing",
|
||||
},
|
||||
{
|
||||
operationId: "chatSend",
|
||||
method: "post",
|
||||
path: "/api/chat/send",
|
||||
reason: "path is missing",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("normalizes trailing slashes and path parameter names", () => {
|
||||
assert.equal(
|
||||
normalizePath("/api/albums/{album_id}/unlock/"),
|
||||
"/api/albums/{}/unlock",
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects documents without OpenAPI paths", () => {
|
||||
assert.throws(
|
||||
() => findMissingOperations({}, {}),
|
||||
/does not contain a paths object/u,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,37 +0,0 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
|
||||
import {
|
||||
findMissingOperations,
|
||||
loadJsonSource,
|
||||
} from "./openapi-contract.mjs";
|
||||
|
||||
const source = process.argv[2] ?? process.env.BACKEND_OPENAPI_SOURCE;
|
||||
if (!source) {
|
||||
throw new Error(
|
||||
"Provide an OpenAPI JSON path/URL or set BACKEND_OPENAPI_SOURCE",
|
||||
);
|
||||
}
|
||||
|
||||
const contractUrl = new URL(
|
||||
"../../src/data/services/api/api_contract.json",
|
||||
import.meta.url,
|
||||
);
|
||||
const [contract, openApiDocument] = await Promise.all([
|
||||
readFile(contractUrl, "utf8").then(JSON.parse),
|
||||
loadJsonSource(source),
|
||||
]);
|
||||
const missing = findMissingOperations(contract, openApiDocument);
|
||||
|
||||
if (missing.length > 0) {
|
||||
const details = missing
|
||||
.map(
|
||||
({ operationId, method, path, reason }) =>
|
||||
`- ${operationId}: ${method.toUpperCase()} ${path} (${reason})`,
|
||||
)
|
||||
.join("\n");
|
||||
throw new Error(`Backend OpenAPI is missing frontend operations:\n${details}`);
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Backend OpenAPI covers all ${Object.keys(contract).length} frontend operations.`,
|
||||
);
|
||||
@@ -1,51 +0,0 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
export async function loadJsonSource(source) {
|
||||
if (/^https?:\/\//u.test(source)) {
|
||||
const response = await fetch(source, {
|
||||
headers: { accept: "application/json" },
|
||||
signal: AbortSignal.timeout(15_000),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Unable to load OpenAPI document: ${response.status} ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
return response.json();
|
||||
}
|
||||
|
||||
const content = await readFile(resolve(source), "utf8");
|
||||
return JSON.parse(content);
|
||||
}
|
||||
|
||||
export function findMissingOperations(contract, openApiDocument) {
|
||||
const openApiPaths = openApiDocument?.paths;
|
||||
if (!openApiPaths || typeof openApiPaths !== "object") {
|
||||
throw new Error("OpenAPI document does not contain a paths object");
|
||||
}
|
||||
|
||||
const normalizedPaths = new Map(
|
||||
Object.entries(openApiPaths).map(([path, pathItem]) => [
|
||||
normalizePath(path),
|
||||
pathItem,
|
||||
]),
|
||||
);
|
||||
|
||||
return Object.entries(contract).flatMap(([operationId, operation]) => {
|
||||
const method = operation.method.toLowerCase();
|
||||
const pathItem = normalizedPaths.get(normalizePath(operation.path));
|
||||
if (!pathItem) {
|
||||
return [{ operationId, ...operation, reason: "path is missing" }];
|
||||
}
|
||||
if (!pathItem[method]) {
|
||||
return [{ operationId, ...operation, reason: "method is missing" }];
|
||||
}
|
||||
return [];
|
||||
});
|
||||
}
|
||||
|
||||
export function normalizePath(path) {
|
||||
const withoutTrailingSlash = path.length > 1 ? path.replace(/\/+$/u, "") : path;
|
||||
return withoutTrailingSlash.replace(/\{[^/{}]+\}/gu, "{}");
|
||||
}
|
||||
@@ -49,6 +49,8 @@ echo "=== compose project: $COMPOSE_PROJECT_NAME ==="
|
||||
"${COMPOSE[@]}" up -d --remove-orphans --no-build web
|
||||
"${COMPOSE[@]}" ps
|
||||
|
||||
docker image prune -f
|
||||
|
||||
prune_project_images() {
|
||||
local retain_count="$1"
|
||||
if ! [[ "$retain_count" =~ ^[0-9]+$ ]] || [ "$retain_count" -le 0 ]; then
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ARCHIVE="${1:-}"
|
||||
IMAGE="${2:-}"
|
||||
ENV_FILE="${3:-}"
|
||||
HOST_PORT="${4:-9135}"
|
||||
CONTAINER_NAME="cozsweet-frontend-domestic-test"
|
||||
INTERNAL_PORT="3000"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVICE_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
SHARED_ROOT="$SERVICE_ROOT/shared"
|
||||
RELEASE_ROOT="$SERVICE_ROOT/releases/docker"
|
||||
|
||||
if [ -z "$ARCHIVE" ] || [ -z "$IMAGE" ] || [ -z "$ENV_FILE" ]; then
|
||||
echo "Usage: $0 <image-archive> <image> <env-file> [host-port]" >&2
|
||||
exit 64
|
||||
fi
|
||||
if [ "$HOST_PORT" != "9135" ]; then
|
||||
echo "Domestic frontend test must use isolated host port 9135" >&2
|
||||
exit 64
|
||||
fi
|
||||
case "$ENV_FILE" in
|
||||
"$SHARED_ROOT"/*) ;;
|
||||
*)
|
||||
echo "Environment file must be stored under $SHARED_ROOT" >&2
|
||||
exit 64
|
||||
;;
|
||||
esac
|
||||
if [ ! -s "$ARCHIVE" ] || [ ! -s "$ENV_FILE" ]; then
|
||||
echo "Image archive or environment file is missing" >&2
|
||||
exit 66
|
||||
fi
|
||||
|
||||
mkdir -p "$RELEASE_ROOT"
|
||||
chmod 700 "$SHARED_ROOT"
|
||||
gzip -dc "$ARCHIVE" | docker load >/dev/null
|
||||
docker image inspect "$IMAGE" >/dev/null
|
||||
|
||||
old_image_id=""
|
||||
old_image_ref=""
|
||||
if docker container inspect "$CONTAINER_NAME" >/dev/null 2>&1; then
|
||||
old_image_id="$(docker inspect -f '{{.Image}}' "$CONTAINER_NAME")"
|
||||
old_image_ref="$(docker inspect -f '{{.Config.Image}}' "$CONTAINER_NAME")"
|
||||
elif ss -ltnH "sport = :$HOST_PORT" 2>/dev/null | grep -q .; then
|
||||
echo "Host port $HOST_PORT is already used by another service" >&2
|
||||
exit 69
|
||||
fi
|
||||
|
||||
run_container() {
|
||||
local image_ref="$1"
|
||||
docker run -d \
|
||||
--name "$CONTAINER_NAME" \
|
||||
--restart unless-stopped \
|
||||
-p "127.0.0.1:$HOST_PORT:$INTERNAL_PORT" \
|
||||
--env-file "$ENV_FILE" \
|
||||
-e "PORT=$INTERNAL_PORT" \
|
||||
"$image_ref" >/dev/null
|
||||
}
|
||||
|
||||
wait_healthy() {
|
||||
local deadline=$((SECONDS + 180))
|
||||
while [ "$SECONDS" -le "$deadline" ]; do
|
||||
state="$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' "$CONTAINER_NAME" 2>/dev/null || true)"
|
||||
status="$(curl -sS -o /dev/null -w '%{http_code}' "http://127.0.0.1:$HOST_PORT/" 2>/dev/null || true)"
|
||||
if [[ "$status" =~ ^(200|204|301|302|303|307|308)$ ]] && { [ "$state" = "healthy" ] || [ "$state" = "running" ]; }; then
|
||||
return 0
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
docker rm -f "$CONTAINER_NAME" >/dev/null 2>&1 || true
|
||||
deployment_ok="1"
|
||||
if ! run_container "$IMAGE"; then
|
||||
deployment_ok="0"
|
||||
elif ! wait_healthy; then
|
||||
deployment_ok="0"
|
||||
fi
|
||||
|
||||
if [ "$deployment_ok" != "1" ]; then
|
||||
docker logs --tail 120 "$CONTAINER_NAME" >&2 || true
|
||||
docker rm -f "$CONTAINER_NAME" >/dev/null 2>&1 || true
|
||||
if [ -n "$old_image_id" ] && docker image inspect "$old_image_id" >/dev/null 2>&1; then
|
||||
echo "New container failed health checks; restoring previous image" >&2
|
||||
run_container "$old_image_id"
|
||||
wait_healthy || true
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
created_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
image_id="$(docker image inspect "$IMAGE" -f '{{.Id}}')"
|
||||
record="{\"createdAt\":\"$created_at\",\"environment\":\"domestic-test\",\"image\":\"$IMAGE\",\"imageId\":\"$image_id\",\"container\":\"$CONTAINER_NAME\",\"hostPort\":$HOST_PORT}"
|
||||
if [ -f "$RELEASE_ROOT/current.json" ]; then
|
||||
cp "$RELEASE_ROOT/current.json" "$RELEASE_ROOT/previous.json"
|
||||
fi
|
||||
printf '%s\n' "$record" > "$RELEASE_ROOT/current.json"
|
||||
printf '%s\n' "$record" >> "$RELEASE_ROOT/releases.jsonl"
|
||||
|
||||
echo "Domestic frontend test is healthy"
|
||||
echo "container=$CONTAINER_NAME"
|
||||
echo "host_port=$HOST_PORT"
|
||||
echo "image=$IMAGE"
|
||||
if [ -n "$old_image_ref" ]; then
|
||||
echo "previous_image=$old_image_ref"
|
||||
fi
|
||||
@@ -48,13 +48,7 @@ describe("shared Tailwind components", () => {
|
||||
|
||||
it("renders CharacterAvatar with dynamic sizing and image utilities", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<CharacterAvatar
|
||||
src="/images/avatar/maya.png"
|
||||
alt="Maya Tan"
|
||||
size={48}
|
||||
imageSize={96}
|
||||
className="custom-avatar"
|
||||
/>,
|
||||
<CharacterAvatar size={48} imageSize={96} className="custom-avatar" />,
|
||||
);
|
||||
|
||||
expect(html).toContain("inline-flex");
|
||||
@@ -62,7 +56,7 @@ describe("shared Tailwind components", () => {
|
||||
expect(html).toContain("width:48px");
|
||||
expect(html).toContain("height:48px");
|
||||
expect(html).toContain("size-full object-cover");
|
||||
expect(html).toContain("%2Fimages%2Favatar%2Fmaya.png");
|
||||
expect(html).toContain("%2Fimages%2Fchat%2Fpic-chat-elio.png");
|
||||
});
|
||||
|
||||
it("renders UserMessageAvatar custom and fallback images", () => {
|
||||
@@ -77,36 +71,6 @@ describe("shared Tailwind components", () => {
|
||||
expect(userHtml).toContain("size-full object-cover");
|
||||
expect(userHtml).toContain("%2Favatar.png");
|
||||
expect(guestHtml).toContain('aria-label="Guest avatar"');
|
||||
expect(guestHtml).toContain("%2Fimages%2Favatar%2Fplaceholder.png");
|
||||
});
|
||||
|
||||
it("renders interactive avatars as accessible buttons", () => {
|
||||
const characterHtml = renderToStaticMarkup(
|
||||
<CharacterAvatar
|
||||
src="/images/avatar/elio.png"
|
||||
alt="Elio Silvestri"
|
||||
actionLabel="Open Elio's private zone"
|
||||
analyticsKey="chat.open_private_zone_from_avatar"
|
||||
onClick={() => undefined}
|
||||
/>,
|
||||
);
|
||||
const userHtml = renderToStaticMarkup(
|
||||
<UserMessageAvatar
|
||||
actionLabel="Open profile"
|
||||
analyticsKey="chat.open_profile_from_avatar"
|
||||
onClick={() => undefined}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(characterHtml).toContain('<button type="button"');
|
||||
expect(characterHtml).toContain(
|
||||
'aria-label="Open Elio's private zone"',
|
||||
);
|
||||
expect(characterHtml).toContain(
|
||||
'data-analytics-key="chat.open_private_zone_from_avatar"',
|
||||
);
|
||||
expect(userHtml).toContain('<button type="button"');
|
||||
expect(userHtml).toContain('aria-label="Open profile"');
|
||||
expect(userHtml).toContain("focus-visible:outline-3");
|
||||
expect(guestHtml).toContain("%2Fimages%2Fchat%2Fpic-chat-guest.png");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
export type AvatarInteractionProps =
|
||||
| {
|
||||
onClick?: undefined;
|
||||
actionLabel?: never;
|
||||
analyticsKey?: never;
|
||||
}
|
||||
| {
|
||||
onClick: () => void;
|
||||
actionLabel: string;
|
||||
analyticsKey?: string;
|
||||
};
|
||||
@@ -3,30 +3,22 @@
|
||||
import Image from "next/image";
|
||||
import type { CSSProperties } from "react";
|
||||
|
||||
import type { AvatarInteractionProps } from "./avatar-interaction";
|
||||
|
||||
interface CharacterAvatarVisualProps {
|
||||
src: string;
|
||||
alt: string;
|
||||
export interface CharacterAvatarProps {
|
||||
src?: string;
|
||||
alt?: string;
|
||||
className?: string;
|
||||
size?: number | string;
|
||||
imageSize?: number;
|
||||
priority?: boolean;
|
||||
}
|
||||
|
||||
export type CharacterAvatarProps = CharacterAvatarVisualProps &
|
||||
AvatarInteractionProps;
|
||||
|
||||
export function CharacterAvatar({
|
||||
src,
|
||||
alt,
|
||||
src = "/images/chat/pic-chat-elio.png",
|
||||
alt = "Elio Silvestri",
|
||||
className,
|
||||
size = 43,
|
||||
imageSize,
|
||||
priority = false,
|
||||
onClick,
|
||||
actionLabel,
|
||||
analyticsKey,
|
||||
}: CharacterAvatarProps) {
|
||||
const resolvedImageSize =
|
||||
imageSize ?? (typeof size === "number" ? size : 96);
|
||||
@@ -35,45 +27,24 @@ export function CharacterAvatar({
|
||||
height: size,
|
||||
};
|
||||
|
||||
const avatarClassName = [
|
||||
"inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full border-0 bg-(--color-avatar-border,#fbf3f5)",
|
||||
onClick
|
||||
? "cursor-pointer p-0 transition-transform duration-150 focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-accent active:scale-96"
|
||||
: undefined,
|
||||
className,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" ");
|
||||
const image = (
|
||||
<Image
|
||||
src={src}
|
||||
alt={alt}
|
||||
width={resolvedImageSize}
|
||||
height={resolvedImageSize}
|
||||
priority={priority}
|
||||
className="size-full object-cover"
|
||||
/>
|
||||
);
|
||||
|
||||
if (onClick) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={avatarClassName}
|
||||
style={style}
|
||||
aria-label={actionLabel}
|
||||
data-analytics-key={analyticsKey}
|
||||
data-analytics-label={actionLabel}
|
||||
onClick={onClick}
|
||||
>
|
||||
{image}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<span className={avatarClassName} style={style}>
|
||||
{image}
|
||||
<span
|
||||
className={[
|
||||
"inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-(--color-avatar-border,#fbf3f5)",
|
||||
className,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" ")}
|
||||
style={style}
|
||||
>
|
||||
<Image
|
||||
src={src}
|
||||
alt={alt}
|
||||
width={resolvedImageSize}
|
||||
height={resolvedImageSize}
|
||||
priority={priority}
|
||||
className="size-full object-cover"
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
/* @vitest-environment jsdom */
|
||||
|
||||
import { act } from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { BrowserDetector } from "@/utils/browser-detect";
|
||||
import { PlatformDetector } from "@/utils/platform-detect";
|
||||
import { pwaUtil } from "@/utils/pwa";
|
||||
|
||||
import { FavoriteEntryButton } from "../favorite-entry-button";
|
||||
|
||||
describe("FavoriteEntryButton install flow", () => {
|
||||
let container: HTMLDivElement;
|
||||
let root: Root;
|
||||
|
||||
beforeEach(() => {
|
||||
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean })
|
||||
.IS_REACT_ACT_ENVIRONMENT = true;
|
||||
window.localStorage.setItem("cozsweet:favorite_entry", "1");
|
||||
vi.spyOn(BrowserDetector, "isInAppBrowser").mockReturnValue(false);
|
||||
vi.spyOn(pwaUtil, "isInstalled").mockReturnValue(false);
|
||||
vi.spyOn(pwaUtil, "prepareInstallPrompt").mockImplementation(() => undefined);
|
||||
vi.spyOn(pwaUtil, "subscribe").mockReturnValue(() => undefined);
|
||||
container = document.createElement("div");
|
||||
document.body.append(container);
|
||||
root = createRoot(container);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
act(() => root.unmount());
|
||||
container.remove();
|
||||
window.localStorage.clear();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("shows Download on iOS and opens Safari add-to-home instructions", () => {
|
||||
vi.spyOn(PlatformDetector, "isIOS").mockReturnValue(true);
|
||||
vi.spyOn(PlatformDetector, "isAndroid").mockReturnValue(false);
|
||||
|
||||
renderButton();
|
||||
const downloadButton = getButton("Download");
|
||||
act(() => downloadButton.click());
|
||||
|
||||
expect(container.querySelector('[role="dialog"]')).not.toBeNull();
|
||||
expect(container.textContent).toContain("Add CozSweet to Home Screen");
|
||||
expect(container.textContent).toContain(
|
||||
"In Safari, tap the Share button, then choose “Add to Home Screen”.",
|
||||
);
|
||||
});
|
||||
|
||||
it("opens the native Android install prompt and marks an accepted install as Saved", async () => {
|
||||
vi.spyOn(PlatformDetector, "isIOS").mockReturnValue(false);
|
||||
vi.spyOn(PlatformDetector, "isAndroid").mockReturnValue(true);
|
||||
const install = vi.spyOn(pwaUtil, "install").mockResolvedValue("accepted");
|
||||
|
||||
renderButton();
|
||||
await act(async () => {
|
||||
getButton("Download").click();
|
||||
await Promise.resolve();
|
||||
});
|
||||
|
||||
expect(install).toHaveBeenCalledTimes(1);
|
||||
expect(getButton("Saved")).not.toBeNull();
|
||||
});
|
||||
|
||||
function renderButton(): void {
|
||||
act(() => {
|
||||
root.render(<FavoriteEntryButton characterSlug="elio" />);
|
||||
});
|
||||
}
|
||||
|
||||
function getButton(label: string): HTMLButtonElement {
|
||||
const button = container.querySelector<HTMLButtonElement>(
|
||||
`button[aria-label="${label}"]`,
|
||||
);
|
||||
if (!button) throw new Error(`Missing button: ${label}`);
|
||||
return button;
|
||||
}
|
||||
});
|
||||
@@ -1,119 +0,0 @@
|
||||
import { act } from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { ModalPortal } from "../modal-portal";
|
||||
|
||||
describe("ModalPortal", () => {
|
||||
let container: HTMLDivElement;
|
||||
let root: Root;
|
||||
|
||||
beforeEach(() => {
|
||||
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean })
|
||||
.IS_REACT_ACT_ENVIRONMENT = true;
|
||||
container = document.createElement("div");
|
||||
container.style.transform = "translateX(50%)";
|
||||
document.body.appendChild(container);
|
||||
document.body.style.overflow = "auto";
|
||||
root = createRoot(container);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
act(() => root.unmount());
|
||||
container.remove();
|
||||
document.body.style.overflow = "";
|
||||
});
|
||||
|
||||
it("portals outside transformed ancestors and exposes dialog semantics", () => {
|
||||
const onClose = vi.fn();
|
||||
|
||||
act(() =>
|
||||
root.render(
|
||||
<ModalPortal
|
||||
open
|
||||
onClose={onClose}
|
||||
scrimClassName="fixed inset-0"
|
||||
panelClassName="payment-panel"
|
||||
scrimOpacity={0.5}
|
||||
role="alertdialog"
|
||||
ariaLabelledBy="payment-title"
|
||||
ariaDescribedBy="payment-description"
|
||||
>
|
||||
<h2 id="payment-title">Complete payment</h2>
|
||||
<p id="payment-description">Choose a payment method.</p>
|
||||
</ModalPortal>,
|
||||
),
|
||||
);
|
||||
|
||||
const dialog = document.body.querySelector('[role="alertdialog"]');
|
||||
expect(dialog).not.toBeNull();
|
||||
expect(container.contains(dialog)).toBe(false);
|
||||
expect(dialog?.parentElement?.parentElement).toBe(document.body);
|
||||
expect(dialog?.getAttribute("aria-labelledby")).toBe("payment-title");
|
||||
expect(dialog?.getAttribute("aria-describedby")).toBe(
|
||||
"payment-description",
|
||||
);
|
||||
expect(document.body.style.overflow).toBe("hidden");
|
||||
});
|
||||
|
||||
it("restores the previous body overflow after the final modal closes", () => {
|
||||
const renderModals = (showFirst: boolean, showSecond: boolean) => (
|
||||
<>
|
||||
<ModalPortal
|
||||
open={showFirst}
|
||||
onClose={() => undefined}
|
||||
scrimClassName="first-scrim"
|
||||
panelClassName="first-panel"
|
||||
scrimOpacity={0.4}
|
||||
>
|
||||
First
|
||||
</ModalPortal>
|
||||
<ModalPortal
|
||||
open={showSecond}
|
||||
onClose={() => undefined}
|
||||
scrimClassName="second-scrim"
|
||||
panelClassName="second-panel"
|
||||
scrimOpacity={0.4}
|
||||
>
|
||||
Second
|
||||
</ModalPortal>
|
||||
</>
|
||||
);
|
||||
|
||||
act(() => root.render(renderModals(true, true)));
|
||||
expect(document.body.style.overflow).toBe("hidden");
|
||||
|
||||
act(() => root.render(renderModals(false, true)));
|
||||
expect(document.body.style.overflow).toBe("hidden");
|
||||
|
||||
act(() => root.render(renderModals(false, false)));
|
||||
expect(document.body.style.overflow).toBe("auto");
|
||||
});
|
||||
|
||||
it("keeps persistent payment modals open on scrim click and Escape", () => {
|
||||
const onClose = vi.fn();
|
||||
|
||||
act(() =>
|
||||
root.render(
|
||||
<ModalPortal
|
||||
open
|
||||
persistent
|
||||
onClose={onClose}
|
||||
scrimClassName="fixed inset-0"
|
||||
panelClassName="payment-panel"
|
||||
scrimOpacity={0.5}
|
||||
>
|
||||
Payment
|
||||
</ModalPortal>,
|
||||
),
|
||||
);
|
||||
|
||||
const scrim = document.body.querySelector(".fixed.inset-0");
|
||||
act(() => scrim?.dispatchEvent(new MouseEvent("click", { bubbles: true })));
|
||||
act(() =>
|
||||
document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" })),
|
||||
);
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -79,20 +79,16 @@ describe("core Tailwind components", () => {
|
||||
<AppBottomNav
|
||||
activeItem="chat"
|
||||
variant="dark"
|
||||
privateZoneLabel="Maya Private Zone"
|
||||
onChatClick={() => undefined}
|
||||
onPrivateZoneClick={() => undefined}
|
||||
onMenuClick={() => undefined}
|
||||
onPrivateRoomClick={() => undefined}
|
||||
/>,
|
||||
);
|
||||
const privateZoneHtml = renderToStaticMarkup(
|
||||
const privateRoomHtml = renderToStaticMarkup(
|
||||
<AppBottomNav
|
||||
activeItem="privateZone"
|
||||
activeItem="privateRoom"
|
||||
variant="warm"
|
||||
privateZoneLabel="Maya Private Zone"
|
||||
onChatClick={() => undefined}
|
||||
onPrivateZoneClick={() => undefined}
|
||||
onMenuClick={() => undefined}
|
||||
onPrivateRoomClick={() => undefined}
|
||||
/>,
|
||||
);
|
||||
|
||||
@@ -101,15 +97,13 @@ describe("core Tailwind components", () => {
|
||||
expect(chatHtml).toMatch(
|
||||
/<button[^>]*aria-current="page"[^>]*>.*?<span>Chat<\/span>/,
|
||||
);
|
||||
expect(privateZoneHtml).toMatch(/class="[^"]*warm[^"]*"/);
|
||||
expect(privateZoneHtml).toMatch(
|
||||
/<button[^>]*aria-current="page"[^>]*>.*?<span>Maya Private Zone<\/span>/,
|
||||
expect(privateRoomHtml).toMatch(/class="[^"]*warm[^"]*"/);
|
||||
expect(privateRoomHtml).toMatch(
|
||||
/<button[^>]*aria-current="page"[^>]*>.*?<span>Elio Private room<\/span>/,
|
||||
);
|
||||
expect(chatHtml).toContain('data-analytics-key="navigation.chat"');
|
||||
expect(privateZoneHtml).toContain(
|
||||
'data-analytics-key="navigation.private_zone"',
|
||||
expect(privateRoomHtml).toContain(
|
||||
'data-analytics-key="navigation.private_room"',
|
||||
);
|
||||
expect(chatHtml).toContain('data-analytics-key="navigation.menu"');
|
||||
expect(chatHtml).toContain("<span>Menu</span>");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
left: 50%;
|
||||
z-index: 30;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
grid-template-columns: 1fr 1fr;
|
||||
box-sizing: border-box;
|
||||
width: min(100vw, var(--app-max-width, 540px));
|
||||
min-height: calc(
|
||||
|
||||