Compare commits

...

4 Commits

Author SHA1 Message Date
Joel
4d4db95f1d chore: fix waring 2025-12-18 11:37:34 +08:00
Joel
632d247059 chore: test to it 2025-12-18 11:31:23 +08:00
Joel
6e38812414 chroe: ts problems 2025-12-18 11:28:23 +08:00
Joel
4fd20dbff9 chore: fix lint problems 2025-12-18 11:25:37 +08:00
3 changed files with 18 additions and 9 deletions

View File

@@ -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', () => {

View File

@@ -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,

View File

@@ -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) {