<?php

namespace Tests\Feature;

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

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

        $res = $this->get('/admin/plans/create');
        $res->assertOk();

        $html = (string) $res->getContent();

        $this->assertStringContainsString('data-action="disable-on-submit"', $html);
        $this->assertStringContainsString('保存套餐', $html);
    }
}
