- Plan 11-01 moved the add-printer form from /printers to /printers/new - Update page.goto URL to match the current route - Comment updated to explain the route change context
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
"""UX-02: live-browser verification of PRNT-03 Alpine IP->port auto-derivation."""
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
|
|
def test_port_autofill(page, live_server: str) -> None:
|
|
"""Typing an IP address into the printer form auto-populates port_name.
|
|
|
|
Evidence for UX-02: tests/e2e/test_port_autofill.py
|
|
Closes: PRNT-03 Alpine.js port auto-derivation requirement.
|
|
"""
|
|
# /printers/new renders a full page (extends base.html) with Alpine.js loaded
|
|
# and the add-printer form (moved from /printers to /printers/new in Plan 11-01)
|
|
page.goto(f"{live_server}/printers/new", wait_until="domcontentloaded")
|
|
|
|
# Wait for Alpine to initialise (x-data hydration on the form wrapper)
|
|
page.wait_for_selector("input[name='ip_address']")
|
|
|
|
# Fill triggers the 'input' event that Alpine @input listens to
|
|
page.fill("input[name='ip_address']", "192.168.1.100")
|
|
|
|
# Alpine @input reacts synchronously; wait_for_function keeps the test stable
|
|
page.wait_for_function(
|
|
"document.querySelector(\"input[name='port_name']\").value === 'IP_192_168_1_100'",
|
|
timeout=2000,
|
|
)
|
|
|
|
assert page.input_value("input[name='port_name']") == "IP_192_168_1_100"
|