57 lines
2.1 KiB
TypeScript
57 lines
2.1 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
|
|
|
test.describe("Logger Page", () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto("/logger");
|
|
await expect(page.locator('[data-testid="page-title"]')).toContainText(
|
|
"@suaveplan/logger",
|
|
);
|
|
});
|
|
|
|
test("demo-card and output are visible", async ({ page }) => {
|
|
await expect(page.locator('[data-testid="demo-card"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="output"]')).toBeVisible();
|
|
});
|
|
|
|
test("logging info message shows entry in output", async ({ page }) => {
|
|
await page.locator('input[type="text"]').fill("Test info message");
|
|
await page.locator('select').selectOption("info");
|
|
await page.locator('button:has-text("Log")').click();
|
|
|
|
const output = page.locator('[data-testid="output"]');
|
|
await expect(output).toContainText("Test info message");
|
|
await expect(output).toContainText("[INFO]");
|
|
});
|
|
|
|
test("logging error message shows entry in output", async ({ page }) => {
|
|
await page.locator('input[type="text"]').fill("Test error message");
|
|
await page.locator('select').selectOption("error");
|
|
await page.locator('button:has-text("Log")').click();
|
|
|
|
await expect(page.locator('[data-testid="output"]')).toContainText("[ERROR]");
|
|
});
|
|
|
|
test("clear button removes all entries", async ({ page }) => {
|
|
await page.locator('button:has-text("Log")').click();
|
|
await expect(page.locator('[data-testid="output"]')).not.toContainText(
|
|
"Log entries will appear here.",
|
|
);
|
|
|
|
await page.locator('button:has-text("Clear")').click();
|
|
await expect(page.locator('[data-testid="output"]')).toContainText(
|
|
"Log entries will appear here.",
|
|
);
|
|
});
|
|
|
|
test("multiple levels can be logged", async ({ page }) => {
|
|
const levels = ["debug", "info", "warn", "error"] as const;
|
|
for (const lvl of levels) {
|
|
await page.locator('select').selectOption(lvl);
|
|
await page.locator('button:has-text("Log")').click();
|
|
}
|
|
const output = page.locator('[data-testid="output"]');
|
|
await expect(output).toContainText("[DEBUG]");
|
|
await expect(output).toContainText("[ERROR]");
|
|
});
|
|
});
|