fix: resolve 3 pre-existing issues found during test coverage expansion

1. passport-photo 404 vs 501: add base route at /api/v1/tools/passport-photo
   that returns 501 FEATURE_NOT_INSTALLED when the AI bundle is missing,
   matching other AI tools. The /generate sub-route is Sharp-only (no
   sidecar) so it correctly skips the isToolInstalled guard.

2. AuthGuard analytics consent race: don't evaluate shouldShowConsent()
   until analyticsConfig has been fetched (guard on analyticsConfig !== null).
   Prevents redirect to /analytics-consent before config is loaded.

3. Fragile sidebar Settings selector: add openSettings(page) helper to
   E2E helpers that checks sidebar visibility with fallback to button role.
   Replace all 134 occurrences of page.locator("aside").getByText("Settings")
   across 18 test files.
This commit is contained in:
SnapOtter
2026-05-01 13:44:04 +08:00
parent 7ce0f7b431
commit fa479dcee4
22 changed files with 195 additions and 207 deletions
+5 -8
View File
@@ -1,4 +1,4 @@
import { expect, test, uploadTestImage } from "./helpers";
import { expect, openSettings, test, uploadTestImage } from "./helpers";
// ---------------------------------------------------------------------------
// GUI Performance: Page load budgets, SPA navigation, interaction responsiveness
@@ -160,16 +160,14 @@ test.describe("Settings Dialog Timing", () => {
await page.waitForLoadState("networkidle");
const start = Date.now();
await page.locator("aside").getByText("Settings").click();
await page.locator("h2").filter({ hasText: "Settings" }).waitFor({ state: "visible" });
await openSettings(page);
const openTime = Date.now() - start;
expect(openTime).toBeLessThan(300);
});
test("settings dialog closes within 300ms", async ({ loggedInPage: page }) => {
await page.locator("aside").getByText("Settings").click();
await page.locator("h2").filter({ hasText: "Settings" }).waitFor({ state: "visible" });
await openSettings(page);
const start = Date.now();
await page.keyboard.press("Escape");
@@ -180,8 +178,7 @@ test.describe("Settings Dialog Timing", () => {
});
test("switching settings tabs renders within 200ms", async ({ loggedInPage: page }) => {
await page.locator("aside").getByText("Settings").click();
await page.locator("h2").filter({ hasText: "Settings" }).waitFor({ state: "visible" });
await openSettings(page);
// Switch to About tab
const start = Date.now();
@@ -362,7 +359,7 @@ test.describe("Repeated Operations Performance", () => {
for (let i = 0; i < 20; i++) {
const start = Date.now();
await page.locator("aside").getByText("Settings").click();
await openSettings(page);
await page.locator("h2").filter({ hasText: "Settings" }).waitFor({ state: "visible" });
timings.push(Date.now() - start);