2020-11-25 02:26:00 +00:00
|
|
|
import findAsync from './find-async';
|
|
|
|
|
2021-03-03 20:00:56 +00:00
|
|
|
const findDropdownItemWithText = async (parent, text, fromComponentLibrary) => {
|
2020-11-25 02:26:00 +00:00
|
|
|
let item;
|
2021-03-03 20:00:56 +00:00
|
|
|
await parent.waitUntil(async () => {
|
|
|
|
const items = fromComponentLibrary
|
|
|
|
? await parent.$$('button[class^=dropdown-item]')
|
|
|
|
: await parent.react$$('DropdownItem');
|
2020-11-25 02:26:00 +00:00
|
|
|
item = await findAsync(items, async i => (await i.getText()) === text);
|
|
|
|
return !!item;
|
|
|
|
});
|
2021-03-03 20:00:56 +00:00
|
|
|
return item;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const clickDropdownItemByText = async (parent, text, fromComponentLibrary = false) => {
|
|
|
|
const item = await findDropdownItemWithText(parent, text, fromComponentLibrary);
|
2020-11-25 02:26:00 +00:00
|
|
|
await item.waitForDisplayed();
|
|
|
|
await item.click();
|
|
|
|
};
|
2020-12-04 21:47:04 +00:00
|
|
|
|
|
|
|
export const clickOpenDropdownItemByText = async (app, text) => {
|
|
|
|
const item = await app.client
|
|
|
|
.$('.dropdown__menu[aria-hidden=false]')
|
|
|
|
.then(e => e.$(`button*=${text}`));
|
|
|
|
await item.waitForDisplayed();
|
|
|
|
await item.click();
|
|
|
|
};
|