Files
nextcloud-server-mirror/playwright.config.ts
skjnldsv 6c41c6d8d8 test(playwright): bring the viewer e2e suite into the server harness
The suite the viewer app carried in Cypress, ported to Playwright and to
the fixtures the server harness already sets up: opening every media
type, navigating between files, sorting, sharing, odd names, the list a
caller hands over, and the actions around them. The tests wait for what
they check rather than racing it.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
2026-10-01 15:21:15 +02:00

101 lines
2.8 KiB
TypeScript

/*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
/// <reference types="@types/node" />
import { defineConfig, devices } from '@playwright/test'
type DeviceDescriptor = typeof devices[string]
const BROWSWER_CONFIG_CHROME: DeviceDescriptor & { channel: string } = {
...devices['Desktop Chrome'],
channel: process.env.CI
? 'chrome' // on CI use the chrome browser provided by the GitHub Actions runner
: 'chromium', // locally use the default playwright chromium browser
}
// Port of the Nextcloud container under test. Override it to run several
// checkouts in parallel, as each one needs its own server.
const NEXTCLOUD_PORT = process.env.NEXTCLOUD_PORT ?? '8042'
export default defineConfig({
testDir: './tests/playwright/e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
workers: process.env.CI ? 1 : undefined,
timeout: process.env.CI ? 45_000 : undefined, // on CI allow 1.5x the default timeout to compensate for shared server resources
reporter: process.env.CI ? [['blob'], ['dot'], ['github']] : 'html',
use: {
baseURL: `http://localhost:${NEXTCLOUD_PORT}/index.php/`,
trace: 'on-first-retry',
},
projects: [
{
// Installation-wizard tests. They un-install and re-install the shared
// server, so they must never run alongside other tests
name: 'setup',
fullyParallel: false,
workers: 1,
grep: /@setup/,
use: {
...BROWSWER_CONFIG_CHROME,
},
},
{
name: 'admin-settings',
fullyParallel: false,
workers: 1, // only one admin setting test can run at a time due to shared state
testMatch: '**/admin-settings*.spec.ts',
// The sharing ones belong to the serial `sharing` project below
testIgnore: '**/e2e/files_sharing/**',
use: {
...BROWSWER_CONFIG_CHROME,
},
},
{
// Sharing tests. Which sidebar the sharing tab renders is an
// instance-wide switch (`sharing.unified_api_enable`): the unified specs
// need it on, the share editor specs need it off, so none of them may
// run alongside another
name: 'sharing',
fullyParallel: false,
workers: 1,
testMatch: '**/e2e/files_sharing/**/*.spec.ts',
use: {
...BROWSWER_CONFIG_CHROME,
},
},
{
name: 'default',
testMatch: /\/(?!admin-settings)[^/]*\.spec\.ts$/,
testIgnore: '**/e2e/files_sharing/**',
grepInvert: /@setup/,
use: {
...BROWSWER_CONFIG_CHROME,
},
},
],
webServer: {
command: 'node tests/playwright/start-nextcloud-server.js',
env: {
NEXTCLOUD_PORT,
},
stderr: 'pipe',
stdout: 'pipe',
gracefulShutdown: {
signal: 'SIGTERM',
timeout: 10_000,
},
reuseExistingServer: !process.env.CI,
timeout: 300_000,
wait: {
stdout: /Nextcloud container ready to run Playwright tests/,
},
},
})