feat: export author spread metrics
This commit is contained in:
@@ -293,7 +293,10 @@ describe("market-content-entry", () => {
|
||||
});
|
||||
|
||||
test("renders the plugin action bar inside the native market action row", async () => {
|
||||
document.body.innerHTML = buildMarketFixture();
|
||||
document.body.innerHTML = buildRealMarketFixture([
|
||||
{ authorId: "a", authorName: "Alpha", price21To60s: "450000" },
|
||||
{ authorId: "b", authorName: "Beta", price21To60s: "70000" }
|
||||
]);
|
||||
|
||||
const { createMarketController } = await import("../src/content/market/index");
|
||||
const controller = trackController(createMarketController({
|
||||
@@ -1217,6 +1220,71 @@ describe("market-content-entry", () => {
|
||||
expect(onCsvReady).toHaveBeenCalledWith("csv-output");
|
||||
});
|
||||
|
||||
test("export hydrates spread info with attribute_datas.id before building csv", async () => {
|
||||
document.body.innerHTML = buildRealMarketFixture([
|
||||
{ authorId: "a", authorName: "Alpha", price21To60s: "450000" },
|
||||
{ authorId: "b", authorName: "Beta", price21To60s: "70000" }
|
||||
]);
|
||||
attachMarketListState([
|
||||
{
|
||||
attribute_datas: {
|
||||
id: "spread-a",
|
||||
nickname: "Alpha"
|
||||
},
|
||||
star_id: "a"
|
||||
},
|
||||
{
|
||||
attribute_datas: {
|
||||
id: "spread-b",
|
||||
nickname: "Beta"
|
||||
},
|
||||
star_id: "b"
|
||||
}
|
||||
]);
|
||||
const buildCsv = vi.fn(() => "csv-output");
|
||||
const loadSpreadMetrics = vi.fn(async (spreadAuthorId: string) => ({
|
||||
"个人视频_近30天_完播率": spreadAuthorId === "spread-a" ? "28.24%" : "18.24%"
|
||||
}));
|
||||
|
||||
const { createMarketController } = await import("../src/content/market/index");
|
||||
const controller = trackController(createMarketController({
|
||||
buildCsv,
|
||||
document,
|
||||
loadAuthorMetrics: async () => ({
|
||||
success: false,
|
||||
reason: "request-failed"
|
||||
}),
|
||||
loadSpreadMetrics,
|
||||
onCsvReady: vi.fn(),
|
||||
window
|
||||
}));
|
||||
|
||||
await controller.ready;
|
||||
setSelectValue('[data-plugin-export-range="select"]', "current");
|
||||
dispatchChange('[data-plugin-export-range="select"]');
|
||||
click('[data-plugin-export="button"]');
|
||||
await waitForMockCall(buildCsv, 80, 50);
|
||||
|
||||
expect(loadSpreadMetrics).toHaveBeenCalledWith("spread-a");
|
||||
expect(loadSpreadMetrics).toHaveBeenCalledWith("spread-b");
|
||||
expect(buildCsv.mock.calls[0][0]).toEqual([
|
||||
expect.objectContaining({
|
||||
authorId: "a",
|
||||
spreadAuthorId: "spread-a",
|
||||
spreadMetrics: {
|
||||
"个人视频_近30天_完播率": "28.24%"
|
||||
}
|
||||
}),
|
||||
expect.objectContaining({
|
||||
authorId: "b",
|
||||
spreadAuthorId: "spread-b",
|
||||
spreadMetrics: {
|
||||
"个人视频_近30天_完播率": "18.24%"
|
||||
}
|
||||
})
|
||||
]);
|
||||
});
|
||||
|
||||
test(
|
||||
"default export captures the first 5 pages and keeps non-empty fields when merging duplicates",
|
||||
async () => {
|
||||
|
||||
Reference in New Issue
Block a user