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) (CP: 24.5) #8466

Merged
merged 1 commit into from
Jan 9, 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.1",
"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 @@ -65,9 +70,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);
});
});
});
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 @@ -17,7 +17,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
14 changes: 5 additions & 9 deletions packages/grid/test/keyboard-interaction-mode.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from '@vaadin/chai-plugins';
import { aTimeout, fixtureSync, keyDownOn, nextFrame, nextRender, oneEvent } from '@vaadin/testing-helpers';
import { aTimeout, fixtureSync, keyDownOn, nextFrame, nextRender } from '@vaadin/testing-helpers';
import { sendKeys } from '@web/test-runner-commands';
import sinon from 'sinon';
import { getDeepActiveElement } from '@vaadin/a11y-base/src/focus-utils.js';
Expand Down Expand Up @@ -540,8 +540,7 @@ describe('keyboard interaction mode', () => {
// Tab downwards
for (let i = 1; i <= tabToIndex; i++) {
await rendered();
queueMicrotask(async () => await sendKeys({ press: 'Tab' }));
await oneEvent(grid, 'focusin');
await sendKeys({ press: 'Tab' });
await rendered();

const focusedRow = document.activeElement.parentElement.assignedSlot.parentElement.parentElement;
Expand All @@ -551,12 +550,9 @@ describe('keyboard interaction mode', () => {
// Tab upwards
for (let i = tabToIndex - 1; i >= 0; i--) {
await rendered();
queueMicrotask(async () => {
await sendKeys({ down: 'Shift' });
await sendKeys({ press: 'Tab' });
await sendKeys({ up: 'Shift' });
});
await oneEvent(grid, 'focusin');
await sendKeys({ down: 'Shift' });
await sendKeys({ press: 'Tab' });
await sendKeys({ up: 'Shift' });
await rendered();
const focusedRow = document.activeElement.parentElement.assignedSlot.parentElement.parentElement;
expect(focusedRow.index).to.equal(i);
Expand Down
4 changes: 2 additions & 2 deletions packages/grid/test/keyboard-navigation.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2221,7 +2221,7 @@ describe('empty state', () => {
}

function getEmptyStateFocusables() {
return [...getEmptyState().querySelectorAll('button')];
return [...getEmptyState().querySelectorAll('input')];
}

function getEmptyStateBody() {
Expand All @@ -2233,7 +2233,7 @@ describe('empty state', () => {
<vaadin-grid>
<vaadin-grid-column path="name"></vaadin-grid-column>
<div slot="empty-state">
No items <button>button 1</button> <button>button 2</button>
No items <input /> <input />
</div>
</vaadin-grid>
`);
Expand Down
16 changes: 2 additions & 14 deletions packages/grid/test/scrolling-mode.common.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import { expect } from '@vaadin/chai-plugins';
import {
fixtureSync,
isDesktopSafari,
isFirefox,
listenOnce,
nextFrame,
nextRender,
nextResize,
} from '@vaadin/testing-helpers';
import { fixtureSync, listenOnce, nextFrame, nextRender, nextResize } from '@vaadin/testing-helpers';
import { flushGrid, infiniteDataProvider, scrollToEnd } from './helpers.js';

describe('scrolling mode', () => {
Expand Down Expand Up @@ -107,11 +99,7 @@ describe('scrolling mode', () => {
expect(grid.getAttribute('overflow')).to.equal('top start left');
});

// This test constantly fails in WebKit when the test is running on CI.
// It perhaps has something to do with the specific version of WebKit
// Playwright uses on CI. It sometimes fails also in Firefox on CI,
// but not as often as in WebKit.
(isDesktopSafari || isFirefox ? it.skip : it)('update on resize', async () => {
it('update on resize', async () => {
grid.style.width = '200px';
await nextResize(grid);
await nextFrame();
Expand Down
Loading