Initial Commit
This commit is contained in:
48
apps/testbed/e2e/libraries/datetime.spec.ts
Normal file
48
apps/testbed/e2e/libraries/datetime.spec.ts
Normal 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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user