Fix stale Staff On Site count after sign-out.
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:
isaacclad
2026-06-28 22:42:38 +00:00
co-authored by Cursor
parent a4788d1796
commit a216666867
2 changed files with 43 additions and 14 deletions
@@ -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);
}
}