@@ -455,6 +455,72 @@ public function buildListConfig(): void
455455 ->where ('key ' , 'nope ' )
456456 ->where ('entityKey ' , 'person:nope ' )
457457 ->where ('label ' , 'No Nobel prize ' )
458+
459+ ->etc ()
460+ )
461+ ->has ('entityList.data.0 ' , fn (Assert $ json ) => $ json
462+ ->where ('_meta.url ' , route ('code16.sharp.show.show ' , ['parentUri ' => 's-list/person ' , 'entityKey ' => 'person:yes ' , 'instanceId ' => 1 ]))
463+ ->etc ()
464+ )
465+ ->has ('entityList.data.1 ' , fn (Assert $ json ) => $ json
466+ ->where ('_meta.url ' , route ('code16.sharp.show.show ' , ['parentUri ' => 's-list/person ' , 'entityKey ' => 'person:nope ' , 'instanceId ' => 2 ]))
467+ ->etc ()
468+ )
469+ );
470+ });
471+
472+ it ('gets multiform form url if configured ' , function () {
473+ $ this ->withoutExceptionHandling ();
474+ fakeListFor ('person ' , new class () extends PersonList
475+ {
476+ public function getListData (): array |Arrayable
477+ {
478+ return [
479+ ['id ' => 1 , 'name ' => 'Marie Curie ' , 'nobel ' => 'yes ' ],
480+ ['id ' => 2 , 'name ' => 'Rosalind Franklin ' , 'nobel ' => 'nope ' ],
481+ ];
482+ }
483+
484+ public function buildListConfig (): void
485+ {
486+ $ this ->configureMultiformAttribute ('nobel ' );
487+ }
488+ });
489+
490+ app (SharpEntityManager::class)
491+ ->entityFor ('person ' )
492+ ->setShow (null )
493+ ->setMultiforms ([
494+ 'yes ' => [PersonForm::class, 'With Nobel prize ' ],
495+ 'nope ' => [PersonForm::class, 'No Nobel prize ' ],
496+ ]);
497+
498+ $ this ->get ('/sharp/s-list/person ' )
499+ ->assertOk ()
500+ ->assertInertia (fn (Assert $ page ) => $ page
501+ ->has ('entityList.data.0 ' , fn (Assert $ json ) => $ json
502+ ->where ('_meta.url ' , route ('code16.sharp.form.edit ' , ['parentUri ' => 's-list/person ' , 'entityKey ' => 'person:yes ' , 'instanceId ' => 1 ]))
503+ ->etc ()
504+ )
505+ ->has ('entityList.data.1 ' , fn (Assert $ json ) => $ json
506+ ->where ('_meta.url ' , route ('code16.sharp.form.edit ' , ['parentUri ' => 's-list/person ' , 'entityKey ' => 'person:nope ' , 'instanceId ' => 2 ]))
507+ ->etc ()
508+ )
509+ );
510+
511+ app (SharpEntityManager::class)
512+ ->entityFor ('person ' )
513+ ->setForm (null );
514+
515+ $ this ->get ('/sharp/s-list/person ' )
516+ ->assertOk ()
517+ ->assertInertia (fn (Assert $ page ) => $ page
518+ ->has ('entityList.data.0 ' , fn (Assert $ json ) => $ json
519+ ->where ('_meta.url ' , route ('code16.sharp.form.edit ' , ['parentUri ' => 's-list/person ' , 'entityKey ' => 'person:yes ' , 'instanceId ' => 1 ]))
520+ ->etc ()
521+ )
522+ ->has ('entityList.data.1 ' , fn (Assert $ json ) => $ json
523+ ->where ('_meta.url ' , route ('code16.sharp.form.edit ' , ['parentUri ' => 's-list/person ' , 'entityKey ' => 'person:nope ' , 'instanceId ' => 2 ]))
458524 ->etc ()
459525 )
460526 );
0 commit comments