Skip to content

Commit 969d119

Browse files
committed
fix: Add playwright server setup for CI
Signed-off-by: Enjeck C. <patrathewhiz@gmail.com>
1 parent da8b309 commit 969d119

File tree

3 files changed

+132
-60
lines changed

3 files changed

+132
-60
lines changed

package.json

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,58 @@
11
{
2-
"name": "notes",
3-
"homepage": "https://github.com/nextcloud/notes",
4-
"license": "agpl",
5-
"private": true,
6-
"scripts": {
7-
"build": "webpack --node-env production --progress",
8-
"dev": "webpack --node-env development --progress",
9-
"watch": "webpack --node-env development --progress --watch",
10-
"lint": "eslint --ext .js,.vue src playwright",
11-
"lint:fix": "eslint --ext .js,.vue src playwright --fix",
12-
"stylelint": "stylelint 'src/**/*.vue' 'css/**/*.css'",
13-
"stylelint:fix": "stylelint 'src/**/*.vue' 'css/**/*.css' --fix",
14-
"test:e2e": "playwright test",
15-
"test:e2e:headed": "playwright test --headed"
16-
},
17-
"dependencies": {
18-
"@nextcloud/axios": "^2.5.1",
19-
"@nextcloud/dialogs": "^7.1.0",
20-
"@nextcloud/event-bus": "^3.3.3",
21-
"@nextcloud/initial-state": "^3.0.0",
22-
"@nextcloud/moment": "^1.3.5",
23-
"@nextcloud/router": "^3.1.0",
24-
"@nextcloud/vue": "^8.34.0",
25-
"diff": "^8.0.2",
26-
"easymde": "^2.20.0",
27-
"markdown-it": "^14.1.0",
28-
"markdown-it-bidi": "^0.2.0",
29-
"markdown-it-task-checkbox": "^1.0.6",
30-
"vue": "^2.7.16",
31-
"vue-frag": "^1.4.3",
32-
"vue-material-design-icons": "^5.3.1",
33-
"vue-observe-visibility": "^1.0.0",
34-
"vue-router": "^3.5.3",
35-
"vuex": "^3.6.2"
36-
},
37-
"devDependencies": {
38-
"@nextcloud/babel-config": "^1.3.0",
39-
"@nextcloud/browserslist-config": "^3.1.2",
40-
"@nextcloud/e2e-test-server": "^0.4.0",
41-
"@nextcloud/eslint-config": "^8.4.2",
42-
"@nextcloud/stylelint-config": "^3.1.1",
43-
"@nextcloud/webpack-vue-config": "^7.0.2",
44-
"@playwright/test": "^1.57.0",
45-
"playwright": "^1.57.0",
46-
"typescript": "^5.9.3",
47-
"vue-loader": "^15.11.1"
48-
},
49-
"engines": {
50-
"node": "^24.0.0",
51-
"npm": "^11.3.0"
52-
},
53-
"browserslist": [
54-
"extends @nextcloud/browserslist-config"
55-
],
56-
"version": "4.12.4"
2+
"name": "notes",
3+
"homepage": "https://github.com/nextcloud/notes",
4+
"license": "agpl",
5+
"private": true,
6+
"scripts": {
7+
"build": "webpack --node-env production --progress",
8+
"dev": "webpack --node-env development --progress",
9+
"watch": "webpack --node-env development --progress --watch",
10+
"lint": "eslint --ext .js,.vue src playwright",
11+
"lint:fix": "eslint --ext .js,.vue src playwright --fix",
12+
"stylelint": "stylelint 'src/**/*.vue' 'css/**/*.css'",
13+
"stylelint:fix": "stylelint 'src/**/*.vue' 'css/**/*.css' --fix",
14+
"start:nextcloud": "node playwright/start-nextcloud-server.mjs",
15+
"test:e2e": "playwright test",
16+
"test:e2e:headed": "playwright test --headed"
17+
},
18+
"dependencies": {
19+
"@nextcloud/axios": "^2.5.1",
20+
"@nextcloud/dialogs": "^7.1.0",
21+
"@nextcloud/event-bus": "^3.3.3",
22+
"@nextcloud/initial-state": "^3.0.0",
23+
"@nextcloud/moment": "^1.3.5",
24+
"@nextcloud/router": "^3.1.0",
25+
"@nextcloud/vue": "^8.34.0",
26+
"diff": "^8.0.2",
27+
"easymde": "^2.20.0",
28+
"markdown-it": "^14.1.0",
29+
"markdown-it-bidi": "^0.2.0",
30+
"markdown-it-task-checkbox": "^1.0.6",
31+
"vue": "^2.7.16",
32+
"vue-frag": "^1.4.3",
33+
"vue-material-design-icons": "^5.3.1",
34+
"vue-observe-visibility": "^1.0.0",
35+
"vue-router": "^3.5.3",
36+
"vuex": "^3.6.2"
37+
},
38+
"devDependencies": {
39+
"@nextcloud/babel-config": "^1.3.0",
40+
"@nextcloud/browserslist-config": "^3.1.2",
41+
"@nextcloud/e2e-test-server": "^0.4.0",
42+
"@nextcloud/eslint-config": "^8.4.2",
43+
"@nextcloud/stylelint-config": "^3.1.1",
44+
"@nextcloud/webpack-vue-config": "^7.0.2",
45+
"@playwright/test": "^1.57.0",
46+
"playwright": "^1.57.0",
47+
"typescript": "^5.9.3",
48+
"vue-loader": "^15.11.1"
49+
},
50+
"engines": {
51+
"node": "^24.0.0",
52+
"npm": "^11.3.0"
53+
},
54+
"browserslist": [
55+
"extends @nextcloud/browserslist-config"
56+
],
57+
"version": "4.12.4"
5758
}

playwright.config.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,40 @@ export default defineConfig({
2424
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2525
use: {
2626
/* Base URL to use in actions like `await page.goto('./')`. */
27-
baseURL: process.env.BASE_URL ?? 'http://nextcloud.local',
27+
baseURL: process.env.BASE_URL ?? "http://localhost:8089",
2828

2929
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
30-
trace: 'on-first-retry',
30+
trace: "on-first-retry",
3131

3232
/* Capture screenshot on failure */
33-
screenshot: 'only-on-failure',
33+
screenshot: "only-on-failure",
34+
},
35+
36+
webServer: {
37+
// Starts the Nextcloud docker container
38+
command: "npm run start:nextcloud",
39+
// we use sigterm to notify the script to stop the container
40+
// if it does not respond, we force kill it after 10 seconds
41+
gracefulShutdown: {
42+
signal: "SIGTERM",
43+
timeout: 10000,
44+
},
45+
reuseExistingServer: !process.env.CI,
46+
stderr: "pipe",
47+
stdout: "pipe",
48+
url: "http://127.0.0.1:8089",
49+
timeout: 5 * 60 * 1000, // max. 5 minutes for creating the container
50+
wait: {
51+
// we wait for this line to appear in the output of the webserver until consider it done
52+
stdout: /Nextcloud is now ready to use/,
53+
},
3454
},
3555

3656
projects: [
3757
{
38-
name: 'chromium',
58+
name: "chromium",
3959
use: {
40-
...devices['Desktop Chrome'],
60+
...devices["Desktop Chrome"],
4161
},
4262
},
4363
],
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*!
2+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: MIT
4+
*/
5+
6+
import {
7+
configureNextcloud,
8+
startNextcloud,
9+
stopNextcloud,
10+
waitOnNextcloud,
11+
} from '@nextcloud/e2e-test-server/docker'
12+
import { readFileSync } from 'fs'
13+
import { execSync } from 'node:child_process'
14+
15+
async function start() {
16+
const appinfo = readFileSync('appinfo/info.xml').toString()
17+
const maxVersion = appinfo.match(
18+
/<nextcloud min-version="\d+" max-version="(\d\d+)" \/>/,
19+
)?.[1]
20+
21+
let branch = 'master'
22+
if (maxVersion) {
23+
const refs = execSync('git ls-remote --refs').toString('utf-8')
24+
branch = refs.includes(`refs/heads/stable${maxVersion}`)
25+
? `stable${maxVersion}`
26+
: branch
27+
}
28+
29+
return await startNextcloud(branch, true, {
30+
exposePort: 8089,
31+
})
32+
}
33+
34+
async function stop() {
35+
process.stderr.write('Stopping Nextcloud server…\n')
36+
await stopNextcloud()
37+
process.exit(0)
38+
}
39+
40+
process.on('SIGTERM', stop)
41+
process.on('SIGINT', stop)
42+
43+
// Start the Nextcloud docker container
44+
const ip = await start()
45+
await waitOnNextcloud(ip)
46+
await configureNextcloud(['notes'])
47+
48+
// Idle to wait for shutdown
49+
while (true) {
50+
await new Promise((resolve) => setTimeout(resolve, 5000))
51+
}

0 commit comments

Comments
 (0)