feat(tests): add integration tests for explore app list, installed apps, and sidebar lifecycle flows (#32248)

Co-authored-by: CodingOnStar <hanxujiang@dify.com>
This commit is contained in:
Coding On Star
2026-02-12 10:29:03 +08:00
committed by GitHub
parent b65678bd4c
commit 3fd1eea4d7
27 changed files with 1186 additions and 550 deletions

View File

@ -1,12 +1,6 @@
import { cleanup, render, screen, waitFor } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import BasicAppPreview from './basic-app-preview'
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string) => key,
}),
}))
import BasicAppPreview from '../basic-app-preview'
const mockUseGetTryAppInfo = vi.fn()
const mockUseAllToolProviders = vi.fn()
@ -22,7 +16,7 @@ vi.mock('@/service/use-tools', () => ({
useAllToolProviders: () => mockUseAllToolProviders(),
}))
vi.mock('../../../header/account-setting/model-provider-page/hooks', () => ({
vi.mock('../../../../header/account-setting/model-provider-page/hooks', () => ({
useTextGenerationCurrentProviderAndModelAndModelList: (...args: unknown[]) =>
mockUseTextGenerationCurrentProviderAndModelAndModelList(...args),
}))
@ -518,7 +512,6 @@ describe('BasicAppPreview', () => {
render(<BasicAppPreview appId="test-app-id" />)
// Should still render (with default model config)
await waitFor(() => {
expect(mockUseGetTryAppDataSets).toHaveBeenCalled()
})

View File

@ -1,6 +1,6 @@
import { cleanup, render, screen } from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import FlowAppPreview from './flow-app-preview'
import FlowAppPreview from '../flow-app-preview'
const mockUseGetTryAppFlowPreview = vi.fn()

View File

@ -1,9 +1,9 @@
import type { TryAppInfo } from '@/service/try-app'
import { cleanup, render, screen } from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import Preview from './index'
import Preview from '../index'
vi.mock('./basic-app-preview', () => ({
vi.mock('../basic-app-preview', () => ({
default: ({ appId }: { appId: string }) => (
<div data-testid="basic-app-preview" data-app-id={appId}>
BasicAppPreview
@ -11,7 +11,7 @@ vi.mock('./basic-app-preview', () => ({
),
}))
vi.mock('./flow-app-preview', () => ({
vi.mock('../flow-app-preview', () => ({
default: ({ appId, className }: { appId: string, className?: string }) => (
<div data-testid="flow-app-preview" data-app-id={appId} className={className}>
FlowAppPreview