diff --git a/e2e-tests/editor.spec.ts b/e2e-tests/editor.spec.ts index 57eb3eee2..0e93dc46d 100644 --- a/e2e-tests/editor.spec.ts +++ b/e2e-tests/editor.spec.ts @@ -7,7 +7,7 @@ import * as kb_events from './util/keyboard-events' test( "press Chinese parenthesis 【 by 2 times #3251 should trigger [[]], " + "but dont trigger RIME #3440 ", - // cases should trigger [[]] + // cases should trigger [[]] #3251 async ({ page }) => { for (let left_full_bracket of [ kb_events.macos_pinyin_left_full_bracket, @@ -22,16 +22,22 @@ test( await page.type(':nth-match(textarea, 1)', "【") await dispatch_kb_events(page, ':nth-match(textarea, 1)', left_full_bracket) expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('[[]]') - } + }; - // cases should NOT trigger [[]] - await createRandomPage(page) - await page.type(':nth-match(textarea, 1)', "【") - await dispatch_kb_events(page, ':nth-match(textarea, 1)', kb_events.win10_RIME_left_full_bracket) - expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('【') - await page.type(':nth-match(textarea, 1)', "【") - await dispatch_kb_events(page, ':nth-match(textarea, 1)', kb_events.win10_RIME_left_full_bracket) - expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('【【') + // dont trigger RIME #3440 + for (let [idx, selecting_candidate_left_bracket] of [ + kb_events.macos_pinyin_selecting_candidate_left_bracket, + kb_events.win10_RIME_selecting_candidate_left_bracket + ].entries()) { + await createRandomPage(page) + let prefix = "#3440 test " + idx + ": " + await page.type(':nth-match(textarea, 1)', prefix + "【") + await dispatch_kb_events(page, ':nth-match(textarea, 1)', selecting_candidate_left_bracket) + expect(await page.inputValue(':nth-match(textarea, 1)')).toBe(prefix + '【') + await page.type(':nth-match(textarea, 1)', "【") + await dispatch_kb_events(page, ':nth-match(textarea, 1)', selecting_candidate_left_bracket) + expect(await page.inputValue(':nth-match(textarea, 1)')).toBe(prefix + '【【') + } }) test('hashtag and quare brackets in same line #4178', async ({ page }) => { diff --git a/e2e-tests/util/keyboard-events.ts b/e2e-tests/util/keyboard-events.ts index 7f6120be2..cb824b662 100644 --- a/e2e-tests/util/keyboard-events.ts +++ b/e2e-tests/util/keyboard-events.ts @@ -123,7 +123,115 @@ export let win10_legacy_pinyin_left_full_bracket = [ } ] -export let win10_RIME_left_full_bracket = [ +export let macos_pinyin_selecting_candidate_left_bracket = [ + { + "event_type": "keydown", + "event": { + "key": "a", + "code": "KeyA", + "location": 0, + "ctrlKey": false, + "shiftKey": false, + "altKey": false, + "metaKey": false, + "repeat": false, + "isComposing": false, + "composed": true + } + }, + { + "event_type": "keyup", + "event": { + "key": "a", + "code": "KeyA", + "location": 0, + "ctrlKey": false, + "shiftKey": false, + "altKey": false, + "metaKey": false, + "repeat": false, + "isComposing": true, + "composed": true + } + }, + { + "event_type": "keydown", + "event": { + "key": "【", + "code": "BracketLeft", + "location": 0, + "ctrlKey": false, + "shiftKey": false, + "altKey": false, + "metaKey": false, + "repeat": false, + "isComposing": true, + "composed": true + } + }, + { + "event_type": "keyup", + "event": { + "key": "【", + "code": "BracketLeft", + "location": 0, + "ctrlKey": false, + "shiftKey": false, + "altKey": false, + "metaKey": false, + "repeat": false, + "isComposing": true, + "composed": true + } + } +] + +export let win10_RIME_selecting_candidate_left_bracket = [ + { + "event_type": "keydown", + "event": { + "key": "Process", + "code": "KeyA", + "location": 0, + "ctrlKey": false, + "shiftKey": false, + "altKey": false, + "metaKey": false, + "repeat": false, + "isComposing": false, + "composed": true + } + }, + { + "event_type": "keyup", + "event": { + "key": "Process", + "code": "KeyA", + "location": 0, + "ctrlKey": false, + "shiftKey": false, + "altKey": false, + "metaKey": false, + "repeat": false, + "isComposing": true, + "composed": true + } + }, + { + "event_type": "keyup", + "event": { + "key": "a", + "code": "KeyA", + "location": 0, + "ctrlKey": false, + "shiftKey": false, + "altKey": false, + "metaKey": false, + "repeat": false, + "isComposing": true, + "composed": true + } + }, { "event_type": "keydown", "event": { @@ -135,7 +243,7 @@ export let win10_RIME_left_full_bracket = [ "altKey": false, "metaKey": false, "repeat": false, - "isComposing": false, + "isComposing": true, "composed": true } }, @@ -213,50 +321,5 @@ export let win10_RIME_left_full_bracket = [ "isComposing": true, "composed": true } - }, - { - "event_type": "keydown", - "event": { - "key": "Process", - "code": "Space", - "location": 0, - "ctrlKey": false, - "shiftKey": false, - "altKey": false, - "metaKey": false, - "repeat": false, - "isComposing": true, - "composed": true - } - }, - { - "event_type": "keyup", - "event": { - "key": "Process", - "code": "Space", - "location": 0, - "ctrlKey": false, - "shiftKey": false, - "altKey": false, - "metaKey": false, - "repeat": false, - "isComposing": false, - "composed": true - } - }, - { - "event_type": "keyup", - "event": { - "key": " ", - "code": "Space", - "location": 0, - "ctrlKey": false, - "shiftKey": false, - "altKey": false, - "metaKey": false, - "repeat": false, - "isComposing": false, - "composed": true - } } ] \ No newline at end of file