/**
 * User stories covered: Feature 1 — PPMS Rebrand
 *   - Login page displays "PPMS" and "Pelagia Payment Management System"
 *   - Sidebar shows "PPMS" after login
 *   - Browser tab title contains "PPMS"
 *
 * Created: 2026-05-17
 */
import { test, expect } from "@playwright/test";
import { login, USERS } from "./helpers/login";

test.describe("Feature 1 — PPMS Rebrand", () => {
  test("US-1a: login page shows PPMS brand name", async ({ page }) => {
    await page.goto("/login");
    await expect(page.getByText("PPMS")).toBeVisible();
    console.log("✓ PPMS text visible on login page");
  });

  test("US-1a: login page shows full app name 'Pelagia Payment Management System'", async ({
    page,
  }) => {
    await page.goto("/login");
    await expect(
      page.getByText("Pelagia Payment Management System")
    ).toBeVisible();
    console.log("✓ Full app name visible on login page");
  });

  test("US-1a: login page does NOT show old brand name 'Pelagia Portal'", async ({
    page,
  }) => {
    await page.goto("/login");
    await expect(page.getByText("Pelagia Portal")).not.toBeVisible();
    console.log("✓ Old brand name 'Pelagia Portal' is absent from login page");
  });

  test("US-1b: sidebar shows PPMS after login", async ({ page }) => {
    await login(page, USERS.TECH);
    // Sidebar brand text rendered by sidebar.tsx
    const sidebar = page.locator("aside");
    await expect(sidebar.getByText("PPMS")).toBeVisible();
    console.log("✓ Sidebar shows PPMS");
  });

  test("US-1c: browser tab title contains PPMS", async ({ page }) => {
    await login(page, USERS.TECH);
    await expect(page).toHaveTitle(/PPMS/i);
    console.log("✓ Page title contains PPMS");
  });

  test("US-1c: login page tab title contains PPMS", async ({ page }) => {
    await page.goto("/login");
    await expect(page).toHaveTitle(/PPMS/i);
    console.log("✓ Login page title contains PPMS");
  });
});
