mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
@@ -1,4 +1,4 @@
|
||||
import { expect, test } from "./helpers";
|
||||
import { expect, openSettings, test } from "./helpers";
|
||||
|
||||
const API = process.env.API_URL || "http://localhost:13490";
|
||||
|
||||
@@ -64,7 +64,7 @@ const UID = Date.now().toString(36);
|
||||
|
||||
test.describe("GUI Settings - People Tab", () => {
|
||||
test("displays user count and user table", async ({ loggedInPage: page }) => {
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /people/i }).click();
|
||||
|
||||
// User count
|
||||
@@ -80,7 +80,7 @@ test.describe("GUI Settings - People Tab", () => {
|
||||
});
|
||||
|
||||
test("search filters users and shows empty state", async ({ loggedInPage: page }) => {
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /people/i }).click();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
@@ -96,7 +96,7 @@ test.describe("GUI Settings - People Tab", () => {
|
||||
test("Add Members opens form with username, password, role, team fields", async ({
|
||||
loggedInPage: page,
|
||||
}) => {
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /people/i }).click();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
@@ -124,7 +124,7 @@ test.describe("GUI Settings - People Tab", () => {
|
||||
let adminToken: string;
|
||||
|
||||
try {
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /people/i }).click();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
@@ -155,7 +155,7 @@ test.describe("GUI Settings - People Tab", () => {
|
||||
});
|
||||
|
||||
// Try to create same username via GUI
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /people/i }).click();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
@@ -174,7 +174,7 @@ test.describe("GUI Settings - People Tab", () => {
|
||||
test("three-dot menu shows Edit Role/Team, Reset Password, and Delete", async ({
|
||||
loggedInPage: page,
|
||||
}) => {
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /people/i }).click();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
@@ -187,7 +187,7 @@ test.describe("GUI Settings - People Tab", () => {
|
||||
});
|
||||
|
||||
test("cannot delete yourself via the menu", async ({ loggedInPage: page }) => {
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /people/i }).click();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
@@ -216,7 +216,7 @@ test.describe("GUI Settings - People Tab", () => {
|
||||
body: JSON.stringify({ username, password: "TestPass123!", role: "user" }),
|
||||
});
|
||||
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /people/i }).click();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
@@ -238,7 +238,7 @@ test.describe("GUI Settings - People Tab", () => {
|
||||
});
|
||||
|
||||
test("cannot demote your own admin role via Edit Role / Team", async ({ loggedInPage: page }) => {
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /people/i }).click();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
@@ -263,7 +263,7 @@ test.describe("GUI Settings - People Tab", () => {
|
||||
});
|
||||
|
||||
test("Reset Password opens the reset form for a user", async ({ loggedInPage: page }) => {
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /people/i }).click();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
@@ -284,7 +284,7 @@ test.describe("GUI Settings - People Tab", () => {
|
||||
|
||||
test.describe("GUI Settings - Teams Tab", () => {
|
||||
test("displays team list with Default team", async ({ loggedInPage: page }) => {
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /teams/i }).click();
|
||||
|
||||
await expect(page.locator("h3").filter({ hasText: "Teams" })).toBeVisible();
|
||||
@@ -300,7 +300,7 @@ test.describe("GUI Settings - Teams Tab", () => {
|
||||
const adminToken = await getAdminToken();
|
||||
|
||||
try {
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /teams/i }).click();
|
||||
|
||||
await page.getByRole("button", { name: /create new team/i }).click();
|
||||
@@ -328,7 +328,7 @@ test.describe("GUI Settings - Teams Tab", () => {
|
||||
body: JSON.stringify({ name: teamName }),
|
||||
});
|
||||
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /teams/i }).click();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
@@ -353,7 +353,7 @@ test.describe("GUI Settings - Teams Tab", () => {
|
||||
|
||||
test.describe("GUI Settings - Roles Tab", () => {
|
||||
test("displays built-in roles with Built-in badge", async ({ loggedInPage: page }) => {
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /^roles$/i }).click();
|
||||
|
||||
await expect(page.locator("h3").filter({ hasText: "Roles" })).toBeVisible();
|
||||
@@ -369,7 +369,7 @@ test.describe("GUI Settings - Roles Tab", () => {
|
||||
});
|
||||
|
||||
test("built-in roles do not show edit or delete buttons", async ({ loggedInPage: page }) => {
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /^roles$/i }).click();
|
||||
|
||||
await expect(page.getByText("Built-in").first()).toBeVisible();
|
||||
@@ -386,7 +386,7 @@ test.describe("GUI Settings - Roles Tab", () => {
|
||||
});
|
||||
|
||||
test("Create Custom Role button is visible", async ({ loggedInPage: page }) => {
|
||||
await page.locator("aside").getByText("Settings").click();
|
||||
await openSettings(page);
|
||||
await page.getByRole("button", { name: /^roles$/i }).click();
|
||||
|
||||
await expect(page.getByRole("button", { name: /create custom role/i })).toBeVisible();
|
||||
|
||||
Reference in New Issue
Block a user