<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class AdminPlatformOrderIndexBatchActivationRunIdBadgeQuickLinksShouldRenderTest 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_platform_orders_page_should_render_run_id_badge_quick_links(): void
    {
        $this->loginAsPlatformAdmin();

        $runId = 'BAS_TEST_BADGE_0001';
        $html = $this->get('/admin/platform-orders?batch_activation_run_id=' . $runId)
            ->assertOk()
            ->getContent();

        $this->assertStringContainsString('当前 BAS run_id：<strong>' . $runId . '</strong>', $html);

        // 本批次全部
        $this->assertStringContainsString('batch_activation_run_id=' . $runId, $html);

        // 本批次失败
        $this->assertStringContainsString('sync_status=failed', $html);

        // 本批次可同步重试（unsynced + syncable_only=1）
        $this->assertStringContainsString('syncable_only=1', $html);
        $this->assertStringContainsString('sync_status=unsynced', $html);
    }
}
