Files
saasshop/tests/Feature/AdminPlatformOrderIndexClearSyncBlockedHintShouldIncludeGoFailedLinkTest.php

50 lines
1.8 KiB
PHP

<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderIndexClearSyncBlockedHintShouldIncludeGoFailedLinkTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_blocked_hint_should_include_link_to_sync_failed_set(): void
{
$this->loginAsPlatformAdmin();
// 构造会触发 clear_sync_errors 被阻断的复杂上下文;
// blocked hint 应给出“切到同步失败集合”入口,并保留 back、清空 page、清理 BMPA 冲突开关。
$res = $this->get('/admin/platform-orders?bmpa_failed_only=1&syncable_only=1&page=2&back=/admin');
$res->assertOk();
$html = (string) $res->getContent();
$this->assertStringContainsString('data-role="clear-sync-errors-blocked-hint"', $html);
$this->assertMatchesRegularExpression('/href="([^"]+)"[^>]*>切到同步失败集合<\/a>/', $html);
preg_match('/href="([^"]+)"[^>]*>切到同步失败集合<\/a>/', $html, $m);
$href = html_entity_decode((string) ($m[1] ?? ''));
$query = parse_url($href, PHP_URL_QUERY) ?: '';
parse_str($query, $q);
$this->assertSame('failed', (string) ($q['sync_status'] ?? ''));
$this->assertSame('/admin', (string) ($q['back'] ?? ''));
$this->assertArrayNotHasKey('page', $q);
$this->assertArrayNotHasKey('bmpa_failed_only', $q);
$this->assertArrayNotHasKey('bmpa_error_keyword', $q);
$this->assertArrayNotHasKey('syncable_only', $q);
}
}