feat: stabilize Xingtu market data sync
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user