Files
ladill-events/tests/Feature/SearchTest.php
T
isaaccladandCursor 849617da85
Deploy Ladill Events / deploy (push) Successful in 29s
Add mobile and desktop search for Events.
Introduce a dedicated /search page, wire the bottom nav and topbar to it, and expose JSON results for live lookup of events and programmes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-07 15:37:44 +00:00

51 lines
1.3 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\QrCode;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Str;
use Tests\TestCase;
class SearchTest extends TestCase
{
use RefreshDatabase;
private function user(): User
{
return User::create(['public_id' => (string) Str::uuid(), 'name' => 'A', 'email' => 'a+'.uniqid().'@x.com']);
}
public function test_user_can_search_owned_event_by_label(): void
{
$user = $this->user();
QrCode::query()->create([
'user_id' => $user->id,
'short_code' => 'summit',
'type' => QrCode::TYPE_EVENT,
'label' => 'NextGen Summit',
'destination_url' => 'https://example.com',
'is_active' => true,
]);
$response = $this->actingAs($user)
->getJson(route('events.search', ['q' => 'NextGen']));
$response->assertOk();
$response->assertJsonPath('results.0.type', 'event');
$response->assertJsonPath('results.0.title', 'NextGen Summit');
}
public function test_search_page_renders_for_authenticated_user(): void
{
$user = $this->user();
$this->actingAs($user)
->get(route('events.search'))
->assertOk()
->assertSee('Find events and programmes', false);
}
}