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); + } +}