Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade playwright to 1.48.2 #8355

Merged
merged 17 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
run: yarn --frozen-lockfile --no-progress --non-interactive

- name: Install Playwright
run: npx playwright install-deps firefox
run: npx playwright install firefox --with-deps

- name: Test
run: yarn test:firefox
Expand All @@ -65,7 +65,7 @@ jobs:
run: yarn --frozen-lockfile --no-progress --non-interactive

- name: Install Playwright
run: npx playwright install-deps webkit
run: npx playwright install webkit --with-deps

- name: Test
run: yarn test:webkit
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
"stylelint-config-vaadin": "^1.0.0-alpha.2",
"typescript": "^5.5.2"
},
"resolutions": {
"playwright": "^1.48.2"
},
"lint-staged": {
"*.{js,ts}": [
"eslint --fix",
Expand Down
16 changes: 11 additions & 5 deletions packages/checkbox-group/test/checkbox-group.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,18 @@ describe('vaadin-checkbox-group', () => {
});

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

beforeEach(async () => {
group = fixtureSync(`
<vaadin-checkbox-group>
<vaadin-checkbox value="1" label="Checkbox 1"></vaadin-checkbox>
</vaadin-checkbox-group>
`);
[firstGlobalFocusable, group] = fixtureSync(
`<div>
<input id="first-global-focusable" />
<vaadin-checkbox-group>
<vaadin-checkbox value="1" label="Checkbox 1"></vaadin-checkbox>
</vaadin-checkbox-group>
</div>`,
).children;
firstGlobalFocusable.focus();
await nextFrame();
checkboxes = [...group.querySelectorAll('vaadin-checkbox')];
});
Expand Down
20 changes: 13 additions & 7 deletions packages/checkbox-group/test/validation.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,20 @@ describe('validation', () => {
});

describe('basic', () => {
let firstGlobalFocusable;

beforeEach(async () => {
group = fixtureSync(`
<vaadin-checkbox-group>
<vaadin-checkbox name="language" value="en" label="English"></vaadin-checkbox>
<vaadin-checkbox name="language" value="fr" label="Français"></vaadin-checkbox>
<vaadin-checkbox name="language" value="de" label="Deutsch"></vaadin-checkbox>
</vaadin-checkbox-group>
`);
[firstGlobalFocusable, group] = fixtureSync(
`<div>
<input id="first-global-focusable" />
<vaadin-checkbox-group>
<vaadin-checkbox name="language" value="en" label="English"></vaadin-checkbox>
<vaadin-checkbox name="language" value="fr" label="Français"></vaadin-checkbox>
<vaadin-checkbox name="language" value="de" label="Deutsch"></vaadin-checkbox>
</vaadin-checkbox-group>
</div>`,
).children;
firstGlobalFocusable.focus();
await nextRender();
validateSpy = sinon.spy(group, 'validate');
});
Expand Down
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>
<input id="last-global-focusable" />
</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
8 changes: 7 additions & 1 deletion packages/combo-box/test/interactions.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ describe('interactions', () => {
let comboBox, overlay, input;

beforeEach(async () => {
comboBox = fixtureSync('<vaadin-combo-box label="Label"></vaadin-combo-box>');
comboBox = fixtureSync(
`<div>
<vaadin-combo-box label="Label"></vaadin-combo-box>
<input id="last-global-focusable" />
</div>`,
).firstElementChild;

await nextRender();
comboBox.items = ['foo', 'bar', 'baz'];
input = comboBox.inputElement;
Expand Down
28 changes: 10 additions & 18 deletions packages/combo-box/test/keyboard.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ import sinon from 'sinon';
import { getViewportItems, getVisibleItemsCount, scrollToIndex, setInputValue } from './helpers.js';

describe('keyboard', () => {
let comboBox, input;
let comboBox, input, lastGlobalFocusable;

function getFocusedIndex() {
return comboBox._focusedIndex;
}

beforeEach(async () => {
comboBox = fixtureSync('<vaadin-combo-box></vaadin-combo-box>');
[comboBox, lastGlobalFocusable] = fixtureSync(
`<div>
<vaadin-combo-box></vaadin-combo-box>
<input id="last-global-focusable" />
</div>`,
).children;

await nextRender();
comboBox.items = ['foo', 'bar', 'baz'];
input = comboBox.inputElement;
Expand Down Expand Up @@ -128,36 +134,22 @@ describe('keyboard', () => {

it('should tab to the next focusable', async () => {
await sendKeys({ press: 'Tab' });

expect(document.activeElement).to.equal(document.body);
expect(document.activeElement).to.equal(lastGlobalFocusable);
});

describe('focusable items content', () => {
let focusable;

beforeEach(() => {
focusable = document.createElement('input');
});

afterEach(() => {
focusable.remove();
});

it('should tab to the next focusable when items have focusable content', async () => {
comboBox.renderer = (root) => {
root.innerHTML = '<input>';
};
document.body.appendChild(focusable);

// Workaround Playwright sendKeys bug
focusable.focus();
input.focus();
arrowDownKeyDown(input);

await aTimeout(0);

await sendKeys({ press: 'Tab' });
expect(document.activeElement).to.equal(focusable);
expect(document.activeElement).to.equal(lastGlobalFocusable);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from '@vaadin/chai-plugins';
import { fixtureSync, mousedown, mouseup, nextFrame, oneEvent } from '@vaadin/testing-helpers';
import { fixtureSync, mousedown, mouseup, nextFrame } from '@vaadin/testing-helpers';
import { sendKeys } from '@web/test-runner-commands';
import sinon from 'sinon';
import { Virtualizer } from '../src/virtualizer.js';
Expand Down Expand Up @@ -144,21 +144,17 @@ describe('reorder elements', () => {
// Tab downwards
for (let i = 1; i <= tabToIndex; i++) {
await nextFrame();
queueMicrotask(async () => await sendKeys({ press: 'Tab' }));
await oneEvent(elementsContainer, 'focusin');
await sendKeys({ press: 'Tab' });
await nextFrame();
expect(document.activeElement.id).to.equal(`item-${i}`);
}

// Tab upwards
for (let i = tabToIndex - 1; i >= 0; i--) {
await nextFrame();
queueMicrotask(async () => {
await sendKeys({ down: 'Shift' });
await sendKeys({ press: 'Tab' });
await sendKeys({ up: 'Shift' });
});
await oneEvent(elementsContainer, 'focusin');
await sendKeys({ down: 'Shift' });
await sendKeys({ press: 'Tab' });
await sendKeys({ up: 'Shift' });
await nextFrame();
expect(document.activeElement.id).to.equal(`item-${i}`);
}
Expand Down
12 changes: 6 additions & 6 deletions packages/context-menu/test/a11y.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import { getMenuItems } from './helpers.js';

describe('a11y', () => {
describe('focus restoration', () => {
let contextMenu, contextMenuButton, beforeButton, afterButton;
let contextMenu, contextMenuButton, firstGlobalFocusable, lastGlobalFocusable;

beforeEach(async () => {
const wrapper = fixtureSync(`
<div>
<button>Before</button>
<input id="first-global-focusable" />
<vaadin-context-menu open-on="click">
<button>Open context menu</button>
</vaadin-context-menu>
<button>After</button>
<input id="last-global-focusable" />
</div>
`);
[beforeButton, contextMenu, afterButton] = wrapper.children;
[firstGlobalFocusable, contextMenu, lastGlobalFocusable] = wrapper.children;
contextMenu.items = [{ text: 'Item 0' }, { text: 'Item 1', children: [{ text: 'Item 1/0' }] }];
await nextRender();
contextMenuButton = contextMenu.querySelector('button');
Expand Down Expand Up @@ -82,14 +82,14 @@ describe('a11y', () => {
await sendKeys({ down: 'Shift' });
await sendKeys({ press: 'Tab' });
await sendKeys({ up: 'Shift' });
expect(getDeepActiveElement()).to.equal(beforeButton);
expect(getDeepActiveElement()).to.equal(firstGlobalFocusable);
});

it('should move focus to the next element outside the menu on Tab pressed inside', async () => {
contextMenuButton.click();
await nextRender();
await sendKeys({ press: 'Tab' });
expect(getDeepActiveElement()).to.equal(afterButton);
expect(getDeepActiveElement()).to.equal(lastGlobalFocusable);
});
});
});
34 changes: 16 additions & 18 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>
<input id="first-global-focusable" />
<vaadin-dashboard></vaadin-dashboard>
</div>`,
).children as unknown as [HTMLElement, Dashboard<TestDashboardItem>];
firstGlobalFocusable.focus();
await nextFrame();
dashboard.editable = true;
keydownSpy = sinon.spy();
Expand All @@ -56,15 +63,6 @@ describe('dashboard - keyboard interaction', () => {

dashboard.style.width = `${columnWidth * 2}px`;
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();
});

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

(isChrome || isFirefox ? it : it.skip)('should not remove the widget on backspace', async () => {
(isChrome || isFirefox ? it : it.skip)('should not remove the widget on Delete', async () => {
Copy link
Contributor Author

@vursen vursen Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Changed to Delete because Backspace sometimes triggered navigation to the previous page in Webkit, which interrupted the execution of the entire test file.

await sendKeys({ press: 'Tab' });
await sendKeys({ press: 'Backspace' });
await sendKeys({ press: 'Delete' });
expect(dashboard.items).to.eql([{ id: 0 }, { id: 1 }, { items: [{ id: 2 }, { id: 3 }] }]);
});

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

it('should remove the widget on backspace', async () => {
await sendKeys({ press: 'Backspace' });
it('should remove the widget on Delete', async () => {
await sendKeys({ press: 'Delete' });
expect(dashboard.items).to.eql([{ id: 1 }, { items: [{ id: 2 }, { id: 3 }] }]);
});

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

it('should dispatch an item removed event on backspace', async () => {
it('should dispatch an item removed event on Delete', async () => {
const spy = sinon.spy();
dashboard.addEventListener('dashboard-item-removed', spy);
await sendKeys({ press: 'Backspace' });
await sendKeys({ press: 'Delete' });
expect(spy.calledOnce).to.be.true;
expect(spy.firstCall.args[0].detail.item).to.eql({ id: 0 });
expect(spy.firstCall.args[0].detail.items).to.eql(dashboard.items);
Expand Down Expand Up @@ -288,9 +286,9 @@ describe('dashboard - keyboard interaction', () => {
expect(dashboard.items).to.eql([{ id: 0 }, { id: 1 }, { items: [{ id: 2 }, { id: 3 }] }]);
});

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

Expand Down
7 changes: 6 additions & 1 deletion packages/date-picker/test/dropdown.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ describe('dropdown', () => {
let datePicker, input, overlay;

beforeEach(async () => {
datePicker = fixtureSync(`<vaadin-date-picker></vaadin-date-picker>`);
datePicker = fixtureSync(
`<div>
<vaadin-date-picker></vaadin-date-picker>
<input id="last-global-focusable" />
</div>`,
).firstElementChild;
await nextRender();
input = datePicker.inputElement;
overlay = datePicker.$.overlay;
Expand Down
7 changes: 6 additions & 1 deletion packages/field-base/test/virtual-keyboard-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ describe('virtual-keyboard-controller', () => {
let element, input;

beforeEach(() => {
element = fixtureSync('<virtual-keyboard-controller-element></virtual-keyboard-controller-element>');
element = fixtureSync(
`<div>
<virtual-keyboard-controller-element></virtual-keyboard-controller-element>
<input id="last-global-focusable" />
</div>`,
).firstElementChild;
input = element.inputElement;
});

Expand Down
2 changes: 1 addition & 1 deletion packages/field-highlighter/test/user-tags.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ describe('user-tags', () => {

describe('adding users when the field is partially visible and focused', () => {
beforeEach(async () => {
container.scrollTop = 220;
field.inputElement.focus();
container.scrollTop = 220;
await waitForIntersectionObserver();
addUser(user1);
addUser(user2);
Expand Down
1 change: 1 addition & 0 deletions packages/grid/test/drag-and-drop.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,7 @@ describe('drag and drop', () => {

async function assertDragSucceeds(draggedElement) {
await dragElement(draggedElement);
await nextFrame();
expect(grid.$.scroller.style.display).to.equal('');
}

Expand Down
Loading