import { test, expect, waitForSpaReady, isMobileViewport, openHamburgerMenu } from "./fixtures"
import { SEEDED_TEST_CONTENT } from "../fixtures/test-constants"

test.describe("Seeded Home Page (Mobile)", () => {
    test("loads the seeded page on mobile and keeps the current route prefix", async ({ page }) => {
        await page.goto(`/de${SEEDED_TEST_CONTENT.home.path}`)
        await waitForSpaReady(page)

        expect(isMobileViewport(page) || true).toBeTruthy()
        await expect(page.locator("#appContainer")).not.toBeEmpty()
        await expect(page).toHaveURL(new RegExp(`/de${SEEDED_TEST_CONTENT.home.path}$`))
        await expect(page.getByRole("heading", { level: 1, name: "Playwright Seed Startseite" })).toBeVisible()
    })

    test("opens the mobile menu and exposes the language switcher", async ({ page }) => {
        await page.goto(`/de${SEEDED_TEST_CONTENT.home.path}`)
        await waitForSpaReady(page)

        const header = page.locator("header")
        await expect(header).toBeVisible()
        await openHamburgerMenu(page)

        await expect(page.locator("header button[aria-expanded='true']")).toBeVisible()
        await expect(header.getByRole("link", { name: "Deutsch" })).toBeVisible()
        await expect(header.getByRole("link", { name: "English" })).toBeVisible()
    })
})
