增加统一倍率调整按钮
This commit is contained in:
1 parent
be655b6569
commit
4195525dc7
23 files changed
+750
-16
No files matched your search
@@ -11,6 +11,7 @@ describe("billing HTTP compatibility fixture", () => {
|
||||
});
|
||||
expect(fixture.routes).toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({ method: "GET", path: "/api/billing", organizationSource: "refreshed_session" }),
|
||||
expect.objectContaining({ method: "PATCH", path: "/api/admin/billing/prices", requirement: "super_admin", allowedFields: ["ruleIds", "markupMultiplier"], atomic: true }),
|
||||
expect.objectContaining({ method: "PATCH", path: "/api/admin/billing/prices/{id}", requirement: "super_admin" })
|
||||
]));
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import { createElement } from "react";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { PriceCatalog } from "@/components/billing-manager";
|
||||
import { groupedPriceRuleSections, priceTierEditTarget } from "@/lib/client/billing-price-catalog";
|
||||
import { groupedPriceRuleSections, priceCatalogBulkTarget, priceTierEditTarget } from "@/lib/client/billing-price-catalog";
|
||||
import type { BillingParameterDimension, BillingPriceRule } from "@/lib/types";
|
||||
|
||||
const size: BillingParameterDimension = {
|
||||
@@ -32,6 +32,25 @@ function rule(id: string, overrides: Partial<BillingPriceRule> = {}): BillingPri
|
||||
}
|
||||
|
||||
describe("billing price catalog grouped rules", () => {
|
||||
it("targets the entire catalog, including disabled rules and every parameter tier", () => {
|
||||
const sameModel = rule("basic", { parameterDimensions: [size] });
|
||||
const disabledBusiness = rule("layers", { enabled: false, conditions: { layerDecomposition: true }, parameterDimensions: [{ ...size, tiers: [size.tiers[0]] }] });
|
||||
const video = rule("video", { provider: "seedance", capability: "video.generate", reqKey: "seedance-2.0", unit: "video_second", markupMultiplier: 1.3 });
|
||||
expect(priceCatalogBulkTarget([sameModel, disabledBusiness, video])).toEqual({
|
||||
ruleIds: ["basic", "layers", "video"],
|
||||
modelCount: 2,
|
||||
tierCount: 4,
|
||||
currentMultiplier: null
|
||||
});
|
||||
expect(priceCatalogBulkTarget([])).toEqual({ ruleIds: [], modelCount: 0, tierCount: 0, currentMultiplier: null });
|
||||
});
|
||||
|
||||
it("only preselects the current multiplier when every rule and tier agrees", () => {
|
||||
const uniformSize = { ...size, tiers: size.tiers.map((tier) => ({ ...tier, markupMultiplier: 1.2 })) };
|
||||
expect(priceCatalogBulkTarget([rule("basic", { parameterDimensions: [uniformSize] }), rule("video")]).currentMultiplier).toBe(1.2);
|
||||
expect(priceCatalogBulkTarget([rule("basic", { parameterDimensions: [size] })]).currentMultiplier).toBeNull();
|
||||
});
|
||||
|
||||
it("keeps separate Seedream businesses and their resolution edit targets", () => {
|
||||
const basic = rule("basic", { parameterDimensions: [size] });
|
||||
const layers = rule("layers", {
|
||||
|
||||
Reference in new issue
Block a user