Fix bracketed paste blocking provider form submit (#818)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { expect, test } from 'bun:test'
|
||||
import { supportsClipboardImageFallback } from './usePasteHandler.ts'
|
||||
import {
|
||||
shouldHandleInputAsPaste,
|
||||
supportsClipboardImageFallback,
|
||||
} from './usePasteHandler.ts'
|
||||
|
||||
test('supports clipboard image fallback on Windows', () => {
|
||||
expect(supportsClipboardImageFallback('windows')).toBe(true)
|
||||
@@ -20,3 +23,42 @@ test('does not support clipboard image fallback on WSL', () => {
|
||||
test('does not support clipboard image fallback on unknown platforms', () => {
|
||||
expect(supportsClipboardImageFallback('unknown')).toBe(false)
|
||||
})
|
||||
|
||||
test('does not treat a bracketed paste as pending when no paste handlers are provided', () => {
|
||||
expect(
|
||||
shouldHandleInputAsPaste({
|
||||
hasTextPasteHandler: false,
|
||||
hasImagePasteHandler: false,
|
||||
inputLength: 'kimi-k2.5'.length,
|
||||
pastePending: false,
|
||||
hasImageFilePath: false,
|
||||
isFromPaste: true,
|
||||
}),
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
test('treats bracketed text paste as pending when a text paste handler exists', () => {
|
||||
expect(
|
||||
shouldHandleInputAsPaste({
|
||||
hasTextPasteHandler: true,
|
||||
hasImagePasteHandler: false,
|
||||
inputLength: 'kimi-k2.5'.length,
|
||||
pastePending: false,
|
||||
hasImageFilePath: false,
|
||||
isFromPaste: true,
|
||||
}),
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
test('treats image path paste as pending when only an image handler exists', () => {
|
||||
expect(
|
||||
shouldHandleInputAsPaste({
|
||||
hasTextPasteHandler: false,
|
||||
hasImagePasteHandler: true,
|
||||
inputLength: 'C:\\Users\\jat\\image.png'.length,
|
||||
pastePending: false,
|
||||
hasImageFilePath: true,
|
||||
isFromPaste: false,
|
||||
}),
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user