Skip to content

Commit

Permalink
fix dashboard, radio-group and checkbox tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Jan 8, 2025
1 parent 185c1af commit 7c8973d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
9 changes: 6 additions & 3 deletions packages/checkbox/test/validation.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ describe('validation', () => {

describe('basic', () => {
beforeEach(async () => {
checkbox = fixtureSync('<vaadin-checkbox label="Checkbox"></vaadin-checkbox>');
checkbox = fixtureSync(
`<div>
<vaadin-checkbox label="Checkbox"></vaadin-checkbox>
<button>Last global focusable</button>
</div>`,
).firstElementChild;
await nextRender();
validateSpy = sinon.spy(checkbox, 'validate');
});
Expand All @@ -63,9 +68,7 @@ describe('validation', () => {
expect(validateSpy.called).to.be.false;

// Blur the checkbox.
await sendKeys({ down: 'Shift' });
await sendKeys({ press: 'Tab' });
await sendKeys({ up: 'Shift' });

expect(validateSpy.calledOnce).to.be.true;
});
Expand Down
23 changes: 15 additions & 8 deletions packages/dashboard/test/dashboard-keyboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@ type TestDashboardItem = DashboardItem & { id: number };
describe('dashboard - keyboard interaction', () => {
let dashboard: Dashboard<TestDashboardItem>;
let keydownSpy;
let firstGlobalFocusable: HTMLElement;
const columnWidth = 200;

beforeEach(async () => {
dashboard = fixtureSync('<vaadin-dashboard></vaadin-dashboard>');
[firstGlobalFocusable, dashboard] = fixtureSync(
`<div>
<button>First global focusable</button>
<vaadin-dashboard></vaadin-dashboard>
</div>`,
).children as unknown as [HTMLElement, Dashboard<TestDashboardItem>];
firstGlobalFocusable.focus();
await nextFrame();
dashboard.editable = true;
keydownSpy = sinon.spy();
Expand All @@ -58,13 +65,13 @@ describe('dashboard - keyboard interaction', () => {
await nextResize(dashboard);

// Make sure the following tab goes back to the first widget (needed for Firefox)
const widget = getElementFromCell(dashboard, 0, 0)!;
widget.focus();
await nextFrame();
await sendKeys({ down: 'Shift' });
await sendKeys({ press: 'Tab' });
await sendKeys({ up: 'Shift' });
await nextFrame();
// const widget = getElementFromCell(dashboard, 0, 0)!;
// widget.focus();
// await nextFrame();
// await sendKeys({ down: 'Shift' });
// await sendKeys({ press: 'Tab' });
// await sendKeys({ up: 'Shift' });
// await nextFrame();
});

it('should focus the widget', async () => {
Expand Down
7 changes: 5 additions & 2 deletions packages/radio-group/test/radio-group.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,19 @@ describe('radio-group', () => {
});

describe('focused state', () => {
let firstGlobalFocusable;

beforeEach(async () => {
group = fixtureSync(
[firstGlobalFocusable, group] = fixtureSync(
`<div>
<button>First global focusable</button>
<vaadin-radio-group>
<vaadin-radio-button label="Button 1"></vaadin-radio-button>
<vaadin-radio-button label="Button 2"></vaadin-radio-button>
</vaadin-radio-group>
</div>`,
).lastElementChild;
).children;
firstGlobalFocusable.focus();
await nextFrame();
buttons = [...group.querySelectorAll('vaadin-radio-button')];
});
Expand Down

0 comments on commit 7c8973d

Please sign in to comment.