test(e2e): add Playwright tests for settings toggles

Tests cover:
- Debug mode toggle on/off
- Sidebar visibility toggle
- Settings persistence after page reload
This commit is contained in:
oyi77
2026-03-31 10:54:07 +07:00
parent 981c1c1263
commit 8f5c9a3c72

View File

@@ -0,0 +1,62 @@
import { test, expect } from "@playwright/test";
test.describe("Settings Toggles", () => {
test.describe("Debug Mode Toggle", () => {
test("should toggle debug mode on and off", async ({ page }) => {
await page.goto("/dashboard/settings");
await page.waitForLoadState("networkidle");
await page.click("text=Advanced");
const debugToggle = page.locator('[aria-label*="debug" i], [data-testid*="debug" i]').first();
if (await debugToggle.isVisible({ timeout: 3000 }).catch(() => false)) {
const initialState = await debugToggle.isChecked();
await debugToggle.click();
await page.waitForTimeout(500);
const newState = await debugToggle.isChecked();
expect(newState).not.toBe(initialState);
}
});
});
test.describe("Sidebar Visibility Toggle", () => {
test("should toggle sidebar items visibility", async ({ page }) => {
await page.goto("/dashboard/settings");
await page.waitForLoadState("networkidle");
await page.click("text=General");
const sidebarToggle = page
.locator('[aria-label*="sidebar" i], [data-testid*="sidebar" i]')
.first();
if (await sidebarToggle.isVisible({ timeout: 3000 }).catch(() => false)) {
const initialState = await sidebarToggle.isChecked();
await sidebarToggle.click();
await page.waitForTimeout(500);
const newState = await sidebarToggle.isChecked();
expect(newState).not.toBe(initialState);
}
});
});
test.describe("Settings Persistence", () => {
test("should persist debug mode after page reload", async ({ page }) => {
await page.goto("/dashboard/settings");
await page.waitForLoadState("networkidle");
await page.click("text=Advanced");
const debugToggle = page.locator('[aria-label*="debug" i], [data-testid*="debug" i]').first();
if (await debugToggle.isVisible({ timeout: 3000 }).catch(() => false)) {
const wasChecked = await debugToggle.isChecked();
await debugToggle.click();
await page.waitForTimeout(500);
await page.reload();
await page.waitForLoadState("networkidle");
await page.click("text=Advanced");
const isChecked = await debugToggle.isChecked();
expect(isChecked).not.toBe(wasChecked);
}
});
});
});