fix: respect selected audience export fields

This commit is contained in:
wxs
2026-07-20 11:16:40 +08:00
parent c683e1c0c2
commit e062be6431
6 changed files with 176 additions and 38 deletions
@@ -0,0 +1,33 @@
/** @vitest-environment jsdom */
import { describe, expect, test } from "vitest";
import { promptForAudienceProfileFields } from "../src/content/market/audience-profile-field-dialog";
describe("audience-profile-field-dialog", () => {
test("keeps an explicitly empty field selection empty", async () => {
const result = promptForAudienceProfileFields(
document,
[
{
headers: ["粉丝数", "观众画像-男性占比"],
label: "测试字段"
}
],
[]
);
const fields = Array.from(
document.querySelectorAll('[data-audience-profile-field-dialog-field="checkbox"]')
) as HTMLInputElement[];
expect(fields).toHaveLength(2);
expect(fields.every((field) => !field.checked)).toBe(true);
const saveButton = document.querySelector(
'[data-audience-profile-field-dialog-save="button"]'
) as HTMLButtonElement;
saveButton.click();
await expect(result).resolves.toEqual([]);
});
});