From 47cd94ec3e68c4c3b7e8adab2d179096e9b066ff Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 16 Dec 2025 15:06:53 +0800 Subject: [PATCH] chore: tests for billings (#29720) --- web/__mocks__/react-i18next.ts | 8 +- .../plans/cloud-plan-item/button.spec.tsx | 50 +++++ .../plans/cloud-plan-item/index.spec.tsx | 188 ++++++++++++++++++ .../plans/cloud-plan-item/list/index.spec.tsx | 30 +++ .../billing/pricing/plans/index.spec.tsx | 87 ++++++++ .../self-hosted-plan-item/button.spec.tsx | 61 ++++++ .../self-hosted-plan-item/index.spec.tsx | 143 +++++++++++++ .../self-hosted-plan-item/list/index.spec.tsx | 25 +++ .../self-hosted-plan-item/list/item.spec.tsx | 12 ++ 9 files changed, 603 insertions(+), 1 deletion(-) create mode 100644 web/app/components/billing/pricing/plans/cloud-plan-item/button.spec.tsx create mode 100644 web/app/components/billing/pricing/plans/cloud-plan-item/index.spec.tsx create mode 100644 web/app/components/billing/pricing/plans/cloud-plan-item/list/index.spec.tsx create mode 100644 web/app/components/billing/pricing/plans/index.spec.tsx create mode 100644 web/app/components/billing/pricing/plans/self-hosted-plan-item/button.spec.tsx create mode 100644 web/app/components/billing/pricing/plans/self-hosted-plan-item/index.spec.tsx create mode 100644 web/app/components/billing/pricing/plans/self-hosted-plan-item/list/index.spec.tsx create mode 100644 web/app/components/billing/pricing/plans/self-hosted-plan-item/list/item.spec.tsx diff --git a/web/__mocks__/react-i18next.ts b/web/__mocks__/react-i18next.ts index b0d22e0cc0..1e3f58927e 100644 --- a/web/__mocks__/react-i18next.ts +++ b/web/__mocks__/react-i18next.ts @@ -19,7 +19,13 @@ */ export const useTranslation = () => ({ - t: (key: string) => key, + t: (key: string, options?: Record) => { + if (options?.returnObjects) + return [`${key}-feature-1`, `${key}-feature-2`] + if (options) + return `${key}:${JSON.stringify(options)}` + return key + }, i18n: { language: 'en', changeLanguage: jest.fn(), diff --git a/web/app/components/billing/pricing/plans/cloud-plan-item/button.spec.tsx b/web/app/components/billing/pricing/plans/cloud-plan-item/button.spec.tsx new file mode 100644 index 0000000000..0c50c80c87 --- /dev/null +++ b/web/app/components/billing/pricing/plans/cloud-plan-item/button.spec.tsx @@ -0,0 +1,50 @@ +import React from 'react' +import { fireEvent, render, screen } from '@testing-library/react' +import Button from './button' +import { Plan } from '../../../type' + +describe('CloudPlanButton', () => { + describe('Disabled state', () => { + test('should disable button and hide arrow when plan is not available', () => { + const handleGetPayUrl = jest.fn() + // Arrange + render( +