Fix stale Staff On Site count after sign-out.
Deploy Ladill Frontdesk / deploy (push) Successful in 52s
Deploy Ladill Frontdesk / deploy (push) Successful in 52s
Compute staff presence stats outside the dashboard cache so counts update immediately when employees sign out. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Models\Organization;
|
||||
use App\Models\User;
|
||||
use App\Services\Frontdesk\EmployeePresenceService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Tests\TestCase;
|
||||
|
||||
class FrontdeskEmployeePresenceTest extends TestCase
|
||||
@@ -155,4 +156,25 @@ class FrontdeskEmployeePresenceTest extends TestCase
|
||||
->assertSee('Jane Staff', false)
|
||||
->assertSee('Staff on premises', false);
|
||||
}
|
||||
|
||||
public function test_dashboard_staff_on_site_updates_immediately_after_sign_out(): void
|
||||
{
|
||||
Cache::flush();
|
||||
|
||||
$employee = $this->createEmployee();
|
||||
$service = app(EmployeePresenceService::class);
|
||||
$service->signIn($employee);
|
||||
|
||||
$this->actingAs($this->user)
|
||||
->get(route('frontdesk.dashboard'))
|
||||
->assertOk()
|
||||
->assertViewHas('stats', fn (array $stats) => $stats['staff_on_site'] === 1);
|
||||
|
||||
$service->signOut($employee);
|
||||
|
||||
$this->actingAs($this->user)
|
||||
->get(route('frontdesk.dashboard'))
|
||||
->assertOk()
|
||||
->assertViewHas('stats', fn (array $stats) => $stats['staff_on_site'] === 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user