"""E2E tests for Wagtail admin editor experience improvements.""" from __future__ import annotations import pytest from playwright.sync_api import Page, expect def admin_login(page: Page, base_url: str) -> None: """Log in to the Wagtail admin using the seeded E2E admin user.""" page.goto(f"{base_url}/cms/login/", wait_until="networkidle") page.fill('input[name="username"]', "e2e-admin") page.fill('input[name="password"]', "e2e-admin-pass") page.click('button[type="submit"]') page.wait_for_load_state("networkidle") @pytest.mark.e2e def test_articles_menu_item_visible(page: Page, base_url: str) -> None: """The admin sidebar should contain an 'Articles' menu item.""" admin_login(page, base_url) sidebar = page.locator("[data-side-panel]").first articles_link = sidebar.get_by_role("link", name="Articles") expect(articles_link).to_be_visible() @pytest.mark.e2e def test_articles_listing_page_loads(page: Page, base_url: str) -> None: """Clicking 'Articles' should load the articles listing with seeded articles.""" admin_login(page, base_url) page.goto(f"{base_url}/cms/articles/", wait_until="networkidle") expect(page.get_by_role("heading").first).to_be_visible() # Seeded articles should appear expect(page.get_by_text("Nightly Playwright Journey")).to_be_visible() @pytest.mark.e2e def test_dashboard_has_articles_panel(page: Page, base_url: str) -> None: """The admin dashboard should include the articles summary panel.""" admin_login(page, base_url) page.goto(f"{base_url}/cms/", wait_until="networkidle") expect(page.get_by_text("Articles overview")).to_be_visible() @pytest.mark.e2e def test_article_editor_has_tabs(page: Page, base_url: str) -> None: """The article editor should have Content, Metadata, Publishing, and SEO tabs.""" admin_login(page, base_url) page.goto(f"{base_url}/cms/articles/", wait_until="networkidle") # Click the first article to edit it page.get_by_text("Nightly Playwright Journey").first.click() page.wait_for_load_state("networkidle") expect(page.get_by_role("tab", name="Content")).to_be_visible() expect(page.get_by_role("tab", name="Metadata")).to_be_visible() expect(page.get_by_role("tab", name="Publishing")).to_be_visible() expect(page.get_by_role("tab", name="SEO")).to_be_visible()