fix: refine market toolbar filters

This commit is contained in:
wxs
2026-07-09 21:33:58 +08:00
parent b4440e2ca3
commit 370cc0170b
4 changed files with 72 additions and 74 deletions
+18
View File
@@ -55,4 +55,22 @@ describe("batch-payload", () => {
})
).toThrow(/user/i);
});
test("throws when no creator records are available", () => {
expect(() =>
createBatchPayload({
authState: {
isAuthenticated: true,
resource: "https://talent-search.intelligrow.cn",
userInfo: {
name: "王少卿",
sub: "p7pdhhtde8kj"
}
},
batchName: "空结果批次",
createdAt: "2026-07-03T03:05:52.432Z",
records: []
})
).toThrow("当前没有可提交的达人");
});
});
+18 -25
View File
@@ -331,7 +331,7 @@ describe("market-content-entry", () => {
expect(
(document.querySelector('[data-plugin-export-range="select"]') as HTMLSelectElement | null)
?.hidden
).toBe(true);
).toBe(false);
expect(
(
document.querySelector(
@@ -342,7 +342,7 @@ describe("market-content-entry", () => {
expect(
(document.querySelector('[data-plugin-export="button"]') as HTMLButtonElement | null)
?.hidden
).toBe(true);
).toBe(false);
expect(
document.querySelector('[data-plugin-export-audience-profile="button"]')
).not.toBeNull();
@@ -464,39 +464,32 @@ describe("market-content-entry", () => {
expect(titles[0]?.style.background).toBe("rgb(238, 245, 255)");
expect(titles[1]?.style.background).toBe("rgb(238, 245, 255)");
expect(document.querySelector("[data-plugin-spread-threshold-rule]")).toBeNull();
expect(operators).toEqual(["≥", "≥", "≥", "≥", "≥", "≥", "≥"]);
expect(conjunctions).toEqual(["且", "且", "且", "且", "且", "且"]);
expect(operators).toEqual(["≥", "≥"]);
expect(conjunctions).toEqual(["且"]);
expect(thresholdInputs.map((input) => input.placeholder)).toEqual([
"",
"",
"",
"",
"",
"",
""
]);
expect(thresholdInputs.map((input) => input.step)).toEqual([
"1",
"1",
"1",
"1",
"0.1",
"0.1",
"1"
"0.1"
]);
expect(thresholdControls.map((control) => control.textContent)).toEqual([
"评论≥条",
"时长≥秒",
"点赞≥次",
"转发≥次",
"完播率≥%",
"互动率≥%",
"播放中位数≥次"
"互动率≥%"
]);
expect(buttons.map((button) => button.textContent)).toEqual([
"导出CSV",
"导出选中达人数据",
"按星图ID导出",
"选择字段",
"提交批次"
]);
expect(buttons.map((button) => button.style.backgroundColor)).toEqual([
"rgb(127, 29, 45)",
"rgb(127, 29, 45)",
"rgb(127, 29, 45)",
"rgb(127, 29, 45)",
"rgb(127, 29, 45)"
]);
});
@@ -1253,7 +1246,7 @@ describe("market-content-entry", () => {
expect(readDivAuthorOrder()).toEqual(["达人 B", "达人 A"]);
});
test("toolbar keeps export range controls hidden while retaining the internal default range", async () => {
test("toolbar shows export range controls and reveals custom page input only for custom range", async () => {
document.body.innerHTML = buildMarketFixture();
const { createMarketController } = await import("../src/content/market/index");
@@ -1276,7 +1269,7 @@ describe("market-content-entry", () => {
) as HTMLInputElement | null;
expect(exportRangeSelect?.value).toBe("first-5");
expect(exportRangeSelect?.hidden).toBe(true);
expect(exportRangeSelect?.hidden).toBe(false);
expect(customPagesInput?.hidden).toBe(true);
expect(
document.querySelector('[data-plugin-batch-submit="button"]')
@@ -1285,8 +1278,8 @@ describe("market-content-entry", () => {
setSelectValue('[data-plugin-export-range="select"]', "custom");
dispatchChange('[data-plugin-export-range="select"]');
expect(exportRangeSelect?.hidden).toBe(true);
expect(customPagesInput?.hidden).toBe(true);
expect(exportRangeSelect?.hidden).toBe(false);
expect(customPagesInput?.hidden).toBe(false);
});
test("toolbar exposes spread threshold filters and disables fixed personal-video controls", async () => {