mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 05:37:20 +08:00
Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: Hiep Le <69354317+hieptl@users.noreply.github.com> Co-authored-by: Abhay Mishra <grabhaymishra@gmail.com> Co-authored-by: Hyun Han <62870362+smosco@users.noreply.github.com> Co-authored-by: Nhan Nguyen <nhan13574@gmail.com> Co-authored-by: Bharath A V <avbharath1221@gmail.com> Co-authored-by: hieptl <hieptl.developer@gmail.com> Co-authored-by: Chloe <chloe@openhands.com> Co-authored-by: HeyItsChloe <54480367+HeyItsChloe@users.noreply.github.com>
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { isBillingHidden } from "#/utils/org/billing-visibility";
|
|
import { WebClientConfig } from "#/api/option-service/option.types";
|
|
|
|
describe("isBillingHidden", () => {
|
|
const createConfig = (
|
|
featureFlagOverrides: Partial<WebClientConfig["feature_flags"]> = {},
|
|
): WebClientConfig =>
|
|
({
|
|
app_mode: "saas",
|
|
posthog_client_key: "test",
|
|
feature_flags: {
|
|
enable_billing: true,
|
|
hide_llm_settings: false,
|
|
enable_jira: false,
|
|
enable_jira_dc: false,
|
|
enable_linear: false,
|
|
...featureFlagOverrides,
|
|
},
|
|
}) as WebClientConfig;
|
|
|
|
it("should return true when config is undefined (safe default)", () => {
|
|
expect(isBillingHidden(undefined, true)).toBe(true);
|
|
});
|
|
|
|
it("should return true when enable_billing is false", () => {
|
|
const config = createConfig({ enable_billing: false });
|
|
expect(isBillingHidden(config, true)).toBe(true);
|
|
});
|
|
|
|
it("should return true when user lacks view_billing permission", () => {
|
|
const config = createConfig();
|
|
expect(isBillingHidden(config, false)).toBe(true);
|
|
});
|
|
|
|
it("should return true when both enable_billing is false and user lacks permission", () => {
|
|
const config = createConfig({ enable_billing: false });
|
|
expect(isBillingHidden(config, false)).toBe(true);
|
|
});
|
|
|
|
it("should return false when enable_billing is true and user has view_billing permission", () => {
|
|
const config = createConfig();
|
|
expect(isBillingHidden(config, true)).toBe(false);
|
|
});
|
|
|
|
it("should treat enable_billing as true by default (billing visible, subject to permission)", () => {
|
|
const config = createConfig({ enable_billing: true });
|
|
expect(isBillingHidden(config, true)).toBe(false);
|
|
});
|
|
});
|