Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

fix stubs playwright (#6274)

Anthony Stirlingd8c1ffa8ef1a
diff --git a/frontend/src/core/tests/helpers/api-stubs.ts b/frontend/src/core/tests/helpers/api-stubs.ts
index 9bc851abae..4dd0286b1d 100644
--- a/frontend/src/core/tests/helpers/api-stubs.ts
+++ b/frontend/src/core/tests/helpers/api-stubs.ts
@@ -14,7 +14,25 @@ import type { Page, Route } from "@playwright/test";
* patterns.
*/
-const ALL_TOOL_IDS = [
+/**
+ * URL-path slugs for backend endpoints under `/api/v1/`. Used only to seed
+ * the stub responses for `endpoints-availability` and `endpoints-enabled`
+ * so the React app sees a populated map at startup.
+ *
+ * NOTE: this is *not* the frontend tool-registry IDs and several entries
+ * here have already drifted from the real registry endpoints (e.g. `merge`
+ * vs `merge-pdfs`, `compress` vs `compress-pdf`, `ocr` vs `ocr-pdf`).
+ * Tests still pass because the frontend's `useEndpointConfig` defaults
+ * absent keys to `enabled: true`, so a wrong key is functionally the same
+ * as a missing key — every endpoint reports enabled either way.
+ *
+ * TODO: derive this from `getAllApplicationEndpoints(registry, …)` instead
+ * of hand-maintaining it. That requires extracting endpoint metadata out of
+ * `useTranslatedToolRegistry` (currently a React hook with deep i18n + tool
+ * component imports — can't be called from Node-side Playwright setup) into
+ * a pure-data module both the hook and this helper can import.
+ */
+const ALL_BACKEND_ENDPOINTS = [
"pdf-to-img",
"img-to-pdf",
"pdf-to-word",
@@ -73,10 +91,28 @@ const ALL_TOOL_IDS = [
"remove-blanks",
"remove-annotations",
"remove-image",
+ "extract-pages",
+ "reorganize-pages",
+ "extract-images",
+ "add-stamp",
+ "add-attachments",
+ "change-metadata",
+ "overlay-pdfs",
+ "get-pdf-info",
+ "validate-signature",
+ "timestamp-pdf",
+ "replace-color",
+ "show-j-s",
+ "booklet-imposition",
+ "pdf-text-editor",
+ "form-fill",
+ "multi-tool",
+ "read",
+ "automate",
];
const DEFAULT_ENDPOINTS_AVAILABILITY = Object.fromEntries(
- ALL_TOOL_IDS.map((k) => [k, { enabled: true }]),
+ ALL_BACKEND_ENDPOINTS.map((k) => [k, { enabled: true }]),
);
export interface MockAppApiOptions {
diff --git a/frontend/src/core/tests/helpers/stub-test-base.ts b/frontend/src/core/tests/helpers/stub-test-base.ts
index c7ba74c590..72116e909a 100644
--- a/frontend/src/core/tests/helpers/stub-test-base.ts
+++ b/frontend/src/core/tests/helpers/stub-test-base.ts
@@ -49,7 +49,11 @@ export const test = base.extend<StubFixtures>({
await skipOnboarding(page);
await mockAppApis(page, stubOptions);
if (autoGoto !== false) {
- await page.goto(autoGoto);
+ // waitUntil: 'domcontentloaded' avoids hanging on third-party CDN
+ // resources (iconify, posthog, stripe) the stub doesn't mock — the
+ // default 'load' event waits for ALL subresources, which can time out
+ // on slow runners and is rarely what tests actually need.
+ await page.goto(autoGoto, { waitUntil: "domcontentloaded" });
}
await use(page);
},
diff --git a/frontend/src/core/tests/stubbed/all-tool-pages-load.spec.ts b/frontend/src/core/tests/stubbed/all-tool-pages-load.spec.ts
index 78efd69dae..bb104a32c4 100644
--- a/frontend/src/core/tests/stubbed/all-tool-pages-load.spec.ts
+++ b/frontend/src/core/tests/stubbed/all-tool-pages-load.spec.ts
@@ -90,8 +90,10 @@ async function verifyToolPageLoads(
page: import("@playwright/test").Page,
urlPath: string,
) {
- await page.goto(urlPath);
- await page.waitForLoadState("domcontentloaded");
+ // waitUntil: 'domcontentloaded' avoids hanging on third-party CDN resources
+ // (iconify, posthog, stripe) the stub doesn't mock — the default 'load'
+ // event waits for ALL subresources, which can time out on slow runners.
+ await page.goto(urlPath, { waitUntil: "domcontentloaded" });
// Page should not show an unhandled error / white screen
await expect(page.locator("body").first()).not.toBeEmpty();