forked from cms/tibi-svelte-starter
✨ feat: enhance admin API helpers with CRUD operations for collections and seed data management
- Added functions for creating, updating, deleting, and listing collection entries in admin API. - Introduced seed data management for consistent test content across tests. - Updated global setup and teardown processes to ensure seeded content is created and cleaned up. - Refactored existing tests to utilize seeded content for improved reliability and maintainability.
This commit is contained in:
+35
-29
@@ -1,44 +1,51 @@
|
||||
import { test, expect, waitForSpaReady } from "./fixtures"
|
||||
import { test, expect, clickSpaLink, waitForSpaReady } from "./fixtures"
|
||||
import { SEEDED_TEST_CONTENT } from "../fixtures/test-constants"
|
||||
|
||||
test.describe("Home Page", () => {
|
||||
test("should load the start page", async ({ page }) => {
|
||||
await page.goto("/de/")
|
||||
test.describe("Seeded Home Page", () => {
|
||||
test("renders the seeded German page with the expected block content", async ({ page }) => {
|
||||
await page.goto(`/de${SEEDED_TEST_CONTENT.home.path}`)
|
||||
const lang = await waitForSpaReady(page)
|
||||
|
||||
expect(lang).toBe("de")
|
||||
await expect(page.getByRole("heading", { level: 1, name: "Playwright Seed Startseite" })).toBeVisible()
|
||||
await expect(page.locator("[data-block='features'] .feature-card")).toHaveCount(3)
|
||||
await expect(page.locator("[data-block='richtext']")).toContainText(
|
||||
"Dieser Richtext-Block prueft, dass formatierter HTML-Inhalt im SPA gerendert wird."
|
||||
)
|
||||
await expect(page.locator("[data-block='accordion'] button[aria-expanded]").first()).toHaveAttribute(
|
||||
"aria-expanded",
|
||||
"true"
|
||||
)
|
||||
})
|
||||
|
||||
test("should have a visible header with navigation", async ({ page }) => {
|
||||
await page.goto("/de/")
|
||||
test("keeps the route stable when switching the language", async ({ page }) => {
|
||||
await page.goto(`/de${SEEDED_TEST_CONTENT.home.path}`)
|
||||
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 header.getByRole("link", { name: "en", exact: true }).click()
|
||||
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")
|
||||
}
|
||||
await expect(page).toHaveURL(new RegExp(`/en${SEEDED_TEST_CONTENT.home.path}$`))
|
||||
await expect(page.getByRole("heading", { level: 1, name: "Playwright Seed Home" })).toBeVisible()
|
||||
})
|
||||
|
||||
test("should allow skipping directly to main content", async ({ page }) => {
|
||||
await page.goto("/de/")
|
||||
test("navigates to the seeded contact page via SPA CTA and keeps the form usable", async ({ page }) => {
|
||||
await page.goto(`/de${SEEDED_TEST_CONTENT.home.path}`)
|
||||
await waitForSpaReady(page)
|
||||
|
||||
await clickSpaLink(page, "[data-block='hero'] a")
|
||||
|
||||
await expect(page).toHaveURL(new RegExp(`/de${SEEDED_TEST_CONTENT.contact.path}$`))
|
||||
await expect(page.locator("[data-block='contact-form']")).toBeVisible()
|
||||
await expect(page.getByLabel("Name")).toBeVisible()
|
||||
await expect(page.getByLabel("E-Mail")).toBeVisible()
|
||||
await expect(page.locator("textarea[name='message']")).toBeVisible()
|
||||
})
|
||||
|
||||
test("moves focus to the main content via the skip link", async ({ page }) => {
|
||||
await page.goto(`/de${SEEDED_TEST_CONTENT.home.path}`)
|
||||
await waitForSpaReady(page)
|
||||
|
||||
await page.keyboard.press("Tab")
|
||||
@@ -50,6 +57,5 @@ test.describe("Home Page", () => {
|
||||
|
||||
const mainContent = page.locator("main#main-content")
|
||||
await expect(mainContent).toBeFocused()
|
||||
await expect(page).toHaveURL(/#main-content$/)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user