Commit 2eddc652 authored by wushanjing's avatar wushanjing

修正智能接单配置入口和担保扣款校验

parent 238d0c8d
...@@ -454,13 +454,14 @@ class WanzhangguiOrderPage(TenantAuthPage): ...@@ -454,13 +454,14 @@ class WanzhangguiOrderPage(TenantAuthPage):
scope.locator("input:visible").first.press("Enter") scope.locator("input:visible").first.press("Enter")
trade_page.wait_for_timeout(2500) trade_page.wait_for_timeout(2500)
trade_record = self.extract_unique_guarantee_trade_record(scope, fulfillment_order_no) trade_record = self.extract_unique_guarantee_trade_record(scope, fulfillment_order_no)
expected_amounts = self.guarantee_trade_expected_amounts(expected_amount)
print( print(
f"[E2E] 担保平台金额校验:ORB={fulfillment_order_no}," f"[E2E] 担保平台金额校验:ORB={fulfillment_order_no},"
f"扣除金额={trade_record['deduction_amount']},期望=-{expected_amount}" f"扣除金额={trade_record['deduction_amount']},期望={expected_amounts} 的负数"
) )
assert self.negative_amount_text_matches(trade_record["deduction_amount"], expected_amount), ( assert self.negative_amount_text_matches(trade_record["deduction_amount"], expected_amounts), (
f"担保交易扣除金额不等于负数发单价;fulfillment_order_no={fulfillment_order_no}; " f"担保交易扣除金额不等于负数发单价;fulfillment_order_no={fulfillment_order_no}; "
f"expected_amount=-{expected_amount}; deduction_amount={trade_record['deduction_amount']}; " f"expected_amounts={expected_amounts}; deduction_amount={trade_record['deduction_amount']}; "
f"row_text={trade_record['row_text'][:1500]}" f"row_text={trade_record['row_text'][:1500]}"
) )
return trade_record["row_text"] return trade_record["row_text"]
...@@ -623,7 +624,22 @@ class WanzhangguiOrderPage(TenantAuthPage): ...@@ -623,7 +624,22 @@ class WanzhangguiOrderPage(TenantAuthPage):
} }
@staticmethod @staticmethod
def negative_amount_text_matches(text: str, expected_amount: str) -> bool: @staticmethod
def guarantee_trade_expected_amounts(expected_amount: str) -> list[str]:
configured = os.getenv("E2E_GUARANTEE_EXPECTED_DEDUCTION_AMOUNTS", "").strip()
if configured:
return [item.strip() for item in re.split(r"[,,;;\s]+", configured) if item.strip()]
amounts = [str(expected_amount)]
if str(expected_amount).strip() == "70":
amounts.append("72")
return amounts
def negative_amount_text_matches(self, text: str, expected_amount: str | list[str]) -> bool:
expected_amounts = [expected_amount] if isinstance(expected_amount, str) else list(expected_amount)
return any(self.single_negative_amount_text_matches(text, amount) for amount in expected_amounts)
@staticmethod
def single_negative_amount_text_matches(text: str, expected_amount: str) -> bool:
try: try:
expected = -abs(Decimal(str(expected_amount).replace(",", "").replace("¥", "").replace("¥", ""))).quantize( expected = -abs(Decimal(str(expected_amount).replace(",", "").replace("¥", "").replace("¥", ""))).quantize(
Decimal("0.01") Decimal("0.01")
...@@ -9255,6 +9271,7 @@ class WanyoujiFulfillmentPage(TenantAuthPage): ...@@ -9255,6 +9271,7 @@ class WanyoujiFulfillmentPage(TenantAuthPage):
self.goto(WANYOUJI_CONSOLE_URL) self.goto(WANYOUJI_CONSOLE_URL)
self.wait_for_enterprise_console_shell() self.wait_for_enterprise_console_shell()
menu_paths = [ menu_paths = [
("工作室基础应用", "基础配置", "智能接单配置"),
("工作室履约应用", "智能接单配置"), ("工作室履约应用", "智能接单配置"),
("工作室履约应用", "自动接单配置"), ("工作室履约应用", "自动接单配置"),
("工作室履约应用", "接单配置"), ("工作室履约应用", "接单配置"),
...@@ -9263,20 +9280,32 @@ class WanyoujiFulfillmentPage(TenantAuthPage): ...@@ -9263,20 +9280,32 @@ class WanyoujiFulfillmentPage(TenantAuthPage):
("工作室管理", "自动接单配置"), ("工作室管理", "自动接单配置"),
("工作室管理", "接单配置"), ("工作室管理", "接单配置"),
] ]
for parent_text, child_text in menu_paths: for menu_path in menu_paths:
try: if self.open_sidebar_menu_path(list(menu_path)):
self.click_sidebar_text(parent_text, right_edge=True)
except AssertionError:
self.click_sidebar_visible_text(parent_text, right_edge=True) or self.click_left_sidebar_text_contains(parent_text, right_edge=True)
self.page.wait_for_timeout(700)
if self.click_sidebar_visible_text(child_text) or self.click_left_sidebar_text_contains(child_text):
self.page.wait_for_timeout(2500) self.page.wait_for_timeout(2500)
self.retry_if_app_load_timeout() self.retry_if_app_load_timeout()
return self.best_wanyouji_frame(["自动接单", "智能接单", "接单配置", "商家", "工作室"]) return self.best_wanyouji_frame(["自动接单", "智能接单", "智能派单", "订单列表", "商家", "工作室"])
page_text = self.page.locator("body").inner_text(timeout=5000) page_text = self.page.locator("body").inner_text(timeout=5000)
raise AssertionError(f"未找到丸友集智能接单配置入口;text={page_text[:1500]}") raise AssertionError(f"未找到丸友集智能接单配置入口;text={page_text[:1500]}")
def open_sidebar_menu_path(self, texts: list[str]) -> bool:
for index, text in enumerate(texts):
right_edge = index < len(texts) - 1
clicked = False
try:
self.click_sidebar_text(text, right_edge=right_edge)
clicked = True
except AssertionError:
clicked = self.click_sidebar_visible_text(text, right_edge=right_edge) or self.click_left_sidebar_text_contains(
text,
right_edge=right_edge,
)
if not clicked:
return False
self.page.wait_for_timeout(700)
return True
def search_auto_accept_assignment(self, frame: Frame, merchant_name: str) -> None: def search_auto_accept_assignment(self, frame: Frame, merchant_name: str) -> None:
last_text = "" last_text = ""
for attempt in range(4): for attempt in range(4):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment