fix(mobile): resolve timesheet and p2h mobile search button and space-insensitive matching
This commit is contained in:
@@ -32,11 +32,19 @@ class P2hFormController extends Controller
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$search = trim($request->input('search'));
|
||||
$query->where(function ($q) use ($search) {
|
||||
$cleanSearch = preg_replace('/[^a-zA-Z0-9]/', '', $search);
|
||||
|
||||
$query->where(function ($q) use ($search, $cleanSearch) {
|
||||
$q->where('code', 'like', "%{$search}%")
|
||||
->orWhere('brand_type', 'like', "%{$search}%")
|
||||
->orWhere('unit_category', 'like', "%{$search}%")
|
||||
->orWhere('location', 'like', "%{$search}%");
|
||||
->orWhere('location', 'like', "%{$search}%")
|
||||
->orWhere('license_plate', 'like', "%{$search}%");
|
||||
|
||||
if (!empty($cleanSearch)) {
|
||||
$q->orWhereRaw("REPLACE(REPLACE(code, ' ', ''), '-', '') LIKE ?", ["%{$cleanSearch}%"])
|
||||
->orWhereRaw("REPLACE(REPLACE(license_plate, ' ', ''), '-', '') LIKE ?", ["%{$cleanSearch}%"]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -35,11 +35,19 @@ class VehicleActivityFormController extends Controller
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$search = trim($request->input('search'));
|
||||
$query->where(function ($q) use ($search) {
|
||||
$cleanSearch = preg_replace('/[^a-zA-Z0-9]/', '', $search);
|
||||
|
||||
$query->where(function ($q) use ($search, $cleanSearch) {
|
||||
$q->where('code', 'like', "%{$search}%")
|
||||
->orWhere('brand_type', 'like', "%{$search}%")
|
||||
->orWhere('license_plate', 'like', "%{$search}%")
|
||||
->orWhere('ownership', 'like', "%{$search}%");
|
||||
->orWhere('ownership', 'like', "%{$search}%")
|
||||
->orWhere('unit_category', 'like', "%{$search}%");
|
||||
|
||||
if (!empty($cleanSearch)) {
|
||||
$q->orWhereRaw("REPLACE(REPLACE(code, ' ', ''), '-', '') LIKE ?", ["%{$cleanSearch}%"])
|
||||
->orWhereRaw("REPLACE(REPLACE(license_plate, ' ', ''), '-', '') LIKE ?", ["%{$cleanSearch}%"]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -85,17 +85,24 @@ class SupportTimesheetController extends Controller
|
||||
// Filter Pencarian Kata Kunci
|
||||
if ($request->filled('search')) {
|
||||
$search = trim($request->input('search'));
|
||||
$query->where(function (Builder $q) use ($search) {
|
||||
$cleanSearch = preg_replace('/[^a-zA-Z0-9]/', '', $search);
|
||||
|
||||
$query->where(function (Builder $q) use ($search, $cleanSearch) {
|
||||
$q->where('timesheet_no', 'like', "%{$search}%")
|
||||
->orWhere('location', 'like', "%{$search}%")
|
||||
->orWhere('activity_type', 'like', "%{$search}%")
|
||||
->orWhere('task_description', 'like', "%{$search}%")
|
||||
->orWhere('notes', 'like', "%{$search}%")
|
||||
->orWhereHas('vehicle', function (Builder $vq) use ($search) {
|
||||
->orWhereHas('vehicle', function (Builder $vq) use ($search, $cleanSearch) {
|
||||
$vq->where('code', 'like', "%{$search}%")
|
||||
->orWhere('brand_type', 'like', "%{$search}%")
|
||||
->orWhere('license_plate', 'like', "%{$search}%")
|
||||
->orWhere('serial_number', 'like', "%{$search}%");
|
||||
|
||||
if (!empty($cleanSearch)) {
|
||||
$vq->orWhereRaw("REPLACE(REPLACE(code, ' ', ''), '-', '') LIKE ?", ["%{$cleanSearch}%"])
|
||||
->orWhereRaw("REPLACE(REPLACE(license_plate, ' ', ''), '-', '') LIKE ?", ["%{$cleanSearch}%"]);
|
||||
}
|
||||
})
|
||||
->orWhereHas('operator', function (Builder $oq) use ($search) {
|
||||
$oq->where('name', 'like', "%{$search}%")
|
||||
|
||||
@@ -52,9 +52,9 @@
|
||||
<!-- Filter & Search Bar (Tanpa Card Wrapper, Format Referensi Sesuai Standar) -->
|
||||
<form method="GET" action="{{ route('mobilisasi.index') }}" id="lvFilterForm" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-2.5 sm:gap-3">
|
||||
<input type="hidden" name="type" value="{{ $type ?? 'all' }}">
|
||||
<!-- Pencarian Cepat di Kiri -->
|
||||
<div class="relative w-full sm:max-w-md">
|
||||
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400">
|
||||
<!-- Pencarian Cepat di Kiri dengan Tombol Cari -->
|
||||
<div class="relative w-full sm:max-w-md flex items-center">
|
||||
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400 z-10">
|
||||
<i class="fa-solid fa-magnifying-glass text-xs"></i>
|
||||
</span>
|
||||
<input type="text"
|
||||
@@ -62,13 +62,19 @@
|
||||
id="lvSearchInput"
|
||||
value="{{ request('search') }}"
|
||||
placeholder="Cari kode unit (LV01), nopol, atau model..."
|
||||
class="w-full text-xs pl-10 pr-4 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition">
|
||||
autocomplete="off"
|
||||
class="w-full text-xs pl-10 pr-20 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition">
|
||||
<button type="submit"
|
||||
id="lvSearchBtn"
|
||||
class="absolute right-1.5 inset-y-1.5 px-3 bg-[#1b5e20] hover:bg-[#144918] active:scale-95 text-white font-bold text-xs rounded-lg flex items-center gap-1.5 transition shadow-sm cursor-pointer z-10">
|
||||
<span>Cari</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Tombol Reset Filter di Kanan -->
|
||||
<div id="lvResetContainer" class="flex items-center justify-end">
|
||||
@if(request()->filled('search'))
|
||||
<a href="{{ route('mobilisasi.index') }}"
|
||||
<a href="{{ route('mobilisasi.index', ['type' => $type ?? 'all']) }}"
|
||||
id="lvResetBtn"
|
||||
class="text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center justify-center sm:justify-start space-x-1.5 transition whitespace-nowrap py-1 sm:py-0">
|
||||
<i class="fa-solid fa-rotate-left text-[11px]"></i>
|
||||
@@ -191,12 +197,13 @@
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Search Real-Time Client-Side
|
||||
// Search Real-Time Client-Side & Smart Server Query
|
||||
const searchInput = document.getElementById('lvSearchInput');
|
||||
const resetContainer = document.getElementById('lvResetContainer');
|
||||
const cardsContainer = document.getElementById('lvCardsContainer');
|
||||
const paginationContainer = document.getElementById('lvPaginationContainer');
|
||||
const serverEmptyCard = document.getElementById('lvServerEmptyCard');
|
||||
const filterForm = document.getElementById('lvFilterForm');
|
||||
const hasServerFilters = {{ request()->filled('search') ? 'true' : 'false' }};
|
||||
|
||||
function escapeHtml(str) {
|
||||
@@ -208,12 +215,14 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
searchInput?.addEventListener('input', function(e) {
|
||||
const rawValue = e.target.value;
|
||||
const query = rawValue.toLowerCase().trim();
|
||||
const cleanQuery = query.replace(/[\s\-_]/g, '');
|
||||
const items = document.querySelectorAll('#lvCardsContainer .lv-card');
|
||||
let visibleCount = 0;
|
||||
|
||||
items.forEach(item => {
|
||||
const text = item.textContent.toLowerCase();
|
||||
const match = text.includes(query);
|
||||
const cleanText = text.replace(/[\s\-_]/g, '');
|
||||
const match = text.includes(query) || (cleanQuery.length > 0 && cleanText.includes(cleanQuery));
|
||||
item.style.display = match ? '' : 'none';
|
||||
if (match) visibleCount++;
|
||||
});
|
||||
@@ -229,22 +238,27 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
existingEmptyCard.remove();
|
||||
}
|
||||
|
||||
// Tampilkan pesan kosong jika tidak ada data yang cocok
|
||||
// Tampilkan notifikasi jika tidak ada data yang cocok di halaman ini
|
||||
if (visibleCount === 0 && query.length > 0) {
|
||||
const emptyDiv = document.createElement('div');
|
||||
emptyDiv.id = 'lvEmptySearchCard';
|
||||
emptyDiv.className = 'col-span-full bg-white rounded-2xl border border-slate-200 p-12 text-center shadow-sm';
|
||||
emptyDiv.className = 'col-span-full bg-white rounded-2xl border border-slate-200 p-8 sm:p-12 text-center shadow-sm';
|
||||
emptyDiv.innerHTML = `
|
||||
<div class="w-16 h-16 rounded-full bg-rose-50 text-rose-500 flex items-center justify-center mx-auto mb-3">
|
||||
<i class="fa-solid fa-magnifying-glass text-2xl"></i>
|
||||
</div>
|
||||
<h3 class="text-base font-bold text-slate-800">
|
||||
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
|
||||
Unit "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ada di halaman ini
|
||||
</h3>
|
||||
<p class="text-xs text-slate-500 mt-1">
|
||||
Pastikan kode unit atau nopol kendaraan yang dicari sudah benar.
|
||||
<p class="text-xs text-slate-500 mt-1 max-w-md mx-auto">
|
||||
Unit mungkin berada di halaman lain. Tekan tombol <strong>Cari di Semua Halaman</strong> untuk mencari di seluruh database kendaraan.
|
||||
</p>
|
||||
<div class="mt-4">
|
||||
<div class="mt-4 flex flex-wrap items-center justify-center gap-2">
|
||||
<button type="submit" form="lvFilterForm"
|
||||
class="inline-flex items-center space-x-1.5 px-4 py-2 rounded-xl text-xs font-bold text-white bg-[#1b5e20] hover:bg-[#144918] active:scale-95 transition shadow-sm cursor-pointer">
|
||||
<i class="fa-solid fa-magnifying-glass text-[11px]"></i>
|
||||
<span>Cari di Semua Halaman</span>
|
||||
</button>
|
||||
<button type="button"
|
||||
onclick="const inp = document.getElementById('lvSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
|
||||
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
|
||||
@@ -261,13 +275,13 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
paginationContainer.style.display = query.length > 0 ? 'none' : '';
|
||||
}
|
||||
|
||||
// Tampilkan / sembunyikan tombol Reset Filter (merah fa-rotate-left) secara real-time
|
||||
// Tampilkan / sembunyikan tombol Reset Filter secara real-time
|
||||
let resetBtn = document.getElementById('lvResetBtn');
|
||||
if (query.length > 0) {
|
||||
if (!resetBtn && resetContainer) {
|
||||
resetBtn = document.createElement('a');
|
||||
resetBtn.id = 'lvResetBtn';
|
||||
resetBtn.href = "{{ route('mobilisasi.index') }}";
|
||||
resetBtn.href = "{{ route('mobilisasi.index', ['type' => $type ?? 'all']) }}";
|
||||
resetBtn.className = "text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center justify-center sm:justify-start space-x-1.5 transition whitespace-nowrap py-1 sm:py-0";
|
||||
|
||||
const resetIcon = document.createElement('i');
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
|
||||
<!-- Filter & Search Bar (Tanpa Card Wrapper, Format Referensi Data Karyawan) -->
|
||||
<form method="GET" action="{{ route('p2h.index') }}" id="p2hFilterForm" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-2.5 sm:gap-3">
|
||||
<!-- Pencarian Cepat di Kiri -->
|
||||
<div class="relative w-full sm:max-w-md">
|
||||
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400">
|
||||
<!-- Pencarian Cepat di Kiri dengan Tombol Cari -->
|
||||
<div class="relative w-full sm:max-w-md flex items-center">
|
||||
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400 z-10">
|
||||
<i class="fa-solid fa-magnifying-glass text-xs"></i>
|
||||
</span>
|
||||
<input type="text"
|
||||
@@ -45,7 +45,13 @@
|
||||
id="p2hSearchInput"
|
||||
value="{{ request('search') }}"
|
||||
placeholder="Cari kode unit (EX01), model, atau lokasi..."
|
||||
class="w-full text-xs pl-10 pr-4 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition">
|
||||
autocomplete="off"
|
||||
class="w-full text-xs pl-10 pr-20 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition">
|
||||
<button type="submit"
|
||||
id="p2hSearchBtn"
|
||||
class="absolute right-1.5 inset-y-1.5 px-3 bg-[#1b5e20] hover:bg-[#144918] active:scale-95 text-white font-bold text-xs rounded-lg flex items-center gap-1.5 transition shadow-sm cursor-pointer z-10">
|
||||
<span>Cari</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Filter Dropdown & Tombol di Kanan -->
|
||||
@@ -164,12 +170,13 @@
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Search Real-Time Client-Side
|
||||
// Search Real-Time Client-Side & Smart Server Query
|
||||
const searchInput = document.getElementById('p2hSearchInput');
|
||||
const resetContainer = document.getElementById('p2hResetContainer');
|
||||
const cardsContainer = document.getElementById('p2hCardsContainer');
|
||||
const paginationContainer = document.getElementById('p2hPaginationContainer');
|
||||
const serverEmptyCard = document.getElementById('p2hServerEmptyCard');
|
||||
const filterForm = document.getElementById('p2hFilterForm');
|
||||
const hasServerFilters = {{ request()->anyFilled(['search', 'unit_category']) ? 'true' : 'false' }};
|
||||
|
||||
function escapeHtml(str) {
|
||||
@@ -181,13 +188,15 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
searchInput?.addEventListener('input', function(e) {
|
||||
const rawValue = e.target.value;
|
||||
const query = rawValue.toLowerCase().trim();
|
||||
const cleanQuery = query.replace(/[\s\-_]/g, '');
|
||||
// Pencarian multi-field ke kartu/baris unit
|
||||
const items = document.querySelectorAll('#p2hCardsContainer .p2h-card, #p2hCardsContainer tr.p2h-row');
|
||||
let visibleCount = 0;
|
||||
|
||||
items.forEach(item => {
|
||||
const text = item.textContent.toLowerCase();
|
||||
const match = text.includes(query);
|
||||
const cleanText = text.replace(/[\s\-_]/g, '');
|
||||
const match = text.includes(query) || (cleanQuery.length > 0 && cleanText.includes(cleanQuery));
|
||||
item.style.display = match ? '' : 'none';
|
||||
if (match) visibleCount++;
|
||||
});
|
||||
@@ -203,22 +212,27 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
existingEmptyCard.remove();
|
||||
}
|
||||
|
||||
// Tampilkan pesan kosong jika tidak ada data yang cocok
|
||||
// Tampilkan pesan kosong jika tidak ada data yang cocok di halaman ini
|
||||
if (visibleCount === 0 && query.length > 0) {
|
||||
const emptyDiv = document.createElement('div');
|
||||
emptyDiv.id = 'p2hEmptySearchCard';
|
||||
emptyDiv.className = 'col-span-full bg-white rounded-2xl border border-slate-200 p-12 text-center shadow-sm';
|
||||
emptyDiv.className = 'col-span-full bg-white rounded-2xl border border-slate-200 p-8 sm:p-12 text-center shadow-sm';
|
||||
emptyDiv.innerHTML = `
|
||||
<div class="w-16 h-16 rounded-full bg-rose-50 text-rose-500 flex items-center justify-center mx-auto mb-3">
|
||||
<i class="fa-solid fa-magnifying-glass text-2xl"></i>
|
||||
</div>
|
||||
<h3 class="text-base font-bold text-slate-800">
|
||||
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
|
||||
Unit "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ada di halaman ini
|
||||
</h3>
|
||||
<p class="text-xs text-slate-500 mt-1">
|
||||
Pastikan kode unit atau kategori alat berat yang dicari sudah benar.
|
||||
<p class="text-xs text-slate-500 mt-1 max-w-md mx-auto">
|
||||
Unit mungkin berada di halaman lain atau kategori lain. Tekan tombol <strong>Cari di Semua Halaman</strong> untuk mencari di seluruh database alat berat.
|
||||
</p>
|
||||
<div class="mt-4">
|
||||
<div class="mt-4 flex flex-wrap items-center justify-center gap-2">
|
||||
<button type="submit" form="p2hFilterForm"
|
||||
class="inline-flex items-center space-x-1.5 px-4 py-2 rounded-xl text-xs font-bold text-white bg-[#1b5e20] hover:bg-[#144918] active:scale-95 transition shadow-sm cursor-pointer">
|
||||
<i class="fa-solid fa-magnifying-glass text-[11px]"></i>
|
||||
<span>Cari di Semua Halaman</span>
|
||||
</button>
|
||||
<button type="button"
|
||||
onclick="const inp = document.getElementById('p2hSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
|
||||
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
|
||||
|
||||
@@ -102,9 +102,9 @@
|
||||
|
||||
<!-- Kotak Pencarian & Filter Status Timesheet (Tanpa Card Wrapper, Format Persis HSE Employees) -->
|
||||
<form method="GET" action="{{ url()->current() }}" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-2.5 sm:gap-3">
|
||||
<!-- Pencarian Cepat di Kiri -->
|
||||
<div class="relative w-full sm:max-w-md">
|
||||
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400">
|
||||
<!-- Pencarian Cepat di Kiri dengan Tombol Cari -->
|
||||
<div class="relative w-full sm:max-w-md flex items-center">
|
||||
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400 z-10">
|
||||
<i class="fa-solid fa-magnifying-glass text-xs"></i>
|
||||
</span>
|
||||
<input type="text"
|
||||
@@ -112,7 +112,13 @@
|
||||
id="timesheetSearchInput"
|
||||
value="{{ request('search') }}"
|
||||
placeholder="Cari No. TS, nama/NIK operator, atau lokasi..."
|
||||
class="w-full text-xs pl-10 pr-4 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition">
|
||||
autocomplete="off"
|
||||
class="w-full text-xs pl-10 pr-20 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition">
|
||||
<button type="submit"
|
||||
id="timesheetSearchBtn"
|
||||
class="absolute right-1.5 inset-y-1.5 px-3 bg-[#1b5e20] hover:bg-[#144918] active:scale-95 text-white font-bold text-xs rounded-lg flex items-center gap-1.5 transition shadow-sm cursor-pointer z-10">
|
||||
<span>Cari</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Filter di Kanan (Pada Mobile: Sejajar Grid di Bawah Search Bar) -->
|
||||
@@ -1627,12 +1633,15 @@
|
||||
|
||||
timesheetSearchInput?.addEventListener('input', function(e) {
|
||||
const query = e.target.value.toLowerCase().trim();
|
||||
const cleanQuery = query.replace(/[\s\-_]/g, '');
|
||||
const rows = document.querySelectorAll('#timesheetTableBody tr.timesheet-row');
|
||||
let visibleCount = 0;
|
||||
|
||||
rows.forEach(row => {
|
||||
const text = row.innerText.toLowerCase();
|
||||
if (query === '' || text.includes(query)) {
|
||||
const cleanText = text.replace(/[\s\-_]/g, '');
|
||||
const match = query === '' || text.includes(query) || (cleanQuery.length > 0 && cleanText.includes(cleanQuery));
|
||||
if (match) {
|
||||
row.style.display = '';
|
||||
visibleCount++;
|
||||
} else {
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user