Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ public function events(Request $request): Response

return Inertia::render('Events/Index', [
'events' => $events,
'endpoints' => $request->user()->endpoints()->get(['id', 'name', 'url', 'description', 'is_active']),
'endpoints' => $request->user()->endpoints()
->select(['id', 'name', 'url', 'description', 'is_active'])
->orderBy('name')
->limit(500)
->get(),
'eventTypes' => $eventTypes,
'filters' => $request->only(['search', 'type']),
]);
Expand All @@ -99,7 +103,11 @@ public function editEvent(Request $request, Event $event): Response
abort_if($event->user_id !== $request->user()->id, 404);

$event->load('endpoints');
$endpoints = $request->user()->endpoints()->get();
$endpoints = $request->user()->endpoints()
->select(['id', 'name', 'url', 'description', 'is_active'])
->orderBy('name')
->limit(500)
->get();

return Inertia::render('Events/Edit', [
'event' => $event,
Expand Down
47 changes: 47 additions & 0 deletions tests/Feature/DashboardEventsEndpointsPickerLimitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Tests\Feature;

use App\Models\Endpoint;
use App\Models\Event;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class DashboardEventsEndpointsPickerLimitTest extends TestCase
{
use RefreshDatabase;

public function test_events_index_caps_the_endpoint_picker_list(): void
{
$user = User::factory()->withPersonalTeam()->create();

Endpoint::factory()->for($user)->count(501)->create();

$response = $this->actingAs($user)->get(route('events'));

$response->assertOk();
$response->assertInertia(
fn ($page) => $page
->component('Events/Index')
->has('endpoints', 500)
);
}

public function test_edit_event_caps_the_endpoint_picker_list(): void
{
$user = User::factory()->withPersonalTeam()->create();
$event = Event::factory()->for($user)->create();

Endpoint::factory()->for($user)->count(501)->create();

$response = $this->actingAs($user)->get(route('events.edit', $event));

$response->assertOk();
$response->assertInertia(
fn ($page) => $page
->component('Events/Edit')
->has('endpoints', 500)
);
}
}
Loading