Skip to content

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented Oct 3, 2025

Previously, the test checked for a style attribute to determine if the BPMN container was initialized.
This approach was unreliable, especially on macOS with Firefox in CI environments, because the attribute could exist before its value was updated by the library, causing the test to miss the actual initialization and fail intermittently.

This change replaces the attribute check with a more robust method: it now waits for the presence of SVG elements (specifically, the expected group nodes) in the DOM, which reliably indicates that the library has completed initialization and rendering.

This change improves test stability and reduces flakiness in CI environments.

Notes

The e2e tests with firefox on macos seem stabilized. I ran them 8 times in a row and they all succeeded. See https://github.com/process-analytics/bpmn-visualization-js/actions/runs/18231009284/job/51948148044?pr=3388

Here are the top five longest lib initialization that occured during the 7th run of the e2e tests. We see that some are quite long, which can explain why the tests previously failed. The lib initialization is sometime slow, so the style attribute of the bpmn container is not updated right away. This confirms that the former check failed in that case.

#1: 256 ms
Start: 2025-10-04T09:27:12.8915970Z 2025-10-04T09:27:12.849Z bv:test:page-check Waiting for the BPMN container to be initialized (verifying bpmn-visualization setup)
End  : 2025-10-04T09:27:13.1768060Z 2025-10-04T09:27:13.105Z bv:test:page-check BPMN container initialized - 256 ms

#2: 254 ms
Start: 2025-10-04T09:24:48.2335600Z 2025-10-04T09:24:48.232Z bv:test:page-check Waiting for the BPMN container to be initialized (verifying bpmn-visualization setup)
End  : 2025-10-04T09:24:48.4868010Z 2025-10-04T09:24:48.486Z bv:test:page-check BPMN container initialized - 254 ms

#3: 254 ms
Start: 2025-10-04T09:25:50.7292760Z 2025-10-04T09:25:50.678Z bv:test:page-check Waiting for the BPMN container to be initialized (verifying bpmn-visualization setup)
End  : 2025-10-04T09:25:50.9460230Z 2025-10-04T09:25:50.932Z bv:test:page-check BPMN container initialized - 254 ms

#4: 252 ms
Start: 2025-10-04T09:26:34.6757160Z 2025-10-04T09:26:34.624Z bv:test:page-check Waiting for the BPMN container to be initialized (verifying bpmn-visualization setup)
End  : 2025-10-04T09:26:34.8777770Z 2025-10-04T09:26:34.876Z bv:test:page-check BPMN container initialized - 252 ms

#5: 241 ms
Start: 2025-10-04T09:24:35.9892840Z 2025-10-04T09:24:35.965Z bv:test:page-check Waiting for the BPMN container to be initialized (verifying bpmn-visualization setup)
End  : 2025-10-04T09:24:36.2066840Z 2025-10-04T09:24:36.206Z bv:test:page-check BPMN container initialized - 241 ms

01_initialization.txt
02_initialization_with_duration.txt

Previously, the test checked for a style attribute to determine if the BPMN container was initialized.
This approach was unreliable, especially on macOS with Firefox in CI environments, because the attribute could exist before its value was updated by the library, causing the test to miss the actual initialization and fail intermittently.

This commit replaces the attribute check with a more robust method: it now waits for the presence of SVG elements (specifically, the expected group nodes) in the DOM, which reliably indicates that the library has completed initialization and rendering.

This change improves test stability and reduces flakiness in CI environments.
@tbouffard tbouffard added the chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...) label Oct 3, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 3, 2025

@tbouffard tbouffard changed the title fix(e2e): stabilize flaky BPMN container initialization check fix(e2e): stabilize flaky lib initialization check Oct 3, 2025
@tbouffard tbouffard requested a review from Copilot October 3, 2025 19:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This change improves the reliability of BPMN library initialization detection in end-to-end tests by replacing an unreliable style attribute check with a more robust DOM structure verification.

  • Replaces checking for a style attribute with waiting for specific SVG group elements
  • Updates log messages to better reflect the initialization verification process
  • Adds explanatory comments about the SVG DOM structure being checked

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

async expectAvailableBpmnContainer(options?: PageWaitForSelectorOptions): Promise<void> {
pageCheckLog('Expecting the BPMN container available (confirm bpmn-visualization initialization)');
pageCheckLog('Waiting for the BPMN container to be initialized (verifying bpmn-visualization setup)');
// Check that mxGraph updated the DOM with the SVG element. This is done during the bpmn-visualization initialization.
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentions 'mxGraph' but this may be outdated or incorrect. Consider verifying if this is the correct library name or updating the comment to reflect the actual library being used for BPMN visualization.

Suggested change
// Check that mxGraph updated the DOM with the SVG element. This is done during the bpmn-visualization initialization.
// Check that bpmn-visualization updated the DOM with the SVG element. This is done during the bpmn-visualization initialization.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mxGraph is correct. It is in charge of generating the SVG nodes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tbouffard tbouffard marked this pull request as ready for review October 6, 2025 07:57
@tbouffard tbouffard merged commit f3be490 into master Oct 6, 2025
103 checks passed
@tbouffard tbouffard deleted the fix/flaky_e2e_tests branch October 6, 2025 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants