Files
dify/web/app/components/workflow/comment/cursor.spec.tsx
Novice 499d237b7e fix: pass all CI quality checks - ESLint, TypeScript, basedpyright, pyrefly, lint-imports
Frontend:
- Migrate deprecated imports: modal→dialog, toast→ui/toast, tooltip→tooltip-plus,
  portal-to-follow-elem→portal-to-follow-elem-plus, select→ui/select, confirm→alert-dialog
- Replace next/* with @/next/* wrapper modules
- Convert TypeScript enums to const objects (erasable-syntax-only)
- Replace all `any` types with `unknown` or specific types in workflow types
- Fix unused vars, react-hooks-extra, react-refresh/only-export-components
- Extract InteractionMode to separate module, tool-block commands to commands.ts

Backend:
- Fix pyrefly errors: type narrowing, null guards, getattr patterns
- Remove unused TYPE_CHECKING imports in LLM node
- Add ignore_imports entries to .importlinter for dify_graph boundary violations

Made-with: Cursor
2026-03-24 10:54:58 +08:00

51 lines
1.3 KiB
TypeScript

import { render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { ControlMode } from '../types'
import { CommentCursor } from './cursor'
const mockState: {
controlMode: ControlMode
isCommentPlacing: boolean
mousePosition: { elementX: number, elementY: number }
} = {
controlMode: ControlMode.Pointer,
isCommentPlacing: false,
mousePosition: {
elementX: 10,
elementY: 20,
},
}
vi.mock('@/app/components/base/icons/src/public/other', () => ({
Comment: (props: { className?: string }) => <svg data-testid="comment-icon" {...props} />,
}))
vi.mock('../store', () => ({
useStore: (selector: (state: typeof mockState) => unknown) => selector(mockState),
}))
describe('CommentCursor', () => {
beforeEach(() => {
vi.clearAllMocks()
})
it('renders nothing when not in comment mode', () => {
mockState.controlMode = ControlMode.Pointer
render(<CommentCursor />)
expect(screen.queryByTestId('comment-icon')).not.toBeInTheDocument()
})
it('renders at current mouse position when in comment mode', () => {
mockState.controlMode = ControlMode.Comment
render(<CommentCursor />)
const icon = screen.getByTestId('comment-icon')
const container = icon.parentElement as HTMLElement
expect(container).toHaveStyle({ left: '10px', top: '20px' })
})
})