2026-05-01 13:44:04 +08:00
|
|
|
|
import { expect, openSettings, test } from "./helpers";
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
|
|
|
|
|
test.describe("Settings Dialog", () => {
|
2026-06-28 18:57:53 +08:00
|
|
|
|
test("opens from the avatar menu", async ({ loggedInPage: page }) => {
|
|
|
|
|
|
// 2.0 removed the desktop sidebar; openSettings drives the avatar dropdown.
|
2026-05-01 13:44:04 +08:00
|
|
|
|
await openSettings(page);
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
|
|
|
|
|
// Settings dialog should appear with sections
|
|
|
|
|
|
await expect(page.getByText("General").first()).toBeVisible();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test("General section shows user info", async ({ loggedInPage: page }) => {
|
2026-05-01 13:44:04 +08:00
|
|
|
|
await openSettings(page);
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
|
|
|
|
|
// Should show username and version info
|
|
|
|
|
|
await expect(page.getByText(/admin/i).first()).toBeVisible();
|
2026-06-28 18:57:53 +08:00
|
|
|
|
await expect(page.getByText(/2\.0\.0|version/i).first()).toBeVisible();
|
2026-03-22 19:28:57 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-03-25 09:27:12 +08:00
|
|
|
|
test("General section has logout button", async ({ loggedInPage: page }) => {
|
2026-05-01 13:44:04 +08:00
|
|
|
|
await openSettings(page);
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
|
|
|
|
|
const logoutBtn = page.getByRole("button", { name: /logout|log out/i });
|
|
|
|
|
|
await expect(logoutBtn).toBeVisible();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-03-25 09:27:12 +08:00
|
|
|
|
test("Security section has change password form", async ({ loggedInPage: page }) => {
|
2026-05-01 13:44:04 +08:00
|
|
|
|
await openSettings(page);
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
2026-06-28 18:57:53 +08:00
|
|
|
|
// Navigate to Security section via the dialog nav button (the section
|
|
|
|
|
|
// heading reuses the same label, so scope to the button to avoid strict-mode
|
|
|
|
|
|
// ambiguity).
|
|
|
|
|
|
await page.getByRole("button", { name: "Security", exact: true }).click();
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
|
|
|
|
|
// Should show password change fields
|
2026-03-25 09:27:12 +08:00
|
|
|
|
await expect(page.getByText(/change password|current password/i).first()).toBeVisible();
|
2026-03-22 19:28:57 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test("People section shows user list", async ({ loggedInPage: page }) => {
|
2026-05-01 13:44:04 +08:00
|
|
|
|
await openSettings(page);
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
2026-06-28 18:57:53 +08:00
|
|
|
|
// Navigate to People section via the dialog nav button
|
|
|
|
|
|
await page.getByRole("button", { name: "People", exact: true }).click();
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
|
|
|
|
|
// Should show admin user
|
|
|
|
|
|
await expect(page.getByText("admin").first()).toBeVisible();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-07-27 15:37:30 +08:00
|
|
|
|
test("API Keys section has generate button", async ({ loggedInPage: page }) => {
|
2026-05-01 13:44:04 +08:00
|
|
|
|
await openSettings(page);
|
2026-07-27 15:37:30 +08:00
|
|
|
|
await page.getByRole("button", { name: /api keys/i }).click();
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
2026-03-25 09:27:12 +08:00
|
|
|
|
await expect(page.getByRole("button", { name: /generate api key/i })).toBeVisible({
|
|
|
|
|
|
timeout: 5_000,
|
|
|
|
|
|
});
|
2026-03-22 19:28:57 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test("About section shows app info", async ({ loggedInPage: page }) => {
|
2026-05-01 13:44:04 +08:00
|
|
|
|
await openSettings(page);
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
2026-06-28 18:57:53 +08:00
|
|
|
|
// Navigate to About section via the dialog nav button
|
|
|
|
|
|
await page.getByRole("button", { name: "About", exact: true }).click();
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
|
|
|
|
|
// Should show app description
|
2026-04-24 18:02:21 +08:00
|
|
|
|
await expect(page.getByText(/snapotter|privacy|self-hosted/i).first()).toBeVisible();
|
2026-03-22 19:28:57 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-03-25 09:27:12 +08:00
|
|
|
|
test("System Settings section has configuration", async ({ loggedInPage: page }) => {
|
2026-05-01 13:44:04 +08:00
|
|
|
|
await openSettings(page);
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
2026-06-28 18:57:53 +08:00
|
|
|
|
// Navigate to System Settings section via the dialog nav button
|
|
|
|
|
|
await page.getByRole("button", { name: "System Settings", exact: true }).click();
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
|
|
|
|
|
// Should show system configuration options
|
2026-03-25 09:27:12 +08:00
|
|
|
|
await expect(page.getByText(/app name|upload limit|theme/i).first()).toBeVisible();
|
2026-03-22 19:28:57 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test("settings dialog can be closed", async ({ loggedInPage: page }) => {
|
2026-05-01 13:44:04 +08:00
|
|
|
|
await openSettings(page);
|
2026-03-22 19:28:57 +08:00
|
|
|
|
await expect(page.getByText("General").first()).toBeVisible();
|
|
|
|
|
|
|
|
|
|
|
|
// Close by clicking X or outside
|
|
|
|
|
|
const closeBtn = page.getByRole("button", { name: /close|×/i }).first();
|
|
|
|
|
|
if (await closeBtn.isVisible()) {
|
|
|
|
|
|
await closeBtn.click();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
await page.keyboard.press("Escape");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Dialog should be gone
|
|
|
|
|
|
await page.waitForTimeout(300);
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|