<?php

namespace Tests\Feature;

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

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

        $res = $this->get('/admin/platform-orders');
        $res->assertOk();

        $html = (string) $res->getContent();
        $this->assertMatchesRegularExpression('/data-role="po-summary-card-paid-no-receipt"[\s\S]*?po-summary-link-view-receipt-orders[\s\S]*?查看有回执订单/u', $html);
    }
}
