Skip to content

Commit d5f1b08

Browse files
Copilotszaimen
andcommitted
chore(e2e): update start-nextcloud-server.mjs to mirror nextcloud/text pattern
- Import and call `waitOnNextcloud` to ensure NC is ready before tests start - Import and call `configureNextcloud(['viewer', 'files_pdfviewer'])` in startup script - Use `git ls-remote --refs` to check if `stable${maxVersion}` branch exists; fall back to `master` if not (with error handling for offline environments) - Add SIGTERM/SIGINT handlers for clean container shutdown - Remove debug.spec.ts (investigation-only file from previous session) Co-authored-by: szaimen <42591237+szaimen@users.noreply.github.com> Agent-Logs-Url: https://github.com/nextcloud/files_pdfviewer/sessions/511d0124-9021-405e-9a82-4ef2221ffb66
1 parent c031cea commit d5f1b08

2 files changed

Lines changed: 36 additions & 105 deletions

File tree

playwright/e2e/debug.spec.ts

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

playwright/start-nextcloud-server.mjs

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,51 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import { startNextcloud, stopNextcloud } from '@nextcloud/e2e-test-server/docker'
6+
import {
7+
configureNextcloud,
8+
startNextcloud,
9+
stopNextcloud,
10+
waitOnNextcloud,
11+
} from '@nextcloud/e2e-test-server/docker'
712
import { readFileSync } from 'fs'
13+
import { execSync } from 'node:child_process'
814

9-
const start = async () => {
10-
return await startNextcloud(getBranch(), true, {
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+
try {
24+
const refs = execSync('git ls-remote --refs').toString('utf-8')
25+
branch = refs.includes(`refs/heads/stable${maxVersion}`)
26+
? `stable${maxVersion}`
27+
: branch
28+
} catch {
29+
// If we cannot check remote refs (e.g., no network), fall back to master
30+
}
31+
}
32+
33+
return await startNextcloud(branch, true, {
1134
exposePort: 8089,
1235
})
1336
}
1437

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 (error) {
23-
if (error.code === 'ENOENT') {
24-
console.warn('No appinfo/info.xml found. Using default server branch.')
25-
}
26-
}
38+
async function stop() {
39+
process.stderr.write('Stopping Nextcloud server…\n')
40+
await stopNextcloud()
41+
process.exit(0)
2742
}
2843

44+
process.on('SIGTERM', stop)
45+
process.on('SIGINT', stop)
46+
2947
// 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', () => {
33-
stopNextcloud()
34-
})
48+
const ip = await start()
49+
await waitOnNextcloud(ip)
50+
await configureNextcloud(['viewer', 'files_pdfviewer'])
3551

3652
// Idle to wait for shutdown
3753
while (true) {

0 commit comments

Comments
 (0)