2026-09-30 17:29:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-10-02 12:14:48 +02:00
|
|
|
use App\Jobs\FetchAndUpsertArcadiaEmployees;
|
2026-09-30 17:29:57 +02:00
|
|
|
use App\Models\User;
|
|
|
|
|
use Domain\Enums\UserRole;
|
2026-10-02 12:14:48 +02:00
|
|
|
use Illuminate\Support\Facades\Queue;
|
2026-09-30 17:29:57 +02:00
|
|
|
|
|
|
|
|
describe('EmployeesController', function () {
|
|
|
|
|
beforeEach(function () {
|
|
|
|
|
// GIVEN
|
|
|
|
|
/** @var \Tests\TestCase $this */
|
|
|
|
|
$this->user = User::factory()->create(['role' => UserRole::SuperAdmin]);
|
|
|
|
|
$this->actingAs($this->user, 'backend');
|
|
|
|
|
});
|
|
|
|
|
|
2026-10-02 12:14:48 +02:00
|
|
|
it('can launch employee sync job', function () {
|
|
|
|
|
// GIVEN
|
2026-09-30 17:29:57 +02:00
|
|
|
/** @var \Tests\TestCase $this */
|
2026-10-02 12:14:48 +02:00
|
|
|
Queue::fake();
|
2026-09-30 17:29:57 +02:00
|
|
|
|
|
|
|
|
// WHEN
|
2026-10-02 12:14:48 +02:00
|
|
|
$response = $this->post('/bo/settings/employees/sync');
|
2026-09-30 17:29:57 +02:00
|
|
|
|
|
|
|
|
// THEN
|
2026-10-02 12:14:48 +02:00
|
|
|
$response->assertSessionHasNoErrors();
|
|
|
|
|
$response->assertRedirect(route('bo.dashboard'));
|
|
|
|
|
Queue::assertPushed(FetchAndUpsertArcadiaEmployees::class);
|
2026-09-30 17:29:57 +02:00
|
|
|
});
|
|
|
|
|
|
2026-10-02 12:14:48 +02:00
|
|
|
it('redirects unauthenticated users to login', function () {
|
2026-09-30 17:29:57 +02:00
|
|
|
// GIVEN
|
|
|
|
|
/** @var \Tests\TestCase $this */
|
2026-10-02 12:14:48 +02:00
|
|
|
auth()->guard('backend')->logout();
|
2026-09-30 17:29:57 +02:00
|
|
|
|
|
|
|
|
// WHEN
|
2026-10-02 12:14:48 +02:00
|
|
|
$response = $this->post('/bo/settings/employees/sync');
|
2026-09-30 17:29:57 +02:00
|
|
|
|
|
|
|
|
// THEN
|
2026-10-02 12:14:48 +02:00
|
|
|
$response->assertRedirect('/bo/login');
|
2026-09-30 17:29:57 +02:00
|
|
|
});
|
|
|
|
|
});
|