fix(mobile): resolve timesheet and p2h mobile search button and space-insensitive matching

This commit is contained in:
Ray1111-aa
2026-10-27 08:34:34 +07:00
parent 58f1801810
commit c8d14c9470
8 changed files with 157 additions and 38 deletions
+32
View File
@@ -98,6 +98,38 @@ class P2hInspectionTest extends TestCase
$response->assertSee($this->supportVehicle->code);
}
public function test_p2h_catalog_search_is_space_and_hyphen_insensitive(): void
{
// Unit dengan spasi pada kode
$vehicleWithSpace = Vehicle::create([
'code' => 'EX 01',
'category' => 'unit_support',
'p2h_template_id' => $this->template->id,
'brand_type' => 'KOMATSU PC200 HYDRAULIC',
'unit_category' => 'Excavator',
'status' => 'Operation',
'current_km' => 2000.0,
]);
// 1. Tombol 'Cari' tersedia di UI
$response = $this->actingAs($this->operatorUser)->get(route('p2h.index'));
$response->assertStatus(200);
$response->assertSee('id="p2hSearchBtn"', false);
$response->assertSee('Cari');
// 2. Cari 'EX01' tanpa spasi mencocokkan 'EX 01'
$searchResponse1 = $this->actingAs($this->operatorUser)->get(route('p2h.index', ['search' => 'EX01']));
$searchResponse1->assertStatus(200);
$searchResponse1->assertSee('EX 01');
$searchResponse1->assertDontSee('EX99');
// 3. Cari 'EX 99' dengan spasi mencocokkan 'EX99'
$searchResponse2 = $this->actingAs($this->operatorUser)->get(route('p2h.index', ['search' => 'EX 99']));
$searchResponse2->assertStatus(200);
$searchResponse2->assertSee('EX99');
$searchResponse2->assertDontSee('EX 01');
}
public function test_all_28_p2h_categories_are_seeded_and_displayed(): void
{
$this->seed(\Database\Seeders\P2hTemplateSeeder::class);
@@ -200,4 +200,31 @@ class VehicleActivitySimperValidationTest extends TestCase
'current_km' => 5050.00,
]);
}
/**
* Pencarian katalog timesheet tidak sensitif terhadap spasi dan tanda hubung,
* serta tombol submit Cari tersedia untuk pengguna mobile.
*/
public function test_timesheet_catalog_search_is_space_and_hyphen_insensitive(): void
{
// 1. Tombol submit 'Cari' tersedia di tampilan mobile/desktop
$response = $this->actingAs($this->driverUser)->get(route('mobilisasi.index'));
$response->assertStatus(200);
$response->assertSee('id="lvSearchBtn"', false);
$response->assertSee('Cari');
// 2. Cari 'DT01' tanpa spasi mencocokkan kode 'DT-01'
$searchResponse1 = $this->actingAs($this->driverUser)->get(route('mobilisasi.index', ['search' => 'DT01']));
$searchResponse1->assertStatus(200);
$searchResponse1->assertSee('DT-01');
$searchResponse1->assertDontSee('Toyota Hilux');
// 3. Cari plat nomor tanpa spasi 'BH1234' mencocokkan 'BH 1234 KM'
$searchResponse2 = $this->actingAs($this->driverUser)->get(route('mobilisasi.index', ['search' => 'BH1234']));
$searchResponse2->assertStatus(200);
$searchResponse2->assertSee('Toyota Hilux');
$searchResponse2->assertDontSee('Hino 500');
$searchResponse2->assertSee('LV-01');
$searchResponse2->assertDontSee('DT-01');
}
}