feat: streamline export field selection
This commit is contained in:
+24
-110
@@ -1,14 +1,11 @@
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
|
||||
import {
|
||||
buildSpreadInfoConfigKey,
|
||||
buildSpreadInfoColumns,
|
||||
buildSpreadInfoUrl,
|
||||
createSpreadInfoClient,
|
||||
DEFAULT_SPREAD_INFO_CONFIGS,
|
||||
filterUnloadedSpreadInfoConfigs,
|
||||
matchesSpreadMetricRule,
|
||||
normalizeSpreadInfoConfig,
|
||||
mapSpreadInfoResponse,
|
||||
selectSpreadInfoConfigsForHeaders
|
||||
} from "../src/content/market/spread-info";
|
||||
@@ -246,12 +243,14 @@ describe("spread-info", () => {
|
||||
});
|
||||
|
||||
await expect(
|
||||
client.loadAuthorSpreadMetricSnapshot("7361012802036695050", {
|
||||
flowType: 0,
|
||||
onlyAssign: true,
|
||||
range: 2,
|
||||
type: 2
|
||||
})
|
||||
client.loadAuthorSpreadMetrics("7361012802036695050", [
|
||||
{
|
||||
flowType: 0,
|
||||
onlyAssign: true,
|
||||
range: 2,
|
||||
type: 2
|
||||
}
|
||||
])
|
||||
).rejects.toThrow("HTTP 429: Too Many Requests");
|
||||
});
|
||||
|
||||
@@ -269,12 +268,14 @@ describe("spread-info", () => {
|
||||
});
|
||||
|
||||
await expect(
|
||||
client.loadAuthorSpreadMetricSnapshot("7361012802036695050", {
|
||||
flowType: 0,
|
||||
onlyAssign: true,
|
||||
range: 2,
|
||||
type: 2
|
||||
})
|
||||
client.loadAuthorSpreadMetrics("7361012802036695050", [
|
||||
{
|
||||
flowType: 0,
|
||||
onlyAssign: true,
|
||||
range: 2,
|
||||
type: 2
|
||||
}
|
||||
])
|
||||
).rejects.toThrow(
|
||||
"星图传播数据接口被限流 (status_code=31157): 您访问过于频繁,请24小时后重试"
|
||||
);
|
||||
@@ -288,101 +289,14 @@ describe("spread-info", () => {
|
||||
});
|
||||
|
||||
await expect(
|
||||
client.loadAuthorSpreadMetricSnapshot("7361012802036695050", {
|
||||
flowType: 0,
|
||||
onlyAssign: true,
|
||||
range: 2,
|
||||
type: 2
|
||||
})
|
||||
client.loadAuthorSpreadMetrics("7361012802036695050", [
|
||||
{
|
||||
flowType: 0,
|
||||
onlyAssign: true,
|
||||
range: 2,
|
||||
type: 2
|
||||
}
|
||||
])
|
||||
).rejects.toThrow("network unavailable");
|
||||
});
|
||||
|
||||
test("normalizes fixed personal-video parameters before grouping", () => {
|
||||
expect(
|
||||
normalizeSpreadInfoConfig({
|
||||
flowType: 1,
|
||||
onlyAssign: true,
|
||||
range: 3,
|
||||
type: 1
|
||||
})
|
||||
).toEqual({
|
||||
flowType: 0,
|
||||
onlyAssign: false,
|
||||
range: 3,
|
||||
type: 1
|
||||
});
|
||||
});
|
||||
|
||||
test("uses all normalized video dimensions in the config key", () => {
|
||||
expect(
|
||||
buildSpreadInfoConfigKey({
|
||||
flowType: 1,
|
||||
onlyAssign: true,
|
||||
range: 3,
|
||||
type: 1
|
||||
})
|
||||
).toBe(
|
||||
buildSpreadInfoConfigKey({
|
||||
flowType: 0,
|
||||
onlyAssign: false,
|
||||
range: 3,
|
||||
type: 1
|
||||
})
|
||||
);
|
||||
|
||||
expect(
|
||||
buildSpreadInfoConfigKey({
|
||||
flowType: 0,
|
||||
onlyAssign: false,
|
||||
range: 2,
|
||||
type: 2
|
||||
})
|
||||
).not.toBe(
|
||||
buildSpreadInfoConfigKey({
|
||||
flowType: 0,
|
||||
onlyAssign: false,
|
||||
range: 3,
|
||||
type: 2
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test("matches only the metric named by one filter rule", () => {
|
||||
expect(
|
||||
matchesSpreadMetricRule(
|
||||
{
|
||||
finishRate: "28.24%",
|
||||
interactionRate: "4.02%"
|
||||
},
|
||||
{
|
||||
config: {
|
||||
flowType: 0,
|
||||
onlyAssign: false,
|
||||
range: 2,
|
||||
type: 1
|
||||
},
|
||||
metric: "finishRate",
|
||||
threshold: 28
|
||||
}
|
||||
)
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
matchesSpreadMetricRule(
|
||||
{
|
||||
finishRate: "28.24%"
|
||||
},
|
||||
{
|
||||
config: {
|
||||
flowType: 0,
|
||||
onlyAssign: false,
|
||||
range: 2,
|
||||
type: 1
|
||||
},
|
||||
metric: "interactionRate",
|
||||
threshold: 1
|
||||
}
|
||||
)
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user