Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe2f4b2

Browse files
committed
minor #7589 Fix CrudTestSelectors::getActionSelector() not matching grouped actions (lacatoire)
This PR was submitted for the 5.x branch but it was merged into the 4.x branch instead. Discussion ---------- Fix CrudTestSelectors::getActionSelector() not matching grouped actions ``CrudTestSelectors::getActionSelector()`` looked for the ``.action-<name>`` CSS class. That class is set only on top-level actions by ``ActionFactory::transformActions()``; actions nested inside an ``ActionGroup`` go through ``processActionGroup()`` and never receive it, so test helpers like ``assertIndexEntityActionExists()`` silently failed on grouped actions. Switch the selector to ``[data-action-name="<name>"]``, which ``ActionFactory::processAction()`` sets unconditionally on every action (top-level or nested). A single attribute selector also avoids the comma-OR composition pitfall in ``getGlobalActionSelector()`` / ``getIndexEntityActionSelector()``, which otherwise let the right-hand branch escape the scope. Fixes #7518 Commits ------- 0977a23 Make getActionSelector() match grouped actions via data-action-name
2 parents b41a560 + 0977a23 commit fe2f4b2

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/Test/Trait/CrudTestSelectors.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ protected function getIndexEntityRowSelector(string|int $entityId): string
1616

1717
protected function getActionSelector(string $action): string
1818
{
19-
return sprintf('.action-%s', $action);
19+
// every action (top-level or nested in an ActionGroup) carries a
20+
// `data-action-name` attribute set by ActionFactory::processAction(),
21+
// so it's the only reliable selector for the test helpers. The legacy
22+
// `.action-<name>` CSS class is only set on top-level actions and is
23+
// therefore not usable when the action lives inside an ActionGroup.
24+
return sprintf('[data-action-name="%s"]', $action);
2025
}
2126

2227
protected function getGlobalActionSelector(string $action): string

0 commit comments

Comments
 (0)