Browse Source

fix(e2e): wrong log match condition

Andelf 3 years ago
parent
commit
78d9c6f2fe
1 changed files with 11 additions and 4 deletions
  1. 11 4
      e2e-tests/fixtures.ts

+ 11 - 4
e2e-tests/fixtures.ts

@@ -22,12 +22,13 @@ export let graphDir = path.resolve(testTmpDir, "e2e-test", repoName)
 let logs: string
 const consoleLogWatcher = (msg: ConsoleMessage) => {
   // console.log(msg.text())
-  logs += msg.text() + '\n'
-  expect(msg.text(), logs).not.toMatch(/^(Failed to|Uncaught)/)
+  const text = msg.text()
+  logs += text + '\n'
+  expect(text, logs).not.toMatch(/^(Failed to|Uncaught)/)
 
   // youtube video
-  if (!logs.match(/^Error with Permissions-Policy header: Unrecognized feature/)) {
-    expect(logs).not.toMatch(/^Error/)
+  if (!text.match(/^Error with Permissions-Policy header: Unrecognized feature/)) {
+    expect(text, logs).not.toMatch(/^Error/)
   }
 
   // NOTE: React warnings will be logged as error.
@@ -133,6 +134,8 @@ interface Block {
   waitForBlocks(total: number): Promise<void>;
   /** Await for a certain number of selected blocks, with default timeout. */
   waitForSelectedBlocks(total: number): Promise<void>;
+  /** Escape editing mode, modal popup and selection. */
+  escapeEditing(): Promise<void>;
 }
 
 // hijack electron app into the test context
@@ -193,6 +196,10 @@ export const test = base.extend<{ page: Page, block: Block, context: BrowserCont
         // NOTE: `nth=` counts from 0.
         await page.waitForSelector(`.ls-block.selected >> nth=${total - 1}`, { timeout: 1000 })
       },
+      escapeEditing: async (): Promise<void> => {
+        await page.keyboard.press('Escape')
+        await page.keyboard.press('Escape')
+      }
     }
     use(block)
   },