mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-04 06:12:10 +03:00
- fix(memory): wrap JSON.parse in try/catch in retrieval.ts to prevent 500 on corrupt metadata; add stats to GET /api/memory response - fix(#949): add sanitizeToolId() to replace invalid chars in cross-provider tool IDs; clamp max_tokens to Math.max(1, value) - feat(skills): add SkillsMP marketplace integration (search + install via /api/skills/marketplace); add skill upload/install modal and DELETE endpoint; wire skillsEnabled guard in executor - feat(settings): add Maintenance section to General tab (Clear Cache + Purge Expired Logs buttons) - feat(lkgp): add lkgpEnabled toggle and Clear LKGP Cache button to Routing settings; add clearAllLKGP(); respect toggle in LKGPStrategyImpl - test: add vitest coverage for all new functionality Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
91 lines
3.3 KiB
TypeScript
91 lines
3.3 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
|
|
|
test.describe("Settings Toggles", () => {
|
|
test("Debug mode toggle should work", async ({ page }) => {
|
|
await page.goto("/dashboard/settings");
|
|
await page.waitForLoadState("networkidle");
|
|
await page.getByRole("tab", { name: /advanced/i }).click();
|
|
|
|
const debugToggle = page.getByRole("switch").first();
|
|
|
|
await expect(debugToggle).toBeVisible({ timeout: 5000 });
|
|
|
|
const initialState = await debugToggle.getAttribute("aria-checked");
|
|
await debugToggle.click();
|
|
await expect(debugToggle).toHaveAttribute(
|
|
"aria-checked",
|
|
initialState === "true" ? "false" : "true",
|
|
{ timeout: 5000 }
|
|
);
|
|
});
|
|
|
|
test("Sidebar visibility toggle should work", async ({ page }) => {
|
|
await page.goto("/dashboard/settings");
|
|
await page.waitForLoadState("networkidle");
|
|
await page.getByRole("tab", { name: /appearance/i }).click();
|
|
|
|
const sidebarToggle = page.getByRole("switch").first();
|
|
|
|
await expect(sidebarToggle).toBeVisible({ timeout: 5000 });
|
|
|
|
const initialState = await sidebarToggle.getAttribute("aria-checked");
|
|
await sidebarToggle.click();
|
|
await expect(sidebarToggle).toHaveAttribute(
|
|
"aria-checked",
|
|
initialState === "true" ? "false" : "true",
|
|
{ timeout: 5000 }
|
|
);
|
|
});
|
|
|
|
test("Clear Cache button calls DELETE /api/cache", async ({ page }) => {
|
|
await page.goto("/dashboard/settings");
|
|
await page.waitForLoadState("networkidle");
|
|
await page.getByRole("tab", { name: /general/i }).click();
|
|
|
|
const clearBtn = page.getByRole("button", { name: /clear cache/i });
|
|
await expect(clearBtn).toBeVisible({ timeout: 5000 });
|
|
|
|
const [request] = await Promise.all([
|
|
page.waitForRequest((req) => req.url().includes("/api/cache") && req.method() === "DELETE"),
|
|
clearBtn.click(),
|
|
]);
|
|
expect(request).toBeTruthy();
|
|
});
|
|
|
|
test("Purge Expired Logs button calls POST /api/settings/purge-logs", async ({ page }) => {
|
|
await page.goto("/dashboard/settings");
|
|
await page.waitForLoadState("networkidle");
|
|
await page.getByRole("tab", { name: /general/i }).click();
|
|
|
|
const purgeBtn = page.getByRole("button", { name: /purge expired logs/i });
|
|
await expect(purgeBtn).toBeVisible({ timeout: 5000 });
|
|
|
|
const [request] = await Promise.all([
|
|
page.waitForRequest(
|
|
(req) => req.url().includes("/api/settings/purge-logs") && req.method() === "POST"
|
|
),
|
|
purgeBtn.click(),
|
|
]);
|
|
expect(request).toBeTruthy();
|
|
});
|
|
|
|
test("Debug mode should persist after page reload", async ({ page }) => {
|
|
await page.goto("/dashboard/settings");
|
|
await page.waitForLoadState("networkidle");
|
|
await page.getByRole("tab", { name: /advanced/i }).click();
|
|
|
|
const debugToggle = page.getByRole("switch").first();
|
|
|
|
await expect(debugToggle).toBeVisible({ timeout: 5000 });
|
|
|
|
const initialState = await debugToggle.getAttribute("aria-checked");
|
|
await debugToggle.click();
|
|
const nextState = initialState === "true" ? "false" : "true";
|
|
await expect(debugToggle).toHaveAttribute("aria-checked", nextState, { timeout: 5000 });
|
|
await page.reload();
|
|
await page.waitForLoadState("networkidle");
|
|
await page.getByRole("tab", { name: /advanced/i }).click();
|
|
await expect(debugToggle).toHaveAttribute("aria-checked", nextState, { timeout: 5000 });
|
|
});
|
|
});
|