mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-14 10:34:06 +02:00
fix stubs playwright (#6274)
This commit is contained in:
@@ -14,7 +14,25 @@ import type { Page, Route } from "@playwright/test";
|
|||||||
* patterns.
|
* 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",
|
"pdf-to-img",
|
||||||
"img-to-pdf",
|
"img-to-pdf",
|
||||||
"pdf-to-word",
|
"pdf-to-word",
|
||||||
@@ -73,10 +91,28 @@ const ALL_TOOL_IDS = [
|
|||||||
"remove-blanks",
|
"remove-blanks",
|
||||||
"remove-annotations",
|
"remove-annotations",
|
||||||
"remove-image",
|
"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(
|
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 {
|
export interface MockAppApiOptions {
|
||||||
|
|||||||
@@ -49,7 +49,11 @@ export const test = base.extend<StubFixtures>({
|
|||||||
await skipOnboarding(page);
|
await skipOnboarding(page);
|
||||||
await mockAppApis(page, stubOptions);
|
await mockAppApis(page, stubOptions);
|
||||||
if (autoGoto !== false) {
|
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);
|
await use(page);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -90,8 +90,10 @@ async function verifyToolPageLoads(
|
|||||||
page: import("@playwright/test").Page,
|
page: import("@playwright/test").Page,
|
||||||
urlPath: string,
|
urlPath: string,
|
||||||
) {
|
) {
|
||||||
await page.goto(urlPath);
|
// waitUntil: 'domcontentloaded' avoids hanging on third-party CDN resources
|
||||||
await page.waitForLoadState("domcontentloaded");
|
// (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
|
// Page should not show an unhandled error / white screen
|
||||||
await expect(page.locator("body").first()).not.toBeEmpty();
|
await expect(page.locator("body").first()).not.toBeEmpty();
|
||||||
|
|||||||
Reference in New Issue
Block a user