Skip to content

Commit fdcae54

Browse files
authored
Merge pull request #3272 from nextcloud/feature/migrate-e2e-to-playwright
test: migrate e2e tests from Cypress to Playwright
2 parents de10475 + cb18c00 commit fdcae54

161 files changed

Lines changed: 3518 additions & 6296 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/cypress-snapshot-update.yml

Lines changed: 0 additions & 73 deletions
This file was deleted.

.github/workflows/cypress.yml

Lines changed: 0 additions & 171 deletions
This file was deleted.

.github/workflows/playwright.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: MIT
3+
4+
name: Playwright
5+
6+
on: pull_request
7+
8+
concurrency:
9+
group: playwright-${{ github.head_ref || github.run_id }}
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: read
14+
15+
env:
16+
APP_NAME: ${{ github.event.repository.name }}
17+
BRANCH: ${{ github.base_ref || github.ref_name }}
18+
19+
jobs:
20+
playwright:
21+
runs-on: ubuntu-latest
22+
23+
name: Playwright E2E tests
24+
25+
steps:
26+
- name: Disabled on forks
27+
if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
28+
run: |
29+
echo 'Can not run Playwright on forks'
30+
exit 1
31+
32+
- name: Checkout app
33+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34+
with:
35+
persist-credentials: false
36+
37+
- name: Check composer.json
38+
id: check_composer
39+
uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
40+
with:
41+
files: 'composer.json'
42+
43+
- name: Install composer dependencies
44+
if: steps.check_composer.outputs.files_exists == 'true'
45+
run: composer install --no-dev
46+
47+
- name: Read package.json node and npm engines version
48+
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
49+
id: versions
50+
with:
51+
fallbackNode: '^24'
52+
fallbackNpm: '^11'
53+
54+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
55+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
56+
with:
57+
node-version: ${{ steps.versions.outputs.nodeVersion }}
58+
59+
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
60+
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
61+
62+
- name: Install dependencies & build app
63+
run: |
64+
npm ci
65+
TESTING=true npm run build --if-present
66+
67+
- name: Install Playwright browsers
68+
run: npx playwright install chromium --with-deps
69+
70+
- name: Run Playwright tests
71+
run: npx playwright test
72+
env:
73+
BRANCH: ${{ env.BRANCH }}
74+
CI: true
75+
76+
- name: Show Nextcloud logs on failure
77+
if: failure()
78+
run: |
79+
docker exec nextcloud-e2e-test-server_${{ env.APP_NAME }} cat data/nextcloud.log || true
80+
81+
- name: Upload Playwright report
82+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
83+
if: ${{ !cancelled() }}
84+
with:
85+
name: playwright-report
86+
path: playwright-report/
87+
retention-days: 7
88+
if-no-files-found: ignore
89+
90+
- name: Upload Playwright traces
91+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
92+
if: failure()
93+
with:
94+
name: playwright-traces
95+
path: test-results/
96+
retention-days: 7
97+
if-no-files-found: ignore
98+
99+
summary:
100+
runs-on: ubuntu-latest-low
101+
needs: playwright
102+
if: always()
103+
name: playwright-summary
104+
steps:
105+
- name: Summary status
106+
run: if ${{ needs.playwright.result != 'success' && needs.playwright.result != 'skipped' }}; then exit 1; fi

.gitignore

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ coverage/
2626
vendor
2727
.php_cs.cache
2828

29-
# Cypress files
29+
# Playwright files
3030
js/*roboto*
31-
cypress/downloads
32-
cypress/screenshots
33-
cypress/snapshots
34-
cypress/videos
35-
cypress/snapshots/actual
36-
cypress/snapshots/diff
31+
playwright-report/
32+
test-results/
33+
blob-report/
34+
playwright/.cache/
3735

3836
# RelativeCI webpack bundle stats
3937
webpack-stats.json

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,19 @@ Show your latest holiday photos and videos like in the movies. Show a glimpse of
2222
### 🧙 Advanced development stuff
2323
To build the Javascript whenever you make changes, you can also run `npm run dev` for development builds.
2424

25-
### 📷 Running cypress tests
26-
To run e2e cypress tests, execute `npm run cypress`.
25+
### 📷 Running Playwright tests
26+
The end-to-end tests use [Playwright](https://playwright.dev/) and a disposable Nextcloud Docker container.
2727

28-
The `visual-regression` tests require additional care as they depend on installation of fonts in the application. To achieve repeatable results run the tests using `npm run cypress:visual-regression`. This will build the app with the required fonts and run the tests.
28+
Build the app once, then run the tests:
2929

30-
If changes are required to the reference (base) screenshots used by the `visual-regression` tests, run `cypress:update-snapshots` and commit the updated screenshots.
30+
```sh
31+
npm ci
32+
npx playwright install chromium
33+
TESTING=true npm run build
34+
npm run test:e2e
35+
```
36+
37+
`npm run test:e2e:ui` opens the interactive UI. The Nextcloud container is started automatically by `playwright/start-server.mjs` (port 8081) and reused between local runs; set `PLAYWRIGHT_BASE_URL` to target an existing instance instead.
3138

3239
## API
3340

0 commit comments

Comments
 (0)