Files
computer-playbook/roles/web-app-nextcloud/files/playwright/addons/user_oidc.spec.js
kevinveenbirkenbachandClaude Opus 4.8 07c6ad8e7c test(e2e): scale every nav click + timeout literal for onion targets
Over Tor the redirect chain behind a login/logout/OIDC click routinely exceeds Playwright's fixed 30s action timeout, so the click throws before the flow's scaled waits run. Sweep all role Playwright suites and the shared persona helpers: give every navigation/auth-transition click an onion-scaled timeout (.click({ timeout: resolveTimeout(30_000) })) and route the remaining raw millisecond literals (timeout options, waitForTimeout, sleep-promise setTimeout, positional wait args) through resolveTimeout. Local UI clicks (menus, toggles, modal dismissals, DOM clicks inside evaluate) stay untouched.

Two new lints keep it that way: test_no_raw_timeout_literals forbids raw numeric timeout literals in Playwright specs (opt-out: nocheck: raw-timeout), test_persona_clicks_scaled requires every click in the shared persona auth flows to carry a resolveTimeout timeout (opt-out: nocheck: unscaled-click).

Verified: node --check on all 133 changed JS files, all 13 playwright lints green, make autoformat clean, make test green (2745+196+163+4 tests OK).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-14 11:35:53 +02:00

35 lines
1.4 KiB
JavaScript

const { test, expect } = require("@playwright/test");
const { resolveTimeout } = require("../timeouts");
const { skipUnlessAddonEnabled } = require("../addon-gating");
const { skipUnlessServiceEnabled } = require("../service-gating");
const shared = require("../_shared");
// `user_oidc` is the OIDC auth-path plugin selected when sso_oidc_plugin ==
// "user_oidc". Like the other OIDC plugins it has no distinct in-app page; its
// only browser-reachable surface is the login journey. Reuse the shared
// `loginToStandaloneNextcloud` flow (which handles the Keycloak handoff for
// every OIDC flavor) instead of reimplementing OIDC mechanics, and assert that
// an authenticated Nextcloud shell results.
test("addon user_oidc: nextcloud OIDC login surface authenticates", async ({ browser }) => {
skipUnlessAddonEnabled("user_oidc");
skipUnlessServiceEnabled("sso");
const context = await browser.newContext({ ignoreHTTPSErrors: true });
const page = await context.newPage();
try {
await shared.loginToStandaloneNextcloud(page);
const shellState = await shared.waitForVisibleCandidate(
page,
shared.getNextcloudShellCandidates(page),
resolveTimeout(60_000),
"Timed out waiting for an authenticated Nextcloud shell after the user_oidc OIDC login flow",
);
await expect(shellState.locator).toBeVisible();
} finally {
await page.close().catch(() => {});
await context.close().catch(() => {});
}
});