Skip to content

Commit 23bacc6

Browse files
authored
Merge pull request #7007 from LibreSign/backport/6998/stable33
[stable33] feat: playwright e2e tests
2 parents 4a77dfe + 40d6709 commit 23bacc6

9 files changed

Lines changed: 701 additions & 1 deletion

File tree

.github/workflows/playwright.yml

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
name: Playwright Tests
5+
6+
on:
7+
pull_request:
8+
branches: [main]
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: playwright-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
matrix:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
server-max: ${{ steps.versions.outputs.branches-max-list }}
22+
steps:
23+
- name: Checkout app
24+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
with:
26+
persist-credentials: false
27+
28+
- name: Get version matrix
29+
id: versions
30+
uses: icewind1991/nextcloud-version-matrix@8a7bac6300b2f0f3100088b297995a229558ddba # v1.3.2.3.1.3.2
31+
32+
changes:
33+
runs-on: ubuntu-latest
34+
35+
outputs:
36+
src: ${{ steps.changes.outputs.src }}
37+
38+
steps:
39+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
40+
id: changes
41+
continue-on-error: true
42+
with:
43+
filters: |
44+
src:
45+
- '.github/workflows/playwright.yml'
46+
- 'appinfo/**'
47+
- 'lib/**'
48+
- 'src/**'
49+
- 'templates/**'
50+
- 'playwright/**'
51+
- 'playwright.config.ts'
52+
- 'package.json'
53+
- 'package-lock.json'
54+
55+
playwright:
56+
runs-on: ubuntu-latest
57+
timeout-minutes: 60
58+
59+
needs: [matrix, changes]
60+
if: needs.changes.outputs.src != 'false'
61+
62+
strategy:
63+
matrix:
64+
server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
65+
66+
name: Playwright E2E Tests
67+
68+
services:
69+
mailpit:
70+
image: axllent/mailpit
71+
ports:
72+
- 8025:8025/tcp
73+
- 1025:1025/tcp
74+
75+
steps:
76+
- name: Set app env
77+
run: |
78+
# Split and keep last
79+
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
80+
81+
- name: Install system dependencies
82+
run: sudo apt update && sudo apt install poppler-utils
83+
84+
- name: Checkout server
85+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
86+
with:
87+
persist-credentials: false
88+
submodules: true
89+
repository: nextcloud/server
90+
ref: ${{ matrix.server-versions }}
91+
92+
- name: Checkout app
93+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
94+
with:
95+
persist-credentials: false
96+
submodules: true
97+
path: apps/${{ env.APP_NAME }}
98+
99+
- name: Get php version
100+
id: php_versions
101+
uses: icewind1991/nextcloud-version-matrix@8a7bac6300b2f0f3100088b297995a229558ddba # v1.3.2.3.1.3.2
102+
with:
103+
filename: apps/${{ env.APP_NAME }}/appinfo/info.xml
104+
105+
- name: Set up php ${{ steps.php_versions.outputs.php-min }}
106+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
107+
with:
108+
php-version: ${{ steps.php_versions.outputs.php-min }}
109+
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, sqlite, pdo_sqlite, xmlreader, xmlwriter, zip, zlib
110+
coverage: none
111+
ini-file: development
112+
ini-values: disable_functions=
113+
env:
114+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
115+
116+
- name: Check composer file existence
117+
id: check_composer
118+
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
119+
with:
120+
files: apps/${{ env.APP_NAME }}/composer.json
121+
122+
- name: Set up composer dependencies
123+
if: steps.check_composer.outputs.files_exists == 'true'
124+
working-directory: apps/${{ env.APP_NAME }}
125+
run: |
126+
composer remove nextcloud/ocp --dev --no-scripts
127+
composer install --no-dev
128+
129+
- name: Read package.json node and npm engines version
130+
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
131+
id: versions
132+
with:
133+
path: apps/${{ env.APP_NAME }}
134+
fallbackNode: '^24'
135+
fallbackNpm: '^11'
136+
137+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
138+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
139+
with:
140+
node-version: ${{ steps.versions.outputs.nodeVersion }}
141+
142+
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
143+
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
144+
145+
- name: Install node dependencies & build app
146+
working-directory: apps/${{ env.APP_NAME }}
147+
env:
148+
CYPRESS_INSTALL_BINARY: 0
149+
run: |
150+
npm ci
151+
TESTING=true npm run build --if-present
152+
153+
- name: Set up Nextcloud
154+
run: |
155+
sudo echo "127.0.0.1 mailpit" | sudo tee -a /etc/hosts
156+
mkdir data
157+
./occ maintenance:install \
158+
--verbose \
159+
--database=sqlite \
160+
--admin-user admin \
161+
--admin-pass admin
162+
./occ --version
163+
164+
- name: Install app dependencies
165+
run: |
166+
git clone --depth 1 -b ${{ matrix.server-versions }} https://github.com/nextcloud/notifications apps/notifications
167+
composer --working-dir=apps/notifications install --no-dev
168+
./occ app:enable --force notifications
169+
git clone --depth 1 -b ${{ matrix.server-versions }} https://github.com/nextcloud/activity apps/activity
170+
composer --working-dir=apps/activity install --no-dev
171+
./occ app:enable --force activity
172+
173+
- name: Set up LibreSign
174+
run: |
175+
./occ app:enable --force ${{ env.APP_NAME }}
176+
./occ config:system:set allow_local_remote_servers --value true --type boolean
177+
./occ config:system:set auth.bruteforce.protection.enabled --value false --type boolean
178+
./occ config:system:set ratelimit.protection.enabled --value false --type boolean
179+
./occ config:system:set mail_smtphost --value mailpit
180+
./occ config:system:set mail_smtpport --value 1025 --type integer
181+
./occ config:system:set overwrite.cli.url --value 'http://localhost:8080'
182+
./occ config:system:set overwritehost --value 'localhost:8080'
183+
./occ config:system:set debug --value true --type boolean
184+
./occ libresign:install --use-local-cert --java
185+
./occ libresign:install --use-local-cert --jsignpdf
186+
./occ libresign:install --use-local-cert --pdftk
187+
./occ libresign:configure:openssl \
188+
--cn="Common Name" \
189+
--c=BR \
190+
--ou="Organization Unit" \
191+
--st="Rio de Janeiro" \
192+
--o=LibreSign \
193+
--l="Rio de Janeiro"
194+
./occ user:setting admin settings email admin@email.tld
195+
196+
- name: Start PHP built-in server
197+
run: |
198+
# front_controller_active tells Nextcloud to generate clean URLs (without index.php prefix)
199+
# This mirrors what Apache mod_rewrite does via .htaccess RewriteRule
200+
front_controller_active=true php -S localhost:8080 -t . apps/${{ env.APP_NAME }}/playwright/router.php &
201+
# Wait for server to become available
202+
timeout 30 bash -c 'until curl -s http://localhost:8080/status.php > /dev/null; do sleep 1; done'
203+
echo "Nextcloud is ready at http://localhost:8080"
204+
205+
- name: Install Playwright browsers
206+
working-directory: apps/${{ env.APP_NAME }}
207+
run: npx playwright install chromium --with-deps
208+
209+
- name: Run Playwright tests
210+
working-directory: apps/${{ env.APP_NAME }}
211+
env:
212+
PLAYWRIGHT_BASE_URL: http://localhost:8080
213+
NEXTCLOUD_ADMIN_USER: admin
214+
NEXTCLOUD_ADMIN_PASSWORD: admin
215+
run: npx playwright test
216+
217+
- name: Upload Playwright report
218+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
219+
if: always()
220+
with:
221+
name: playwright-report
222+
path: apps/${{ env.APP_NAME }}/playwright-report/
223+
retention-days: 30
224+
225+
- name: Upload test results
226+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
227+
if: always()
228+
with:
229+
name: playwright-test-results
230+
path: apps/${{ env.APP_NAME }}/test-results/
231+
retention-days: 30
232+
233+
- name: Print Nextcloud logs
234+
if: always()
235+
run: cat data/nextcloud.log 2>/dev/null || echo "No Nextcloud logs found"
236+
237+
summary:
238+
permissions:
239+
contents: none
240+
runs-on: ubuntu-latest
241+
needs: [matrix, changes, playwright]
242+
243+
if: always()
244+
245+
name: playwright-summary
246+
247+
steps:
248+
- name: Summary status
249+
run: if ${{ needs.changes.outputs.src != 'false' && needs.playwright.result != 'success' }}; then exit 1; fi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ node_modules/
2222
/lib/Vendor/
2323
/coverage
2424
/dist/
25+
/test-results/

package-lock.json

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
"stylelint:fix": "stylelint src/**/*.scss src/**/*.vue --fix",
1818
"test": "vitest run",
1919
"test:watch": "vitest",
20-
"test:coverage": "vitest run --coverage"
20+
"test:coverage": "vitest run --coverage",
21+
"test:e2e": "playwright test",
22+
"test:e2e:ui": "playwright test --ui --ui-host=0.0.0.0 --ui-port=9323",
23+
"test:e2e:report": "playwright show-report"
2124
},
2225
"dependencies": {
2326
"@codemirror/autocomplete": "^6.18.3",
@@ -75,6 +78,7 @@
7578
"npm": "^11.3.0"
7679
},
7780
"devDependencies": {
81+
"@playwright/test": "^1.58.1",
7882
"@nextcloud/browserslist-config": "^3.1.2",
7983
"@nextcloud/eslint-config": "^8.4.2",
8084
"@nextcloud/stylelint-config": "^3.2.1",

0 commit comments

Comments
 (0)