import { test, expect } from "@playwright/test";
import {
    installOnboardingApiStubs,
    opportunityRequestsApplications,
} from "./fixtures/api-stubs";
import { loginAsDdAdmin } from "./fixtures/login";

test.describe("Onboarding — Opportunity Requests", () => {
    test.beforeEach(async ({ page }) => {
        await installOnboardingApiStubs(page, {
            applications: opportunityRequestsApplications,
        });
    });

    test("loads page and opportunity-stage applications (direct URL after login)", async ({
        page,
    }) => {
        await loginAsDdAdmin(page);

        // DD Admin has no sidebar entry for this route; deep link matches real usage / bookmarks.
        await page.goto("/opportunity-requests");
        await expect(page).toHaveURL(/\/opportunity-requests$/);

        // Header h1 only — body also has an h3 containing "Opportunity Requests".
        await expect(
            page.getByRole("heading", { level: 1, name: "Opportunity Requests" })
        ).toBeVisible();

        await expect(page.getByText("E2E Opportunity Dealer")).toBeVisible();
    });
});
