test(e2e): addressing #3440 related case on macOS

pull/4789/head
Junyi Du 2022-03-08 01:33:22 +08:00 committed by Tienson Qin
parent 2cfa95d17b
commit a520781503
2 changed files with 126 additions and 57 deletions

View File

@ -7,7 +7,7 @@ import * as kb_events from './util/keyboard-events'
test( test(
"press Chinese parenthesis 【 by 2 times #3251 should trigger [[]], " + "press Chinese parenthesis 【 by 2 times #3251 should trigger [[]], " +
"but dont trigger RIME #3440 ", "but dont trigger RIME #3440 ",
// cases should trigger [[]] // cases should trigger [[]] #3251
async ({ page }) => { async ({ page }) => {
for (let left_full_bracket of [ for (let left_full_bracket of [
kb_events.macos_pinyin_left_full_bracket, kb_events.macos_pinyin_left_full_bracket,
@ -22,16 +22,22 @@ test(
await page.type(':nth-match(textarea, 1)', "【") await page.type(':nth-match(textarea, 1)', "【")
await dispatch_kb_events(page, ':nth-match(textarea, 1)', left_full_bracket) await dispatch_kb_events(page, ':nth-match(textarea, 1)', left_full_bracket)
expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('[[]]') expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('[[]]')
} };
// cases should NOT trigger [[]] // dont trigger RIME #3440
await createRandomPage(page) for (let [idx, selecting_candidate_left_bracket] of [
await page.type(':nth-match(textarea, 1)', "【") kb_events.macos_pinyin_selecting_candidate_left_bracket,
await dispatch_kb_events(page, ':nth-match(textarea, 1)', kb_events.win10_RIME_left_full_bracket) kb_events.win10_RIME_selecting_candidate_left_bracket
expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('【') ].entries()) {
await page.type(':nth-match(textarea, 1)', "【") await createRandomPage(page)
await dispatch_kb_events(page, ':nth-match(textarea, 1)', kb_events.win10_RIME_left_full_bracket) let prefix = "#3440 test " + idx + ": "
expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('【【') 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 }) => { test('hashtag and quare brackets in same line #4178', async ({ page }) => {

View File

@ -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_type": "keydown",
"event": { "event": {
@ -135,7 +243,7 @@ export let win10_RIME_left_full_bracket = [
"altKey": false, "altKey": false,
"metaKey": false, "metaKey": false,
"repeat": false, "repeat": false,
"isComposing": false, "isComposing": true,
"composed": true "composed": true
} }
}, },
@ -213,50 +321,5 @@ export let win10_RIME_left_full_bracket = [
"isComposing": true, "isComposing": true,
"composed": 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
}
} }
] ]