45 lines
1.8 KiB
TypeScript
45 lines
1.8 KiB
TypeScript
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();
|
|
});
|
|
});
|