Skip to content

Commit

Permalink
test: reduce flakiness in grid element tabbing tests (#7348)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki authored Apr 19, 2024
1 parent f501817 commit 1191e0f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/grid/test/keyboard-navigation.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
keyUpOn,
listenOnce,
nextFrame,
nextRender,
oneEvent,
up as mouseUp,
} from '@vaadin/testing-helpers';
Expand Down Expand Up @@ -2000,26 +2001,33 @@ describe('keyboard navigation', () => {

const tabToIndex = 20;

async function rendered() {
await nextFrame();
await nextRender(grid);
await nextFrame();
}

// Tab downwards
for (let i = 1; i <= tabToIndex; i++) {
await nextFrame();
await rendered();
queueMicrotask(async () => await sendKeys({ press: 'Tab' }));
await oneEvent(grid, 'focusin');
await nextFrame();
await rendered();

const focusedRow = document.activeElement.parentElement.assignedSlot.parentElement.parentElement;
expect(focusedRow.index).to.equal(i);
}

// Tab upwards
for (let i = tabToIndex - 1; i >= 0; i--) {
await nextFrame();
await rendered();
queueMicrotask(async () => {
await sendKeys({ down: 'Shift' });
await sendKeys({ press: 'Tab' });
await sendKeys({ up: 'Shift' });
});
await oneEvent(grid, 'focusin');
await nextFrame();
await rendered();
const focusedRow = document.activeElement.parentElement.assignedSlot.parentElement.parentElement;
expect(focusedRow.index).to.equal(i);
}
Expand Down

0 comments on commit 1191e0f

Please sign in to comment.