Add KOC resource filters and export

This commit is contained in:
巫凤萍
2026-08-06 10:18:23 +08:00
parent 85110bbfce
commit 72f8862f8a
6 changed files with 623 additions and 18 deletions

View File

@@ -50,3 +50,34 @@ test("creates an xlsx archive whose pictures are embedded in worksheet cells", (
assert.match(strFromU8(archive["xl/drawings/drawing1.xml"]), /oneCellAnchor/);
assert.match(strFromU8(archive["xl/drawings/_rels/drawing1.xml.rels"]), /image2\.png/);
});
test("creates clickable external hyperlinks for resource exports", () => {
const workbook = buildRecoveryWorkbook({
sheetName: "KOC资源库",
headers: ["账号名称", "账号主页"],
columnWidths: [20, 40],
rows: [
{
cells: ["小满的轻生活", "https://www.xiaohongshu.com/user/profile/test?x=1&y=2"],
images: [],
hyperlinks: [
{
column: 1,
url: "https://www.xiaohongshu.com/user/profile/test?x=1&y=2",
},
],
},
],
});
const archive = unzipSync(workbook);
const sheet = strFromU8(archive["xl/worksheets/sheet1.xml"]);
const relationships = strFromU8(
archive["xl/worksheets/_rels/sheet1.xml.rels"],
);
assert.match(sheet, /<hyperlink ref="B2" r:id="rId1"\/>/);
assert.match(sheet, /<c r="B2" t="inlineStr" s="5">/);
assert.match(relationships, /relationships\/hyperlink/);
assert.match(relationships, /TargetMode="External"/);
assert.match(relationships, /x=1&amp;y=2/);
});

View File

@@ -250,6 +250,25 @@ test("exports complete task recovery data to Excel with embedded images", async
assert.match(workbook, /oneCellAnchor/);
});
test("filters and exports the current KOC resource result set", async () => {
const [adminApp, exportRoute, workbook] = await Promise.all([
readFile(new URL("../app/admin-app.tsx", import.meta.url), "utf8"),
readFile(new URL("../app/api/resources-export/route.ts", import.meta.url), "utf8"),
readFile(new URL("../lib/recovery-workbook.ts", import.meta.url), "utf8"),
]);
assert.match(adminApp, /搜索账号名称 \/ 账号ID/);
assert.match(adminApp, /全部IP地区/);
assert.match(adminApp, /全部合作来源/);
assert.match(adminApp, /导出筛选结果/);
assert.match(adminApp, /filteredAccounts\.map\(\(item\) => item\.account\.id\)/);
assert.match(exportRoute, /小红书号\/抖音号/);
assert.match(exportRoute, /历史合作来源/);
assert.match(exportRoute, /合作社资源 · 不可直联/);
assert.match(exportRoute, /isAdminRequest/);
assert.match(workbook, /relationships\/hyperlink/);
});
test("supports anonymous partner delegation without creating a second data flow", async () => {
const [
adminApp,