Skip to content
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
102 changes: 73 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"@octokit/rest": "16.26.0",
"@octokit/types": "6.34.0",
"@octokit/webhooks-types": "5.6.0",
"@playwright/test": "1.32.0",
"@playwright/test": "1.39.0",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
"@storybook/addon-a11y": "7.2.2",
"@storybook/addon-actions": "7.2.2",
Expand Down
36 changes: 20 additions & 16 deletions packages/e2e-test-utils-playwright/src/page-utils/drag-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getType } from 'mime';
* Internal dependencies
*/
import type { PageUtils } from './index';
import type { ElementHandle, Locator } from '@playwright/test';
import type { Locator } from '@playwright/test';

type FileObject = {
name: string;
Expand Down Expand Up @@ -118,25 +118,29 @@ async function dragFiles(

/**
* Drop the files at the current position.
*
* @param locator
*/
drop: async ( locator: Locator | ElementHandle | null ) => {
if ( ! locator ) {
const topMostElement = await this.page.evaluateHandle(
( { x, y } ) => {
return document.elementFromPoint( x, y );
},
position
);
locator = topMostElement.asElement();
}
drop: async () => {
const topMostElement = await this.page.evaluateHandle(
( { x, y } ) => {
const element = document.elementFromPoint( x, y );
if ( element instanceof HTMLIFrameElement ) {
const offsetBox = element.getBoundingClientRect();
return element.contentDocument!.elementFromPoint(
x - offsetBox.x,
y - offsetBox.y
);
}
return element;
},
position
);
const elementHandle = topMostElement.asElement();

if ( ! locator ) {
if ( ! elementHandle ) {
throw new Error( 'Element not found.' );
}

const dataTransfer = await locator.evaluateHandle(
const dataTransfer = await elementHandle.evaluateHandle(
async ( _node, _fileObjects ) => {
const dt = new DataTransfer();
const fileInstances = await Promise.all(
Expand All @@ -159,7 +163,7 @@ async function dragFiles(
fileObjects
);

await locator.dispatchEvent( 'drop', { dataTransfer } );
await elementHandle.dispatchEvent( 'drop', { dataTransfer } );

await cdpSession.detach();
},
Expand Down
4 changes: 2 additions & 2 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"minimist": "^1.2.0",
"npm-package-json-lint": "^6.4.0",
"npm-packlist": "^3.0.0",
"playwright-core": "1.32.0",
"playwright-core": "1.39.0",
"postcss": "^8.4.5",
"postcss-loader": "^6.2.1",
"prettier": "npm:[email protected]",
Expand All @@ -92,7 +92,7 @@
"webpack-dev-server": "^4.15.1"
},
"peerDependencies": {
"@playwright/test": "^1.32.0",
"@playwright/test": "^1.39.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
Expand Down
6 changes: 5 additions & 1 deletion packages/scripts/scripts/test-playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ process.on( 'unhandledRejection', ( err ) => {
/**
* External dependencies
*/
const path = require( 'path' );
const { resolve } = require( 'node:path' );
const { sync: spawn } = require( 'cross-spawn' );

Expand All @@ -27,7 +28,10 @@ const {

const result = spawn(
'node',
[ require.resolve( 'playwright-core/cli' ), 'install' ],
[
path.resolve( require.resolve( 'playwright-core' ), '..', 'cli.js' ),
'install',
],
Comment on lines +31 to +34
Copy link
Member Author

Choose a reason for hiding this comment

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

@swissspidy, @kevin940726, I had to change the CLI path resolution to this (reason #22612).

Copy link
Member

Choose a reason for hiding this comment

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

If it works it works :)

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Could we just use npx?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried that when I initially found the issue, but it failed locally for me. Pascal might have more details on why we're using node vs. npx.

{
stdio: 'inherit',
}
Expand Down
Loading