Skip to content

Commit a1aa2d5

Browse files
committed
fix(playwright): use server master branch for unreleased version
Fixed by syncing the start script with what end_to_end encryption uses. Also renders the setup steps superfluous. Signed-off-by: Max <max@nextcloud.com>
1 parent 59cdcd8 commit a1aa2d5

3 files changed

Lines changed: 37 additions & 49 deletions

File tree

playwright.config.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,31 @@ export default defineConfig({
3131
},
3232

3333
projects: [
34-
// Our global setup to configure the Nextcloud docker container
35-
{
36-
name: 'setup',
37-
testMatch: /setup\.ts$/,
38-
},
39-
4034
{
4135
name: 'chromium',
4236
use: {
4337
...devices['Desktop Chrome'],
4438
},
45-
dependencies: ['setup'],
4639
},
4740
],
4841

4942
webServer: {
5043
// Starts the Nextcloud docker container
5144
command: 'npm run start:nextcloud',
45+
// we use sigterm to notify the script to stop the container
46+
// if it does not respond, we force kill it after 10 seconds
47+
gracefulShutdown: {
48+
signal: 'SIGTERM',
49+
timeout: 10000,
50+
},
5251
reuseExistingServer: !process.env.CI,
53-
url: 'http://127.0.0.1:8089',
5452
stderr: 'pipe',
5553
stdout: 'pipe',
54+
url: 'http://127.0.0.1:8089',
5655
timeout: 5 * 60 * 1000, // max. 5 minutes for creating the container
56+
wait: {
57+
// we wait for this line to appear in the output of the webserver until consider it done
58+
stdout: /Nextcloud is now ready to use/,
59+
},
5760
},
5861
})

playwright/start-nextcloud-server.mjs

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,40 @@
1-
/**
2-
* SPDX-FileCopyrightText: 2024 Ferdinand Thiessen <opensource@fthiessen.de>
3-
* SPDX-License-Identifier: AGPL-3.0-or-later
1+
/*!
2+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: MIT
44
*/
55

6-
import { startNextcloud, stopNextcloud } from '@nextcloud/e2e-test-server/docker'
6+
import { configureNextcloud, startNextcloud, stopNextcloud, waitOnNextcloud } from '@nextcloud/e2e-test-server/docker'
77
import { readFileSync } from 'fs'
8+
import { execSync } from 'node:child_process'
89

9-
const start = async () => {
10-
return await startNextcloud(getBranch(), true, {
10+
async function start() {
11+
const appinfo = readFileSync('appinfo/info.xml').toString()
12+
const maxVersion = appinfo.match(/<nextcloud min-version="\d+" max-version="(\d\d+)" \/>/)?.[1]
13+
14+
let branch = 'master'
15+
if (maxVersion) {
16+
const refs = execSync('git ls-remote --refs').toString('utf-8')
17+
branch = refs.includes(`refs/heads/stable${maxVersion}`) ? `stable${maxVersion}` : branch
18+
}
19+
20+
return await startNextcloud(branch, true, {
1121
exposePort: 8089,
1222
})
1323
}
1424

15-
const getBranch = () => {
16-
try {
17-
const appinfo = readFileSync('appinfo/info.xml').toString()
18-
const maxVersion = appinfo.match(
19-
/<nextcloud min-version="\d+" max-version="(\d\d+)" \/>/,
20-
)?.[1]
21-
return maxVersion ? `stable${maxVersion}` : undefined
22-
} catch (err) {
23-
if (err.code === 'ENOENT') {
24-
console.warn('No appinfo/info.xml found. Using default server banch.')
25-
}
26-
}
25+
async function stop() {
26+
process.stderr.write('Stopping Nextcloud server…\n')
27+
await stopNextcloud()
28+
process.exit(0)
2729
}
2830

31+
process.on('SIGTERM', stop)
32+
process.on('SIGINT', stop)
33+
2934
// Start the Nextcloud docker container
30-
await start()
31-
// Listen for process to exit (tests done) and shut down the docker container
32-
process.on('beforeExit', (code) => {
33-
stopNextcloud()
34-
})
35+
const ip = await start()
36+
await waitOnNextcloud(ip)
37+
await configureNextcloud(['text', 'viewer'])
3538

3639
// Idle to wait for shutdown
3740
while (true) {

playwright/support/setup.ts

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

0 commit comments

Comments
 (0)