import { test, expect } from "@playwright/test";
import { USERS, login } from "./helpers";

/**
 * Issue #19 — Place of Delivery is a dropdown (admin-managed delivery locations),
 * not free text. The PO forms render <select name="placeOfDelivery">, and the admin
 * surface lives at /admin/delivery-locations.
 */
test("#19 PO form Place of Delivery is a <select> dropdown", async ({ page }) => {
  await login(page, USERS.MANAGER);
  await page.goto("/po/new");
  const select = page.locator('select[name="placeOfDelivery"]');
  await expect(select).toBeVisible();
});

test("#19 admin delivery-locations page renders for a manager", async ({ page }) => {
  await login(page, USERS.MANAGER);
  await page.goto("/admin/delivery-locations");
  await expect(page).not.toHaveURL(/\/login/);
  await expect(page.getByRole("heading", { name: /delivery location/i }).first()).toBeVisible();
});
