Skip to content

Commit

Permalink
test(e2e): addressing #3440 related case on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
cnrpman authored and tiensonqin committed Apr 1, 2022
1 parent 2cfa95d commit a520781
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 21 deletions.
26 changes: 16 additions & 10 deletions e2e-tests/editor.spec.ts
Expand Up @@ -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,
Expand All @@ -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 }) => {
Expand Down
85 changes: 74 additions & 11 deletions e2e-tests/util/keyboard-events.ts
Expand Up @@ -123,12 +123,12 @@ 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": "Process",
"code": "BracketLeft",
"key": "a",
"code": "KeyA",
"location": 0,
"ctrlKey": false,
"shiftKey": false,
Expand All @@ -142,7 +142,22 @@ export let win10_RIME_left_full_bracket = [
{
"event_type": "keyup",
"event": {
"key": "Process",
"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,
Expand All @@ -157,7 +172,7 @@ export let win10_RIME_left_full_bracket = [
{
"event_type": "keyup",
"event": {
"key": "[",
"key": "",
"code": "BracketLeft",
"location": 0,
"ctrlKey": false,
Expand All @@ -168,6 +183,54 @@ export let win10_RIME_left_full_bracket = [
"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",
Expand Down Expand Up @@ -218,7 +281,7 @@ export let win10_RIME_left_full_bracket = [
"event_type": "keydown",
"event": {
"key": "Process",
"code": "Space",
"code": "BracketLeft",
"location": 0,
"ctrlKey": false,
"shiftKey": false,
Expand All @@ -233,29 +296,29 @@ export let win10_RIME_left_full_bracket = [
"event_type": "keyup",
"event": {
"key": "Process",
"code": "Space",
"code": "BracketLeft",
"location": 0,
"ctrlKey": false,
"shiftKey": false,
"altKey": false,
"metaKey": false,
"repeat": false,
"isComposing": false,
"isComposing": true,
"composed": true
}
},
{
"event_type": "keyup",
"event": {
"key": " ",
"code": "Space",
"key": "[",
"code": "BracketLeft",
"location": 0,
"ctrlKey": false,
"shiftKey": false,
"altKey": false,
"metaKey": false,
"repeat": false,
"isComposing": false,
"isComposing": true,
"composed": true
}
}
Expand Down

0 comments on commit a520781

Please sign in to comment.