Skip to content

Conversation

pascalbaljet
Copy link
Member

Inspired by #595.

Inertia::render('page', [
    'foo' => 'bar',
    'lazy' => Inertia::lazy(fn () => 'baz'),
])

//

$response->assertInertia(function ($inertia) {
    $inertia->where('foo', 'bar');
    $inertia->missing('lazy');

    $inertia->partial('lazy', function ($inertia) {
        $inertia->where('lazy', 'baz');
        $inertia->missing('foo');
    });
});

Maybe we can add options for only and except, and add a reload method as well.

@pascalbaljet pascalbaljet mentioned this pull request Jun 5, 2025
@pascalbaljet
Copy link
Member Author

Inertia::render('page', [
    'foo' => 'bar',
    'lazy1' => Inertia::lazy(fn () => 'baz'),
    'lazy2' => Inertia::lazy(fn () => 'qux'),
]);

//

$response->assertInertia(fn ($page) => $page
    ->where('foo', 'bar')
    ->missing('lazy1')
    ->missing('lazy2')
    ->reloadOnly('lazy1', fn ($reload) => $reload
        ->missing('foo')
        ->where('lazy1', 'baz')
        ->missing('lazy2')
    )
);

Renamed partial to reloadOnly and added reloadExcept and reload as well.

@pascalbaljet pascalbaljet marked this pull request as ready for review June 5, 2025 13:28
@pascalbaljet pascalbaljet changed the title Test helper for partial requests [2.x] Test helper for partial requests Jun 6, 2025
@pascalbaljet pascalbaljet merged commit 0b8c005 into 2.x Jun 17, 2025
37 checks passed
@pascalbaljet pascalbaljet deleted the test-helper-for-partial-requests branch June 17, 2025 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant