Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,31 @@ export default defineConfig({
},

projects: [
// Our global setup to configure the Nextcloud docker container
{
name: 'setup',
testMatch: /setup\.ts$/,
},

{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
},
dependencies: ['setup'],
},
],

webServer: {
// Starts the Nextcloud docker container
command: 'npm run start:nextcloud',
// we use sigterm to notify the script to stop the container
// if it does not respond, we force kill it after 10 seconds
gracefulShutdown: {
signal: 'SIGTERM',
timeout: 10000,
},
reuseExistingServer: !process.env.CI,
url: 'http://127.0.0.1:8089',
stderr: 'pipe',
stdout: 'pipe',
url: 'http://127.0.0.1:8089',
timeout: 5 * 60 * 1000, // max. 5 minutes for creating the container
wait: {
// we wait for this line to appear in the output of the webserver until consider it done
stdout: /Nextcloud is now ready to use/,
},
},
})
58 changes: 35 additions & 23 deletions playwright/start-nextcloud-server.mjs
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
/**
* SPDX-FileCopyrightText: 2024 Ferdinand Thiessen <opensource@fthiessen.de>
* SPDX-License-Identifier: AGPL-3.0-or-later
/*!
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: MIT
*/

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

const start = async () => {
return await startNextcloud(getBranch(), true, {
async function start() {
const appinfo = readFileSync('appinfo/info.xml').toString()
const maxVersion = appinfo.match(
/<nextcloud min-version="\d+" max-version="(\d\d+)" \/>/,
)?.[1]

let branch = 'master'
if (maxVersion) {
const refs = execSync('git ls-remote --refs').toString('utf-8')
branch = refs.includes(`refs/heads/stable${maxVersion}`)
? `stable${maxVersion}`
: branch
}

return await startNextcloud(branch, true, {
exposePort: 8089,
})
}

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

process.on('SIGTERM', stop)
process.on('SIGINT', stop)

// Start the Nextcloud docker container
await start()
// Listen for process to exit (tests done) and shut down the docker container
process.on('beforeExit', (code) => {
stopNextcloud()
})
const ip = await start()
await waitOnNextcloud(ip)
await configureNextcloud(['text', 'viewer'])

// Idle to wait for shutdown
while (true) {
Expand Down
18 changes: 0 additions & 18 deletions playwright/support/setup.ts

This file was deleted.

Loading