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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
34 changes: 8 additions & 26 deletions packages/app-layout/test/app-layout.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,11 @@ import {
makeSoloTouchEvent,
nextFrame,
nextRender,
nextResize,
oneEvent,
} from '@vaadin/testing-helpers';
import sinon from 'sinon';

/**
* Resolves once the function is invoked on the given object.
*/
function onceInvoked(object, functionName) {
return new Promise((resolve) => {
sinon.replace(object, functionName, (...args) => {
sinon.restore();
object[functionName](...args);
resolve();
});
});
}

/**
* Resolves once the ResizeObserver has processed a resize.
*/
async function onceResized(layout) {
await onceInvoked(layout, '_updateOffsetSize');
}
import './not-animated-styles.js';

describe('vaadin-app-layout', () => {
let layout;
Expand Down Expand Up @@ -108,12 +90,12 @@ describe('vaadin-app-layout', () => {
navbarContent.style.height = '100px';
navbarContent.setAttribute('slot', 'navbar');
layout.appendChild(navbarContent);
await onceResized(layout);
await nextResize(layout);
const initialOffset = parseInt(getComputedStyle(layout).getPropertyValue('padding-top'));
expect(initialOffset).to.be.greaterThan(0);
// Increase navbar content size and measure increase
navbarContent.style.height = '200px';
await onceResized(layout);
await nextResize(layout);
const updatedOffset = parseInt(getComputedStyle(layout).getPropertyValue('padding-top'));
expect(updatedOffset).to.equal(initialOffset + 100);
});
Expand Down Expand Up @@ -162,12 +144,12 @@ describe('vaadin-app-layout', () => {
navbarContent.style.height = '100px';
navbarContent.setAttribute('slot', 'navbar touch-optimized');
layout.appendChild(navbarContent);
await onceResized(layout);
await nextResize(layout);
const initialOffset = parseInt(getComputedStyle(layout).getPropertyValue('padding-bottom'));
expect(initialOffset).to.be.greaterThan(0);
// Increase navbar content size and measure increase
navbarContent.style.height = '200px';
await onceResized(layout);
await nextResize(layout);
const updatedOffset = parseInt(getComputedStyle(layout).getPropertyValue('padding-bottom'));
expect(updatedOffset).to.equal(initialOffset + 100);
});
Expand Down Expand Up @@ -196,7 +178,7 @@ describe('vaadin-app-layout', () => {
drawer = layout.shadowRoot.querySelector('[part=drawer]');
backdrop = layout.shadowRoot.querySelector('[part=backdrop]');
// Wait for the initial resize observer callback
await onceResized(layout);
await nextResize(layout);
await nextFrame();
}

Expand Down Expand Up @@ -289,7 +271,7 @@ describe('vaadin-app-layout', () => {

it('should only update offset size once during the drawer transition', async () => {
layout.primarySection = 'drawer';
await onceResized(layout);
await nextResize(layout);
await nextRender();

layout.style.setProperty('--vaadin-app-layout-transition', '100ms');
Expand Down
10 changes: 10 additions & 0 deletions packages/app-layout/test/not-animated-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';

registerStyles(
'vaadin-app-layout',
css`
:host {
transition: none !important;
}
`,
);
43 changes: 12 additions & 31 deletions packages/avatar-group/test/avatar-group.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,13 @@ import {
fixtureSync,
nextFrame,
nextRender,
nextResize,
oneEvent,
spaceKeyDown,
tabKeyDown,
} from '@vaadin/testing-helpers';
import sinon from 'sinon';

/**
* Resolves once the function is invoked on the given object.
*/
function onceInvoked(object, functionName) {
return new Promise((resolve) => {
sinon.replace(object, functionName, (...args) => {
sinon.restore();
object[functionName](...args);
resolve();
});
});
}

/**
* Resolves once the ResizeObserver in AvatarGroup has processed a resize.
*/
async function onceResized(group) {
await onceInvoked(group, '__setItemsInView');
}

describe('avatar-group', () => {
let group;

Expand Down Expand Up @@ -190,15 +171,15 @@ describe('avatar-group', () => {

it('should consider element width when maxItemsVisible is set', async () => {
group.style.width = '100px';
await onceResized(group);
await nextResize(group);

const items = group.querySelectorAll('vaadin-avatar');
expect(items.length).to.equal(3);
});

it('should set abbr property correctly if maxItemsVisible and width are set', async () => {
group.style.width = '100px';
await onceResized(group);
await nextResize(group);

const overflow = group._overflow;
expect(overflow.abbr).to.equal('+3');
Expand All @@ -218,7 +199,7 @@ describe('avatar-group', () => {

it('should render avatars to fit width on resize', async () => {
group.style.width = '110px';
await onceResized(group);
await nextResize(group);
const items = group.querySelectorAll('vaadin-avatar');
expect(items.length).to.equal(3);
expect(overflow.abbr).to.equal('+3');
Expand All @@ -227,27 +208,27 @@ describe('avatar-group', () => {
it('should always show at least two avatars', async () => {
group.items = group.items.slice(0, 2);
group.style.width = '50px';
await onceResized(group);
await nextResize(group);
const items = group.querySelectorAll('vaadin-avatar:not([hidden])');
expect(items.length).to.equal(2);
});

it('should not show overlay with only one avatar', async () => {
group.style.width = '170px';
await onceResized(group);
await nextResize(group);
expect(overflow.hasAttribute('hidden')).to.be.true;
});

it('should re-render avatars on items change', async () => {
group.style.width = '110px';
group.items = group.items.slice(0, 2);
await onceResized(group);
await nextResize(group);
expect(overflow.hasAttribute('hidden')).to.be.true;
});

it('should render avatars in the menu items', async () => {
group.style.width = '110px';
await onceResized(group);
await nextResize(group);

overflow.click();
await oneEvent(overlay, 'vaadin-overlay-open');
Expand All @@ -258,27 +239,27 @@ describe('avatar-group', () => {

it('should re-render overflowing avatars on resize', async () => {
group.style.width = '110px';
await onceResized(group);
await nextResize(group);

overflow.click();
await oneEvent(overlay, 'vaadin-overlay-open');

group.style.width = '75px';
await onceResized(group);
await nextResize(group);

const items = overlay.querySelectorAll('vaadin-avatar-group-menu-item');
expect(items.length).to.equal(4);
});

it('should close overlay on resize when all avatars fit', async () => {
group.style.width = '110px';
await onceResized(group);
await nextResize(group);

overflow.click();
await oneEvent(overlay, 'vaadin-overlay-open');

group.style.width = '';
await onceResized(group);
await nextResize(group);

expect(overlay.opened).to.be.false;
});
Expand Down
24 changes: 2 additions & 22 deletions packages/board/test/helpers.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
import sinon from 'sinon';

/**
* Resolves once the function is invoked on the given object.
*/
function onceInvoked(object, functionName) {
return new Promise((resolve) => {
const stub = sinon.stub(object, functionName).callsFake((...args) => {
stub.restore();
object[functionName](...args);
resolve();
});
});
}

/**
* Resolves once the ResizeObserver in BoardRow has processed a resize.
*/
export async function onceResized(boardRow) {
await onceInvoked(boardRow, '_onResize');
}
import { nextResize } from '@vaadin/testing-helpers';

/**
* Resolves once the ResizeObserver in all the BoardRows has processed a resize.
*/
export function allResized(boardRows) {
return Promise.all(boardRows.map((boardRow) => onceResized(boardRow)));
return Promise.all(boardRows.map((boardRow) => nextResize(boardRow)));
}
12 changes: 6 additions & 6 deletions packages/board/test/redraw.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from '@vaadin/chai-plugins';
import { aTimeout, fixtureSync } from '@vaadin/testing-helpers';
import { aTimeout, fixtureSync, nextResize } from '@vaadin/testing-helpers';
import '../vaadin-board.js';
import { allResized, onceResized } from './helpers.js';
import { allResized } from './helpers.js';

describe('redraw', () => {
describe('board', () => {
Expand All @@ -19,7 +19,7 @@ describe('redraw', () => {
</vaadin-board>
`);
row = board.firstElementChild;
await onceResized(row);
await nextResize(row);
});

it('should trigger layout after board style is changed', () => {
Expand Down Expand Up @@ -49,7 +49,7 @@ describe('redraw', () => {
<div>top D</div>
</vaadin-board-row>
`);
await onceResized(row);
await nextResize(row);
});

it('should trigger layout after board row style is changed', () => {
Expand Down Expand Up @@ -85,7 +85,7 @@ describe('redraw', () => {
`);
row = board.querySelector('#nested');

await onceResized(row);
await nextResize(row);
});

it('should trigger layout for nested rows after board style is changed', () => {
Expand Down Expand Up @@ -199,7 +199,7 @@ describe('redraw', () => {
expect(first.className).to.equal('');

container.style.width = '1001px';
await onceResized(first);
await nextResize(first);
expect(first.className).to.equal('large');
});

Expand Down
27 changes: 3 additions & 24 deletions packages/charts/test/chart-element.test.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
import { expect } from '@vaadin/chai-plugins';
import { aTimeout, fixtureSync, nextFrame, nextRender, oneEvent } from '@vaadin/testing-helpers';
import { aTimeout, fixtureSync, nextFrame, nextRender, nextResize, oneEvent } from '@vaadin/testing-helpers';
import sinon from 'sinon';
import '../vaadin-chart.js';

/**
* Resolves once the function is invoked on the given object.
*/
function onceInvoked(object, functionName) {
return new Promise((resolve) => {
sinon.replace(object, functionName, (...args) => {
sinon.restore();
object[functionName](...args);
resolve();
});
});
}

/**
* Resolves once the ResizeObserver in AvatarGroup has processed a resize.
*/
async function onceResized(el) {
// Wait for the _onResize function to be invoked by the ResizeObserver
await onceInvoked(el, '_onResize');
}

describe('vaadin-chart', () => {
describe('custom element definition', () => {
let chart, tagName;
Expand Down Expand Up @@ -346,7 +325,7 @@ describe('vaadin-chart', () => {
expect(charts[1].configuration.chartWidth).to.be.equal(500);

layout.style.width = '500px';
await onceResized(charts[0]);
await nextResize(charts[0]);

expect(layout.getBoundingClientRect().width).to.be.equal(500);
expect(charts[0].configuration.chartWidth).to.be.equal(250);
Expand All @@ -359,7 +338,7 @@ describe('vaadin-chart', () => {
expect(charts[1].configuration.chartHeight).to.be.equal(300);

layout.style.height = '200px';
await onceResized(charts[0]);
await nextResize(charts[0]);

expect(layout.getBoundingClientRect().height).to.be.equal(200);
expect(charts[0].configuration.chartHeight).to.be.equal(200);
Expand Down
2 changes: 2 additions & 0 deletions packages/combo-box/test/interactions.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ describe('interactions', () => {
comboBox.open();
comboBox.close();
await aTimeout(0);
await sendKeys({ down: 'Shift' });
await sendKeys({ press: 'Tab' });
await sendKeys({ up: 'Shift' });
expect(input.inputMode).to.equal('');
});
});
Expand Down
6 changes: 4 additions & 2 deletions packages/combo-box/test/keyboard.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ describe('keyboard', () => {
expect(getFocusedIndex()).to.equal(0);
});

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

expect(document.activeElement).to.equal(document.body);
expect(document.activeElement).to.be.oneOf([document.body, document.documentElement]);
});

describe('focusable items content', () => {
Expand Down
Loading
Loading