Laravel Jetstream Route Test With Inertia Returns Error Code 500

1.3k views Asked by At

Out the test it works, I can visit the page and the controller wroks fine. I wrote the following test:

public function test_logged_user_is_not_redirected()
{
    PartnerFactory::new()->create();

    $request = $this->actingAs(UserFactory::new()->create())
        ->get('partners')
        ->assertRedirect('partners');

    dd($request->inertiaProps());
}

I get error code 500. This is the controller:

public function index()
{
    return Inertia::render('Partners/Index', [
        'filters' => \Illuminate\Support\Facades\Request::all($this->getFilters()),
        'contacts' => function() {
            return $this->getAllContacts();
        }
    ]);
}

This is the route in web.php

Route::get('partners', [PartnersController::class, 'index'])
->name('partners')
->middleware('auth');

Using refresh database, tried url with a '/' before, I still get 500.

edit: without exception handling i get: Trying to get property 'id' of non-object

1

There are 1 answers

0
alteration On

Found the solution: The user in jetstream MUST have the personal team!