import { test, expect, waitForSpaReady } from "./fixtures"

test.describe("Home Page", () => {
    test("should load the start page", async ({ page }) => {
        await page.goto("/de/")
        const lang = await waitForSpaReady(page)
        expect(lang).toBe("de")
    })

    test("should have a visible header with navigation", async ({ page }) => {
        await page.goto("/de/")
        await waitForSpaReady(page)

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

        const nav = header.locator("nav")
        await expect(nav).toBeVisible()
    })

    test("should have language prefix in URL", async ({ page }) => {
        await page.goto("/de/")
        await waitForSpaReady(page)
        expect(page.url()).toContain("/de")
    })

    test("should switch language to English", async ({ page }) => {
        await page.goto("/de/")
        await waitForSpaReady(page)

        // Click on English language link
        const enLink = page.locator('a[href*="/en"]').first()
        if (await enLink.isVisible()) {
            await enLink.click()
            await page.waitForLoadState("domcontentloaded")
            expect(page.url()).toContain("/en")
        }
    })
})
