KOC 详情弹窗(合作方/数据回收/工作台三处入口): - 新增 KocDetailModal:基本信息 / 绑定KOC账号画像 / 参与任务记录 / 履约漏斗 - 工作台最近分发、回收队列账号名、截图回收合作方名、合作方页名称、分发详情头部合作方均可点开 - 分发表行点击仍打开分发详情(stopPropagation 隔离) 任务中心单入口改版(对齐"单任务双阶段"模型): - 任务卡发布/回收面板整块可点,全卡仅保留一个「查看明细」,回收面板重复按钮移除 - 详情页自述身份:动态 label(任务详情·分发与回收一体/仅分发)+ 阶段徽章(含回收·截止/未开通回收) - 内容分发表新增阶段筛选 chips(全部/待发布/已发布待数据/待收截图,未开通回收不显示截图项),筛选落空给专用空态文案 - 数据回收页入口文案改为「选择一个任务进入回收队列」,全站不再区分发布/回收两种任务类型 资源池 KOC 默认加入合作方 + 采集兜底: - partners 新增 released_account_id(mysql/0023):显式解绑/被顶替的账号不再被默认合作方同步回填 - 任务未设置采集计划时,默认按发布时间起连续采集 7 天,等待文案显示「等待D1 · 默认7天」
92 lines
3.2 KiB
JavaScript
92 lines
3.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
const actionRoute = readFileSync(
|
|
new URL("../app/api/action/route.ts", import.meta.url),
|
|
"utf8",
|
|
);
|
|
const mvpDb = readFileSync(
|
|
new URL("../lib/mvp-db.ts", import.meta.url),
|
|
"utf8",
|
|
);
|
|
const adminApp = readFileSync(
|
|
new URL("../app/admin-app.tsx", import.meta.url),
|
|
"utf8",
|
|
);
|
|
const migration = readFileSync(
|
|
new URL("../mysql/0018_partner_resource_binding.sql", import.meta.url),
|
|
"utf8",
|
|
);
|
|
|
|
function section(source, action) {
|
|
const start = source.indexOf(`"${action}"`);
|
|
assert.ok(start >= 0, `action ${action} 不存在于路由源码`);
|
|
const next = source.indexOf("} else if (body.action ===", start);
|
|
return source.slice(start, next === -1 ? undefined : next);
|
|
}
|
|
|
|
test("partner_bind_account enforces one partner per resource account", () => {
|
|
const body = section(actionRoute, "partner_bind_account");
|
|
assert.match(
|
|
body,
|
|
/SELECT id, name, partner_type, wecom_external_user_id, wecom_userid\s+FROM partners WHERE account_id = \? AND id != \? LIMIT 1/,
|
|
"绑定前必须检查资源账号是否已被其它合作方占用",
|
|
);
|
|
assert.match(body, /该 KOC 资源已绑定合作方/, "占用时返回可读错误");
|
|
assert.match(
|
|
body,
|
|
/UPDATE partners SET account_id = '', released_account_id = \? WHERE id = \?/,
|
|
"空 accountId 表示解绑,并记录释放的资源账号避免默认合作方同步回填",
|
|
);
|
|
assert.match(body, /群主合作方不绑定 KOC 资源/);
|
|
});
|
|
|
|
test("partner_create_from_account creates external_koc bound to account", () => {
|
|
const body = section(actionRoute, "partner_create_from_account");
|
|
assert.match(
|
|
body,
|
|
/SELECT id, name FROM partners WHERE account_id = \? LIMIT 1/,
|
|
"一键创建前必须确认资源未被绑定",
|
|
);
|
|
assert.match(
|
|
body,
|
|
/partner-koc-/,
|
|
"合作方 id 使用 partner-koc- 前缀,避免与领取流程冲突",
|
|
);
|
|
assert.match(body, /'external_koc'/);
|
|
assert.match(
|
|
body,
|
|
/INSERT INTO partners[\s\S]*account_id[\s\S]*VALUES/,
|
|
"INSERT 必须写入 account_id",
|
|
);
|
|
});
|
|
|
|
test("dashboard partners query joins accounts for contact display", () => {
|
|
assert.match(
|
|
mvpDb,
|
|
/FROM partners p\s+LEFT JOIN accounts a ON a\.id = p\.account_id/,
|
|
"partners 列表需带出资源昵称与联系方式",
|
|
);
|
|
assert.match(mvpDb, /a\.current_contact AS account_contact/);
|
|
assert.match(
|
|
mvpDb,
|
|
/ensureColumn\(\s*"partners",\s*"account_id"/,
|
|
"自托管路径也要补 account_id 列",
|
|
);
|
|
});
|
|
|
|
test("migration 0018 adds partners.account_id with index", () => {
|
|
assert.match(migration, /ADD COLUMN `account_id`/);
|
|
assert.match(migration, /partners_account_idx/);
|
|
});
|
|
|
|
test("admin app renders resource binding affordances", () => {
|
|
assert.match(adminApp, /partner_bind_account/);
|
|
assert.match(adminApp, /partner_create_from_account/);
|
|
assert.match(adminApp, /绑定资源/, "未绑合作方有绑定入口");
|
|
assert.match(adminApp, /换绑/, "已绑合作方可换绑");
|
|
assert.match(adminApp, /解绑中…/, "已绑合作方可解绑");
|
|
assert.match(adminApp, /设为合作方/, "资源页支持一键创建合作方");
|
|
});
|