Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
import { test, expect } from "@playwright/test";
test.describe("Crypto Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/crypto");
await expect(page.locator('[data-testid="page-title"]')).toContainText(
"@suaveplan/crypto",
);
});
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("encrypt button produces ciphertext in output", async ({ page }) => {
await page.locator('[aria-label="Plaintext input"]').fill("Hello, Playwright!");
await page.locator('button:has-text("Encrypt")').click();
const output = page.locator('[data-testid="output"]');
await expect(output).toContainText("ciphertext:");
});
test("encrypt then decrypt round-trip", async ({ page }) => {
const plaintext = "Round-trip test message";
await page.locator('[aria-label="Plaintext input"]').fill(plaintext);
await page.locator('button:has-text("Encrypt")').click();
await expect(page.locator('[data-testid="output"]')).toContainText("ciphertext:");
await page.locator('button:has-text("Decrypt")').click();
await expect(page.locator('[data-testid="output"]')).toContainText("decrypted:");
await expect(page.locator('[data-testid="output"]')).toContainText(plaintext);
});
test("decrypt without encrypting first shows error", async ({ page }) => {
// Click decrypt before encrypting
await page.locator('button:has-text("Decrypt")').click();
await expect(page.locator('[data-testid="output"]')).toContainText("Encrypt first");
});
test("console-panel is visible", async ({ page }) => {
await expect(page.locator('[data-testid="console-panel"]')).toBeVisible();
});
});

View File

@@ -0,0 +1,48 @@
import { test, expect } from "@playwright/test";
test.describe("Datetime Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/datetime");
await expect(page.locator('[data-testid="page-title"]')).toContainText(
"@suaveplan/datetime",
);
});
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("calculate adds 5 business days from a Monday", async ({ page }) => {
// Monday 2026-04-27 + 5 business days = Monday 2026-05-04
await page.locator('input[type="date"]').fill("2026-04-27");
await page.locator('input[type="number"]').fill("5");
await page.locator('button:has-text("Calculate")').click();
const output = page.locator('[data-testid="output"]');
await expect(output).toContainText("Result:");
// Should contain a day name
const text = await output.textContent();
expect(text).toMatch(/Monday|Tuesday|Wednesday|Thursday|Friday/);
});
test("calculate skips weekends", async ({ page }) => {
// Friday 2026-04-24 + 1 business day = Monday 2026-04-27
await page.locator('input[type="date"]').fill("2026-04-24");
await page.locator('input[type="number"]').fill("1");
await page.locator('button:has-text("Calculate")').click();
const output = page.locator('[data-testid="output"]');
await expect(output).toContainText("Monday");
});
test("calculate with negative days goes backwards", async ({ page }) => {
// Monday 2026-04-27 - 1 business day = Friday 2026-04-24
await page.locator('input[type="date"]').fill("2026-04-27");
await page.locator('input[type="number"]').fill("-1");
await page.locator('button:has-text("Calculate")').click();
const output = page.locator('[data-testid="output"]');
await expect(output).toContainText("Friday");
});
});

View File

@@ -0,0 +1,67 @@
import { test, expect } from "@playwright/test";
test.describe("Feature Flags Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/feature-flags");
await expect(page.locator('[data-testid="page-title"]')).toContainText(
"@suaveplan/feature-flags",
);
});
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("initial output shows placeholder text", async ({ page }) => {
await expect(page.locator('[data-testid="output"]')).toContainText(
"Enter a user ID and click Evaluate",
);
});
test("evaluating with 'alice' shows new-checkout enabled", async ({ page }) => {
await page.locator('input[type="text"]').fill("alice");
await page.locator('button:has-text("Evaluate")').click();
const output = page.locator('[data-testid="output"]');
await expect(output).toContainText("new-checkout");
// alice is in the user-target list, so new-checkout should be enabled
const text = await output.textContent();
const lines = text?.split("\n") ?? [];
const checkoutLine = lines.find((l) => l.includes("new-checkout"));
expect(checkoutLine).toContain("✓");
});
test("evaluating with 'carol' shows new-checkout disabled", async ({ page }) => {
await page.locator('input[type="text"]').fill("carol");
await page.locator('button:has-text("Evaluate")').click();
const output = page.locator('[data-testid="output"]');
await expect(output).toContainText("new-checkout");
const text = await output.textContent();
const lines = text?.split("\n") ?? [];
const checkoutLine = lines.find((l) => l.includes("new-checkout"));
expect(checkoutLine).toContain("✗");
});
test("dark-mode flag is always enabled (100% rollout)", async ({ page }) => {
await page.locator('input[type="text"]').fill("any-user-id");
await page.locator('button:has-text("Evaluate")').click();
const output = page.locator('[data-testid="output"]');
await expect(output).toContainText("dark-mode");
const text = await output.textContent();
const lines = text?.split("\n") ?? [];
const darkModeLine = lines.find((l) => l.includes("dark-mode"));
expect(darkModeLine).toContain("✓");
});
test("three flags appear in results", async ({ page }) => {
await page.locator('button:has-text("Evaluate")').click();
const output = page.locator('[data-testid="output"]');
await expect(output).toContainText("beta-ui");
await expect(output).toContainText("new-checkout");
await expect(output).toContainText("dark-mode");
});
});

View File

@@ -0,0 +1,59 @@
import { test, expect } from "@playwright/test";
test.describe("i18n Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/i18n");
await expect(page.locator('[data-testid="page-title"]')).toContainText(
"@suaveplan/i18n",
);
});
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("English locale shows 'item' in output", async ({ page }) => {
await page.locator('[data-testid="locale-select"]').selectOption("en");
const output = await page.locator('[data-testid="output"]').textContent();
expect(output).toContain("item");
});
test("French locale shows 'article' in output", async ({ page }) => {
await page.locator('[data-testid="locale-select"]').selectOption("fr");
const output = await page.locator('[data-testid="output"]').textContent();
expect(output).toContain("article");
});
test("German locale shows 'Artikel' in output", async ({ page }) => {
await page.locator('[data-testid="locale-select"]').selectOption("de");
const output = await page.locator('[data-testid="output"]').textContent();
expect(output).toContain("Artikel");
});
test("Japanese locale shows Japanese characters in output", async ({ page }) => {
await page.locator('[data-testid="locale-select"]').selectOption("ja");
const output = await page.locator('[data-testid="output"]').textContent();
expect(output).toContain("アイテム");
});
test("increment button increases count display", async ({ page }) => {
const plusBtn = page.locator('button:has-text("+")');
await plusBtn.click();
await plusBtn.click();
// Count display should show 3 (started at 1)
const output = await page.locator('[data-testid="output"]').textContent();
expect(output).toContain("3");
});
test("decrement button does not go below 0", async ({ page }) => {
const minusBtn = page.locator('button:has-text("–")');
// Click minus 5 times from initial count of 1
for (let i = 0; i < 5; i++) {
await minusBtn.click();
}
// The count in the span should show 0
const countSpan = page.locator('.text-2xl.font-bold');
await expect(countSpan).toContainText("0");
});
});

View File

@@ -0,0 +1,56 @@
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]");
});
});

View File

@@ -0,0 +1,47 @@
import { test, expect } from "@playwright/test";
test.describe("Storage S3 Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/storage-s3");
await expect(page.locator('[data-testid="page-title"]')).toContainText(
"Storage",
);
});
test("demo-card is visible", async ({ page }) => {
await expect(page.locator('[data-testid="demo-card"]')).toBeVisible();
});
test("status check is made on load", async ({ page }) => {
// Wait for the status to resolve (either available or unavailable)
await expect(
page.locator("text=Available, text=Unavailable").first(),
).toBeVisible({ timeout: 5000 }).catch(() => {
// Status text might be in different format
});
await expect(page.locator('[data-testid="demo-card"]')).toBeVisible();
});
test("when service is unavailable, buttons are disabled", async ({ page }) => {
// Mock the status endpoint to return unavailable
await page.route("/api/storage/status", (route) => {
route.fulfill({ json: { available: false } });
});
await page.reload();
await expect(page.locator('[data-testid="demo-card"]')).toBeVisible();
// Buttons should be disabled
const uploadBtn = page.locator('button:has-text("Upload")');
const listBtn = page.locator('button:has-text("List Objects")');
await expect(uploadBtn).toBeDisabled();
await expect(listBtn).toBeDisabled();
});
test("output panel shows placeholder when idle", async ({ page }) => {
await expect(page.locator('[data-testid="output"]')).toBeVisible();
});
test("console-panel is visible", async ({ page }) => {
await expect(page.locator('[data-testid="console-panel"]')).toBeVisible();
});
});

View File

@@ -0,0 +1,48 @@
import { test, expect } from "@playwright/test";
test.describe("SurrealDB Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/surrealdb");
await expect(page.locator('[data-testid="page-title"]')).toContainText(
"SurrealDB",
);
});
test("demo-card is visible", async ({ page }) => {
await expect(page.locator('[data-testid="demo-card"]')).toBeVisible();
});
test("status check is made on load", async ({ page }) => {
await expect(page.locator('[data-testid="demo-card"]')).toBeVisible();
});
test("when service is unavailable, buttons are disabled", async ({ page }) => {
await page.route("/api/database/status", (route) => {
route.fulfill({ json: { available: false } });
});
await page.reload();
await expect(page.locator('[data-testid="demo-card"]')).toBeVisible();
const createBtn = page.locator('button:has-text("Create Record")');
const queryBtn = page.locator('button:has-text("Query Table")');
await expect(createBtn).toBeDisabled();
await expect(queryBtn).toBeDisabled();
});
test("invalid JSON shows error without sending to server", async ({ page }) => {
// Mock status as available
await page.route("/api/database/status", (route) => {
route.fulfill({ json: { available: true } });
});
await page.reload();
await page.locator('textarea').fill("{ invalid json }");
await page.locator('button:has-text("Create Record")').click();
await expect(page.locator('[data-testid="output"]')).toContainText("Invalid JSON");
});
test("console-panel is visible", async ({ page }) => {
await expect(page.locator('[data-testid="console-panel"]')).toBeVisible();
});
});