Files
suaveplan/apps/testbed/e2e/libraries/i18n.spec.ts
2026-05-27 23:29:53 +01:00

60 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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");
});
});