Skip to content

Commit 2ead7f1

Browse files
test: fix flaky breadcrumbs visual tests (#12088) (CP: 25.2) (#12089)
This PR cherry-picks changes from the original PR #12088 to branch 25.2. --- #### Original PR description > Breadcrumbs visual tests involving the overflow overlay have been flaky and sometimes needed a retry in CI. The issue seems to be that the asynchronous `sendKeys` can result in the overlay opening before the command resolves in the test, causing the tests to time out. Changed it so that the event listener is registered before running the async command. Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
1 parent f02e564 commit 2ead7f1

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

packages/breadcrumbs/test/visual/aura/breadcrumbs.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,19 @@ describe('breadcrumbs', () => {
7777
it('overflow-opened', async () => {
7878
div.style.height = '150px';
7979
breadcrumbs.$.overflow.focus();
80+
const opened = oneEvent(overlay, 'vaadin-overlay-open');
8081
await sendKeys({ press: 'Enter' });
81-
await oneEvent(overlay, 'vaadin-overlay-open');
82+
await opened;
8283
await visualDiff(div, 'overflow-opened');
8384
});
8485

8586
it('accent', async () => {
8687
div.style.height = '150px';
8788
breadcrumbs.setAttribute('theme', 'accent');
8889
breadcrumbs.$.overflow.focus();
90+
const opened = oneEvent(overlay, 'vaadin-overlay-open');
8991
await sendKeys({ press: 'Enter' });
90-
await oneEvent(overlay, 'vaadin-overlay-open');
92+
await opened;
9193
await visualDiff(div, 'theme-accent');
9294
});
9395
});

packages/breadcrumbs/test/visual/base/breadcrumbs.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ describe('breadcrumbs', () => {
114114
const overlay = breadcrumbs.shadowRoot.querySelector('vaadin-breadcrumbs-overlay');
115115
const button = breadcrumbs.shadowRoot.querySelector('[part="overflow-button"]');
116116
button.focus();
117+
const opened = oneEvent(overlay, 'vaadin-overlay-open');
117118
await sendKeys({ press: 'Enter' });
118-
await oneEvent(overlay, 'vaadin-overlay-open');
119+
await opened;
119120
await visualDiff(div, 'overflow-opened');
120121
});
121122
});

packages/breadcrumbs/test/visual/lumo/breadcrumbs.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,19 @@ describe('breadcrumbs', () => {
7777
it('overflow-opened', async () => {
7878
div.style.height = '150px';
7979
breadcrumbs.$.overflow.focus();
80+
const opened = oneEvent(overlay, 'vaadin-overlay-open');
8081
await sendKeys({ press: 'Enter' });
81-
await oneEvent(overlay, 'vaadin-overlay-open');
82+
await opened;
8283
await visualDiff(div, 'overflow-opened');
8384
});
8485

8586
it('primary', async () => {
8687
div.style.height = '150px';
8788
breadcrumbs.setAttribute('theme', 'primary');
8889
breadcrumbs.$.overflow.focus();
90+
const opened = oneEvent(overlay, 'vaadin-overlay-open');
8991
await sendKeys({ press: 'Enter' });
90-
await oneEvent(overlay, 'vaadin-overlay-open');
92+
await opened;
9193
await visualDiff(div, 'theme-primary');
9294
});
9395
});

0 commit comments

Comments
 (0)