Skip to content

Commit

Permalink
test(e2e): split build and test
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Sep 6, 2022
1 parent dee6c9a commit 43dd321
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 47 deletions.
73 changes: 58 additions & 15 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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() }}
Expand Down
61 changes: 29 additions & 32 deletions e2e-tests/editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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")
Expand All @@ -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()

Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
}
Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 43dd321

Please sign in to comment.