feat: stabilize Xingtu market data sync

This commit is contained in:
2026-04-21 14:16:29 +08:00
parent 85e835a96a
commit 55324a5bb7
19 changed files with 2150 additions and 1366 deletions
+57
View File
@@ -107,6 +107,63 @@ describe("full-scan-controller", () => {
status: "success"
});
});
test("uses current page market-list rates and still loads missing metrics", async () => {
const store = createMarketResultStore();
const loadAuthorMetrics = vi.fn(async (authorId: string) => ({
success: true as const,
rates:
authorId === "a"
? {
singleVideoAfterSearchRate: "0.02%",
personalVideoAfterSearchRate: "0.03% - 0.2%"
}
: {
singleVideoAfterSearchRate: "0.5%-1%",
personalVideoAfterSearchRate: "0.01% - 0.1%"
}
}));
const controller = createFullScanController({
goToNextPage: async () => false,
hasNextPage: () => false,
loadAuthorMetrics,
readCurrentPageRows: vi.fn(() => [
{
authorId: "a",
authorName: "Alpha",
hasDirectRatesSource: true,
rates: {
singleVideoAfterSearchRate: "0.02%"
}
},
{
authorId: "b",
authorName: "Beta",
hasDirectRatesSource: true
}
]),
resultStore: store
});
await controller.ensureScanForFilter();
expect(loadAuthorMetrics).toHaveBeenCalledTimes(2);
expect(store.getRecord("a")).toMatchObject({
status: "success",
rates: {
singleVideoAfterSearchRate: "0.02%",
personalVideoAfterSearchRate: "0.03% - 0.2%"
}
});
expect(store.getRecord("b")).toMatchObject({
status: "success",
rates: {
singleVideoAfterSearchRate: "0.5%-1%",
personalVideoAfterSearchRate: "0.01% - 0.1%"
}
});
});
});
function createHarness() {