diff --git a/web/app/components/base/prompt-editor/plugins/shortcuts-popup-plugin/index.spec.tsx b/web/app/components/base/prompt-editor/plugins/shortcuts-popup-plugin/index.spec.tsx index f377e7acb4..ad44970187 100644 --- a/web/app/components/base/prompt-editor/plugins/shortcuts-popup-plugin/index.spec.tsx +++ b/web/app/components/base/prompt-editor/plugins/shortcuts-popup-plugin/index.spec.tsx @@ -8,6 +8,32 @@ import { useState } from 'react' import ShortcutsPopupPlugin, { SHORTCUTS_EMPTY_CONTENT } from './index' import '@testing-library/jest-dom' +// Mock Range.getClientRects and getBoundingClientRect for JSDOM +const mockDOMRect = { + x: 100, + y: 100, + width: 100, + height: 20, + top: 100, + right: 200, + bottom: 120, + left: 100, + toJSON: () => ({}), +} + +beforeAll(() => { + // Mock getClientRects on Range prototype + Range.prototype.getClientRects = vi.fn(() => { + const rectList = [mockDOMRect] as unknown as DOMRectList + Object.defineProperty(rectList, 'length', { value: 1 }) + Object.defineProperty(rectList, 'item', { value: (index: number) => index === 0 ? mockDOMRect : null }) + return rectList + }) + + // Mock getBoundingClientRect on Range prototype + Range.prototype.getBoundingClientRect = vi.fn(() => mockDOMRect as DOMRect) +}) + const CONTAINER_ID = 'host' const CONTENT_EDITABLE_ID = 'ce' diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.spec.tsx index 543d3deebc..35539a2144 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.spec.tsx @@ -1247,6 +1247,10 @@ describe('CommonCreateModal', () => { const input = screen.getByTestId('form-field-webhook_url') fireEvent.change(input, { target: { value: 'https://example.com/webhook' } }) + await waitFor(() => { + expect(mockUpdateBuilder).toHaveBeenCalled() + }) + await waitFor(() => { expect(mockToastNotify).toHaveBeenCalledWith({ type: 'error', diff --git a/web/app/components/rag-pipeline/components/index.spec.tsx b/web/app/components/rag-pipeline/components/index.spec.tsx index 827fe124a7..e17f07303d 100644 --- a/web/app/components/rag-pipeline/components/index.spec.tsx +++ b/web/app/components/rag-pipeline/components/index.spec.tsx @@ -295,6 +295,8 @@ vi.mock('@/utils/var', () => ({ // Mock provider context vi.mock('@/context/provider-context', () => ({ useProviderContext: () => createMockProviderContextValue(), + useProviderContextSelector: (selector: (state: ReturnType) => T): T => + selector(createMockProviderContextValue()), })) // Mock WorkflowWithInnerContext diff --git a/web/app/components/rag-pipeline/components/rag-pipeline-header/index.spec.tsx b/web/app/components/rag-pipeline/components/rag-pipeline-header/index.spec.tsx index 1a7a7422c1..4f3465a920 100644 --- a/web/app/components/rag-pipeline/components/rag-pipeline-header/index.spec.tsx +++ b/web/app/components/rag-pipeline/components/rag-pipeline-header/index.spec.tsx @@ -141,6 +141,8 @@ vi.mock('@/context/modal-context', () => ({ let mockProviderContextValue = createMockProviderContextValue() vi.mock('@/context/provider-context', () => ({ useProviderContext: () => mockProviderContextValue, + useProviderContextSelector: (selector: (s: ReturnType) => T): T => + selector(mockProviderContextValue), })) // Mock event emitter context diff --git a/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/index.spec.tsx b/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/index.spec.tsx index 86cd15db97..2a01218ee6 100644 --- a/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/index.spec.tsx +++ b/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/index.spec.tsx @@ -131,6 +131,8 @@ vi.mock('@/context/provider-context', () => ({ useProviderContext: () => ({ isAllowPublishAsCustomKnowledgePipelineTemplate: mockIsAllowPublishAsCustomKnowledgePipelineTemplate(), }), + useProviderContextSelector: (selector: (s: { isAllowPublishAsCustomKnowledgePipelineTemplate: boolean }) => T): T => + selector({ isAllowPublishAsCustomKnowledgePipelineTemplate: mockIsAllowPublishAsCustomKnowledgePipelineTemplate() }), })) // Mock toast context