✨ feat: add admin smoke tests and enhance testing documentation with new strategies and configurations
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import { test, expect, openContentCollection, openNewContentEntry } from "./fixtures"
|
||||
|
||||
test.describe("Admin content collection config", () => {
|
||||
test("renders a meaningful content list with configured columns and pagebuilder summaries", async ({ page }) => {
|
||||
await openContentCollection(page)
|
||||
|
||||
const main = page.locator("main")
|
||||
const table = page.getByRole("table")
|
||||
const homeRow = page.getByRole("row", { name: /Startseite\s+\// }).first()
|
||||
|
||||
await expect(table).toBeVisible()
|
||||
await expect(main).toContainText("Sprache")
|
||||
await expect(main).toContainText("Pfad")
|
||||
await expect(main).toContainText("Inhaltsblöcke")
|
||||
await expect(homeRow).toContainText("Startseite")
|
||||
await expect(homeRow).toContainText("Hero")
|
||||
await expect(homeRow).toContainText("Features")
|
||||
await expect(table.locator("tbody img").first()).toBeVisible()
|
||||
})
|
||||
|
||||
test("shows the configured content widgets in the new entry form", async ({ page }) => {
|
||||
await openNewContentEntry(page)
|
||||
|
||||
await expect(page.getByLabel("Name")).toBeVisible()
|
||||
await expect(page.getByLabel("Pfad")).toBeVisible()
|
||||
await expect(page.getByLabel("Teasertext")).toBeVisible()
|
||||
await expect(page.getByText("Alternative Pfade")).toBeVisible()
|
||||
await expect(page.getByText("Inhaltsblöcke").first()).toBeVisible()
|
||||
await expect(page.getByRole("button", { name: /Desktop \(1280px\)/ })).toBeVisible()
|
||||
await expect(page.getByRole("button", { name: /Tablet \(768px\)/ })).toBeVisible()
|
||||
await expect(page.getByRole("button", { name: /Mobil \(375px\)/ })).toBeVisible()
|
||||
await expect(page.getByRole("button", { name: /Block hinzufügen/ }).first()).toBeVisible()
|
||||
})
|
||||
|
||||
test("loads the pagebuilder block chooser and renders the hero preview live", async ({ page }) => {
|
||||
await openNewContentEntry(page)
|
||||
|
||||
await page
|
||||
.getByRole("button", { name: /Block hinzufügen/ })
|
||||
.first()
|
||||
.click()
|
||||
|
||||
await expect(page.getByRole("button", { name: /Hero .*Call-to-Action\./ })).toBeVisible()
|
||||
await expect(page.getByRole("button", { name: /Features .*strukturierten Boxen\./ })).toBeVisible()
|
||||
await expect(page.getByRole("button", { name: /Richtext .*Bild\./ })).toBeVisible()
|
||||
await expect(page.getByRole("button", { name: /Akkordeon .*Fragen und Antworten\./ })).toBeVisible()
|
||||
await expect(page.getByRole("button", { name: /Kontaktformular .*Intro-Text\./ })).toBeVisible()
|
||||
|
||||
await page.getByRole("button", { name: /Hero .*Call-to-Action\./ }).click()
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: /Hero #1 bearbeiten/ })
|
||||
await expect(dialog).toBeVisible()
|
||||
await expect(dialog.getByLabel("Blocktyp")).toBeVisible()
|
||||
await expect(dialog.getByLabel("Unterzeile")).toBeVisible()
|
||||
await expect(dialog.getByLabel("Containerbreite")).toBeVisible()
|
||||
await expect(dialog.getByRole("button", { name: /Vorhandene durchsuchen/ })).toBeVisible()
|
||||
|
||||
await dialog.getByLabel("Überschrift").fill("Admin Preview Test")
|
||||
await dialog.getByLabel("Unterzeile").fill("Pagebuilder Vorschau aktualisiert")
|
||||
|
||||
await expect(dialog.getByRole("heading", { name: "Admin Preview Test" })).toBeVisible()
|
||||
await expect(dialog).toContainText("Pagebuilder Vorschau aktualisiert")
|
||||
await expect(page.getByRole("button", { name: /Admin Preview Test/ })).toBeVisible()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,69 @@
|
||||
import { test as base, expect, type Page } from "@playwright/test"
|
||||
import { attachConsoleMonitor } from "../fixtures/console-monitor"
|
||||
import { ADMIN_UI_CREDENTIALS, TEST_ADMIN_BASE_URL } from "../fixtures/test-constants"
|
||||
|
||||
export const test = base.extend({
|
||||
page: async ({ page }, use) => {
|
||||
const monitor = attachConsoleMonitor(page)
|
||||
|
||||
const origGoto = page.goto.bind(page)
|
||||
const origReload = page.reload.bind(page)
|
||||
|
||||
page.goto = ((url: string, opts?: any) =>
|
||||
origGoto(url, { waitUntil: "domcontentloaded", ...opts })) as typeof page.goto
|
||||
page.reload = ((opts?: any) => origReload({ waitUntil: "domcontentloaded", ...opts })) as typeof page.reload
|
||||
|
||||
await use(page)
|
||||
monitor.assertNoErrors()
|
||||
},
|
||||
})
|
||||
|
||||
export async function loginToAdmin(page: Page): Promise<void> {
|
||||
await page.goto(`${TEST_ADMIN_BASE_URL}/login`)
|
||||
|
||||
await page.getByLabel(/Benutzername|Username/i).fill(ADMIN_UI_CREDENTIALS.username)
|
||||
await page.getByLabel(/Passwort|Password/i).fill(ADMIN_UI_CREDENTIALS.password)
|
||||
await page.getByRole("button", { name: /Anmelden|Sign in|Login/i }).click()
|
||||
|
||||
await expect(page).toHaveURL(/\/projects\//, { timeout: 15000 })
|
||||
await expect(page.locator("main")).toBeVisible()
|
||||
}
|
||||
|
||||
export async function openNovaProjectDashboard(page: Page): Promise<void> {
|
||||
await loginToAdmin(page)
|
||||
|
||||
const germanLocaleButton = page.getByRole("button", { name: /^Deutsch$/ })
|
||||
if ((await germanLocaleButton.count()) > 0) {
|
||||
await germanLocaleButton.first().click()
|
||||
}
|
||||
|
||||
const openNovaButton = page.getByRole("button", { name: /Nova öffnen|Open Nova/i })
|
||||
if ((await openNovaButton.count()) > 0 && (await openNovaButton.first().isVisible())) {
|
||||
await openNovaButton.first().click()
|
||||
}
|
||||
|
||||
await expect(page.getByRole("textbox", { name: /Kollektionen durchsuchen|Search collections/i })).toBeVisible({
|
||||
timeout: 15000,
|
||||
})
|
||||
}
|
||||
|
||||
export async function openContentCollection(page: Page): Promise<void> {
|
||||
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")
|
||||
}
|
||||
|
||||
export async function openNewContentEntry(page: Page): Promise<void> {
|
||||
await openContentCollection(page)
|
||||
await page.getByRole("button", { name: /Neuer Eintrag|New Entry/i }).click()
|
||||
|
||||
await expect(page).toHaveURL(/\/collections\/content\/entries\/new/)
|
||||
await expect(page.getByRole("heading", { level: 1, name: /Neuer Eintrag|New Entry/i })).toBeVisible()
|
||||
}
|
||||
|
||||
export { expect, type Page }
|
||||
@@ -0,0 +1,30 @@
|
||||
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")
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user