<?php

use App\Models\User;

use function Pest\Laravel\actingAs;

beforeEach(function () {
    $this->admin = User::factory()->create(['role' => 'super_admin', 'active' => 1]);
});

test('settings page is accessible', function () {
    actingAs($this->admin)
        ->get(route('settings.edit'))
        ->assertStatus(200)
        ->assertSee('System Settings');
});

test('admin can update profile', function () {
    actingAs($this->admin)
        ->patch(route('settings.profile.update'), [
            'name' => 'Updated Name',
            'phone_number' => '9998887776',
        ])
        ->assertRedirect();

    $this->admin->refresh();
    expect($this->admin->name)->toBe('Updated Name');
    expect($this->admin->phone_number)->toBe('9998887776');
});
