Skip to content

Commit 56191a2

Browse files
fix: run into GitHub Action
test: add router script for E2E server ci: use router script for PHP built-in server with correct document root fix: cs build: ignore playwright test artifacts test(e2e): wait for Vue app to load before running tests ci(e2e): add debug steps to check build artifacts and server status test(e2e): remove redundant wait - rely on Playwright auto-waiting ci(e2e): add more debug checks for app page and enablement status - Check what HTML is returned when curling /apps/libresign - Verify if app is enabled with occ app:list test(e2e): add debug logging to investigate CI timeout - Capture browser console logs - Log page URL, title, and HTML before button click - Take screenshot for visual debugging - Remove workaround navigation to /apps/files (works fine locally) Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 4d0e1c7 commit 56191a2

4 files changed

Lines changed: 74 additions & 2 deletions

File tree

.github/workflows/playwright.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,28 @@ jobs:
188188
189189
- name: Start PHP built-in server
190190
run: |
191-
php -S localhost:8080 index.php &
191+
php -S localhost:8080 -t . apps/${{ env.APP_NAME }}/playwright/router.php &
192192
# Wait for server to become available
193193
timeout 30 bash -c 'until curl -s http://localhost:8080/status.php > /dev/null; do sleep 1; done'
194194
echo "Nextcloud is ready at http://localhost:8080"
195195
196+
- name: Debug - Check if build artifacts exist
197+
run: |
198+
echo "Checking for LibreSign JS build artifacts..."
199+
ls -lah apps/${{ env.APP_NAME }}/js/ || echo "js/ directory not found"
200+
echo "---"
201+
echo "Testing status endpoint:"
202+
curl -v http://localhost:8080/status.php
203+
echo "---"
204+
echo "Testing index endpoint:"
205+
curl -I http://localhost:8080/index.php
206+
echo "---"
207+
echo "Testing app endpoint (should load HTML with JS):"
208+
curl -s http://localhost:8080/apps/libresign | head -100
209+
echo "---"
210+
echo "Checking if app is enabled:"
211+
php occ app:list | grep libresign
212+
196213
- name: Install Playwright browsers
197214
working-directory: apps/${{ env.APP_NAME }}
198215
run: npx playwright install chromium --with-deps

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ node_modules/
2222
/lib/Vendor/
2323
/coverage
2424
/dist/
25+
/test-results/

playwright/e2e/sign-herself-with-click-to-sign.spec.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,19 @@ test('sign herself with click to sign', async ({ page }) => {
3232
]),
3333
)
3434

35-
await page.goto('./apps/libresign');
35+
// Capture console logs to debug
36+
page.on('console', msg => console.log('BROWSER CONSOLE:', msg.type(), msg.text()))
37+
38+
await page.goto('./apps/libresign')
39+
40+
// Debug: capture page state before looking for button
41+
console.log('Page URL:', page.url())
42+
console.log('Page title:', await page.title())
43+
await page.screenshot({ path: 'debug-before-click.png', fullPage: true })
44+
const bodyHTML = await page.evaluate(() => document.body.innerHTML)
45+
console.log('Body HTML length:', bodyHTML.length)
46+
console.log('Body HTML preview:', bodyHTML.substring(0, 500))
47+
3648
await page.getByRole('button', { name: 'Upload from URL' }).click();
3749
await page.getByRole('textbox', { name: 'URL of a PDF file' }).fill('https://raw.githubusercontent.com/LibreSign/libresign/main/tests/php/fixtures/pdfs/small_valid.pdf');
3850
await page.getByRole('button', { name: 'Send' }).click();

playwright/router.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
// SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
4+
// SPDX-License-Identifier: AGPL-3.0-or-later
5+
6+
/**
7+
* Router script for Playwright E2E tests
8+
* Routes requests to the appropriate Nextcloud entry point
9+
*
10+
* Used by: .github/workflows/playwright.yml
11+
* When running the PHP built-in server for E2E testing
12+
*/
13+
14+
$rootDir = dirname(dirname(dirname(dirname(__FILE__))));
15+
16+
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
17+
$file = $rootDir . $uri;
18+
19+
// Serve static files as-is (except PHP files)
20+
if ($uri !== '/' && file_exists($file) && !is_dir($file) && pathinfo($uri, PATHINFO_EXTENSION) !== 'php') {
21+
return false;
22+
}
23+
24+
$dispatch = function (string $script, string $uri) use ($rootDir): void {
25+
$_SERVER['SCRIPT_NAME'] = $script;
26+
$_SERVER['SCRIPT_FILENAME'] = $rootDir . $script;
27+
$_SERVER['PHP_SELF'] = $script;
28+
$_SERVER['PATH_INFO'] = substr($uri, strlen($script)) ?: '';
29+
require $rootDir . $script;
30+
};
31+
32+
if (str_starts_with($uri, '/ocs/')) {
33+
$dispatch('/ocs/v2.php', $uri);
34+
} elseif (str_starts_with($uri, '/remote.php')) {
35+
$dispatch('/remote.php', $uri);
36+
} elseif (str_starts_with($uri, '/public.php')) {
37+
$dispatch('/public.php', $uri);
38+
} elseif (str_starts_with($uri, '/status.php')) {
39+
$dispatch('/status.php', $uri);
40+
} else {
41+
$dispatch('/index.php', $uri);
42+
}

0 commit comments

Comments
 (0)