diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 430d0ac855..bc22f5833f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -181,105 +181,4 @@ jobs: run: cd deps/db && yarn nbb-logseq script/export_graph.cljs ../../scripts/properties-graph -f properties.edn -T - name: Create graph from the export and diff the two graphs - run: cd deps/db && yarn nbb-logseq -cp src:../outliner/src:script script/create_graph.cljs ./properties-graph2 properties.edn -iv && yarn nbb-logseq script/diff_graphs.cljs ../../scripts/properties-graph ./properties-graph2 -T - - e2e-test: - # TODO: Re-enable when ready to enable tests for file graphs - if: false - runs-on: ubuntu-22.04 - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Node - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'yarn' - cache-dependency-path: | - yarn.lock - static/yarn.lock - - - name: Set up Java - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: ${{ env.JAVA_VERSION }} - - - name: Set up Clojure - uses: DeLaGuardo/setup-clojure@10.1 - with: - cli: ${{ env.CLOJURE_VERSION }} - - - name: Clojure cache - uses: actions/cache@v3 - id: clojure-deps - with: - path: | - ~/.m2/repository - ~/.gitlibs - key: ${{ runner.os }}-clojure-deps-${{ hashFiles('deps.edn') }} - restore-keys: ${{ runner.os }}-clojure-deps- - - - name: Fetch Clojure deps - if: steps.clojure-deps.outputs.cache-hit != 'true' - run: clojure -A:cljs -P - - - name: Shadow-cljs cache - uses: actions/cache@v3 - with: - path: .shadow-cljs - # ensure update cache every time - key: ${{ runner.os }}-shadow-cljs-${{ github.sha }} - # will match most recent upload - restore-keys: | - ${{ runner.os }}-shadow-cljs- - - - name: Fetch yarn deps - run: yarn install - env: - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true - - # NOTE: require the app to be build in debug mode(compile instead of build). - - name: Prepare E2E test build - run: | - yarn gulp:build && clojure -M:cljs compile app publishing electron - (cd static && yarn install && yarn rebuild:all) - - # 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: Install Fluxbox - run: sudo apt-get update && sudo apt-get install -y fluxbox - - # Emulate a virtual framebuffer on machines with no display hardware - - name: Run XVFB - run: Xvfb :1 -screen 0 1024x768x24 >/dev/null 2>&1 & - - # Start a lightweight window manager to simulate window actions (maximize,restore etc) - - name: Start Fluxbox - run: DISPLAY=:1.0 fluxbox >/dev/null 2>&1 & - - - name: Run Playwright test - 1/2 - run: DISPLAY=:1.0 npx playwright test --reporter github --shard=1/2 - env: - LOGSEQ_CI: true - DEBUG: "pw:api" - RELEASE: true # skip dev only test - - - name: Run Playwright test - 2/2 - run: DISPLAY=:1.0 npx playwright test --reporter github --shard=2/2 - env: - LOGSEQ_CI: true - DEBUG: "pw:api" - RELEASE: true # skip dev only test - - - name: Save test artifacts - if: ${{ failure() }} - uses: actions/upload-artifact@v4 - with: - name: e2e-test-report - path: e2e-dump/* - retention-days: 1 + run: cd deps/db && yarn nbb-logseq -cp src:../outliner/src:script script/create_graph.cljs ./properties-graph2 properties.edn -iv && yarn nbb-logseq script/diff_graphs.cljs ../../scripts/properties-graph ./properties-graph2 -T \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4ff0bb10b8..15b7828dc0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -/e2e-dump /target /classes /checkouts diff --git a/clj-e2e/README.md b/clj-e2e/README.md index 9c539aacf9..0d54d20d32 100644 --- a/clj-e2e/README.md +++ b/clj-e2e/README.md @@ -13,3 +13,5 @@ Then, run the project's tests: $ clojure -T:build test If you would like to run individual tests, pass options to the test runner through `clojure -M:test`. For example, add a `^:focus` on a test and then run `clojure -M:test -i focus`. + +If e2e tests fail, `clj-e2e/e2e-dump/` contains console logs and screenshots to help debug. \ No newline at end of file diff --git a/docs/dev-practices.md b/docs/dev-practices.md index 1e25407722..0b388d947b 100644 --- a/docs/dev-practices.md +++ b/docs/dev-practices.md @@ -139,32 +139,8 @@ We have unit, performance and end to end tests. ### End to End Tests Even though we have a nightly release channel, it's hard for testing users (thanks to the brave users!) to notice all issues in a limited time, as Logseq is covering so many features. -The only solution is automatic end-to-end tests - adding tests for GUI software is always painful but necessary. See https://github.com/logseq/logseq/pulls?q=E2E for e2e test examples. -To run end to end tests - -```sh -yarn electron-watch -# in another shell -yarn e2e-test # or npx playwright test -``` - -If e2e failed after first running: -- `rm -rdf ~/.logseq` -- `rm -rdf ~/.config/Logseq` -- `rm -rdf /tmp/` -- Windows: `rmdir /s %APPDATA%/Electron` (Reference: https://www.electronjs.org/de/docs/latest/api/app#appgetpathname) - -There's a `traceAll()` helper function to enable playwright trace file dump for specific test files https://github.com/logseq/logseq/pull/8332 - -If e2e tests fail in the file, they can be debugged by examining a trace dump with [the -playwright trace -viewer](https://playwright.dev/docs/trace-viewer#recording-a-trace). - -Locally this will get dumped into e2e-dump/. - -On CI the trace file will be under Artifacts at the bottom of a run page e.g. -https://github.com/logseq/logseq/actions/runs/3574600322. +To run end to end tests, see [clj-e2e tests](/clj-e2e/README.md). ### Unit Testing diff --git a/package.json b/package.json index 8e162ab80a..b84d2562f3 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,6 @@ "dev-electron-app": "gulp electron", "release-electron": "run-s gulp:build && gulp electronMaker", "debug-electron": "cd static/ && yarn electron:debug", - "e2e-test": "cross-env DEBUG=pw:api CI=true npx playwright test --reporter github", "sync-android-release": "yarn clean && yarn release-mobile && rm -rf ./static/mobile/**/*.map && npx cap sync android", "sync-ios-release": "yarn clean && yarn release-mobile && rm -rf ./static/mobile/**/*.map && npx cap sync ios", "clean": "gulp clean", diff --git a/src/main/frontend/handler.cljs b/src/main/frontend/handler.cljs index e14b31fd03..d428852c2d 100644 --- a/src/main/frontend/handler.cljs +++ b/src/main/frontend/handler.cljs @@ -26,7 +26,6 @@ [frontend.handler.plugin-config :as plugin-config-handler] [frontend.handler.repo :as repo-handler] [frontend.handler.repo-config :as repo-config-handler] - [frontend.handler.test :as test] [frontend.handler.ui :as ui-handler] [frontend.handler.user :as user-handler] [frontend.idb :as idb] @@ -138,7 +137,6 @@ [render] (idb/start) - (test/setup-test!) (get-system-info) (set-global-error-notification!) diff --git a/src/main/frontend/handler/test.cljs b/src/main/frontend/handler/test.cljs deleted file mode 100644 index 26f198b63c..0000000000 --- a/src/main/frontend/handler/test.cljs +++ /dev/null @@ -1,16 +0,0 @@ -(ns frontend.handler.test - "Prepare for running e2e tests" - (:require [frontend.storage :as storage] - [frontend.state :as state])) - -(defn clear-whiteboard-storage-for-e2e-tests - [] - (storage/set :whiteboard/onboarding-whiteboard? false) - (storage/set :whiteboard/onboarding-tour? false) - (state/set-state! :whiteboard/onboarding-whiteboard? false) - (state/set-state! :whiteboard/onboarding-tour? false) - (prn :debug :whiteboard/onboarding-whiteboard? (:whiteboard/onboarding-whiteboard? @state/state))) - -(defn setup-test! - [] - (set! (.-clearWhiteboardStorage js/window) clear-whiteboard-storage-for-e2e-tests))