<?php

namespace Tests\Feature;

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

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

        $res = $this->withSession([
            'warning' => '重复提交',
            'warning_link_href' => '/admin/platform-batches/show?type=bas&run_id=BAS202603171234560001',
            'warning_link_label' => '进入上次批次复盘',
            'warning_copy_text' => 'BAS202603171234560001',
            'warning_copy_label' => '复制run_id',
        ])->get('/admin');

        $res->assertOk();
        $res->assertSee('复制run_id');
        $res->assertSee('data-action="copy-text"', false);
        $res->assertSee('data-copy-text="BAS202603171234560001"', false);
    }
}
