浏览代码

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

Junyi Du 3 年之前
父节点
当前提交
a520781503
共有 2 个文件被更改,包括 90 次插入21 次删除
  1. 16 10
      e2e-tests/editor.spec.ts
  2. 74 11
      e2e-tests/util/keyboard-events.ts

+ 16 - 10
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 }) => {

+ 74 - 11
e2e-tests/util/keyboard-events.ts

@@ -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,
@@ -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,
@@ -157,7 +172,7 @@ export let win10_RIME_left_full_bracket = [
   {
     "event_type": "keyup",
     "event": {
-      "key": "[",
+      "key": "",
       "code": "BracketLeft",
       "location": 0,
       "ctrlKey": false,
@@ -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",
@@ -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,
@@ -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
     }
   }