Skip to content

Commit

Permalink
test: reset keyboardActive between tests (#8504)
Browse files Browse the repository at this point in the history
* test: reset keyboardActive between tests

* reset state in date and time picker tests
  • Loading branch information
sissbruecker authored Jan 14, 2025
1 parent 09164e2 commit 0649d20
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 7 deletions.
9 changes: 8 additions & 1 deletion packages/combo-box/test/visual/lumo/combo-box.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fixtureSync, nextFrame } from '@vaadin/testing-helpers';
import { fixtureSync, mousedown, nextFrame } from '@vaadin/testing-helpers';
import { sendKeys } from '@web/test-runner-commands';
import { visualDiff } from '@web/test-runner-visual-regression';
import '../common.js';
Expand All @@ -15,6 +15,13 @@ describe('combo-box', () => {
element = fixtureSync('<vaadin-combo-box></vaadin-combo-box>', div);
});

afterEach(() => {
// After tests which use sendKeys() the focus-utils.js -> isKeyboardActive is set to true.
// Click once here on body to reset it so other tests are not affected by it.
// An unwanted focus-ring would be shown in other tests otherwise.
mousedown(document.body);
});

it('basic', async () => {
await visualDiff(div, 'basic');
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion packages/date-picker/test/visual/lumo/date-picker.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fixtureSync } from '@vaadin/testing-helpers/dist/fixture.js';
import { fixtureSync, mousedown } from '@vaadin/testing-helpers';
import { sendKeys } from '@web/test-runner-commands';
import { visualDiff } from '@web/test-runner-visual-regression';
import '../../../theme/lumo/vaadin-date-picker.js';
Expand All @@ -15,6 +15,13 @@ describe('date-picker', () => {
element = fixtureSync('<vaadin-date-picker></vaadin-date-picker>', div);
});

afterEach(() => {
// After tests which use sendKeys() the focus-utils.js -> isKeyboardActive is set to true.
// Click once here on body to reset it so other tests are not affected by it.
// An unwanted focus-ring would be shown in other tests otherwise.
mousedown(document.body);
});

it('basic', async () => {
await visualDiff(div, 'basic');
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions packages/time-picker/test/visual/lumo/time-picker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ describe('time-picker', () => {
element.style.setProperty('--vaadin-time-picker-overlay-max-height', '300px');
});

afterEach(() => {
// After tests which use sendKeys() the focus-utils.js -> isKeyboardActive is set to true.
// Click once here on body to reset it so other tests are not affected by it.
// An unwanted focus-ring would be shown in other tests otherwise.
mousedown(document.body);
});

it('basic', async () => {
await visualDiff(div, 'basic');
});
Expand All @@ -23,11 +30,6 @@ describe('time-picker', () => {
await sendKeys({ press: 'Tab' });

await visualDiff(div, 'focus-ring');

// at this moment focus-utils.js -> isKeyboardActive is true.
// Click once here to reset it so other tests are not affected by it.
// A focus-ring would be shown in other tests otherwise.
mousedown(document.body);
});

it('disabled', async () => {
Expand Down

0 comments on commit 0649d20

Please sign in to comment.