Browse Source

test(e2e): improve stability

Junyi Du 3 years ago
parent
commit
87e8bb94bb

+ 3 - 2
.github/workflows/e2e.yml

@@ -1,4 +1,4 @@
-name: E2E Test Repeat
+name: E2E
 
 # Running E2E test multiple times to confirm test stability.
 # E2E test could be randomly failed due to the batch update mechanism of React.
@@ -27,9 +27,10 @@ jobs:
 
   e2e-test-repeat:
     runs-on: ubuntu-latest
+    continue-on-error: true # Don't block other runs in matrix for fast debugging
     strategy:
       matrix:
-        repeat: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # Test 10 times for E2E robustness
+        repeat: [1, 2, 3, 4] # Test 4 times for E2E robustness
 
     steps:
       - name: Repeat message

+ 4 - 1
e2e-tests/accessibility.spec.ts

@@ -1,11 +1,14 @@
-import { injectAxe, checkA11y, getViolations, reportViolations } from 'axe-playwright'
+import { injectAxe, checkA11y } from 'axe-playwright'
 import { test } from './fixtures'
 import { createRandomPage } from './utils'
 
 
 test('check a11y for the whole page', async ({ page }) => {
+    await page.waitForTimeout(2000) // wait for everything be ready
     await injectAxe(page)
+    await page.waitForTimeout(2000) // wait for everything be ready
     await createRandomPage(page)
+    await page.waitForTimeout(2000) // wait for everything be ready
     await checkA11y(page, null, {
         detailedReport: true,
     })

+ 6 - 0
e2e-tests/editor.spec.ts

@@ -256,7 +256,9 @@ test('undo after starting an action should close the action menu #6269', async (
     await page.waitForTimeout(550)
     for (const char of commandTrigger) {
       await page.keyboard.type(char)
+      await page.waitForTimeout(50)
     }
+    await page.waitForTimeout(100) // Tolerable delay for the action menu to open
     await expect(page.locator(`[data-modal-name="${modalName}"]`)).toBeVisible()
 
     // Undo, removing "/today", and closing the action modal
@@ -281,6 +283,7 @@ test('#6266 moving cursor outside of brackets should close autocomplete menu', a
       await page.keyboard.type(char)
       await page.waitForTimeout(10) // Sometimes it doesn't trigger without this
     }
+    await page.waitForTimeout(100) // Sometimes it doesn't trigger without this
     await autocompleteMenu.expectVisible(modalName)
 
     await page.keyboard.press('ArrowLeft')
@@ -321,6 +324,7 @@ test('#6266 moving cursor outside of parens immediately after searching should s
     }
     await page.waitForTimeout(100)
     await page.keyboard.type("some block search text")
+    await page.waitForTimeout(100) // Sometimes it doesn't trigger without this
     await autocompleteMenu.expectVisible(modalName)
 
     // Move cursor outside of the space strictly between the double parens
@@ -340,6 +344,7 @@ test('pressing up and down should NOT close autocomplete menu', async ({ page, b
       await page.keyboard.type(char)
       await page.waitForTimeout(10) // Sometimes it doesn't trigger without this
     }
+    await page.waitForTimeout(100) // Sometimes it doesn't trigger without this
     await autocompleteMenu.expectVisible(modalName)
     const cursorPos = await block.selectionStart()
 
@@ -392,6 +397,7 @@ test('moving cursor inside of brackets when autocomplete menu is closed should N
       await page.keyboard.type(char)
       await page.waitForTimeout(10) // Sometimes it doesn't trigger without this
     }
+    await page.waitForTimeout(100) // Sometimes it doesn't trigger without this
     await autocompleteMenu.expectVisible(modalName)
 
     await block.escapeEditing()

+ 2 - 1
e2e-tests/fixtures.ts

@@ -28,7 +28,8 @@ const consoleLogWatcher = (msg: ConsoleMessage) => {
   expect(text, logs).not.toMatch(/^(Failed to|Uncaught)/)
 
   // youtube video
-  if (!text.match(/^Error with Permissions-Policy header: Unrecognized feature/)) {
+  // Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'ch-ua-reduced'.
+  if (!text.match(/^Error with Permissions-Policy header:/)) {
     expect(text, logs).not.toMatch(/^Error/)
   }
 

+ 4 - 2
e2e-tests/utils.ts

@@ -210,9 +210,11 @@ export async function loadLocalGraph(page: Page, path: string): Promise<void> {
 
   // If there is an error notification from a previous test graph being deleted,
   // close it first so it doesn't cover up the UI
-  while (await (page.locator('.notification-close-button').first()?.isVisible())) {
-    await page.click('.notification-close-button')
+  let locator = await page.locator('.notification-close-button').first()
+  while (await locator?.isVisible()) {
+    await locator.click()
     await page.waitForTimeout(250)
+    locator = await page.locator('.notification-close-button', {timeout: 1000}).first()
   }
 
   console.log('Graph loaded for ' + path)