"""司机苹果端 fixture — Appium + 登录态复用。"""

import pytest
from tests.app._shared import create_driver, make_ensure_logged_in, save_failure_screenshot

from tests.app._shared import pytest_runtest_makereport  # noqa: F401


@pytest.fixture
def driver(driver_ios_config, request):
    """司机苹果端 driver。"""
    cfg = driver_ios_config
    d = None
    try:
        d = create_driver(cfg, platform="ios")
        yield d
        save_failure_screenshot(d, cfg, "ios", request)
    finally:
        if d is not None:
            d.quit()


@pytest.fixture
def ensure_logged_in(driver_ios_config, config):
    """确保已登录态（司机角色）。"""
    fn = make_ensure_logged_in(driver_ios_config, config, account_role="driver")
    return lambda d: fn(d)
