diff --git a/resources/js/Pages/testing.jsx b/resources/js/Pages/testing.jsx index 328a0609..648a31cd 100644 --- a/resources/js/Pages/testing.jsx +++ b/resources/js/Pages/testing.jsx @@ -249,6 +249,58 @@ export default function () { `} />

Instead of passing a single prop as a string, you may also pass an array of props to reloadOnly or reloadExcept.

+

Testing Deferred Props

+

+ You may use the loadDeferredProps method to test how your application responds to{' '} + deferred props. This method performs a follow-up request to load the deferred + properties and allows you to make assertions against the response. +

+ assertInertia(fn (Assert $page) => $page + ->has('users') + ->has('roles') + ->missing('permissions') // Deferred prop not in initial response + ->loadDeferredProps(fn (Assert $reload) => $reload + ->has('permissions') + ->where('permissions.0.name', 'edit users') + ) + ); + `} + /> +

+ You may also load specific deferred prop groups by passing the group name as the first argument to the{' '} + loadDeferredProps method. +

+ assertInertia(fn (Assert $page) => $page + ->has('users') + ->missing('teams') + ->missing('projects') + ->loadDeferredProps('attributes', fn (Assert $reload) => $reload + ->has('teams', 5) + ->has('projects') + ->missing('permissions') // Different group + ) + ); + `} + /> +

Instead of passing a single group as a string, you may also pass an array of groups to loadDeferredProps.

+ assertInertia(fn (Assert $page) => $page + ->loadDeferredProps(['default', 'attributes'], fn (Assert $reload) => $reload + ->has('permissions') + ->has('teams') + ->has('projects') + ) + ); + `} + /> ) }