insomnia/packages/insomnia-smoke-test/modules/modal.js
2020-11-25 15:26:00 +13:00

23 lines
643 B
JavaScript

import findAsync from './find-async';
export const waitUntilOpened = async (app, { modalName, title }) => {
if (modalName) {
const modal = await app.client.react$(modalName);
await modal.waitForDisplayed();
} else {
await app.client.waitUntilTextExists('div.modal__header__children', title);
}
};
export const close = async (app, modalName) => {
let modal;
if (modalName) {
modal = await app.client.react$(modalName);
} else {
const modals = await app.client.react$$('Modal');
modal = await findAsync(modals, m => m.isDisplayed());
}
await modal.$('button.modal__close-btn').then(e => e.click());
};