From 43dd321ce44dec25b29873ac34db2b5852e6db32 Mon Sep 17 00:00:00 2001 From: Andelf Date: Tue, 6 Sep 2022 00:04:24 +0800 Subject: [PATCH] test(e2e): split build and test --- .github/workflows/e2e.yml | 73 +++++++++++++++++++++++++++++++-------- e2e-tests/editor.spec.ts | 61 ++++++++++++++++---------------- resources/package.json | 1 + 3 files changed, 88 insertions(+), 47 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 74c15632705..0bad585fb9a 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -24,18 +24,10 @@ env: BABASHKA_VERSION: '0.8.1' jobs: - - e2e-test-repeat: + e2e-test-build: + name: Build Test Artifact 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: - - name: Repeat message - run: echo running E2E test with repeat id ${{ matrix.repeat }} - - name: Checkout uses: actions/checkout@v2 @@ -88,21 +80,72 @@ jobs: env: 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 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 run: git diff --exit-code static/yarn.lock - name: Run Playwright test - run: xvfb-run -- yarn e2e-test + run: xvfb-run -- npx playwright test --reporter github --shard=${{ matrix.shard }}/3 env: CI: true DEBUG: "pw:api" + RELEASE: true # skip dev only test # - name: Save test artifacts # if: ${{ failure() }} diff --git a/e2e-tests/editor.spec.ts b/e2e-tests/editor.spec.ts index 8051be5b5c6..c8c8854d9c0 100644 --- a/e2e-tests/editor.spec.ts +++ b/e2e-tests/editor.spec.ts @@ -111,6 +111,9 @@ test( "but dont trigger RIME #3440 ", // cases should trigger [[]] #3251 async ({ page, block }) => { + // This test requires dev mode + test.skip(process.env.RELEASE === 'true', 'not avaliable for release version') + for (let [idx, events] of [ kb_events.win10_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 await block.mustType('text1 ') 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 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 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 autocompleteMenu.expectVisible(modalName) @@ -288,10 +291,9 @@ test('#6266 moving cursor outside of brackets should close autocomplete menu', a // Then, right arrow 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 page.waitForTimeout(100) @@ -308,11 +310,8 @@ test('#6266 moving cursor outside of parens immediately after searching should s await createRandomPage(page) // 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.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) // 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) const cursorPos = await block.selectionStart() @@ -355,16 +353,15 @@ test('moving cursor inside of brackets should NOT close autocomplete menu', asyn await createRandomPage(page) // 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) if (commandTrigger === '[[') { await autocompleteMenu.expectVisible(modalName) } - await page.keyboard.type("search") - await page.waitForTimeout(100) + await page.keyboard.type("search", { delay: 20 }) await autocompleteMenu.expectVisible(modalName) // 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 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 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 autocompleteMenu.expectHidden(modalName) - await page.keyboard.press('ArrowLeft', {delay: 50}) + await page.keyboard.press('ArrowLeft', { delay: 50 }) await autocompleteMenu.expectHidden(modalName) - await page.keyboard.press('ArrowLeft', {delay: 50}) + await page.keyboard.press('ArrowLeft', { delay: 50 }) await autocompleteMenu.expectHidden(modalName) // 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 autocompleteMenu.expectVisible(modalName) } @@ -413,12 +410,12 @@ test('selecting text inside of brackets should NOT close autocomplete menu', asy // Open the autocomplete menu await block.mustFill('') - await page.keyboard.type(commandTrigger, { delay: 10 }) + await page.keyboard.type(commandTrigger, { delay: 20 }) await page.waitForTimeout(100) 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 autocompleteMenu.expectVisible(modalName) @@ -434,13 +431,13 @@ test('pressing backspace and remaining inside of brackets should NOT close autoc await createRandomPage(page) // 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 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 autocompleteMenu.expectVisible(modalName) @@ -458,7 +455,7 @@ test('press escape when autocomplete menu is open, should close autocomplete men // Open the action modal await block.mustFill('text ') await page.waitForTimeout(550) - await page.keyboard.type(commandTrigger, { delay: 10 }) + await page.keyboard.type(commandTrigger, { delay: 20 }) await page.waitForTimeout(100) 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 await block.mustFill('') await page.waitForTimeout(550) - await page.keyboard.type(commandTrigger, { delay: 10 }) + await page.keyboard.type(commandTrigger, { delay: 20 }) await page.waitForTimeout(100) 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 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() expect(await block.indent()).toBe(true) diff --git a/resources/package.json b/resources/package.json index 0766bd23702..a55bea950bb 100644 --- a/resources/package.json +++ b/resources/package.json @@ -13,6 +13,7 @@ "electron:make-macos-arm64": "electron-forge make --platform=darwin --arch=arm64", "electron:publish:github": "electron-forge publish", "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" }, "config": {