<?php

namespace Tests\Feature;

use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class SsoApiTest extends TestCase
{
    use RefreshDatabase;

    public function test_user_can_login_and_get_jwt_token(): void
    {
        $password = 'secret123';
        User::factory()->create([
            'email' => 'admin@example.com',
            'password' => bcrypt($password),
        ]);

        $response = $this->postJson('/auth/login', [
            'email' => 'admin@example.com',
            'password' => $password,
        ]);

        $response
            ->assertOk()
            ->assertJsonPath('code', 0)
            ->assertJsonStructure(['data' => ['token', 'type', 'expires_in']]);
    }
}
