insomnia/packages/insomnia-smoke-test/modules/modal.js
Opender Singh aeafe4a7c9
Import a spec and execute a request (#2887)
* feat: add swagger2 for prism

* feat: add test stub

* feat: can import from clipboard

* feat: click folder, request and send

* chore: add comments

* fix: now it actually breaks

* fix: typo

* fix: update webdriver implicit timeout

* feat: replace prism with tinyhttp (similar to express)
2020-12-05 10:47:04 +13:00

31 lines
939 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());
};
export const clickModalFooterByText = async (app, modalName, text) => {
const modal = await app.client.react$(modalName);
await modal.waitForDisplayed();
const btn = await modal.$(`.modal__footer`).then(e => e.$(`button*=${text}`));
await btn.waitForClickable();
await btn.click();
};