inertia-laravel icon indicating copy to clipboard operation
inertia-laravel copied to clipboard

Testing lazy props

Open JeroenGovers opened this issue 1 year ago • 0 comments
trafficstars

I added the method requestProp (name open for discussion 😉) to the AssertableInertia class which let you easy test LazyProps.

/** @test */
public function test_props(): void
{
    $this
        ->get('/')
        ->assertInertia(function (AssertableInertia $page) {
            $page->has('normalPropKey');
            $page->missing('lazyPropKey');

            $page->requestProp('lazyPropKey', function (AssertableInertia $page) {
                $page->where('lazyPropKey', '1');
            });
        });
}

The method uses the previous request, applies the X-Inertia-Partial-Component and X-Inertia-Partial-Data headers, which are automatically seeded and resends it. A convenient way for the tester, and they do not need to know the internal mechanics of Intertia. Which I found in #604.

JeroenGovers avatar Mar 08 '24 19:03 JeroenGovers