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,9 +1,9 @@
import type { CloudPlan } from '@dify/contracts/api/console/features/types.gen'
import type { Mock } from 'vitest'
import type { DocumentIndexingStatus, IndexingStatusResponse } from '@/models/datasets'
import type { InitialDocumentDetail } from '@/models/pipeline'
import { fireEvent, screen, waitFor } from '@testing-library/react'
import * as React from 'react'
import { Plan } from '@/app/components/billing/type'
import { IndexingType } from '@/app/components/datasets/create/step-two'
import { DatasourceType } from '@/models/pipeline'
import { renderWithConsoleQuery as render } from '@/test/console/query-data'
@@ -37,7 +37,7 @@ vi.mock('@/next/link', () => ({
// Mock provider context
let mockEnableBilling = false
let mockPlanType: Plan = Plan.sandbox
let mockPlanType: CloudPlan = 'sandbox'
vi.mock('@/context/provider-context', () => ({
useProviderContext: () => ({
enableBilling: mockEnableBilling,
@@ -159,7 +159,7 @@ describe('EmbeddingProcess', () => {
// Reset mock states
mockEnableBilling = false
mockPlanType = Plan.sandbox
mockPlanType = 'sandbox'
mockIndexingStatusData = []
// Setup default mock for fetchIndexingStatus
@@ -211,7 +211,7 @@ describe('EmbeddingProcess', () => {
it('should show upgrade banner when billing is enabled and plan is not team', () => {
mockEnableBilling = true
mockPlanType = Plan.sandbox
mockPlanType = 'sandbox'
const props = createDefaultProps()
render(<EmbeddingProcess {...props} />)
@@ -223,7 +223,7 @@ describe('EmbeddingProcess', () => {
it('should not show upgrade banner when plan is team', () => {
mockEnableBilling = true
mockPlanType = Plan.team
mockPlanType = 'team'
const props = createDefaultProps()
render(<EmbeddingProcess {...props} />)
@@ -235,7 +235,7 @@ describe('EmbeddingProcess', () => {
it('should show upgrade banner for professional plan', () => {
mockEnableBilling = true
mockPlanType = Plan.professional
mockPlanType = 'professional'
const props = createDefaultProps()
render(<EmbeddingProcess {...props} />)
@@ -387,7 +387,7 @@ describe('EmbeddingProcess', () => {
it('should not suggest an upgrade to team users', async () => {
mockEnableBilling = true
mockPlanType = Plan.team
mockPlanType = 'team'
const doc1 = createMockDocument({ id: 'doc-1' })
mockIndexingStatusData = [
createMockIndexingStatus({
@@ -1074,7 +1074,7 @@ describe('EmbeddingProcess', () => {
// Tests for priority label display
it('should show priority label when billing is enabled', async () => {
mockEnableBilling = true
mockPlanType = Plan.sandbox
mockPlanType = 'sandbox'
const doc1 = createMockDocument({ id: 'doc-1' })
mockIndexingStatusData = [
createMockIndexingStatus({ id: 'doc-1', indexing_status: 'indexing' }),
@@ -19,7 +19,6 @@ import { useTranslation } from 'react-i18next'
import Divider from '@/app/components/base/divider'
import NotionIcon from '@/app/components/base/notion-icon'
import PriorityLabel from '@/app/components/billing/priority-label'
import { Plan } from '@/app/components/billing/type'
import UpgradeBtn from '@/app/components/billing/upgrade-btn'
import DocumentFileIcon from '@/app/components/datasets/common/document-file-icon'
import VectorSpaceAdmissionAlert from '@/app/components/datasets/common/vector-space-admission-alert'
@@ -120,8 +119,7 @@ const EmbeddingProcess = ({
),
[indexingStatusBatchDetail],
)
const showUpgrade =
enableBilling && (plan.type === Plan.sandbox || plan.type === Plan.professional)
const showUpgrade = enableBilling && (plan.type === 'sandbox' || plan.type === 'professional')
const getSourceName = (id: string) => {
const doc = documents.find((document) => document.id === id)
@@ -173,7 +171,7 @@ const EmbeddingProcess = ({
planLimitMb={vectorSpaceAdmissionError.vector_space_limit_mb}
/>
)}
{enableBilling && plan.type !== Plan.team && (
{enableBilling && plan.type !== 'team' && (
<div className="flex h-13 items-center gap-x-2 rounded-xl border-[0.5px] border-components-panel-border-subtle bg-components-panel-on-panel-item-bg p-2.5 pl-3 shadow-xs shadow-shadow-shadow-3">
<div className="flex shrink-0 items-center justify-center rounded-lg border-[0.5px] border-divider-subtle bg-util-colors-blue-brand-blue-brand-500 shadow-md shadow-shadow-shadow-5">
<RiAedFill className="size-4 text-text-primary-on-surface" />