<?php

namespace Tests\Feature;

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

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

        $basRunId = 'BAS_BADGE_REVIEW_LINK_0001';
        $bmpaRunId = 'BMPA_BADGE_REVIEW_LINK_0001';

        $htmlBas = $this->get('/admin/platform-orders?batch_activation_run_id=' . $basRunId)
            ->assertOk()
            ->getContent();

        $this->assertStringContainsString('查看批次复盘', $htmlBas);
        $this->assertStringContainsString('/admin/platform-batches/show?type=bas', $htmlBas);
        $this->assertStringContainsString('run_id=' . $basRunId, $htmlBas);
        $this->assertStringContainsString('back=', $htmlBas);

        $htmlBmpa = $this->get('/admin/platform-orders?batch_bmpa_run_id=' . $bmpaRunId)
            ->assertOk()
            ->getContent();

        $this->assertStringContainsString('查看批次复盘', $htmlBmpa);
        $this->assertStringContainsString('/admin/platform-batches/show?type=bmpa', $htmlBmpa);
        $this->assertStringContainsString('run_id=' . $bmpaRunId, $htmlBmpa);
        $this->assertStringContainsString('back=', $htmlBmpa);
    }
}
