<?php

namespace Tests\Feature;

use App\Models\Attendance;
use App\Models\AttendancePolicy;
use App\Models\Company;
use App\Models\Location;
use App\Models\User;
use App\Models\WorkDuration;
use App\Http\Middleware\VerifyCsrfToken;
use App\Services\Attendance\AttendancePolicyResolver;
use App\Services\TenantRoleService;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Str;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;

class AttendancePolicyPunchTest extends TestCase
{
    use RefreshDatabase;

    private const OFFICE_LAT = 17.385044;

    private const OFFICE_LNG = 78.486671;

    private const REMOTE_LAT = 17.45;

    private const REMOTE_LNG = 78.50;

    private const SELFIE = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////2wBDAf//////////////////////////////////////////////////////////////////////////////////////wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAb/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAX/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAGd/8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABPwB//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAgEBPwB//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPwB//9k=';

    /**
     * @return array{company: Company, roles: array<string, mixed>, employee: User, other: User}
     */
    private function seedTenant(): array
    {
        $suffix = strtolower(Str::random(6));
        $company = Company::query()->create([
            'name' => 'Punch Co '.$suffix,
            'short_name' => 'P'.strtoupper($suffix),
            'email' => 'punch-'.$suffix.'@example.com',
            'status' => 'active',
        ]);
        $roles = TenantRoleService::syncAllDefaultRolesForCompany((int) $company->id);
        $employee = User::factory()->create([
            'company_id' => $company->id,
            'role_id' => $roles['employee']->id,
            'user_type' => User::USER_TYPE_STAFF,
            'allow_login' => true,
        ]);
        $otherCompany = Company::query()->create([
            'name' => 'Other Co '.$suffix,
            'short_name' => 'O'.strtoupper($suffix),
            'email' => 'other-'.$suffix.'@example.com',
            'status' => 'active',
        ]);
        $otherRoles = TenantRoleService::syncAllDefaultRolesForCompany((int) $otherCompany->id);
        $other = User::factory()->create([
            'company_id' => $otherCompany->id,
            'role_id' => $otherRoles['employee']->id,
            'user_type' => User::USER_TYPE_STAFF,
            'allow_login' => true,
        ]);

        return compact('company', 'roles', 'employee', 'other');
    }

    private function setPolicy(int $companyId, string $mode, array $extra = []): AttendancePolicy
    {
        $flags = AttendancePolicy::syncDerivedFlags($mode);

        return AttendancePolicy::query()->updateOrCreate(
            ['company_id' => $companyId],
            array_merge(AttendancePolicy::systemDefaults(), $flags, ['mode' => $mode], $extra)
        );
    }

    private function office(int $companyId, array $overrides = []): Location
    {
        return Location::query()->create(array_merge([
            'company_id' => $companyId,
            'name' => 'Hyderabad HQ',
            'code' => 'HYD'.random_int(100, 999),
            'latitude' => self::OFFICE_LAT,
            'longitude' => self::OFFICE_LNG,
            'radius_meters' => 250,
            'is_active' => true,
        ], $overrides));
    }

    /**
     * @param  array<string, mixed>  $extra
     */
    private function clockIn(User $user, array $extra = [])
    {
        Sanctum::actingAs($user);

        return $this->postJson('/api/attendance/clock-in', array_merge([
            'latitude' => self::OFFICE_LAT,
            'longitude' => self::OFFICE_LNG,
            'accuracy' => 8,
            'selfie' => self::SELFIE,
            'location' => 'test',
        ], $extra));
    }

    /**
     * @param  array<string, mixed>  $extra
     */
    private function clockOut(User $user, array $extra = [])
    {
        Sanctum::actingAs($user);

        return $this->postJson('/api/attendance/clock-out', array_merge([
            'selfie' => self::SELFIE,
        ], $extra));
    }

    public function test_normal_check_in_succeeds_without_geofence(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_NORMAL);

        $response = $this->clockIn($ctx['employee'], [
            'latitude' => 1.0,
            'longitude' => 1.0,
            'attendance_type' => 'normal',
        ]);

        $response->assertCreated();
        $this->assertDatabaseHas('attendances', [
            'user_id' => $ctx['employee']->id,
            'attendance_type' => 'normal',
            'clock_in_method' => 'mobile',
        ]);
    }

    public function test_office_check_in_inside_geofence_succeeds(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_OFFICE_GEOFENCE);
        $office = $this->office((int) $ctx['company']->id);
        $ctx['employee']->update(['location_id' => $office->id]);

        $response = $this->clockIn($ctx['employee']->fresh(), ['attendance_type' => 'office']);

        $response->assertCreated();
        $this->assertDatabaseHas('attendances', [
            'user_id' => $ctx['employee']->id,
            'attendance_type' => 'office',
            'clock_in_location_id' => $office->id,
        ]);
        $this->assertNotNull($response->json('clock_in_distance_meters'));
        $this->assertLessThanOrEqual(250, $response->json('clock_in_distance_meters'));
    }

    public function test_office_check_in_outside_geofence_fails(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_OFFICE_GEOFENCE);
        $this->office((int) $ctx['company']->id);

        $response = $this->clockIn($ctx['employee'], [
            'latitude' => 17.45,
            'longitude' => 78.50,
            'attendance_type' => 'office',
        ]);

        $response->assertStatus(422);
        $this->assertStringContainsString('outside the permitted office location', $response->json('message'));
    }

    public function test_remote_check_in_succeeds_when_enabled(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_REMOTE);

        $response = $this->clockIn($ctx['employee'], [
            'attendance_type' => 'remote',
            'remote_reason' => 'Client visit',
        ]);

        $response->assertCreated();
        $this->assertDatabaseHas('attendances', [
            'user_id' => $ctx['employee']->id,
            'attendance_type' => 'remote',
        ]);
    }

    public function test_remote_check_in_fails_when_disabled(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_OFFICE_GEOFENCE);
        $this->office((int) $ctx['company']->id);

        $response = $this->clockIn($ctx['employee'], ['attendance_type' => 'remote']);

        $response->assertStatus(422);
        $this->assertSame('Your attendance policy does not allow remote check-in.', $response->json('message'));
    }

    public function test_employee_override_takes_precedence_over_tenant_policy(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_OFFICE_GEOFENCE);
        $this->office((int) $ctx['company']->id);
        $ctx['employee']->update(['attendance_mode' => AttendancePolicy::MODE_REMOTE]);

        $resolver = app(AttendancePolicyResolver::class);
        $resolved = $resolver->resolveForUser($ctx['employee']->fresh());
        $this->assertSame(AttendancePolicy::MODE_REMOTE, $resolved->mode);
        $this->assertSame('employee', $resolved->source);

        $response = $this->clockIn($ctx['employee']->fresh(), ['attendance_type' => 'remote']);
        $response->assertCreated();
    }

    public function test_tenant_default_policy_is_used_when_employee_has_no_override(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_REMOTE);

        $resolved = app(AttendancePolicyResolver::class)->resolveForUser($ctx['employee']);
        $this->assertSame(AttendancePolicy::MODE_REMOTE, $resolved->mode);
        $this->assertSame('tenant', $resolved->source);
    }

    public function test_system_default_is_normal_when_no_tenant_policy_exists(): void
    {
        $ctx = $this->seedTenant();
        $resolved = app(AttendancePolicyResolver::class)->resolveForUser($ctx['employee']);
        $this->assertSame(AttendancePolicy::MODE_NORMAL, $resolved->mode);
        $this->assertSame('tenant', $resolved->source);
    }

    public function test_duplicate_check_in_fails(): void
    {
        $ctx = $this->seedTenant();
        $this->clockIn($ctx['employee'])->assertCreated();
        $second = $this->clockIn($ctx['employee']);
        $second->assertStatus(422);
        $this->assertSame('You have already checked in.', $second->json('message'));
    }

    public function test_check_out_without_check_in_fails(): void
    {
        $ctx = $this->seedTenant();
        Sanctum::actingAs($ctx['employee']);
        $response = $this->postJson('/api/attendance/clock-out', [
            'latitude' => self::OFFICE_LAT,
            'longitude' => self::OFFICE_LNG,
            'selfie' => self::SELFIE,
        ]);
        $response->assertStatus(422);
        $this->assertSame('You must check in before checking out.', $response->json('message'));
    }

    public function test_cross_tenant_attendance_show_is_forbidden(): void
    {
        $ctx = $this->seedTenant();
        $this->clockIn($ctx['employee'])->assertCreated();
        $attendance = Attendance::query()->where('user_id', $ctx['employee']->id)->firstOrFail();

        Sanctum::actingAs($ctx['other']);
        $response = $this->getJson('/api/attendance/'.$attendance->id);
        $this->assertTrue(in_array($response->status(), [403, 404], true));
    }

    public function test_inactive_office_cannot_be_used(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_OFFICE_GEOFENCE);
        $this->office((int) $ctx['company']->id, ['is_active' => false, 'name' => 'Closed']);

        $response = $this->clockIn($ctx['employee'], ['attendance_type' => 'office']);
        $response->assertStatus(422);
        $this->assertSame('No valid office location is configured.', $response->json('message'));
    }

    public function test_gps_accuracy_validation_rejects_low_accuracy(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_OFFICE_GEOFENCE, [
            'gps_accuracy_requirement' => 15,
        ]);
        $this->office((int) $ctx['company']->id);

        $response = $this->clockIn($ctx['employee'], [
            'attendance_type' => 'office',
            'accuracy' => 80,
        ]);
        $response->assertStatus(422);
        $this->assertSame('GPS accuracy is too low (80m). Required: 15m.', $response->json('message'));
    }

    public function test_nearest_of_multiple_offices_is_used(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_OFFICE_GEOFENCE);
        $this->office((int) $ctx['company']->id, ['name' => 'Far', 'latitude' => 17.45, 'longitude' => 78.50, 'code' => 'FAR1']);
        $near = $this->office((int) $ctx['company']->id, ['name' => 'Near', 'code' => 'NEAR1']);

        $response = $this->clockIn($ctx['employee'], ['attendance_type' => 'office']);
        $response->assertCreated();
        $this->assertSame($near->id, $response->json('clock_in_location_id'));
    }

    public function test_web_check_in_records_web_method(): void
    {
        Carbon::setTestNow(Carbon::parse('2026-09-07 10:00:00')); // Monday — avoid weekoff block
        $this->withoutMiddleware([
            VerifyCsrfToken::class,
            \Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
        ]);
        $ctx = $this->seedTenant();
        $this->actingAs($ctx['employee']);
        $response = $this->post(route('attendance.check-in'), [
            'latitude' => self::OFFICE_LAT,
            'longitude' => self::OFFICE_LNG,
            'accuracy' => 5,
            'attendance_type' => 'normal',
        ]);
        $response->assertRedirect();
        $this->assertDatabaseHas('attendances', [
            'user_id' => $ctx['employee']->id,
            'clock_in_method' => 'web',
            'attendance_type' => 'normal',
        ]);
        Carbon::setTestNow();
    }

    public function test_mobile_method_is_recorded_on_api_clock_in(): void
    {
        $ctx = $this->seedTenant();
        $this->clockIn($ctx['employee'])->assertCreated();
        $this->assertDatabaseHas('attendances', [
            'user_id' => $ctx['employee']->id,
            'clock_in_method' => 'mobile',
        ]);
    }

    public function test_remote_check_out_succeeds_without_coords(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_HYBRID);
        $this->office((int) $ctx['company']->id);
        $this->clockIn($ctx['employee'], [
            'latitude' => self::REMOTE_LAT,
            'longitude' => self::REMOTE_LNG,
        ])->assertCreated();
        $this->assertDatabaseHas('attendances', [
            'user_id' => $ctx['employee']->id,
            'attendance_type' => 'remote',
        ]);

        $response = $this->clockOut($ctx['employee']);

        $response->assertOk();
        $this->assertNotNull(
            Attendance::query()->where('user_id', $ctx['employee']->id)->value('clock_out_date_time')
        );
    }

    public function test_office_check_out_without_coords_fails(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_OFFICE_GEOFENCE);
        $this->office((int) $ctx['company']->id);
        $this->clockIn($ctx['employee'], ['attendance_type' => 'office'])->assertCreated();

        $response = $this->clockOut($ctx['employee']);

        $response->assertStatus(422);
        $this->assertSame(
            'Location is required for office check-in. Allow location access in your browser, then try again.',
            $response->json('message')
        );
    }

    public function test_office_check_in_without_coords_allowed_when_location_not_required(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_OFFICE_GEOFENCE, [
            'require_location_for_office' => false,
        ]);
        $this->office((int) $ctx['company']->id);

        $response = $this->clockIn($ctx['employee'], [
            'attendance_type' => 'office',
            'latitude' => null,
            'longitude' => null,
            'accuracy' => null,
        ]);

        $response->assertCreated();
        $this->assertDatabaseHas('attendances', [
            'user_id' => $ctx['employee']->id,
            'attendance_type' => 'office',
            'clock_in_location_id' => null,
        ]);
    }

    public function test_office_check_out_with_valid_coords_succeeds(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_OFFICE_GEOFENCE);
        $this->office((int) $ctx['company']->id);
        $this->clockIn($ctx['employee'], ['attendance_type' => 'office'])->assertCreated();

        $response = $this->clockOut($ctx['employee'], [
            'latitude' => self::OFFICE_LAT,
            'longitude' => self::OFFICE_LNG,
            'accuracy' => 8,
        ]);

        $response->assertOk();
        $this->assertNotNull(
            Attendance::query()->where('user_id', $ctx['employee']->id)->value('clock_out_date_time')
        );
    }

    public function test_legacy_null_attendance_type_check_out_succeeds_without_coords_on_normal_policy(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_NORMAL);

        $attendance = Attendance::query()->create([
            'company_id' => $ctx['company']->id,
            'user_id' => $ctx['employee']->id,
            'date' => now()->toDateString(),
            'clock_in_date_time' => now(),
            'clock_in_time' => now()->format('H:i:s'),
            'status' => 'present',
            'attendance_type' => null,
            'clock_in_method' => 'web',
        ]);
        WorkDuration::query()->create([
            'company_id' => $ctx['company']->id,
            'attendance_id' => $attendance->id,
            'start_time' => now()->format('H:i:s'),
            'status' => 'open',
        ]);

        $response = $this->clockOut($ctx['employee']);

        $response->assertOk();
    }

    public function test_hybrid_remote_check_out_uses_stored_session_type_without_request_type(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_HYBRID);
        $this->office((int) $ctx['company']->id);
        $this->clockIn($ctx['employee'], [
            'latitude' => self::REMOTE_LAT,
            'longitude' => self::REMOTE_LNG,
        ])->assertCreated();

        $response = $this->clockOut($ctx['employee'], [
            'attendance_type' => 'office',
            'latitude' => self::REMOTE_LAT,
            'longitude' => self::REMOTE_LNG,
        ]);

        $response->assertOk();
    }

    public function test_web_remote_check_out_succeeds_without_coords(): void
    {
        Carbon::setTestNow(Carbon::parse('2026-09-07 10:00:00')); // Monday — avoid weekoff block
        $this->withoutMiddleware([
            VerifyCsrfToken::class,
            \Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
        ]);
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_HYBRID);
        $this->office((int) $ctx['company']->id);

        $this->actingAs($ctx['employee']);
        $this->post(route('attendance.check-in'), [
            'latitude' => self::REMOTE_LAT,
            'longitude' => self::REMOTE_LNG,
            'accuracy' => 8,
        ])->assertRedirect();
        $this->assertDatabaseHas('attendances', [
            'user_id' => $ctx['employee']->id,
            'attendance_type' => 'remote',
        ]);

        $response = $this->post(route('attendance.check-out'), []);

        $response->assertRedirect();
        $this->assertNotNull(
            Attendance::query()->where('user_id', $ctx['employee']->id)->value('clock_out_date_time')
        );
        Carbon::setTestNow();
    }

    public function test_remote_only_null_attendance_type_check_out_succeeds_without_coords(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_REMOTE);

        $attendance = Attendance::query()->create([
            'company_id' => $ctx['company']->id,
            'user_id' => $ctx['employee']->id,
            'date' => now()->toDateString(),
            'clock_in_date_time' => now(),
            'clock_in_time' => now()->format('H:i:s'),
            'status' => 'present',
            'attendance_type' => null,
            'clock_in_method' => 'mobile',
        ]);
        WorkDuration::query()->create([
            'company_id' => $ctx['company']->id,
            'attendance_id' => $attendance->id,
            'start_time' => now()->format('H:i:s'),
            'status' => 'open',
        ]);

        $response = $this->clockOut($ctx['employee']);

        $response->assertOk();
    }

    public function test_hybrid_legacy_null_attendance_type_check_out_infers_remote(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_HYBRID);
        $this->office((int) $ctx['company']->id);

        $attendance = Attendance::query()->create([
            'company_id' => $ctx['company']->id,
            'user_id' => $ctx['employee']->id,
            'date' => now()->toDateString(),
            'clock_in_date_time' => now(),
            'clock_in_time' => now()->format('H:i:s'),
            'status' => 'present',
            'attendance_type' => null,
            'clock_in_method' => 'mobile',
            'clock_in_location_id' => null,
        ]);
        WorkDuration::query()->create([
            'company_id' => $ctx['company']->id,
            'attendance_id' => $attendance->id,
            'start_time' => now()->format('H:i:s'),
            'status' => 'open',
        ]);

        $response = $this->clockOut($ctx['employee']);

        $response->assertOk();
    }

    public function test_remote_check_out_with_is_mocked_succeeds(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_HYBRID);
        $this->office((int) $ctx['company']->id);
        $this->clockIn($ctx['employee'], [
            'latitude' => self::REMOTE_LAT,
            'longitude' => self::REMOTE_LNG,
        ])->assertCreated();

        $response = $this->clockOut($ctx['employee'], [
            'is_mocked' => true,
        ]);

        $response->assertOk();
    }

    public function test_self_dashboard_punch_forms_receive_policy_like_topbar(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_HYBRID);
        $this->office((int) $ctx['company']->id);

        $this->actingAs($ctx['employee']);

        $dashboard = $this->get(route('dashboard.self'));
        $dashboard->assertOk();
        $dashboard->assertSee('data-prefix="selfdash"', false);
        $dashboard->assertSee('data-is-hybrid="1"', false);
        $dashboard->assertSee('data-punch-type="hybrid"', false);
        $dashboard->assertSee('Check In', false);
        $dashboard->assertDontSee('Office Check In', false);
        $dashboard->assertDontSee('Check In Remotely', false);

        $attendancePage = $this->get(route('attendance.index'));
        $attendancePage->assertOk();
        $attendancePage->assertSee('data-prefix="topbar"', false);
        $attendancePage->assertSee('data-punch-type="hybrid"', false);
        $attendancePage->assertDontSee('Office Check In', false);
    }

    public function test_hybrid_check_in_inside_geofence_resolves_office(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_HYBRID);
        $this->office((int) $ctx['company']->id);

        $response = $this->clockIn($ctx['employee'], [
            'attendance_type' => 'remote', // ignored — GPS decides
        ]);

        $response->assertCreated();
        $this->assertDatabaseHas('attendances', [
            'user_id' => $ctx['employee']->id,
            'attendance_type' => 'office',
        ]);
        $this->assertNotNull(
            Attendance::query()->where('user_id', $ctx['employee']->id)->value('clock_in_location_id')
        );
    }

    public function test_hybrid_check_in_outside_geofence_resolves_remote(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_HYBRID);
        $this->office((int) $ctx['company']->id);

        $response = $this->clockIn($ctx['employee'], [
            'attendance_type' => 'office', // ignored — GPS decides
            'latitude' => self::REMOTE_LAT,
            'longitude' => self::REMOTE_LNG,
        ]);

        $response->assertCreated();
        $this->assertDatabaseHas('attendances', [
            'user_id' => $ctx['employee']->id,
            'attendance_type' => 'remote',
            'clock_in_location_id' => null,
        ]);
    }

    public function test_hybrid_check_in_without_coords_fails(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_HYBRID);
        $this->office((int) $ctx['company']->id);

        $response = $this->clockIn($ctx['employee'], [
            'latitude' => null,
            'longitude' => null,
            'accuracy' => null,
        ]);

        $response->assertStatus(422);
        $this->assertStringContainsString('Location is required', $response->json('message'));
    }

    public function test_remote_mode_dashboard_shows_check_in_label(): void
    {
        $ctx = $this->seedTenant();
        $this->setPolicy((int) $ctx['company']->id, AttendancePolicy::MODE_REMOTE);

        $this->actingAs($ctx['employee']);

        $dashboard = $this->get(route('dashboard.self'));
        $dashboard->assertOk();
        $dashboard->assertSee('data-punch-type="remote"', false);
        $dashboard->assertSee('Check In', false);
        $dashboard->assertDontSee('Check In Remotely', false);
    }
}
