mirror of
https://github.com/langgenius/dify.git
synced 2025-12-19 22:28:46 +00:00
Compare commits
4 Commits
107a464f0a
...
4d4db95f1d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d4db95f1d | ||
|
|
632d247059 | ||
|
|
6e38812414 | ||
|
|
4fd20dbff9 |
@@ -28,13 +28,15 @@ const createActions = (): Record<string, ActionItem> => ({
|
||||
shortcut: '@app',
|
||||
title: 'Apps',
|
||||
search: jest.fn(),
|
||||
} as unknown as ActionItem,
|
||||
description: '',
|
||||
} as ActionItem,
|
||||
plugin: {
|
||||
key: '@plugin',
|
||||
shortcut: '@plugin',
|
||||
title: 'Plugins',
|
||||
search: jest.fn(),
|
||||
} as unknown as ActionItem,
|
||||
description: '',
|
||||
} as ActionItem,
|
||||
})
|
||||
|
||||
describe('CommandSelector', () => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react'
|
||||
import { act, render, screen } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import GotoAnything from './index'
|
||||
import type { ActionItem } from './actions/types'
|
||||
import type { ActionItem, SearchResult } from './actions/types'
|
||||
|
||||
const routerPush = jest.fn()
|
||||
jest.mock('next/navigation', () => ({
|
||||
@@ -32,7 +32,7 @@ const triggerKeyPress = (combo: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
let mockQueryResult = { data: [] as any[], isLoading: false, isError: false, error: null as any }
|
||||
let mockQueryResult = { data: [] as SearchResult[], isLoading: false, isError: false, error: null as Error | null }
|
||||
jest.mock('@tanstack/react-query', () => ({
|
||||
useQuery: () => mockQueryResult,
|
||||
}))
|
||||
@@ -95,7 +95,7 @@ jest.mock('@/app/components/workflow/utils/node-navigation', () => ({
|
||||
selectWorkflowNode: jest.fn(),
|
||||
}))
|
||||
|
||||
jest.mock('../plugins/install-plugin/install-from-marketplace', () => (props: any) => (
|
||||
jest.mock('../plugins/install-plugin/install-from-marketplace', () => (props: { manifest?: { name?: string }, onClose: () => void }) => (
|
||||
<div data-testid="install-modal">
|
||||
<span>{props.manifest?.name}</span>
|
||||
<button onClick={props.onClose}>close</button>
|
||||
@@ -111,7 +111,7 @@ describe('GotoAnything', () => {
|
||||
searchAnythingMock.mockClear()
|
||||
})
|
||||
|
||||
test('should open modal via shortcut and navigate to selected result', async () => {
|
||||
it('should open modal via shortcut and navigate to selected result', async () => {
|
||||
mockQueryResult = {
|
||||
data: [{
|
||||
id: 'app-1',
|
||||
@@ -121,7 +121,7 @@ describe('GotoAnything', () => {
|
||||
path: '/apps/1',
|
||||
icon: <div data-testid="icon">🧩</div>,
|
||||
data: {},
|
||||
}],
|
||||
} as any],
|
||||
isLoading: false,
|
||||
isError: false,
|
||||
error: null,
|
||||
@@ -140,7 +140,7 @@ describe('GotoAnything', () => {
|
||||
expect(routerPush).toHaveBeenCalledWith('/apps/1')
|
||||
})
|
||||
|
||||
test('should open plugin installer when selecting plugin result', async () => {
|
||||
it('should open plugin installer when selecting plugin result', async () => {
|
||||
mockQueryResult = {
|
||||
data: [{
|
||||
id: 'plugin-1',
|
||||
@@ -153,7 +153,7 @@ describe('GotoAnything', () => {
|
||||
name: 'Plugin Item',
|
||||
latest_package_identifier: 'pkg',
|
||||
},
|
||||
}],
|
||||
} as any],
|
||||
isLoading: false,
|
||||
isError: false,
|
||||
error: null,
|
||||
|
||||
@@ -4,6 +4,13 @@ import { cleanup } from '@testing-library/react'
|
||||
// Fix for @headlessui/react compatibility with happy-dom
|
||||
// headlessui tries to override focus properties which may be read-only in happy-dom
|
||||
if (typeof window !== 'undefined') {
|
||||
// Provide a minimal animations API polyfill before @headlessui/react boots
|
||||
if (typeof Element !== 'undefined' && !Element.prototype.getAnimations)
|
||||
Element.prototype.getAnimations = () => []
|
||||
|
||||
if (!document.getAnimations)
|
||||
document.getAnimations = () => []
|
||||
|
||||
const ensureWritable = (target: object, prop: string) => {
|
||||
const descriptor = Object.getOwnPropertyDescriptor(target, prop)
|
||||
if (descriptor && !descriptor.writable) {
|
||||
|
||||
Reference in New Issue
Block a user