Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

test: fix test in #30849 (#31350)

Stephen Zhouaa68966b5558
diff --git a/web/app/components/app/configuration/config-prompt/conversation-history/history-panel.spec.tsx b/web/app/components/app/configuration/config-prompt/conversation-history/history-panel.spec.tsx
index 60627e12c2f..827986f5215 100644
--- a/web/app/components/app/configuration/config-prompt/conversation-history/history-panel.spec.tsx
+++ b/web/app/components/app/configuration/config-prompt/conversation-history/history-panel.spec.tsx
@@ -1,12 +1,6 @@
import { render, screen } from '@testing-library/react'
-import * as React from 'react'
import HistoryPanel from './history-panel'
-const mockDocLink = vi.fn(() => 'doc-link')
-vi.mock('@/context/i18n', () => ({
- useDocLink: () => mockDocLink,
-}))
-
vi.mock('@/app/components/app/configuration/base/operation-btn', () => ({
default: ({ onClick }: { onClick: () => void }) => (
<button type="button" data-testid="edit-button" onClick={onClick}>
@@ -24,12 +18,10 @@ describe('HistoryPanel', () => {
vi.clearAllMocks()
})
- it('should render warning content and link when showWarning is true', () => {
+ it('should render warning content when showWarning is true', () => {
render(<HistoryPanel showWarning onShowEditModal={vi.fn()} />)
expect(screen.getByText('appDebug.feature.conversationHistory.tip')).toBeInTheDocument()
- const link = screen.getByText('appDebug.feature.conversationHistory.learnMore')
- expect(link).toHaveAttribute('href', 'doc-link')
})
it('should hide warning when showWarning is false', () => {
diff --git a/web/app/components/app/overview/customize/index.spec.tsx b/web/app/components/app/overview/customize/index.spec.tsx
index 1cfe5a7130c..e1bb7e938d5 100644
--- a/web/app/components/app/overview/customize/index.spec.tsx
+++ b/web/app/components/app/overview/customize/index.spec.tsx
@@ -305,7 +305,7 @@ describe('CustomizeModal', () => {
// Assert
expect(mockWindowOpen).toHaveBeenCalledTimes(1)
expect(mockWindowOpen).toHaveBeenCalledWith(
- expect.stringContaining('/guides/application-publishing/developing-with-apis'),
+ expect.stringContaining('/use-dify/publish/developing-with-apis'),
'_blank',
)
})
diff --git a/web/app/components/datasets/create/website/watercrawl/index.spec.tsx b/web/app/components/datasets/create/website/watercrawl/index.spec.tsx
index e694537895e..4bb8267cea6 100644
--- a/web/app/components/datasets/create/website/watercrawl/index.spec.tsx
+++ b/web/app/components/datasets/create/website/watercrawl/index.spec.tsx
@@ -24,6 +24,11 @@ vi.mock('@/context/modal-context', () => ({
}),
}))
+// Mock i18n context
+vi.mock('@/context/i18n', () => ({
+ useDocLink: () => (path?: string) => path ? `https://docs.dify.ai/en${path}` : 'https://docs.dify.ai/en/',
+}))
+
// ============================================================================
// Test Data Factories
// ============================================================================
diff --git a/web/app/components/plugins/plugin-page/index.spec.tsx b/web/app/components/plugins/plugin-page/index.spec.tsx
index a3ea7f71250..9b7ada2a87d 100644
--- a/web/app/components/plugins/plugin-page/index.spec.tsx
+++ b/web/app/components/plugins/plugin-page/index.spec.tsx
@@ -24,6 +24,7 @@ vi.mock('@/hooks/use-document-title', () => ({
vi.mock('@/context/i18n', () => ({
useLocale: () => 'en-US',
+ useDocLink: () => (path: string) => `https://docs.example.com${path}`,
}))
vi.mock('@/context/global-public-context', () => ({
diff --git a/web/app/components/workflow-app/components/workflow-onboarding-modal/index.spec.tsx b/web/app/components/workflow-app/components/workflow-onboarding-modal/index.spec.tsx
index 6dac82a642c..e6767a802bc 100644
--- a/web/app/components/workflow-app/components/workflow-onboarding-modal/index.spec.tsx
+++ b/web/app/components/workflow-app/components/workflow-onboarding-modal/index.spec.tsx
@@ -126,18 +126,6 @@ describe('WorkflowOnboardingModal', () => {
expect(descriptionDiv).toHaveTextContent('workflow.onboarding.aboutStartNode')
})
- it('should render learn more link', () => {
- // Arrange & Act
- renderComponent()
-
- // Assert
- const learnMoreLink = screen.getByText('workflow.onboarding.learnMore')
- expect(learnMoreLink).toBeInTheDocument()
- expect(learnMoreLink.closest('a')).toHaveAttribute('href', 'https://docs.example.com/guides/workflow/node/start')
- expect(learnMoreLink.closest('a')).toHaveAttribute('target', '_blank')
- expect(learnMoreLink.closest('a')).toHaveAttribute('rel', 'noopener noreferrer')
- })
-
it('should render StartNodeSelectionPanel', () => {
// Arrange & Act
renderComponent()
@@ -547,16 +535,6 @@ describe('WorkflowOnboardingModal', () => {
expect(heading).toHaveTextContent('workflow.onboarding.title')
})
- it('should have external link with proper attributes', () => {
- // Arrange & Act
- renderComponent()
-
- // Assert
- const link = screen.getByText('workflow.onboarding.learnMore').closest('a')
- expect(link).toHaveAttribute('target', '_blank')
- expect(link).toHaveAttribute('rel', 'noopener noreferrer')
- })
-
it('should have keyboard navigation support via ESC key', () => {
// Arrange
renderComponent({ isShow: true })
@@ -595,16 +573,6 @@ describe('WorkflowOnboardingModal', () => {
const title = screen.getByText('workflow.onboarding.title')
expect(title).toHaveClass('text-text-primary')
})
-
- it('should have underlined learn more link', () => {
- // Arrange & Act
- renderComponent()
-
- // Assert
- const link = screen.getByText('workflow.onboarding.learnMore').closest('a')
- expect(link).toHaveClass('underline')
- expect(link).toHaveClass('cursor-pointer')
- })
})
// Integration Tests
@@ -654,9 +622,6 @@ describe('WorkflowOnboardingModal', () => {
const heading = container.querySelector('h3')
expect(heading).toBeInTheDocument()
- // Assert - Description with link
- expect(screen.getByText('workflow.onboarding.learnMore').closest('a')).toBeInTheDocument()
-
// Assert - Selection panel
expect(screen.getByTestId('start-node-selection-panel')).toBeInTheDocument()