Files
computer-playbook/roles/web-app-nextcloud/files/playwright/addons/integration_github.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

65 lines
2.8 KiB
JavaScript

const { test, expect } = require("@playwright/test");
const { resolveTimeout } = require("../timeouts");
const { skipUnlessAddonEnabled } = require("../addon-gating");
const shared = require("../_shared");
const { gotoOnion } = require("../personas");
test("integration integration_github: per-user OAuth connect reaches github.com/login/oauth/authorize with the provisioned client_id", async ({ browser }) => {
skipUnlessAddonEnabled("integration_github");
test.setTimeout(resolveTimeout(120_000));
const context = await browser.newContext({ ignoreHTTPSErrors: true });
const page = await context.newPage();
try {
await shared.loginToStandaloneNextcloud(page);
await gotoOnion(page,
new URL("settings/user/connected-accounts", shared.env.nextcloudBaseUrl).toString(),
{ waitUntil: "domcontentloaded", timeout: resolveTimeout(60_000) }
);
await shared.dismissBlockingNextcloudModals(page, page);
const connect = page.getByRole("button", { name: /connect to github with oauth/i });
await expect(
connect.first(),
"the 'Connect to GitHub with OAuth' control must render once the admin OAuth client_id is provisioned — its absence means the github.client_id/client_secret api wiring failed to land"
).toBeVisible({ timeout: resolveTimeout(60_000) });
const nextcloudHost = new URL(shared.env.nextcloudBaseUrl).host;
await Promise.all([
page
.waitForURL((u) => /^https?:\/\/github\.com\/login\/oauth\/authorize(?:[/?#]|$)/i.test(u), { timeout: resolveTimeout(60_000) })
.catch(() => {}),
connect.first().click({ timeout: resolveTimeout(30_000) }),
]);
await expect
.poll(() => page.url(), { timeout: resolveTimeout(60_000) })
.toMatch(/^https?:\/\/github\.com\/login\/oauth\/authorize(?:[/?#]|$)/i);
const authorize = new URL(page.url());
expect(
authorize.host,
"the OAuth connect must hand off to the partner GitHub (github.com), not stay on the Nextcloud host"
).toBe("github.com");
expect(authorize.host, "the authorize endpoint must not be Nextcloud itself").not.toBe(nextcloudHost);
expect(
authorize.pathname,
"the connect must reach GitHub's authorization-code endpoint"
).toBe("/login/oauth/authorize");
expect(
(authorize.searchParams.get("client_id") || "").length,
"the authorize redirect must carry the provisioned GitHub OAuth client_id (proves the github.client_id api wiring is live)"
).toBeGreaterThan(0);
expect(
authorize.searchParams.get("redirect_uri") || "",
"the authorize redirect_uri must point back at this Nextcloud instance to complete the code grant"
).toContain(nextcloudHost);
} finally {
await page.close().catch(() => {});
await context.close().catch(() => {});
}
});