from __future__ import annotations

import pytest
from playwright.sync_api import Page

from e2e.utils.data_factory import configure_random_percent_dispatch

from e2e.tests.订单状态流转.上游发单.test_s_flow_007_create_order_with_dispatch import (
    test_s_flow_007_create_order_with_dispatch as _test_s_flow_007_create_order_with_dispatch,
)
from e2e.tests.订单状态流转.上游发单.test_s_flow_014_accept_upstream_order_from_hall import (
    test_s_flow_014_accept_upstream_order_from_hall as _test_s_flow_014_accept_upstream_order_from_hall,
)
from e2e.tests.订单状态流转.多子单履约.test_s_flow_032_continue_dispatch_after_cancelled_child import (
    test_s_flow_032_continue_dispatch_after_cancelled_child as _test_s_flow_032_continue_dispatch_after_cancelled_child,
)
from e2e.tests.订单状态流转.打手取消指派订单.test_s_flow_037_player_cancel_assigned_order import (
    test_s_flow_037_player_cancel_assigned_order as _test_s_flow_037_player_cancel_assigned_order,
)
from e2e.tests.订单状态流转.打手取消指派订单.test_s_flow_039_wanyouji_approve_player_cancel import (
    test_s_flow_039_wanyouji_approve_player_cancel as _test_s_flow_039_wanyouji_approve_player_cancel,
)
from e2e.tests.订单状态流转.打手取消指派订单.test_s_flow_079_dispatch_accepted_order_to_assigned_player import (
    test_s_flow_079_dispatch_accepted_order_to_assigned_player as _test_s_flow_079_dispatch_accepted_order_to_assigned_player,
)


@pytest.mark.flow_022
@pytest.mark.e2e_ledger
@pytest.mark.e2e_chain
def test_flow_022_assigned_player_cancel_approve_chain(page: Page, settings, bug_reporter, monkeypatch) -> None:
    monkeypatch.setenv("E2E_S_FLOW_CREATE_MODE", "create")
    monkeypatch.delenv("E2E_S_FLOW_MAIN_ORDER_NO", raising=False)
    monkeypatch.delenv("E2E_S_FLOW_SOURCE_ORDER_NO", raising=False)
    configure_random_percent_dispatch(monkeypatch)
    monkeypatch.setenv("E2E_TASK_ASSIGNMENT_METHOD", "抢单大厅")

    _test_s_flow_007_create_order_with_dispatch(page, settings, bug_reporter)
    _test_s_flow_014_accept_upstream_order_from_hall(page, settings, bug_reporter)
    _test_s_flow_079_dispatch_accepted_order_to_assigned_player(page, settings, bug_reporter)
    _test_s_flow_037_player_cancel_assigned_order(page, settings, bug_reporter)
    _test_s_flow_039_wanyouji_approve_player_cancel(page, settings, bug_reporter)
    _test_s_flow_032_continue_dispatch_after_cancelled_child(page, settings, bug_reporter)
