From 2db5cb6b7c59f49a52cba3f93d2c3fb04a5d4936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Mon, 16 Mar 2026 13:32:48 +0800 Subject: [PATCH] test(admin-platform-order): guard clear-error buttons enabled in failed scopes --- ...ttonsShouldEnableWhenInFailedScopeTest.php | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexClearErrorButtonsShouldEnableWhenInFailedScopeTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexClearErrorButtonsShouldEnableWhenInFailedScopeTest.php b/tests/Feature/AdminPlatformOrderIndexClearErrorButtonsShouldEnableWhenInFailedScopeTest.php new file mode 100644 index 0000000..00be139 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexClearErrorButtonsShouldEnableWhenInFailedScopeTest.php @@ -0,0 +1,58 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + protected function assertButtonEnabled(string $html, string $label): void + { + $this->assertStringContainsString($label, $html); + + $pattern = '/' . preg_quote(']*>' . preg_quote($label, '/') . preg_quote('', '/') . '/u'; + $this->assertTrue((bool) preg_match($pattern, $html, $m), '未找到按钮:' . $label); + + $btnHtml = (string) ($m[0] ?? ''); + $this->assertFalse(str_contains($btnHtml, 'disabled'), '按钮不应被禁用:' . $label); + } + + public function test_clear_sync_errors_button_should_enable_when_sync_failed_scope(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->get('/admin/platform-orders?sync_status=failed'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + $this->assertButtonEnabled($html, '清除同步失败标记(当前筛选范围)'); + $this->assertStringNotContainsString('data-role="clear-sync-errors-blocked-hint"', $html); + } + + public function test_clear_bmpa_errors_button_should_enable_when_bmpa_failed_scope(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->get('/admin/platform-orders?bmpa_failed_only=1'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + $this->assertButtonEnabled($html, '清除批量标记支付失败标记(当前筛选范围)'); + $this->assertStringNotContainsString('data-role="clear-bmpa-errors-blocked-hint"', $html); + } +}