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

41 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.use({ ignoreHTTPSErrors: true });
test("addon epubviewer: EPUB reader personal settings panel renders and reflects config", async ({ browser }) => {
skipUnlessAddonEnabled("epubviewer");
test.setTimeout(resolveTimeout(120_000));
const context = await browser.newContext({ ignoreHTTPSErrors: true });
const page = await context.newPage();
try {
await shared.loginToStandaloneNextcloud(page);
const settingsUrl = new URL("settings/user/epubviewer", shared.env.nextcloudBaseUrl).toString();
const response = await gotoOnion(page, settingsUrl, { waitUntil: "domcontentloaded", timeout: resolveTimeout(60_000) });
expect(
response === null || response.status() !== 404,
"the epubviewer app must register its settings/user/epubviewer section (app installed + enabled)",
).toBeTruthy();
await shared.dismissBlockingNextcloudModals(page, page);
await expect(
page.locator("#reader-personal").first(),
"the epubviewer app must render its own EPUB reader personal settings panel",
).toBeVisible({ timeout: resolveTimeout(60_000) });
await expect(
page.locator("#EpubEnable").first(),
"the EPUB-enable checkbox must reflect the persisted epubviewer user config",
).toBeChecked({ timeout: resolveTimeout(60_000) });
} finally {
await page.close().catch(() => {});
await context.close().catch(() => {});
}
});