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_021_dispatch_accepted_order_to_player import (
    test_s_flow_021_dispatch_accepted_order_to_player as _test_s_flow_021_dispatch_accepted_order_to_player,
)
from e2e.tests.订单状态流转.上游发单.test_s_flow_026_player_accept_dispatched_order import (
    test_s_flow_026_player_accept_dispatched_order as _test_s_flow_026_player_accept_dispatched_order,
)
from e2e.tests.订单状态流转.订单验收.test_s_flow_040_player_submit_acceptance import (
    test_s_flow_040_player_submit_acceptance as _test_s_flow_040_player_submit_acceptance,
)
from e2e.tests.订单状态流转.订单验收.test_s_flow_043_accept_player_sub_order import (
    test_s_flow_043_accept_player_sub_order as _test_s_flow_043_accept_player_sub_order,
)
from e2e.tests.订单状态流转.订单验收.test_s_flow_045_apply_upstream_acceptance import (
    test_s_flow_045_apply_upstream_acceptance as _test_s_flow_045_apply_upstream_acceptance,
)
from e2e.tests.订单状态流转.订单验收.test_s_flow_082_cancel_upstream_acceptance import (
    test_s_flow_082_cancel_upstream_acceptance as _test_s_flow_082_cancel_upstream_acceptance,
)


@pytest.mark.flow_044
@pytest.mark.e2e_ledger
@pytest.mark.e2e_chain
def test_flow_044_cancel_upstream_acceptance_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)
    monkeypatch.delenv("E2E_S_FLOW_ORDER_TITLE", 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_021_dispatch_accepted_order_to_player(page, settings, bug_reporter)
    _test_s_flow_026_player_accept_dispatched_order(page, settings, bug_reporter)
    _test_s_flow_040_player_submit_acceptance(page, settings, bug_reporter)
    _test_s_flow_043_accept_player_sub_order(page, settings, bug_reporter)
    _test_s_flow_045_apply_upstream_acceptance(page, settings, bug_reporter)
    _test_s_flow_082_cancel_upstream_acceptance(page, settings, bug_reporter)
