chore: run pint
This commit is contained in:
parent
5399505808
commit
87e25c9591
@ -58,7 +58,7 @@ function mountCreateComponent(User $user): Testable
|
||||
});
|
||||
|
||||
it('prevents create when user is unauthorized', function () {
|
||||
Gate::define('create user', fn() => false);
|
||||
Gate::define('create user', fn () => false);
|
||||
|
||||
mountCreateComponent($this->user)
|
||||
->call('save')
|
||||
@ -314,7 +314,7 @@ function mountCreateComponent(User $user): Testable
|
||||
$this->user->givePermissionTo($permission);
|
||||
|
||||
mountCreateComponent($this->user)
|
||||
->set('form.email', str_repeat('a', 90) . '@example.com')
|
||||
->set('form.email', str_repeat('a', 90).'@example.com')
|
||||
->call('save')
|
||||
->assertHasErrors(['form.email']);
|
||||
});
|
||||
|
||||
@ -28,7 +28,7 @@ function createEditUser(array $attributes = []): User
|
||||
return User::factory()
|
||||
->active()
|
||||
->has(Employee::factory())
|
||||
->state(fn() => array_merge([
|
||||
->state(fn () => array_merge([
|
||||
'status' => fake()->randomElement(UserStatus::cases()),
|
||||
], $attributes))
|
||||
->create();
|
||||
@ -122,7 +122,7 @@ function mountEditComponent(User $user, User $employeeUser): Testable
|
||||
$employeeUser = createEditUser();
|
||||
$employeeUser->assignRole($role->id);
|
||||
|
||||
Gate::define('update user', fn() => false);
|
||||
Gate::define('update user', fn () => false);
|
||||
|
||||
mountEditComponent($this->user, $employeeUser)
|
||||
->call('save')
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
use App\Models\Employee;
|
||||
use App\Models\Outlet;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Features\SupportTesting\Testable;
|
||||
use Livewire\Livewire;
|
||||
@ -15,7 +14,7 @@
|
||||
beforeEach(function () {
|
||||
// Create roles for testing
|
||||
collect(['Developer', 'Owner', 'Leader', 'Admin', 'Partner', 'Customer'])
|
||||
->each(fn($role) => \Spatie\Permission\Models\Role::create(['name' => $role]));
|
||||
->each(fn ($role) => \Spatie\Permission\Models\Role::create(['name' => $role]));
|
||||
|
||||
$this->user = User::factory()
|
||||
->active()
|
||||
@ -30,7 +29,7 @@ function createUser(array $attributes = []): User
|
||||
return User::factory()
|
||||
->active()
|
||||
->has(Employee::factory())
|
||||
->state(fn() => array_merge([
|
||||
->state(fn () => array_merge([
|
||||
'status' => fake()->randomElement(UserStatus::cases()),
|
||||
], $attributes))
|
||||
->create();
|
||||
@ -64,7 +63,7 @@ function mountIndexComponent(User $user): Testable
|
||||
$user->outlets()->attach($outlet->id);
|
||||
|
||||
$component = mountIndexComponent($this->user);
|
||||
$loadedEmployee = $component->get('employees')->first(fn($emp) => $emp->user_id === $user->id);
|
||||
$loadedEmployee = $component->get('employees')->first(fn ($emp) => $emp->user_id === $user->id);
|
||||
|
||||
expect($loadedEmployee)->not->toBeNull()
|
||||
->and($loadedEmployee->relationLoaded('user'))->toBeTrue()
|
||||
@ -125,7 +124,7 @@ function mountIndexComponent(User $user): Testable
|
||||
$filteredComponent = mountIndexComponent($this->user)->set('status', [UserStatus::ACTIVE->value]);
|
||||
|
||||
expect(count($filteredComponent->get('employees')))->toBeGreaterThanOrEqual(1); // At least the active user
|
||||
expect($filteredComponent->get('employees')->contains(fn($emp) => $emp->user->status->value === UserStatus::ACTIVE->value))->toBeTrue();
|
||||
expect($filteredComponent->get('employees')->contains(fn ($emp) => $emp->user->status->value === UserStatus::ACTIVE->value))->toBeTrue();
|
||||
});
|
||||
|
||||
it('filters employees by multiple statuses', function () {
|
||||
@ -162,7 +161,7 @@ function mountIndexComponent(User $user): Testable
|
||||
$user->outlets()->attach($outlet->id);
|
||||
|
||||
$component = mountIndexComponent($this->user);
|
||||
$loadedEmployee = $component->get('employees')->first(fn($emp) => $emp->user_id === $user->id);
|
||||
$loadedEmployee = $component->get('employees')->first(fn ($emp) => $emp->user_id === $user->id);
|
||||
|
||||
expect($loadedEmployee)->not->toBeNull()
|
||||
->and($loadedEmployee->user->outlets)->toHaveCount(1)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user