From 19fa1c7dd35cbf755b751922b1b0a2a553436bcd Mon Sep 17 00:00:00 2001 From: QiuSW <105186638@qq.com> Date: Sat, 29 Aug 2026 14:59:19 +0800 Subject: [PATCH] fix(#152): leave saved address panel safely --- android/app/build.gradle.kts | 4 ++-- .../agent/automation/PurchaseLiveAutomation.kt | 14 +++++++------- .../goauto/agent/PurchaseLiveAutomationTest.kt | 7 ++++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 891447d..0cf16cb 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -11,8 +11,8 @@ android { applicationId = "cn.ilapage.goauto.agent" minSdk = 23 targetSdk = 34 - versionCode = 37 - versionName = "0.9.24" + versionCode = 38 + versionName = "0.9.25" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/android/app/src/main/java/cn/ilapage/goauto/agent/automation/PurchaseLiveAutomation.kt b/android/app/src/main/java/cn/ilapage/goauto/agent/automation/PurchaseLiveAutomation.kt index 28e8566..de1d68c 100644 --- a/android/app/src/main/java/cn/ilapage/goauto/agent/automation/PurchaseLiveAutomation.kt +++ b/android/app/src/main/java/cn/ilapage/goauto/agent/automation/PurchaseLiveAutomation.kt @@ -171,7 +171,7 @@ class PurchaseLiveAutomation( val save = uniqueClickable(stable, stable.nodes.filter { it.visible && it.enabled && it.label == "保存" }) if (save.size != 1) fail("PURCHASE_ADDRESS_UPDATE_FAILED", "地址保存按钮不唯一,未创建订单") click(save.single(), "保存地址") - val savedEvidence = waitForStableSavedAddress(expected, suffix) + val savedEvidence = waitForStableAddressEditorExit() if (!hasFinalSavedAddressEvidence(savedEvidence, expected, suffix)) { if (!driver.backPurchase()) fail("PURCHASE_ADDRESS_UPDATE_FAILED", "地址保存后无法返回订单页面,未创建订单") waitFor("PURCHASE_ADDRESS_SAVE_TIMEOUT", "地址保存后无法返回订单页面,未创建订单") { @@ -198,16 +198,16 @@ class PurchaseLiveAutomation( private fun hasFinalSavedAddressEvidence(snapshot: UiSnapshot, expected: String, suffix: String): Boolean = hasSavedAddressEvidence(snapshot, expected, suffix) && finalSubmitTargets(snapshot).size == 1 - private fun waitForStableSavedAddress(expected: String, suffix: String): UiSnapshot { - var consecutiveMatches = 0 + private fun waitForStableAddressEditorExit(): UiSnapshot { + var consecutiveExits = 0 repeat(50) { val snapshot = driver.capture() pageProblem(snapshot) - if (hasSavedAddressEvidence(snapshot, expected, suffix)) { - consecutiveMatches++ - if (consecutiveMatches >= 2) return snapshot + if (snapshot.packageName == PDD_PACKAGE && shippingAddressEditors(snapshot).isEmpty()) { + consecutiveExits++ + if (consecutiveExits >= 2) return snapshot } else { - consecutiveMatches = 0 + consecutiveExits = 0 } pause(200) } diff --git a/android/app/src/test/java/cn/ilapage/goauto/agent/PurchaseLiveAutomationTest.kt b/android/app/src/test/java/cn/ilapage/goauto/agent/PurchaseLiveAutomationTest.kt index 6fd92f5..d99f1a7 100644 --- a/android/app/src/test/java/cn/ilapage/goauto/agent/PurchaseLiveAutomationTest.kt +++ b/android/app/src/test/java/cn/ilapage/goauto/agent/PurchaseLiveAutomationTest.kt @@ -52,8 +52,8 @@ class PurchaseLiveAutomationTest { } @Test - fun `saved address transition without legacy title or phone is accepted before final confirmation`() { - val driver = LiveDriver(savedTransitionWithoutLegacyContext = true) + fun `saved address transition may hide suffix before strict final confirmation`() { + val driver = LiveDriver(savedTransitionWithoutLegacyContext = true, savedTransitionHidesSuffix = true) val automation = PurchaseLiveAutomation(driver, pause = {}) val address = automation.updateShippingAddress("_cg21") @@ -176,6 +176,7 @@ class PurchaseLiveAutomationTest { private val duplicateConfirmationSuffix: Boolean = false, private val saveStaysInEdit: Boolean = false, private val savedTransitionWithoutLegacyContext: Boolean = false, + private val savedTransitionHidesSuffix: Boolean = false, ) : PurchaseUiDriver { private var page = "confirmation" private var addressVisible = !addressClipped @@ -208,7 +209,7 @@ class PurchaseLiveAutomationTest { )) "saved-transition" -> snapshot(listOf( node("transition-title", "选择收货信息"), - node("address-suffix", address.substring(address.lastIndexOf("_cg"))), + node("address-summary", if (savedTransitionHidesSuffix) "已保存的收货信息" else address.substring(address.lastIndexOf("_cg"))), )) "order" -> snapshot(listOf(node("status", "待付款"), node("order", "订单号:PDD-202608210001"), node("time", "下单时间:2026-08-21 10:30:00"), node("pay", "立即支付", clickable = true))) "chooser" -> UiSnapshot(if (trustedChooser) "android" else "example.untrusted", "com.android.internal.app.ChooserActivity", listOf(