Ctrl K
ComunidadGuías…

frontend/tests/app.spec.ts

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
import { test, expect } from "@playwright/test";

test.describe("PrivaTools", () => {
    test("homepage loads and shows title", async ({ page }) => {
        await page.goto("/");
        await expect(page).toHaveTitle(/PrivaTools/);
    });

    test("homepage shows tool count", async ({ page }) => {
        await page.goto("/");
        const body = await page.textContent("body");
        expect(body).toContain("tools");
    });

    test("search bar is visible", async ({ page }) => {
        await page.goto("/");
        const searchInput = page.locator('input[placeholder*="Search"]');
        await expect(searchInput.first()).toBeVisible();
    });

    test("command palette opens with Ctrl+K", async ({ page }) => {
        await page.goto("/");
        await page.keyboard.press("Control+k");
        const palette = page.locator('input[placeholder="Search tools…"]');
        await expect(palette).toBeVisible();
    });

    test("command palette closes with Escape", async ({ page }) => {
        await page.goto("/");
        await page.keyboard.press("Control+k");
        await page.keyboard.press("Escape");
        const palette = page.locator('input[placeholder="Search tools…"]');
        await expect(palette).not.toBeVisible();
    });

    test("navigate to a tool page", async ({ page }) => {
        await page.goto("/tool/compress");
        await expect(page).toHaveTitle(/Compress.*PrivaTools/);
        const body = await page.textContent("body");
        expect(body).toContain("PDF");
    });

    test("404 page shows for unknown routes", async ({ page }) => {
        await page.goto("/this-does-not-exist");
        const body = await page.textContent("body");
        expect(body).toContain("not found");
    });

    test("batch page loads", async ({ page }) => {
        await page.goto("/batch");
        await expect(page).toHaveTitle(/Batch.*PrivaTools/);
        const body = await page.textContent("body");
        expect(body).toContain("Batch Process");
    });

    test("pipeline page loads", async ({ page }) => {
        await page.goto("/pipeline");
        await expect(page).toHaveTitle(/Pipeline.*PrivaTools/);
        const body = await page.textContent("body");
        expect(body).toContain("PDF Pipeline");
    });

    test("dark mode toggle works", async ({ page }) => {
        await page.goto("/");
        // Click the theme toggle (sun/moon button)
        const toggle = page.locator('button[title*="Switch to"]');
        if (await toggle.count() > 0) {
            await toggle.first().click();
            // Check that the html element has or doesn't have .light class
            const html = page.locator("html");
            const classList = await html.getAttribute("class");
            // Just verify it changed (either added or removed light)
            expect(classList !== null || classList === null).toBeTruthy();
        }
    });
});