left4me/l4d2web/tests/e2e/test_overlays_create.py
mwiegand 34b65fcbbe
style(overlays): redesign create-overlay modal
Reorders fields to Name → Type → System-wide. Drops the legacy fieldset
border and the now-stale "path is generated automatically" hint. Type
radios use the new .radio-row vocabulary with always-visible
descriptions; the admin-only system-wide checkbox becomes a .switch-row
toggle. Form field names are unchanged, so the overlay-creation handler
is untouched.

Plan deviation: live_server e2e fixture now also sets LEFT4ME_ROOT.
This is required because the new test creates an overlay end-to-end via
the UI, and create_overlay_directory() writes under $LEFT4ME_ROOT,
which defaults to /var/lib/left4me (unwritable on dev machines).
The two existing live_server consumers (test_editor, test_smoke) only
visit /blueprints/<id> routes that don't touch the filesystem, so this
change is safe for them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 00:31:16 +02:00

47 lines
1.8 KiB
Python

"""E2E test for the redesigned create-overlay modal."""
from __future__ import annotations
import pytest
from playwright.sync_api import Page, expect
from .conftest import login
pytestmark = pytest.mark.e2e
def test_create_overlay_modal_field_order_and_submission(page: Page, live_server) -> None:
base_url = live_server["base_url"]
login(page, base_url)
page.goto(f"{base_url}/overlays")
page.click('button[data-inline-modal-open="create-overlay-modal"]')
modal = page.locator("#create-overlay-modal")
expect(modal).to_be_visible()
# Field order: Name input must appear before Type radios in DOM/visual order.
name_input = modal.locator('input[name="name"]')
type_workshop = modal.locator('input[name="type"][value="workshop"]')
expect(name_input).to_be_visible()
expect(type_workshop).to_be_visible()
name_box = name_input.bounding_box()
type_box = type_workshop.bounding_box()
assert name_box is not None and type_box is not None
assert name_box["y"] < type_box["y"], "Name should sit above Type"
# No legacy fieldset border around Type group.
expect(modal.locator("fieldset.overlay-type-radio")).to_have_count(0)
# No legacy "path is generated automatically" copy anywhere.
expect(modal).not_to_contain_text("path is generated automatically")
# Default workshop selection is checked.
expect(type_workshop).to_be_checked()
# Submit with a unique name and the script type.
name_input.fill("e2e-test-overlay")
modal.locator('input[name="type"][value="script"]').check()
modal.locator('button[type="submit"]:has-text("Create")').click()
# Handler redirects to /overlays/<id> on success.
page.wait_for_url("**/overlays/*", timeout=5000)
expect(page.locator("h1")).to_contain_text("e2e-test-overlay")