|
| 1 | +import os |
| 2 | +import re |
| 3 | + |
| 4 | +import pytest |
| 5 | +from dotenv import load_dotenv |
| 6 | + |
| 7 | +load_dotenv() |
| 8 | + |
| 9 | +# Map test function names to QA Sphere-friendly display names with BD-XXX markers. |
| 10 | +# qas-cli matches markers in the format PROJECT-SEQUENCE (e.g. BD-023). |
| 11 | +_QAS_NAMES: dict[str, str] = { |
| 12 | + "test_bd023_cart_operations": "BD-023: Cart operations", |
| 13 | + "test_bd022_order_with_cash_payment": "BD-022: Order with cash payment", |
| 14 | + "test_bd055_about_page_content": "BD-055: About page content", |
| 15 | + "test_bd026_navbar_navigation_state": "BD-026: Navbar navigation state", |
| 16 | + "test_bd038_menu_tabs_and_products": "BD-038: Menu tabs and products", |
| 17 | + "test_bd052_welcome_banner": "BD-052: Welcome banner", |
| 18 | +} |
| 19 | + |
| 20 | + |
| 21 | +def pytest_itemcollected(item: pytest.Item) -> None: |
| 22 | + """Rewrite test node IDs so JUnit XML contains QA Sphere markers (BD-XXX).""" |
| 23 | + # item.name looks like "test_bd023_cart_operations[chromium]" |
| 24 | + base_name = re.sub(r"\[.*\]$", "", item.name) |
| 25 | + if base_name in _QAS_NAMES: |
| 26 | + suffix = item.name[len(base_name) :] # e.g. "[chromium]" |
| 27 | + item._nodeid = item._nodeid.replace(item.name, _QAS_NAMES[base_name] + suffix) |
| 28 | + item.name = _QAS_NAMES[base_name] + suffix |
| 29 | + |
| 30 | + |
| 31 | +@pytest.fixture(scope="session") |
| 32 | +def demo_base_url() -> str: |
| 33 | + url = os.getenv("DEMO_BASE_URL", "https://hypersequent.github.io/bistro/") |
| 34 | + return url.rstrip("/") |
| 35 | + |
| 36 | + |
| 37 | +@pytest.fixture() |
| 38 | +def browser_context_args(browser_context_args: dict) -> dict: |
| 39 | + return {**browser_context_args, "java_script_enabled": True} |
| 40 | + |
| 41 | + |
| 42 | +@pytest.fixture(scope="session") |
| 43 | +def browser_type_launch_args(browser_type_launch_args: dict) -> dict: |
| 44 | + return {**browser_type_launch_args} |
0 commit comments