feat: 项目层级树+合作方绑定KOC资源+客户群全量可选+精简编辑表单,移除复盘报表
- 项目支持父子层级:树形折叠展示、详情面板内联管理总群成员、推送聚合子项目任务、环检测与子项目删除守卫 - 外部KOC合作方绑定 KOC 资源账号(唯一占用、换绑/解绑、资源页一键设为合作方),列表直显联系方式 - 绑定客户群改为全量外部群缓存(含各群主),同步按钮强刷;member_count 缺失以 member_list 兜底 - 任务/项目编辑模式隐藏不可变字段(平台/内容类型/品牌/总群成员),详情面板维护成员时保留 parent_id - 删除复盘报表整栏(导航/页面/task_report_list/导出路由/CSV lib 及测试)
This commit is contained in:
@@ -10,10 +10,6 @@ const bootstrapRoute = readFileSync(
|
||||
new URL("../app/api/bootstrap/route.ts", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const taskReportExportRoute = readFileSync(
|
||||
new URL("../app/api/task-report-export/route.ts", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const recoveryExportRoute = readFileSync(
|
||||
new URL("../app/api/recovery-export/route.ts", import.meta.url),
|
||||
"utf8",
|
||||
@@ -55,6 +51,8 @@ test("manager-only actions gate on owner scope", () => {
|
||||
"backfill_account_profiles",
|
||||
"set_public_account_ids",
|
||||
"bind_wecom_external_id",
|
||||
"partner_bind_account",
|
||||
"partner_create_from_account",
|
||||
"send_test_wecom",
|
||||
"trigger_wecom_overdue_escalation",
|
||||
"wecom_list_external_contacts",
|
||||
@@ -185,15 +183,6 @@ test("task-scoped actions verify ownership for task owners", () => {
|
||||
assert.match(manual, /distributionOwnerGate\(/);
|
||||
});
|
||||
|
||||
test("task_report_list scopes reports by owner and drops the broken gate", () => {
|
||||
const body = section(actionRoute, "task_report_list");
|
||||
assert.match(body, /getTaskReportData\(db, ownerScopeUserid\(scope\)\)/);
|
||||
assert.ok(
|
||||
!/isManagerRequest/.test(body),
|
||||
"task_report_list 不再是管理员专属(负责人按 scope 过滤)",
|
||||
);
|
||||
});
|
||||
|
||||
test("project_list opens to owner scope with server-side filtering", () => {
|
||||
const body = section(actionRoute, "project_list");
|
||||
assert.match(
|
||||
@@ -232,23 +221,37 @@ test("action fallthrough dashboard is owner-scoped", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("customer chat actions require a task owner before binding", () => {
|
||||
test("customer chat actions list all owners' groups without owner prerequisite", () => {
|
||||
const list = section(actionRoute, "task_customer_chats");
|
||||
assert.match(
|
||||
list,
|
||||
/listGroupChatRows\(db\)/,
|
||||
"task_customer_chats 读全量群缓存(所有群主的外部群)",
|
||||
);
|
||||
assert.match(
|
||||
list,
|
||||
/syncGroupChats\(db, wecomConfig\)/,
|
||||
"缓存为空(或要求刷新)时自动全量同步",
|
||||
);
|
||||
assert.ok(
|
||||
!/请先设置任务负责人/.test(list),
|
||||
"列表不再要求任务先设负责人",
|
||||
);
|
||||
const bind = section(actionRoute, "task_bind_customer_chat");
|
||||
assert.ok(
|
||||
!/请先设置任务负责人/.test(bind),
|
||||
"绑定活码用应用身份,不依赖任务负责人",
|
||||
);
|
||||
assert.match(bind, /bindTaskCustomerChat\(/);
|
||||
assert.match(bind, /unbindTaskCustomerChat\(/);
|
||||
for (const action of ["task_customer_chats", "task_bind_customer_chat"]) {
|
||||
const body = section(actionRoute, action);
|
||||
assert.match(
|
||||
body,
|
||||
/请先设置任务负责人/,
|
||||
`${action} 必须在无负责人时明确报错`,
|
||||
);
|
||||
assert.match(body, /Response\.json\(/);
|
||||
assert.ok(
|
||||
!/getDashboardData/.test(body),
|
||||
`${action} 显式返回,不能落兜底 dashboard`,
|
||||
);
|
||||
}
|
||||
const bind = section(actionRoute, "task_bind_customer_chat");
|
||||
assert.match(bind, /bindTaskCustomerChat\(/);
|
||||
assert.match(bind, /unbindTaskCustomerChat\(/);
|
||||
});
|
||||
|
||||
test("partner claim detail exposes join qr only for claimed tasks", () => {
|
||||
@@ -275,7 +278,7 @@ test("bootstrap scopes dashboard data by owner scope", () => {
|
||||
test("getDashboardData filters tasks and distributions by owner", () => {
|
||||
const dashboard = mvpDb.slice(
|
||||
mvpDb.indexOf("export async function getDashboardData"),
|
||||
mvpDb.indexOf("export type TaskReportRow"),
|
||||
mvpDb.indexOf("export function uid(prefix: string)"),
|
||||
);
|
||||
const occurrences =
|
||||
dashboard.match(
|
||||
@@ -289,8 +292,6 @@ test("getDashboardData filters tasks and distributions by owner", () => {
|
||||
});
|
||||
|
||||
test("export routes enforce owner scope", () => {
|
||||
assert.match(taskReportExportRoute, /getOwnerScope\(request\)/);
|
||||
assert.match(taskReportExportRoute, /ownerScopeUserid\(await getOwnerScope\(request\)\)/);
|
||||
assert.match(recoveryExportRoute, /isTaskOwner\(/);
|
||||
assert.match(screenshotTaskExportRoute, /isTaskOwner\(/);
|
||||
assert.match(taskResultImageRoute, /isDistributionOwner\(/);
|
||||
@@ -301,3 +302,38 @@ test("users route supports wecom binding lifecycle", () => {
|
||||
assert.match(usersRoute, /INSERT INTO users[\s\S]*?wecom_userid/);
|
||||
assert.match(usersRoute, /SELECT id, username, role, wecom_userid, created_at/);
|
||||
});
|
||||
|
||||
test("project detail exposes inline main-chat member management", () => {
|
||||
const adminApp = readFileSync(
|
||||
new URL("../app/admin-app.tsx", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const globalsCss = readFileSync(
|
||||
new URL("../app/globals.css", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(adminApp, /memberPickerOpen/);
|
||||
assert.match(adminApp, /mainGroupMemberIds: nextMembers/);
|
||||
assert.match(adminApp, /project-member-remove/);
|
||||
assert.match(adminApp, /userid !== detail\.project\.ownerUserid/);
|
||||
assert.match(globalsCss, /\.project-member-remove/);
|
||||
});
|
||||
|
||||
test("every project_save payload carries parentProjectId(改总群成员不得清空层级)", () => {
|
||||
const adminApp = readFileSync(
|
||||
new URL("../app/admin-app.tsx", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const starts = [...adminApp.matchAll(/action: "project_save"/g)].map(
|
||||
(match) => match.index,
|
||||
);
|
||||
assert.ok(starts.length >= 2, "至少应有两处 project_save 调用(编辑器/总群成员)");
|
||||
for (const start of starts) {
|
||||
const payload = adminApp.slice(start, start + 600);
|
||||
assert.match(
|
||||
payload,
|
||||
/parentProjectId/,
|
||||
"project_save 载荷缺 parentProjectId,会把 parent_id 重置为空",
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user