Files
computer-playbook/roles/web-app-nextcloud/files/playwright/addons/drawio.spec.js
kevinveenbirkenbachandClaude Opus 5 27a7e8cceb test(nextcloud): retry the standalone login once inside the helper
Three Playwright workers run three spec files at once, and on a fresh instance the first OIDC callback is what provisions the Nextcloud account. Concurrent callbacks then race on INSERT INTO oc_users for the same uid: one wins, the losers answer HTTP 500. The exception is SQLSTATE[23000] 1062 Duplicate entry 'keycloak-<sub>' for key 'PRIMARY', raised from the sociallogin app's ProviderService through OC\User\Manager::createUser, and it is visible both in the CI rescue bundle of run 34653754175 and in the container log of a local variant-1 deploy.

The race is self-closing: once any insert wins, the window is shut for the rest of the run. It has never turned a job red, because Playwright's retries absorb it and a flaky-only run exits 0. What it costs is a rerun of the whole spec file, 1.8 minutes for fileslibreofficeedit against a 42 second first attempt, plus a flaky line in every report.

Retrying inside the helper keeps that cost to one login. The base entry point now makes a second attempt after a five second pause, which resolveTimeout stretches to twenty five over Tor, and the observed failures abort after thirty to forty two seconds against a nine hundred second budget, so the second attempt has room. A persistent failure still fails, and the first attempt's message is appended to the second rather than swallowed, which the old wrapper's bare catch did not do.

loginToStandaloneNextcloudWithRetry is gone: a helper of that name beside a base that retries is a trap, and its five callers now reach the same two attempts through the base. The other forty eight addon specs gain the retry without being touched.

Rejected alternatives, each against a written constraint: a serial globalSetup would have to live in the playwright.config.js that 87 roles share and would force ignoreHTTPSErrors into the central use block; PLAYWRIGHT_WORKERS=1 reverses the measured Tor tuning in playwright_workers.py and leaks through an unnamed include_vars into every later role; pre-creating the account collides with prevent_create_email_exists and turns a one-off flake into a permanent login refusal.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 11:08:15 +02:00

42 lines
1.6 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("addon drawio: app installed + enabled (registered in OC.appswebroots)", async ({ browser }) => {
skipUnlessAddonEnabled("drawio");
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("apps/files/", shared.env.nextcloudBaseUrl).toString(), {
waitUntil: "domcontentloaded",
timeout: resolveTimeout(60_000),
});
await shared.dismissBlockingNextcloudModals(page, page);
const enabled = await page.evaluate(() => {
const oc = window.OC || {};
const webroots = oc.appswebroots || (oc.appConfig && oc.appConfig.appswebroots) || {};
return Object.prototype.hasOwnProperty.call(webroots, "drawio");
});
expect(
enabled,
"drawio must be installed + enabled (registered in OC.appswebroots); it integrates the .drawio editor into Files via a file action and exposes no standalone app route",
).toBe(true);
await expect(
page.locator('script[src*="apps/drawio/"], link[href*="apps/drawio/"]'),
"the enabled drawio app must inject its own frontend bundle into the Files UI (proves the app is loaded, not merely listed)",
).not.toHaveCount(0);
} finally {
await page.close().catch(() => {});
await context.close().catch(() => {});
}
});