[ml] synchronously register embeddables and actions to fix flaky add panel test#267325
Merged
Conversation
Contributor
Author
|
/ci |
Contributor
Author
|
/ci |
Contributor
Author
|
/ci |
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Module Count
Async chunks
Page load bundle
History
|
|
Pinging @elastic/kibana-presentation (Team:Presentation) |
jgowdyelastic
approved these changes
May 5, 2026
Member
jgowdyelastic
left a comment
There was a problem hiding this comment.
LGTM
Thanks for making these changes
nreese
added a commit
that referenced
this pull request
May 6, 2026
Closes #259443 and #259576 ### Problem #267325 broke tests `dashboard_panel_listing.spec.ts` and `dashboard_panel_listing_obs_group.spec.ts`. At the time #267325 merged, there was a bug in CI where CI did not run dashboard tests when code changes were not in dependency chain yet code changes affected registries and had a direct impact on dashboard runtime behavior. The reason the tests broke is that #267325 changed the order in which "Add panel" actions are registered. Before #267325, ml actions where registered async - so they got registered last. After #267325, ml actions where registered sync, so they go registered before some other actions. Registration order mattered because there was a bug in `dashboard_panel_listing.spec.ts` and `dashboard_panel_listing_obs_group.spec.ts` tests. The logic to extract `groups` used a map with `order` as the key. When there was a collision on `order`, only the last value would be preserved. Changing the registration order changed which value survived the order collision. Code snippet showing how values where put into a map and a collision on `order` would lose values. ``` const panelGroupByOrder = new Map<string, string>(); panelGroupData .filter((item): item is { order: string; groupTitle: string } => Boolean(item.order && item.groupTitle) ) .forEach((item) => panelGroupByOrder.set(item.order, item.groupTitle)); return [...panelGroupByOrder.values()]; ``` Image showing how 2 groups have the same order, thus altering test results after action registration race condition resolved. Notice values for `data-group-sort-order`. <img height="400" alt="Screenshot 2026-05-05 at 2 09 51 PM" src="https://github.com/user-attachments/assets/da8299c2-a080-4750-849b-f20235c1e4b5" /> ### Solution PR resolves tests by replacing `getPanelGroupOrder` with `getAddPanelFlyoutGroups` and fixing `order` collision bug. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #259576 and #259443
Image below shows failure case where Dashboard's "add panel" menu only contains
18items instead of the expected21. The reason for this failure is that the ml plugin registers actions asynchronously. This introduces a race condition where mlADD_PANEL_TRIGGERactions are not registered before Dashboard's "add panel" menu is rendered.PR resolves the race condition by registering embeddables and actions synchronously. The license check is moved from registration time to the action's
isCompatiblemethod and embeddable'sbuildEmbeddablemethod.