Skip to content

Commit 20ec46b

Browse files
vursentomivirkki
andauthored
chore: upgrade playwright to 1.48.2 (#8355)
Co-authored-by: Tomi Virkki <virkki@vaadin.com>
1 parent 0292676 commit 20ec46b

29 files changed

Lines changed: 194 additions & 142 deletions

‎.github/workflows/unit-tests.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
run: yarn --frozen-lockfile --no-progress --non-interactive
4444

4545
- name: Install Playwright
46-
run: npx playwright install-deps firefox
46+
run: npx playwright install firefox --with-deps
4747

4848
- name: Test
4949
run: yarn test:firefox
@@ -65,7 +65,7 @@ jobs:
6565
run: yarn --frozen-lockfile --no-progress --non-interactive
6666

6767
- name: Install Playwright
68-
run: npx playwright install-deps webkit
68+
run: npx playwright install webkit --with-deps
6969

7070
- name: Test
7171
run: yarn test:webkit

‎package.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
"stylelint-config-vaadin": "^1.0.0-alpha.2",
7070
"typescript": "^5.5.2"
7171
},
72+
"resolutions": {
73+
"playwright": "^1.48.2"
74+
},
7275
"lint-staged": {
7376
"*.{js,ts}": [
7477
"eslint --fix",

‎packages/checkbox-group/test/checkbox-group.common.js‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,18 @@ describe('vaadin-checkbox-group', () => {
258258
});
259259

260260
describe('focused attribute', () => {
261+
let firstGlobalFocusable;
262+
261263
beforeEach(async () => {
262-
group = fixtureSync(`
263-
<vaadin-checkbox-group>
264-
<vaadin-checkbox value="1" label="Checkbox 1"></vaadin-checkbox>
265-
</vaadin-checkbox-group>
266-
`);
264+
[firstGlobalFocusable, group] = fixtureSync(
265+
`<div>
266+
<input id="first-global-focusable" />
267+
<vaadin-checkbox-group>
268+
<vaadin-checkbox value="1" label="Checkbox 1"></vaadin-checkbox>
269+
</vaadin-checkbox-group>
270+
</div>`,
271+
).children;
272+
firstGlobalFocusable.focus();
267273
await nextFrame();
268274
checkboxes = [...group.querySelectorAll('vaadin-checkbox')];
269275
});

‎packages/checkbox-group/test/validation.common.js‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,20 @@ describe('validation', () => {
3939
});
4040

4141
describe('basic', () => {
42+
let firstGlobalFocusable;
43+
4244
beforeEach(async () => {
43-
group = fixtureSync(`
44-
<vaadin-checkbox-group>
45-
<vaadin-checkbox name="language" value="en" label="English"></vaadin-checkbox>
46-
<vaadin-checkbox name="language" value="fr" label="Français"></vaadin-checkbox>
47-
<vaadin-checkbox name="language" value="de" label="Deutsch"></vaadin-checkbox>
48-
</vaadin-checkbox-group>
49-
`);
45+
[firstGlobalFocusable, group] = fixtureSync(
46+
`<div>
47+
<input id="first-global-focusable" />
48+
<vaadin-checkbox-group>
49+
<vaadin-checkbox name="language" value="en" label="English"></vaadin-checkbox>
50+
<vaadin-checkbox name="language" value="fr" label="Français"></vaadin-checkbox>
51+
<vaadin-checkbox name="language" value="de" label="Deutsch"></vaadin-checkbox>
52+
</vaadin-checkbox-group>
53+
</div>`,
54+
).children;
55+
firstGlobalFocusable.focus();
5056
await nextRender();
5157
validateSpy = sinon.spy(group, 'validate');
5258
});

‎packages/checkbox/test/validation.common.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ describe('validation', () => {
4040

4141
describe('basic', () => {
4242
beforeEach(async () => {
43-
checkbox = fixtureSync('<vaadin-checkbox label="Checkbox"></vaadin-checkbox>');
43+
checkbox = fixtureSync(
44+
`<div>
45+
<vaadin-checkbox label="Checkbox"></vaadin-checkbox>
46+
<input id="last-global-focusable" />
47+
</div>`,
48+
).firstElementChild;
4449
await nextRender();
4550
validateSpy = sinon.spy(checkbox, 'validate');
4651
});
@@ -63,9 +68,7 @@ describe('validation', () => {
6368
expect(validateSpy.called).to.be.false;
6469

6570
// Blur the checkbox.
66-
await sendKeys({ down: 'Shift' });
6771
await sendKeys({ press: 'Tab' });
68-
await sendKeys({ up: 'Shift' });
6972

7073
expect(validateSpy.calledOnce).to.be.true;
7174
});

‎packages/combo-box/test/interactions.common.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ describe('interactions', () => {
2222
let comboBox, overlay, input;
2323

2424
beforeEach(async () => {
25-
comboBox = fixtureSync('<vaadin-combo-box label="Label"></vaadin-combo-box>');
25+
comboBox = fixtureSync(
26+
`<div>
27+
<vaadin-combo-box label="Label"></vaadin-combo-box>
28+
<input id="last-global-focusable" />
29+
</div>`,
30+
).firstElementChild;
31+
2632
await nextRender();
2733
comboBox.items = ['foo', 'bar', 'baz'];
2834
input = comboBox.inputElement;

‎packages/combo-box/test/keyboard.common.js‎

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,20 @@ import sinon from 'sinon';
1515
import { getViewportItems, getVisibleItemsCount, scrollToIndex, setInputValue } from './helpers.js';
1616

1717
describe('keyboard', () => {
18-
let comboBox, input;
18+
let comboBox, input, lastGlobalFocusable;
1919

2020
function getFocusedIndex() {
2121
return comboBox._focusedIndex;
2222
}
2323

2424
beforeEach(async () => {
25-
comboBox = fixtureSync('<vaadin-combo-box></vaadin-combo-box>');
25+
[comboBox, lastGlobalFocusable] = fixtureSync(
26+
`<div>
27+
<vaadin-combo-box></vaadin-combo-box>
28+
<input id="last-global-focusable" />
29+
</div>`,
30+
).children;
31+
2632
await nextRender();
2733
comboBox.items = ['foo', 'bar', 'baz'];
2834
input = comboBox.inputElement;
@@ -128,36 +134,22 @@ describe('keyboard', () => {
128134

129135
it('should tab to the next focusable', async () => {
130136
await sendKeys({ press: 'Tab' });
131-
132-
expect(document.activeElement).to.equal(document.body);
137+
expect(document.activeElement).to.equal(lastGlobalFocusable);
133138
});
134139

135140
describe('focusable items content', () => {
136-
let focusable;
137-
138-
beforeEach(() => {
139-
focusable = document.createElement('input');
140-
});
141-
142-
afterEach(() => {
143-
focusable.remove();
144-
});
145-
146141
it('should tab to the next focusable when items have focusable content', async () => {
147142
comboBox.renderer = (root) => {
148143
root.innerHTML = '<input>';
149144
};
150-
document.body.appendChild(focusable);
151145

152-
// Workaround Playwright sendKeys bug
153-
focusable.focus();
154146
input.focus();
155147
arrowDownKeyDown(input);
156148

157149
await aTimeout(0);
158150

159151
await sendKeys({ press: 'Tab' });
160-
expect(document.activeElement).to.equal(focusable);
152+
expect(document.activeElement).to.equal(lastGlobalFocusable);
161153
});
162154
});
163155
});

‎packages/component-base/test/virtualizer-reorder-elements.test.js‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@vaadin/chai-plugins';
2-
import { fixtureSync, mousedown, mouseup, nextFrame, oneEvent } from '@vaadin/testing-helpers';
2+
import { fixtureSync, mousedown, mouseup, nextFrame } from '@vaadin/testing-helpers';
33
import { sendKeys } from '@web/test-runner-commands';
44
import sinon from 'sinon';
55
import { Virtualizer } from '../src/virtualizer.js';
@@ -144,21 +144,17 @@ describe('reorder elements', () => {
144144
// Tab downwards
145145
for (let i = 1; i <= tabToIndex; i++) {
146146
await nextFrame();
147-
queueMicrotask(async () => await sendKeys({ press: 'Tab' }));
148-
await oneEvent(elementsContainer, 'focusin');
147+
await sendKeys({ press: 'Tab' });
149148
await nextFrame();
150149
expect(document.activeElement.id).to.equal(`item-${i}`);
151150
}
152151

153152
// Tab upwards
154153
for (let i = tabToIndex - 1; i >= 0; i--) {
155154
await nextFrame();
156-
queueMicrotask(async () => {
157-
await sendKeys({ down: 'Shift' });
158-
await sendKeys({ press: 'Tab' });
159-
await sendKeys({ up: 'Shift' });
160-
});
161-
await oneEvent(elementsContainer, 'focusin');
155+
await sendKeys({ down: 'Shift' });
156+
await sendKeys({ press: 'Tab' });
157+
await sendKeys({ up: 'Shift' });
162158
await nextFrame();
163159
expect(document.activeElement.id).to.equal(`item-${i}`);
164160
}

‎packages/context-menu/test/a11y.common.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ import { getMenuItems } from './helpers.js';
66

77
describe('a11y', () => {
88
describe('focus restoration', () => {
9-
let contextMenu, contextMenuButton, beforeButton, afterButton;
9+
let contextMenu, contextMenuButton, firstGlobalFocusable, lastGlobalFocusable;
1010

1111
beforeEach(async () => {
1212
const wrapper = fixtureSync(`
1313
<div>
14-
<button>Before</button>
14+
<input id="first-global-focusable" />
1515
<vaadin-context-menu open-on="click">
1616
<button>Open context menu</button>
1717
</vaadin-context-menu>
18-
<button>After</button>
18+
<input id="last-global-focusable" />
1919
</div>
2020
`);
21-
[beforeButton, contextMenu, afterButton] = wrapper.children;
21+
[firstGlobalFocusable, contextMenu, lastGlobalFocusable] = wrapper.children;
2222
contextMenu.items = [{ text: 'Item 0' }, { text: 'Item 1', children: [{ text: 'Item 1/0' }] }];
2323
await nextRender();
2424
contextMenuButton = contextMenu.querySelector('button');
@@ -82,14 +82,14 @@ describe('a11y', () => {
8282
await sendKeys({ down: 'Shift' });
8383
await sendKeys({ press: 'Tab' });
8484
await sendKeys({ up: 'Shift' });
85-
expect(getDeepActiveElement()).to.equal(beforeButton);
85+
expect(getDeepActiveElement()).to.equal(firstGlobalFocusable);
8686
});
8787

8888
it('should move focus to the next element outside the menu on Tab pressed inside', async () => {
8989
contextMenuButton.click();
9090
await nextRender();
9191
await sendKeys({ press: 'Tab' });
92-
expect(getDeepActiveElement()).to.equal(afterButton);
92+
expect(getDeepActiveElement()).to.equal(lastGlobalFocusable);
9393
});
9494
});
9595
});

‎packages/dashboard/test/dashboard-keyboard.test.ts‎

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,17 @@ type TestDashboardItem = DashboardItem & { id: number };
3030
describe('dashboard - keyboard interaction', () => {
3131
let dashboard: Dashboard<TestDashboardItem>;
3232
let keydownSpy;
33+
let firstGlobalFocusable: HTMLElement;
3334
const columnWidth = 200;
3435

3536
beforeEach(async () => {
36-
dashboard = fixtureSync('<vaadin-dashboard></vaadin-dashboard>');
37+
[firstGlobalFocusable, dashboard] = fixtureSync(
38+
`<div>
39+
<input id="first-global-focusable" />
40+
<vaadin-dashboard></vaadin-dashboard>
41+
</div>`,
42+
).children as unknown as [HTMLElement, Dashboard<TestDashboardItem>];
43+
firstGlobalFocusable.focus();
3744
await nextFrame();
3845
dashboard.editable = true;
3946
keydownSpy = sinon.spy();
@@ -56,15 +63,6 @@ describe('dashboard - keyboard interaction', () => {
5663

5764
dashboard.style.width = `${columnWidth * 2}px`;
5865
await nextResize(dashboard);
59-
60-
// Make sure the following tab goes back to the first widget (needed for Firefox)
61-
const widget = getElementFromCell(dashboard, 0, 0)!;
62-
widget.focus();
63-
await nextFrame();
64-
await sendKeys({ down: 'Shift' });
65-
await sendKeys({ press: 'Tab' });
66-
await sendKeys({ up: 'Shift' });
67-
await nextFrame();
6866
});
6967

7068
it('should focus the widget', async () => {
@@ -111,9 +109,9 @@ describe('dashboard - keyboard interaction', () => {
111109
expect(spy.firstCall.args[0].detail).to.eql({ item: { id: 0 }, value: true });
112110
});
113111

114-
(isChrome || isFirefox ? it : it.skip)('should not remove the widget on backspace', async () => {
112+
(isChrome || isFirefox ? it : it.skip)('should not remove the widget on Delete', async () => {
115113
await sendKeys({ press: 'Tab' });
116-
await sendKeys({ press: 'Backspace' });
114+
await sendKeys({ press: 'Delete' });
117115
expect(dashboard.items).to.eql([{ id: 0 }, { id: 1 }, { items: [{ id: 2 }, { id: 3 }] }]);
118116
});
119117

@@ -183,8 +181,8 @@ describe('dashboard - keyboard interaction', () => {
183181
expect(widget.hasAttribute('focused')).to.be.false;
184182
});
185183

186-
it('should remove the widget on backspace', async () => {
187-
await sendKeys({ press: 'Backspace' });
184+
it('should remove the widget on Delete', async () => {
185+
await sendKeys({ press: 'Delete' });
188186
expect(dashboard.items).to.eql([{ id: 1 }, { items: [{ id: 2 }, { id: 3 }] }]);
189187
});
190188

@@ -193,10 +191,10 @@ describe('dashboard - keyboard interaction', () => {
193191
expect(dashboard.items).to.eql([{ id: 1 }, { items: [{ id: 2 }, { id: 3 }] }]);
194192
});
195193

196-
it('should dispatch an item removed event on backspace', async () => {
194+
it('should dispatch an item removed event on Delete', async () => {
197195
const spy = sinon.spy();
198196
dashboard.addEventListener('dashboard-item-removed', spy);
199-
await sendKeys({ press: 'Backspace' });
197+
await sendKeys({ press: 'Delete' });
200198
expect(spy.calledOnce).to.be.true;
201199
expect(spy.firstCall.args[0].detail.item).to.eql({ id: 0 });
202200
expect(spy.firstCall.args[0].detail.items).to.eql(dashboard.items);
@@ -288,9 +286,9 @@ describe('dashboard - keyboard interaction', () => {
288286
expect(dashboard.items).to.eql([{ id: 0 }, { id: 1 }, { items: [{ id: 2 }, { id: 3 }] }]);
289287
});
290288

291-
it('should cancel the default action on backspace', async () => {
289+
it('should cancel the default action on Delete', async () => {
292290
keydownSpy.resetHistory();
293-
await sendKeys({ press: 'Backspace' });
291+
await sendKeys({ press: 'Delete' });
294292
expect(keydownSpy.firstCall.args[0].defaultPrevented).to.be.true;
295293
});
296294

0 commit comments

Comments
 (0)