60 lines
2.3 KiB
TypeScript
60 lines
2.3 KiB
TypeScript
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");
|
||
});
|
||
});
|