fix(web): render workspace plan badge during SSR (#40581)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
yyhandautofix-ci[bot] authored and GitHub committed 2026-08-12 07:45:39 +00:00
1 parent 750fce7e52
commit 01460f681e
105 files changed
+770 -1581

No files matched your search

@@ -1,11 +1,11 @@
import type { CloudPlan } from '@dify/contracts/api/console/features/types.gen'
import { fireEvent, render, screen, within } from '@testing-library/react'
import { Plan } from '@/app/components/billing/type'
import {
WorkflowVersionApiContent,
WorkflowVersionApiUpgradeNotice,
} from '../workflow-version-api-upgrade-notice'
let mockPlanType = Plan.professional
let mockPlanType: CloudPlan = 'professional'
let mockEnableBilling = true
let mockIsFetchedPlan = true
@@ -69,13 +69,13 @@ vi.mock('@/app/components/billing/upgrade-btn', () => ({
describe('WorkflowVersionApiUpgradeNotice', () => {
beforeEach(() => {
mockPlanType = Plan.professional
mockPlanType = 'professional'
mockEnableBilling = true
mockIsFetchedPlan = true
})
it('should not render before the plan is fetched', () => {
mockPlanType = Plan.sandbox
mockPlanType = 'sandbox'
mockIsFetchedPlan = false
render(<WorkflowVersionApiUpgradeNotice />)
@@ -86,7 +86,7 @@ describe('WorkflowVersionApiUpgradeNotice', () => {
})
it('should not render when billing is disabled', () => {
mockPlanType = Plan.sandbox
mockPlanType = 'sandbox'
mockEnableBilling = false
render(<WorkflowVersionApiUpgradeNotice />)
@@ -105,7 +105,7 @@ describe('WorkflowVersionApiUpgradeNotice', () => {
})
it('should show a small upgrade button and open the plan upgrade modal for sandbox plans', () => {
mockPlanType = Plan.sandbox
mockPlanType = 'sandbox'
render(<WorkflowVersionApiUpgradeNotice />)
@@ -133,7 +133,7 @@ describe('WorkflowVersionApiUpgradeNotice', () => {
describe('WorkflowVersionApiContent', () => {
beforeEach(() => {
mockPlanType = Plan.professional
mockPlanType = 'professional'
mockEnableBilling = true
mockIsFetchedPlan = true
})
@@ -147,7 +147,7 @@ describe('WorkflowVersionApiContent', () => {
})
it('should hide content for sandbox plans', () => {
mockPlanType = Plan.sandbox
mockPlanType = 'sandbox'
const { container } = render(
<>
@@ -168,7 +168,7 @@ describe('WorkflowVersionApiContent', () => {
})
it('should show content when billing is disabled', () => {
mockPlanType = Plan.sandbox
mockPlanType = 'sandbox'
mockEnableBilling = false
mockIsFetchedPlan = false
@@ -4,14 +4,13 @@ import type { PropsWithChildren } from 'react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { PlanUpgradeModal } from '@/app/components/billing/plan-upgrade-modal'
import { Plan } from '@/app/components/billing/type'
import UpgradeBtn from '@/app/components/billing/upgrade-btn'
import { useProviderContext } from '@/context/provider-context'
export const WorkflowVersionApiContent = ({ children }: PropsWithChildren) => {
const { plan, enableBilling, isFetchedPlan } = useProviderContext()
if (enableBilling && (!isFetchedPlan || plan.type === Plan.sandbox)) return <div aria-hidden />
if (enableBilling && (!isFetchedPlan || plan.type === 'sandbox')) return <div aria-hidden />
return children
}
@@ -21,7 +20,7 @@ export const WorkflowVersionApiUpgradeNotice = () => {
const { plan, enableBilling, isFetchedPlan } = useProviderContext()
const [isPlanUpgradeModalOpen, setIsPlanUpgradeModalOpen] = useState(false)
if (!isFetchedPlan || !enableBilling || plan.type !== Plan.sandbox) return null
if (!isFetchedPlan || !enableBilling || plan.type !== 'sandbox') return null
const title = t(($) => $['upgrade.workflowVersionRun.title'])
const description = t(($) => $['upgrade.workflowVersionRun.description'])