<?php

declare(strict_types=1);

use App\Models\User;
use Database\Seeders\RoleAndPermissionSeeder;

beforeEach(function (): void {
    $this->seed(RoleAndPermissionSeeder::class);
    $this->accountUrl = 'http://'.config('app.domains.account');
});

it('redirects unauthenticated users to login', function (): void {
    $this->get($this->accountUrl.'/dashboard')
        ->assertRedirect('https://'.config('app.domains.account').'/login');
});

it('identifies admin users correctly', function (): void {
    $admin = User::factory()->admin()->create();

    expect($admin->isAdmin())->toBeTrue();
    expect($admin->isCustomer())->toBeFalse();
});

it('identifies customer users correctly', function (): void {
    $customer = User::factory()->customer()->create();

    expect($customer->isCustomer())->toBeTrue();
    expect($customer->isAdmin())->toBeFalse();
});

it('identifies suspended users correctly', function (): void {
    $user = User::factory()->suspended()->create();

    expect($user->isSuspended())->toBeTrue();
    expect($user->isBanned())->toBeFalse();
});

it('identifies banned users correctly', function (): void {
    $user = User::factory()->banned()->create();

    expect($user->isBanned())->toBeTrue();
    expect($user->isSuspended())->toBeFalse();
});
