feat: improve chat input, themed menus and agent proposal cancellation
This commit is contained in:
@@ -120,25 +120,25 @@ function elements(root, predicate) {
|
||||
}
|
||||
|
||||
for (const selected of [false, true]) {
|
||||
test(`textarea opens the menu with native selection and editability (selected=${selected})`, async () => {
|
||||
test(`textarea opens the themed menu with a selection snapshot (selected=${selected})`, async () => {
|
||||
let options
|
||||
let prevented = false
|
||||
let stopped = false
|
||||
const { QaInputBox } = compile('../src/renderer/src/components/ChatWidgets.tsx', {
|
||||
'../i18n': { t: key => key, useLocaleRender() {} }, './chatAttachments': {},
|
||||
react: { ...React, useState: initial => [initial, () => {}], useEffect() {}, useRef: () => ({ current: null }) }
|
||||
'../i18n': { t: key => key, useLocaleRender() {} }, './chatAttachments': {}, './ChatTextContextMenu': { ChatTextContextMenu: () => null },
|
||||
react: { ...React, useState: initial => [initial, value => { if (value?.kind === 'input') options = value }], useEffect() {}, useLayoutEffect() {}, useRef: () => ({ current: null }) }
|
||||
}, { window: { chatTextMenu: { show: async input => { options = input; return null } } } })
|
||||
const tree = QaInputBox.type({ dark: true, busy: false, disabled: false, onStop() {}, onSubmit() {} })
|
||||
const textarea = elements(tree, node => node.type === 'textarea')[0]
|
||||
textarea.props.onContextMenu({
|
||||
currentTarget: { selectionStart: 2, selectionEnd: selected ? 5 : 2, disabled: false, readOnly: false },
|
||||
currentTarget: { value: 'abcdef', selectionStart: 2, selectionEnd: selected ? 5 : 2, disabled: false, readOnly: false },
|
||||
preventDefault() { prevented = true }, stopPropagation() { stopped = true }
|
||||
})
|
||||
await Promise.resolve()
|
||||
assert.equal(options.kind, 'input')
|
||||
assert.equal(options.canCopy, selected)
|
||||
assert.equal(options.canPaste, true)
|
||||
assert.equal(options.labels.paste, '붙여넣기')
|
||||
assert.equal(options.text, selected ? 'cde' : '')
|
||||
assert.equal(options.input.disabled, false)
|
||||
assert.equal(options.selectionStart, 2)
|
||||
assert.equal(prevented, true)
|
||||
assert.equal(stopped, true)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user