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

test.describe("Admin smoke", () => {
    test("logs in and shows the core collection groups", async ({ page }) => {
        await openNovaProjectDashboard(page)

        await expect(page.getByRole("heading", { level: 2, name: "Inhalte" })).toBeVisible()
        await expect(page.getByRole("heading", { level: 2, name: "Medien" })).toBeVisible()
        await expect(page.getByRole("heading", { level: 2, name: "Struktur" })).toBeVisible()

        await expect(page.getByRole("link", { name: /Inhalte/ }).first()).toBeVisible()
        await expect(page.getByRole("link", { name: /Mediathek/ }).first()).toBeVisible()
        await expect(page.getByRole("link", { name: /Navigation/ }).first()).toBeVisible()
    })

    test("opens the content collection with the current admin configuration", async ({ page }) => {
        await openNovaProjectDashboard(page)

        await page
            .getByRole("link", { name: /Inhalte/ })
            .first()
            .click()

        await expect(page).toHaveURL(/\/collections\/content$/)
        await expect(page.locator("main h1")).toHaveText("Inhalte")
        await expect(page.getByRole("button", { name: /Neuer Eintrag|New Entry/i })).toBeVisible()
        await expect(page.locator("main")).toContainText("Sprache")
        await expect(page.locator("main")).toContainText("Inhaltsblöcke")
    })
})
