vaadin / testbench

Vaadin TestBench is a tool for automated user interface testing of Vaadin applications.
https://vaadin.com/testbench
Other
20 stars 22 forks source link

Composite causes virtual children components to be fetched twice #1738

Closed mcollovati closed 7 months ago

mcollovati commented 8 months ago

Composite overrides getChildren() to return a stream containing the encapsulated component, but it also overrides getElement() returning the Element of the encapsulated component. This causes the wrapped component virtual children to be fetched twice: first as children of the wrapped component, then as direct children of the Composite.

Below, an example tree printed for a Composite<Dialog> component, where the HorizontalLayout subtree is visible two times.

CompositeDialog[opened='true', virtualChildNodeIds='[256]', headerTitle='Reject Contract C0000013'] matching Button and caption='No': [Button[caption='No', @theme='tertiary'], Button[caption='No', @theme='tertiary']]. Component tree:
└── CompositeDialog[opened='true', virtualChildNodeIds='[256]', headerTitle='Reject Contract C0000013']
    ├── Dialog[opened='true', virtualChildNodeIds='[256]', headerTitle='Reject Contract C0000013']
    │   ├── VerticalLayout[@style='width:100%', @theme='spacing']
    │   │   ├── Span[text='Are you sure you want to reject this contract?']
    │   │   └── TextField[value='', placeholder='reject reason', autofocus='true', @style='width:100%']
    │   └── HorizontalLayout[@style='width:100%;justify-content:space-between', @theme='spacing']
    │       ├── Button[caption='No', @theme='tertiary']
    │       └── Button[DISABLED, caption='Yes', @theme='error primary']
    └── HorizontalLayout[@style='width:100%;justify-content:space-between', @theme='spacing']
        ├── Button[caption='No', @theme='tertiary']
        └── Button[DISABLED, caption='Yes', @theme='error primary']

See also https://github.com/mvysny/karibu-testing/issues/162, and https://github.com/mvysny/karibu-testing/commit/a1661d3088b30a54973d51835d1191583e755a9e for the fix provided by @mvysny