From 8d0c5905f7280d3ee55fb84f5c6a111c13d36b84 Mon Sep 17 00:00:00 2001 From: Pascal Baljet Date: Tue, 23 Sep 2025 23:37:41 +0200 Subject: [PATCH] Update testing.jsx --- resources/js/Pages/testing.jsx | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) 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') + ) + ); + `} + /> ) }