Browse Source

test(e2e): split build and test

Andelf 3 years ago
parent
commit
43dd321ce4
3 changed files with 88 additions and 47 deletions
  1. 58 15
      .github/workflows/e2e.yml
  2. 29 32
      e2e-tests/editor.spec.ts
  3. 1 0
      resources/package.json

+ 58 - 15
.github/workflows/e2e.yml

@@ -24,18 +24,10 @@ env:
   BABASHKA_VERSION: '0.8.1'
   BABASHKA_VERSION: '0.8.1'
 
 
 jobs:
 jobs:
-
-  e2e-test-repeat:
+  e2e-test-build:
+    name: Build Test Artifact
     runs-on: ubuntu-latest
     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] # Test 4 times for E2E robustness
-
     steps:
     steps:
-      - name: Repeat message
-        run: echo running E2E test with repeat id ${{ matrix.repeat }}
-
       - name: Checkout
       - name: Checkout
         uses: actions/checkout@v2
         uses: actions/checkout@v2
 
 
@@ -88,21 +80,72 @@ jobs:
         env:
         env:
           PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
           PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
 
 
-      # NOTE: require the app to be build in debug mode(compile instead of build).
+      # NOTE: require the app to be build in debug mode
       - name: Prepare E2E test build
       - name: Prepare E2E test build
         run: |
         run: |
-          yarn gulp:build && clojure -M:cljs compile app publishing electron
-          (cd static && yarn install && yarn rebuild:better-sqlite3)
+          yarn gulp:build && clojure -M:cljs release app electron --debug
+
+      # NOTE: should include .shadow-cljs if in dev mode(compile)
+      - name: Create Archive for build
+        run: tar czf static.tar.gz static
+
+      - name: Upload Artifact
+        uses: actions/upload-artifact@v3
+        with:
+          name: logseq-e2e-artifact
+          path: static.tar.gz
+          retention-days: 1
+
+  e2e-test-run:
+    needs: [ e2e-test-build ]
+    name: Test Shard ${{ matrix.shard }} Repeat ${{ matrix.repeat }}
+    runs-on: ubuntu-latest
+    continue-on-error: true # Don't block other runs in matrix for fast debugging
+    strategy:
+      matrix:
+        repeat: [1, 2]
+        shard: [1, 2, 3]
+
+    steps:
+      - name: Repeat message
+        run: echo ::info title=StartUp::E2E testing shard ${{ matrix.shard}}/3 repeat ${{ matrix.repeat }}
+
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Download test build artifact
+        uses: actions/download-artifact@v3
+        with:
+          name: logseq-e2e-artifact
+
+      - name: Extract test Artifact
+        run: tar xzf static.tar.gz
+
+      - name: Set up Node
+        uses: actions/setup-node@v2
+        with:
+          node-version: ${{ env.NODE_VERSION }}
+          cache: 'yarn'
+          cache-dependency-path: |
+            yarn.lock
+            static/yarn.lock
+
+      - name: Fetch yarn deps for E2E test
+        run: |
+          yarn install
+          (cd static && yarn install && yarn rebuild:all)
+        env:
+          PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
 
 
-      # Exits with 0 if yarn.lock is up to date or 1 if we forgot to update it
       - name: Ensure static yarn.lock is up to date
       - name: Ensure static yarn.lock is up to date
         run: git diff --exit-code static/yarn.lock
         run: git diff --exit-code static/yarn.lock
 
 
       - name: Run Playwright test
       - name: Run Playwright test
-        run: xvfb-run -- yarn e2e-test
+        run: xvfb-run -- npx playwright test --reporter github --shard=${{ matrix.shard }}/3
         env:
         env:
           CI: true
           CI: true
           DEBUG: "pw:api"
           DEBUG: "pw:api"
+          RELEASE: true # skip dev only test
 
 
       # - name: Save test artifacts
       # - name: Save test artifacts
       #   if: ${{ failure() }}
       #   if: ${{ failure() }}

+ 29 - 32
e2e-tests/editor.spec.ts

@@ -111,6 +111,9 @@ test(
   "but dont trigger RIME #3440 ",
   "but dont trigger RIME #3440 ",
   // cases should trigger [[]] #3251
   // cases should trigger [[]] #3251
   async ({ page, block }) => {
   async ({ page, block }) => {
+    // This test requires dev mode
+    test.skip(process.env.RELEASE === 'true', 'not avaliable for release version')
+
     for (let [idx, events] of [
     for (let [idx, events] of [
       kb_events.win10_pinyin_left_full_square_bracket,
       kb_events.win10_pinyin_left_full_square_bracket,
       kb_events.macos_pinyin_left_full_square_bracket
       kb_events.macos_pinyin_left_full_square_bracket
@@ -253,7 +256,7 @@ test('undo after starting an action should close the action menu #6269', async (
     // Open the action modal
     // Open the action modal
     await block.mustType('text1 ')
     await block.mustType('text1 ')
     await page.waitForTimeout(550)
     await page.waitForTimeout(550)
-    await page.keyboard.type(commandTrigger, { delay: 10 })
+    await page.keyboard.type(commandTrigger, { delay: 20 })
 
 
     await page.waitForTimeout(100) // Tolerable delay for the action menu to open
     await page.waitForTimeout(100) // Tolerable delay for the action menu to open
     await expect(page.locator(`[data-modal-name="${modalName}"]`)).toBeVisible()
     await expect(page.locator(`[data-modal-name="${modalName}"]`)).toBeVisible()
@@ -275,8 +278,8 @@ test('#6266 moving cursor outside of brackets should close autocomplete menu', a
     // First, left arrow
     // First, left arrow
     await createRandomPage(page)
     await createRandomPage(page)
 
 
-    await block.mustFill('')
-    await page.keyboard.type(commandTrigger, { delay: 10 })
+    await block.mustFill('t ')
+    await page.keyboard.type(commandTrigger, { delay: 20 })
 
 
     await page.waitForTimeout(100) // Sometimes it doesn't trigger without this
     await page.waitForTimeout(100) // Sometimes it doesn't trigger without this
     await autocompleteMenu.expectVisible(modalName)
     await autocompleteMenu.expectVisible(modalName)
@@ -288,10 +291,9 @@ test('#6266 moving cursor outside of brackets should close autocomplete menu', a
     // Then, right arrow
     // Then, right arrow
     await createRandomPage(page)
     await createRandomPage(page)
 
 
-    await block.mustFill('')
-    await page.keyboard.type(commandTrigger, { delay: 10 })
+    await block.mustFill('t ')
+    await page.keyboard.type(commandTrigger, { delay: 20 })
 
 
-    await page.waitForTimeout(100)
     await autocompleteMenu.expectVisible(modalName)
     await autocompleteMenu.expectVisible(modalName)
 
 
     await page.waitForTimeout(100)
     await page.waitForTimeout(100)
@@ -308,11 +310,8 @@ test('#6266 moving cursor outside of parens immediately after searching should s
     await createRandomPage(page)
     await createRandomPage(page)
 
 
     // Open the autocomplete menu
     // Open the autocomplete menu
-    // TODO: Maybe remove these "text " entries in tests that don't need them
-    await block.mustFill('')
-    await page.waitForTimeout(550)
-
-    await page.keyboard.type(commandTrigger, { delay: 10 })
+    await block.mustFill('t ')
+    await page.keyboard.type(commandTrigger, { delay: 20 })
 
 
     await page.waitForTimeout(100)
     await page.waitForTimeout(100)
     await page.keyboard.type("some block search text")
     await page.keyboard.type("some block search text")
@@ -331,10 +330,9 @@ test('pressing up and down should NOT close autocomplete menu', async ({ page, b
     await createRandomPage(page)
     await createRandomPage(page)
 
 
     // Open the autocomplete menu
     // Open the autocomplete menu
-    await block.mustFill('')
-    await page.keyboard.type(commandTrigger, { delay: 10 })
+    await block.mustFill('t ')
+    await page.keyboard.type(commandTrigger, { delay: 20 })
 
 
-    await page.waitForTimeout(100) // Sometimes it doesn't trigger without this
     await autocompleteMenu.expectVisible(modalName)
     await autocompleteMenu.expectVisible(modalName)
     const cursorPos = await block.selectionStart()
     const cursorPos = await block.selectionStart()
 
 
@@ -355,16 +353,15 @@ test('moving cursor inside of brackets should NOT close autocomplete menu', asyn
     await createRandomPage(page)
     await createRandomPage(page)
 
 
     // Open the autocomplete menu
     // Open the autocomplete menu
-    await block.mustFill('')
-    await page.keyboard.type(commandTrigger, { delay: 10 })
+    await block.mustType('test ')
+    await page.keyboard.type(commandTrigger, { delay: 20 })
 
 
     await page.waitForTimeout(100)
     await page.waitForTimeout(100)
     if (commandTrigger === '[[') {
     if (commandTrigger === '[[') {
       await autocompleteMenu.expectVisible(modalName)
       await autocompleteMenu.expectVisible(modalName)
     }
     }
 
 
-    await page.keyboard.type("search")
-    await page.waitForTimeout(100)
+    await page.keyboard.type("search", { delay: 20 })
     await autocompleteMenu.expectVisible(modalName)
     await autocompleteMenu.expectVisible(modalName)
 
 
     // Move cursor, still inside the brackets
     // Move cursor, still inside the brackets
@@ -381,7 +378,7 @@ test('moving cursor inside of brackets when autocomplete menu is closed should N
 
 
     // Open the autocomplete menu
     // Open the autocomplete menu
     await block.mustFill('')
     await block.mustFill('')
-    await page.keyboard.type(commandTrigger, { delay: 10 })
+    await page.keyboard.type(commandTrigger, { delay: 20 })
 
 
     await page.waitForTimeout(100) // Sometimes it doesn't trigger without this
     await page.waitForTimeout(100) // Sometimes it doesn't trigger without this
     await autocompleteMenu.expectVisible(modalName)
     await autocompleteMenu.expectVisible(modalName)
@@ -394,14 +391,14 @@ test('moving cursor inside of brackets when autocomplete menu is closed should N
     await page.waitForTimeout(100)
     await page.waitForTimeout(100)
     await autocompleteMenu.expectHidden(modalName)
     await autocompleteMenu.expectHidden(modalName)
 
 
-    await page.keyboard.press('ArrowLeft', {delay: 50})
+    await page.keyboard.press('ArrowLeft', { delay: 50 })
     await autocompleteMenu.expectHidden(modalName)
     await autocompleteMenu.expectHidden(modalName)
 
 
-    await page.keyboard.press('ArrowLeft', {delay: 50})
+    await page.keyboard.press('ArrowLeft', { delay: 50 })
     await autocompleteMenu.expectHidden(modalName)
     await autocompleteMenu.expectHidden(modalName)
 
 
     // Type a letter, this should open the autocomplete menu
     // Type a letter, this should open the autocomplete menu
-    await page.keyboard.type('z', { delay: 10 })
+    await page.keyboard.type('z', { delay: 20 })
     await page.waitForTimeout(100)
     await page.waitForTimeout(100)
     await autocompleteMenu.expectVisible(modalName)
     await autocompleteMenu.expectVisible(modalName)
   }
   }
@@ -413,12 +410,12 @@ test('selecting text inside of brackets should NOT close autocomplete menu', asy
 
 
     // Open the autocomplete menu
     // Open the autocomplete menu
     await block.mustFill('')
     await block.mustFill('')
-    await page.keyboard.type(commandTrigger, { delay: 10 })
+    await page.keyboard.type(commandTrigger, { delay: 20 })
 
 
     await page.waitForTimeout(100)
     await page.waitForTimeout(100)
     await autocompleteMenu.expectVisible(modalName)
     await autocompleteMenu.expectVisible(modalName)
 
 
-    await page.keyboard.type("some page search text", {delay: 10})
+    await page.keyboard.type("some page search text", { delay: 10 })
     await page.waitForTimeout(100)
     await page.waitForTimeout(100)
     await autocompleteMenu.expectVisible(modalName)
     await autocompleteMenu.expectVisible(modalName)
 
 
@@ -434,13 +431,13 @@ test('pressing backspace and remaining inside of brackets should NOT close autoc
     await createRandomPage(page)
     await createRandomPage(page)
 
 
     // Open the autocomplete menu
     // Open the autocomplete menu
-    await block.mustFill('')
-    await page.keyboard.type(commandTrigger, { delay: 10 })
+    await block.mustFill('test ')
+    await page.keyboard.type(commandTrigger, { delay: 20 })
 
 
     await page.waitForTimeout(100)
     await page.waitForTimeout(100)
     await autocompleteMenu.expectVisible(modalName)
     await autocompleteMenu.expectVisible(modalName)
 
 
-    await page.keyboard.type("some page search text", {delay: 10})
+    await page.keyboard.type("some page search text", { delay: 10 })
     await page.waitForTimeout(100)
     await page.waitForTimeout(100)
     await autocompleteMenu.expectVisible(modalName)
     await autocompleteMenu.expectVisible(modalName)
 
 
@@ -458,7 +455,7 @@ test('press escape when autocomplete menu is open, should close autocomplete men
     // Open the action modal
     // Open the action modal
     await block.mustFill('text ')
     await block.mustFill('text ')
     await page.waitForTimeout(550)
     await page.waitForTimeout(550)
-    await page.keyboard.type(commandTrigger, { delay: 10 })
+    await page.keyboard.type(commandTrigger, { delay: 20 })
 
 
     await page.waitForTimeout(100)
     await page.waitForTimeout(100)
     await expect(page.locator(`[data-modal-name="${modalName}"]`)).toBeVisible()
     await expect(page.locator(`[data-modal-name="${modalName}"]`)).toBeVisible()
@@ -480,7 +477,7 @@ test('press escape when link/image dialog is open, should restore focus to input
     // Open the action modal
     // Open the action modal
     await block.mustFill('')
     await block.mustFill('')
     await page.waitForTimeout(550)
     await page.waitForTimeout(550)
-    await page.keyboard.type(commandTrigger, { delay: 10 })
+    await page.keyboard.type(commandTrigger, { delay: 20 })
 
 
     await page.waitForTimeout(100)
     await page.waitForTimeout(100)
     await expect(page.locator(`[data-modal-name="${modalName}"]`)).toBeVisible()
     await expect(page.locator(`[data-modal-name="${modalName}"]`)).toBeVisible()
@@ -503,9 +500,9 @@ test('should show text after soft return when node is collapsed #5074', async ({
   const delay = 100
   const delay = 100
   await createRandomPage(page)
   await createRandomPage(page)
 
 
-  await page.type('textarea >> nth=0', 'Before soft return', {delay: 10})
-  await page.keyboard.press('Shift+Enter', {delay: 10})
-  await page.type('textarea >> nth=0', 'After soft return', {delay: 10})
+  await page.type('textarea >> nth=0', 'Before soft return', { delay: 10 })
+  await page.keyboard.press('Shift+Enter', { delay: 10 })
+  await page.type('textarea >> nth=0', 'After soft return', { delay: 10 })
 
 
   await block.enterNext()
   await block.enterNext()
   expect(await block.indent()).toBe(true)
   expect(await block.indent()).toBe(true)

+ 1 - 0
resources/package.json

@@ -13,6 +13,7 @@
     "electron:make-macos-arm64": "electron-forge make --platform=darwin --arch=arm64",
     "electron:make-macos-arm64": "electron-forge make --platform=darwin --arch=arm64",
     "electron:publish:github": "electron-forge publish",
     "electron:publish:github": "electron-forge publish",
     "rebuild:better-sqlite3": "electron-rebuild -v 19.0.12 -f -w better-sqlite3",
     "rebuild:better-sqlite3": "electron-rebuild -v 19.0.12 -f -w better-sqlite3",
+    "rebuild:all": "electron-rebuild -v 19.0.12 -f",
     "postinstall": "install-app-deps"
     "postinstall": "install-app-deps"
   },
   },
   "config": {
   "config": {