Skip to content

Commit

Permalink
Lodash: Remove completely from e2e-test-utils package
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed Aug 16, 2022
1 parent 82509b6 commit 2e8952f
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 42 deletions.
1 change: 0 additions & 1 deletion package-lock.json

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

1 change: 0 additions & 1 deletion packages/e2e-test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"@wordpress/url": "file:../url",
"change-case": "^4.1.2",
"form-data": "^4.0.0",
"lodash": "^4.17.21",
"node-fetch": "^2.6.0"
},
"peerDependencies": {
Expand Down
11 changes: 3 additions & 8 deletions packages/e2e-test-utils/src/click-menu-item.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
/**
* External dependencies
*/
import { first } from 'lodash';

/**
* Searches for an item in the menu with the text provided and clicks it.
*
* @param {string} label The label to search the menu item for.
*/
export async function clickMenuItem( label ) {
const elementToClick = first(
await page.$x( `//*[@role="menu"]//*[text()="${ label }"]` )
const menuItems = await page.$x(
`//*[@role="menu"]//*[text()="${ label }"]`
);
await elementToClick.click();
await menuItems[ 0 ].click();
}
13 changes: 3 additions & 10 deletions packages/e2e-test-utils/src/click-on-more-menu-item.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { first } from 'lodash';

/**
* Internal dependencies
*/
Expand All @@ -18,10 +13,8 @@ export async function clickOnMoreMenuItem( buttonLabel ) {
const moreMenuContainerSelector =
'//*[contains(concat(" ", @class, " "), " interface-more-menu-dropdown__content ")]';

const elementToClick = first(
await page.$x(
`${ moreMenuContainerSelector }//span[contains(concat(" ", @class, " "), " components-menu-item__item ")][contains(text(), "${ buttonLabel }")]`
)
const menuItems = await page.$x(
`${ moreMenuContainerSelector }//span[contains(concat(" ", @class, " "), " components-menu-item__item ")][contains(text(), "${ buttonLabel }")]`
);
await elementToClick.click();
await menuItems[ 0 ].click();
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { first } from 'lodash';

/** @typedef {import('puppeteer-core').ElementHandle} ElementHandle */

/**
Expand All @@ -13,9 +8,8 @@ import { first } from 'lodash';
* @return {?ElementHandle} Object that represents an in-page DOM element.
*/
export async function findSidebarPanelToggleButtonWithTitle( panelTitle ) {
return first(
await page.$x(
`//div[contains(@class,"edit-post-sidebar")]//button[@class="components-button components-panel__body-toggle"][contains(text(),"${ panelTitle }")]`
)
const buttons = await page.$x(
`//div[contains(@class,"edit-post-sidebar")]//button[@class="components-button components-panel__body-toggle"][contains(text(),"${ panelTitle }")]`
);
return buttons[ 0 ];
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { sortBy, uniq } from 'lodash';

/**
* Returns an array of strings with all inserter item titles.
*
Expand All @@ -25,5 +20,5 @@ export async function getAllBlockInserterItemTitles() {
return inserterItem.innerText;
} );
} );
return sortBy( uniq( inserterItemTitles ) );
return [ ...new Set( inserterItemTitles ) ].sort();
}
2 changes: 1 addition & 1 deletion packages/e2e-test-utils/src/plugins.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { kebabCase } from 'lodash';
import { paramCase as kebabCase } from 'change-case';

/**
* Internal dependencies
Expand Down
7 changes: 1 addition & 6 deletions packages/e2e-test-utils/src/preview.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { last } from 'lodash';

/** @typedef {import('puppeteer-core').Page} Page */

/**
Expand All @@ -29,6 +24,6 @@ export async function openPreviewPage( editorPage = page ) {
openTabs = await browser.pages();
}

const previewPage = last( openTabs );
const previewPage = openTabs[ openTabs.length - 1 ];
return previewPage;
}

0 comments on commit 2e8952f

Please sign in to comment.