Skip to content

Commit 7eb0484

Browse files
committed
test cleanup: rename, dedupe, merge, share helpers
1 parent 36830c1 commit 7eb0484

18 files changed

Lines changed: 198 additions & 863 deletions

frontend/src/core/tests/live/two-factor-auth.spec.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.

frontend/src/core/tests/stubbed/automation-page.spec.ts renamed to frontend/src/core/tests/stubbed/automation-page-ui.spec.ts

File renamed without changes.

frontend/src/core/tests/stubbed/browser-navigation.spec.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

frontend/src/core/tests/stubbed/CertificateValidationE2E.spec.ts renamed to frontend/src/core/tests/stubbed/certificate-validation.spec.ts

File renamed without changes.

frontend/src/core/tests/stubbed/CompareE2E.spec.ts renamed to frontend/src/core/tests/stubbed/compare.spec.ts

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,12 @@
2020

2121
import { test, expect, type Page } from "@playwright/test";
2222
import path from "path";
23+
import { mockAppApis } from "@app/tests/helpers/api-stubs";
2324

2425
const FIXTURES_DIR = path.join(__dirname, "../test-fixtures");
2526
const PDF_A = path.join(FIXTURES_DIR, "compare_sample_a.pdf");
2627
const PDF_B = path.join(FIXTURES_DIR, "compare_sample_b.pdf");
2728

28-
async function mockAppApis(page: Page) {
29-
await page.route("**/api/v1/info/status", (route) =>
30-
route.fulfill({ json: { status: "UP" } }),
31-
);
32-
await page.route("**/api/v1/config/app-config", (route) =>
33-
route.fulfill({
34-
json: {
35-
enableLogin: false,
36-
languages: ["en-GB"],
37-
defaultLocale: "en-GB",
38-
},
39-
}),
40-
);
41-
await page.route("**/api/v1/auth/me", (route) =>
42-
route.fulfill({
43-
json: {
44-
id: 1,
45-
username: "testuser",
46-
email: "test@example.com",
47-
roles: ["ROLE_USER"],
48-
},
49-
}),
50-
);
51-
await page.route("**/api/v1/config/endpoints-availability", (route) =>
52-
route.fulfill({ json: { compare: { enabled: true } } }),
53-
);
54-
await page.route("**/api/v1/config/endpoint-enabled*", (route) =>
55-
route.fulfill({ json: true }),
56-
);
57-
await page.route("**/api/v1/config/group-enabled*", (route) =>
58-
route.fulfill({ json: true }),
59-
);
60-
await page.route("**/api/v1/ui-data/footer-info", (route) =>
61-
route.fulfill({ json: {} }),
62-
);
63-
await page.route("**/api/v1/proprietary/**", (route) =>
64-
route.fulfill({ json: {} }),
65-
);
66-
}
67-
6829
async function navigateToCompare(page: Page) {
6930
await page.locator('[data-tour="tool-button-compare"]').first().click();
7031
await page.waitForSelector('[data-testid="compare-slot-base"]', {

frontend/src/core/tests/stubbed/convert-tool.spec.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

frontend/src/core/tests/stubbed/ConvertE2E.spec.ts renamed to frontend/src/core/tests/stubbed/convert.spec.ts

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -7,98 +7,11 @@
77

88
import { test, expect, type Page } from "@playwright/test";
99
import path from "path";
10+
import { mockAppApis } from "@app/tests/helpers/api-stubs";
1011

1112
const FIXTURES_DIR = path.join(__dirname, "../test-fixtures");
1213
const SAMPLE_PDF = path.join(FIXTURES_DIR, "sample.pdf");
1314

14-
// ---------------------------------------------------------------------------
15-
// Endpoint availability map — all conversion endpoints enabled
16-
// ---------------------------------------------------------------------------
17-
const MOCK_ENDPOINTS_AVAILABILITY = Object.fromEntries(
18-
[
19-
"pdf-to-img",
20-
"img-to-pdf",
21-
"pdf-to-word",
22-
"file-to-pdf",
23-
"pdf-to-text",
24-
"pdf-to-html",
25-
"pdf-to-xml",
26-
"pdf-to-csv",
27-
"pdf-to-xlsx",
28-
"pdf-to-pdfa",
29-
"pdf-to-pdfx",
30-
"pdf-to-presentation",
31-
"pdf-to-markdown",
32-
"pdf-to-cbz",
33-
"pdf-to-cbr",
34-
"pdf-to-epub",
35-
"html-to-pdf",
36-
"svg-to-pdf",
37-
"markdown-to-pdf",
38-
"eml-to-pdf",
39-
"cbz-to-pdf",
40-
"cbr-to-pdf",
41-
].map((k) => [k, { enabled: true }]),
42-
);
43-
44-
// ---------------------------------------------------------------------------
45-
// Helper: mock all standard app APIs needed to load the main UI
46-
// ---------------------------------------------------------------------------
47-
async function mockAppApis(page: Page) {
48-
// Backend probe — must return UP so Landing shows app in anonymous mode
49-
await page.route("**/api/v1/info/status", (route) =>
50-
route.fulfill({ json: { status: "UP" } }),
51-
);
52-
53-
// App config — enableLogin:false puts the app in anonymous mode
54-
await page.route("**/api/v1/config/app-config", (route) =>
55-
route.fulfill({
56-
json: {
57-
enableLogin: false,
58-
languages: ["en-GB"],
59-
defaultLocale: "en-GB",
60-
},
61-
}),
62-
);
63-
64-
// Auth — fallback if anything calls auth/me
65-
await page.route("**/api/v1/auth/me", (route) =>
66-
route.fulfill({
67-
json: {
68-
id: 1,
69-
username: "testuser",
70-
email: "test@example.com",
71-
roles: ["ROLE_USER"],
72-
},
73-
}),
74-
);
75-
76-
// Endpoint availability — queried by ConvertSettings
77-
await page.route("**/api/v1/config/endpoints-availability", (route) =>
78-
route.fulfill({ json: MOCK_ENDPOINTS_AVAILABILITY }),
79-
);
80-
81-
// Single-endpoint check — queried by Convert.tsx for the execute button
82-
await page.route("**/api/v1/config/endpoint-enabled*", (route) =>
83-
route.fulfill({ json: true }),
84-
);
85-
86-
// Group-enabled check
87-
await page.route("**/api/v1/config/group-enabled*", (route) =>
88-
route.fulfill({ json: true }),
89-
);
90-
91-
// Footer info — non-critical
92-
await page.route("**/api/v1/ui-data/footer-info", (route) =>
93-
route.fulfill({ json: {} }),
94-
);
95-
96-
// Proprietary endpoints — silence proxy errors in the Vite dev server
97-
await page.route("**/api/v1/proprietary/**", (route) =>
98-
route.fulfill({ json: {} }),
99-
);
100-
}
101-
10215
// ---------------------------------------------------------------------------
10316
// Helper: dismiss the tour tooltip that can intercept clicks on firefox/webkit
10417
// ---------------------------------------------------------------------------

frontend/src/core/tests/stubbed/direct-url-navigation.spec.ts

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)