Unit (Vitest + jsdom): po-state-machine.test.ts 21 tests — all transitions and helpers permissions.test.ts 11 tests — all 7 roles utils.test.ts 17 tests — formatCurrency INR, formatDate, status labels validations.test.ts 24 tests — createPoSchema, lineItemSchema, TC defaults po-status-badge.test.tsx 17 tests — all 10 statuses po-line-items-editor.test.tsx 20 tests — add/remove, GST calc, read-only, diff mode Integration (Vitest + real DB, mocked auth/notifier): create-po.test.ts — S-01 create, S-02 draft, S-03 submit approval-actions.test.ts — M-02 approve, M-03 reject, M-04 edits/vendor-id, S-06/S-07 payment-actions.test.ts — A-01 queue, A-02 mark paid with reference E2E (Playwright): auth.spec.ts — login, role nav, sign out submitter-journey.spec.ts — S-01 to S-08 manager-approvals.spec.ts — M-01 to M-04 accounts-payment.spec.ts — A-01, A-02 po-export.spec.ts — export buttons, endpoint responses, PDF content
50 lines
2.1 KiB
TypeScript
50 lines
2.1 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
|
|
|
test.describe("Authentication", () => {
|
|
test("redirects unauthenticated user to login", async ({ page }) => {
|
|
await page.goto("/dashboard");
|
|
await expect(page).toHaveURL(/\/login/);
|
|
});
|
|
|
|
test("shows login form elements", async ({ page }) => {
|
|
await page.goto("/login");
|
|
await expect(page.getByLabel("Email address")).toBeVisible();
|
|
await expect(page.getByLabel("Password")).toBeVisible();
|
|
await expect(page.getByRole("button", { name: /sign in/i })).toBeVisible();
|
|
});
|
|
|
|
test("shows error on invalid credentials", async ({ page }) => {
|
|
await page.goto("/login");
|
|
await page.getByLabel("Email address").fill("wrong@example.com");
|
|
await page.getByLabel("Password").fill("wrongpassword");
|
|
await page.getByRole("button", { name: /sign in/i }).click();
|
|
await expect(page.getByText(/invalid email or password/i)).toBeVisible();
|
|
});
|
|
|
|
test("logs in successfully and redirects to dashboard", async ({ page }) => {
|
|
await page.goto("/login");
|
|
await page.getByLabel("Email address").fill("tech@pelagia.local");
|
|
await page.getByLabel("Password").fill("tech1234");
|
|
await page.getByRole("button", { name: /sign in/i }).click();
|
|
await expect(page).toHaveURL(/\/dashboard/);
|
|
await expect(page.getByText("Dashboard")).toBeVisible();
|
|
});
|
|
|
|
test("manager sees approvals in navigation", async ({ page }) => {
|
|
await page.goto("/login");
|
|
await page.getByLabel("Email address").fill("manager@pelagia.local");
|
|
await page.getByLabel("Password").fill("manager1234");
|
|
await page.getByRole("button", { name: /sign in/i }).click();
|
|
await expect(page).toHaveURL(/\/dashboard/);
|
|
await expect(page.getByRole("link", { name: /approvals/i })).toBeVisible();
|
|
});
|
|
|
|
test("signs out and returns to login", async ({ page }) => {
|
|
await page.goto("/login");
|
|
await page.getByLabel("Email address").fill("tech@pelagia.local");
|
|
await page.getByLabel("Password").fill("tech1234");
|
|
await page.getByRole("button", { name: /sign in/i }).click();
|
|
await page.getByTitle("Sign out").click();
|
|
await expect(page).toHaveURL(/\/login/);
|
|
});
|
|
});
|