-
- Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Describe the bug
Test helper method getActionSelector of EasyCorp\Bundle\EasyAdminBundle\Test\Trait\CrudTestSelectors did not get updated to work with new grouped actions from latest updates : https://symfony.com/bundles/EasyAdminBundle/current/actions.html#grouping-actions
In my application tests, I test which action was visible in my index page like this.
$this->assertIndexEntityActionExists('createPlan', $entityId);Before switching to grouped actions, it worked, and after, it broke.
- method
assertIndexEntityActionExistsin EasyCorp\Bundle\EasyAdminBundle\Test\Trait\CrudTestIndexAsserts - method
getActionSelectorin EasyCorp\Bundle\EasyAdminBundle\Test\Trait\CrudTestSelectors
To Reproduce
Easy admin version : v5.0.2
Adding an action group with actions in my crud controller :
#[\Override] public function configureActions(Actions $actions): Actions { $integrationActions = ActionGroup::new('integrations', 'Integrations') ->setIcon('fa-solid fa-plug') // [...] ->addAction($this->getCreatePlan()) ; return parent::configureActions($actions) ->add(Crud::PAGE_INDEX, $integrationActions) ->add(Crud::PAGE_DETAIL, $integrationActions) ; }Additional context
Root cause : Grouped actions do not have the css class action-ACTION_NAME (ex: action-createPlan in my case).
They however do have a data-action-name=ACTION_NAME attribute.
I fixed the bug easily for my tests, by overriding the getActionSelector method like this :
namespace App\Tests\Application\Admin\TestHelpers; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\CrudControllerInterface; use EasyCorp\Bundle\EasyAdminBundle\Test\AbstractCrudTestCase; /** * @template Crud of CrudControllerInterface<object> * * @extends AbstractCrudTestCase<Crud> */ abstract class MyCustomAbstractCrudTestCase extends AbstractCrudTestCase { #[\Override] protected function getActionSelector(string $action): string { return sprintf('[data-action-name="%1$s"], .action-%1$s', $action); } }Please contact me if you need more details ! I would glady see the PR to correct this issue, and next time, i can contribute directly by submitting mine. Here, i feel like my solution might be too hacky.
Thanks a lot,