|
|
@@ -0,0 +1,81 @@
|
|
|
+/**
|
|
|
+ * 档案台账「分成规则」类展示与分成管理列表同一口径(settle-text `shareRuleParts`):
|
|
|
+ * 运营商「分成规则」列取值一行+方式一行;合伙人「分成值」列。四张档案表与 CSV 导出共用 `shareText`。
|
|
|
+ */
|
|
|
+import { cleanup, render, screen, within } from "@testing-library/react";
|
|
|
+import { MemoryRouter } from "react-router";
|
|
|
+import { afterEach, expect, it, vi } from "vitest";
|
|
|
+import type { Operator, OrganizationData, Partner } from "../../lib/organization-demo";
|
|
|
+import { OperatorManagementPage, PartnerManagementPage } from "../OrganizationPages";
|
|
|
+
|
|
|
+vi.mock("../../auth/session", () => ({ useSession: () => ({ ctx: { role_code: "admin" } }) }));
|
|
|
+vi.mock("../../lib/use-horizontal-overflow", () => ({ useHorizontalOverflow: () => ({ ref: null, width: 1160 }) }));
|
|
|
+vi.mock("../../lib/api/bos", async (load) => ({
|
|
|
+ ...await load<typeof import("../../lib/api/bos")>(),
|
|
|
+ billingConfigGet: async () => ({ default_recon_day: 5 }),
|
|
|
+ customerGetList: async () => ({ items: [] }),
|
|
|
+}));
|
|
|
+vi.mock("../../lib/organization-demo", async (load) => {
|
|
|
+ const base = { region: "P", reconcileDay: 5, payCycle: "按月", notify: "", account: "在用" as const, login: "login-x" };
|
|
|
+ const operators: Operator[] = [
|
|
|
+ { ...base, id: "OP-R", name: "比例运营商", brand: "电信", shareMode: "按比例", shareValue: 0.1 },
|
|
|
+ { ...base, id: "OP-A", name: "金额运营商", brand: "联通", shareMode: "按金额", shareValue: 1200 },
|
|
|
+ { ...base, id: "OP-N", name: "每账号运营商", brand: "移动", shareMode: "按每账号", shareValue: 3.5 },
|
|
|
+ { ...base, id: "OP-U", name: "未配运营商", brand: "电信", shareMode: "按比例", shareValue: 0, sharePending: true },
|
|
|
+ ];
|
|
|
+ const partnerBase: Partner = {
|
|
|
+ id: "PT-1", name: "金额合伙人", region: "P", title: "", notify: "", account: "在用", login: "partner-x",
|
|
|
+ scope: { regions: ["P"], enterprises: [] }, shareMode: "按金额", shareValue: 120,
|
|
|
+ };
|
|
|
+ const partners: Partner[] = [partnerBase, { ...partnerBase, id: "PT-2", name: "每账号合伙人", shareMode: "按每账号", shareValue: 1200 }];
|
|
|
+ const data: OrganizationData = {
|
|
|
+ regions: [{ id: "P", name: "江苏省", level: 0, parent: null }],
|
|
|
+ operators, partners, operationsTeams: [], maintenanceTeams: [], enterprises: [],
|
|
|
+ };
|
|
|
+ return {
|
|
|
+ ...await load<typeof import("../../lib/organization-demo")>(),
|
|
|
+ useOrganizationData: () => data,
|
|
|
+ useOrganizationSnapshot: () => data,
|
|
|
+ useOrganizationStatus: () => ({ loading: false, partial: {} }),
|
|
|
+ useOrganizationDemand: () => {},
|
|
|
+ reloadOrganizationData: async () => {},
|
|
|
+ };
|
|
|
+});
|
|
|
+
|
|
|
+afterEach(cleanup);
|
|
|
+
|
|
|
+/** 运营商台账「分成规则」列=第 5 格:取值(`.org-directory-share-value`)+方式小字。 */
|
|
|
+function ruleCell(rowName: RegExp) {
|
|
|
+ const row = screen.getByRole("row", { name: rowName });
|
|
|
+ return within(row).getAllByRole("cell")[4];
|
|
|
+}
|
|
|
+
|
|
|
+it("运营商「分成规则」列三模式与分成管理同一口径(金额补两位小数、不加千分位)", () => {
|
|
|
+ render(<MemoryRouter><OperatorManagementPage /></MemoryRouter>);
|
|
|
+
|
|
|
+ const ratio = ruleCell(/比例运营商档案/);
|
|
|
+ expect(ratio.querySelector(".org-directory-share-value")?.textContent).toBe("10%");
|
|
|
+ expect(ratio.querySelector("small")?.textContent).toBe("按比例");
|
|
|
+
|
|
|
+ const amount = ruleCell(/金额运营商档案/);
|
|
|
+ expect(amount.querySelector(".org-directory-share-value")?.textContent).toBe("¥1200.00 / 月");
|
|
|
+ expect(amount.querySelector("small")?.textContent).toBe("按金额");
|
|
|
+ expect(amount.getAttribute("title")).toBe("¥1200.00 / 月 · 按金额");
|
|
|
+
|
|
|
+ const perAccount = ruleCell(/每账号运营商档案/);
|
|
|
+ expect(perAccount.querySelector(".org-directory-share-value")?.textContent).toBe("¥ 3.50/账号");
|
|
|
+ expect(perAccount.querySelector("small")?.textContent).toBe("按每账号");
|
|
|
+});
|
|
|
+
|
|
|
+it("运营商未配分成 ⇒ 该列占位「未配置」,⛔ 出取值", () => {
|
|
|
+ render(<MemoryRouter><OperatorManagementPage /></MemoryRouter>);
|
|
|
+ const cell = ruleCell(/未配运营商档案/);
|
|
|
+ expect(cell.querySelector(".table-placeholder")?.textContent).toBe("未配置");
|
|
|
+ expect(cell.querySelector(".org-directory-share-value")).toBeNull();
|
|
|
+});
|
|
|
+
|
|
|
+it("合伙人「分成值」列同一口径", () => {
|
|
|
+ render(<MemoryRouter><PartnerManagementPage /></MemoryRouter>);
|
|
|
+ expect(screen.getByRole("row", { name: /金额合伙人档案/ }).querySelector(".org-directory-share-value")?.textContent).toBe("¥120.00 / 月");
|
|
|
+ expect(screen.getByRole("row", { name: /每账号合伙人档案/ }).querySelector(".org-directory-share-value")?.textContent).toBe("¥ 1200.00/账号");
|
|
|
+});
|