2020-08-24 22:49:29 +00:00
|
|
|
const workspaceDropdownExists = async (app, workspaceName = 'Insomnia') => {
|
|
|
|
await app.client.waitUntilTextExists('.workspace-dropdown', workspaceName);
|
|
|
|
};
|
|
|
|
|
2020-09-17 18:05:53 +00:00
|
|
|
const createNewRequest = async (app, name = undefined) => {
|
|
|
|
await app.client.$('.sidebar .dropdown .fa-plus-circle').then(e => e.click());
|
|
|
|
|
|
|
|
await app.client
|
|
|
|
.$('[aria-hidden=false]')
|
|
|
|
.then(e => e.$('button*=New Request'))
|
|
|
|
.then(e => e.click());
|
|
|
|
|
|
|
|
// Wait for modal to open
|
|
|
|
await app.client.waitUntilTextExists('.modal__header', 'New Request');
|
|
|
|
|
|
|
|
// Set name and create request
|
|
|
|
const input = await app.client.$('.modal input');
|
|
|
|
|
|
|
|
if (name) {
|
|
|
|
await input.waitUntil(() => input.isFocused());
|
|
|
|
await input.keys(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
await app.client
|
|
|
|
.$('.modal .modal__footer')
|
|
|
|
.then(e => e.$('button=Create'))
|
|
|
|
.then(e => e.click());
|
|
|
|
};
|
|
|
|
|
|
|
|
const typeUrl = async (app, url) => {
|
|
|
|
const urlEditor = await app.client.$('.urlbar .editor .input');
|
2020-09-22 20:06:54 +00:00
|
|
|
await typeCodeMirror(app, urlEditor, url, 500);
|
2020-09-17 18:05:53 +00:00
|
|
|
};
|
|
|
|
|
2020-09-21 06:17:31 +00:00
|
|
|
const typeCodeMirror = async (app, element, value, debounceWait) => {
|
2020-09-17 18:05:53 +00:00
|
|
|
await element.click();
|
|
|
|
const cm = await element.$('.CodeMirror');
|
|
|
|
await cm.waitForExist();
|
|
|
|
await cm.keys(value);
|
2020-09-21 06:17:31 +00:00
|
|
|
|
|
|
|
// Wait for the code-editor debounce
|
|
|
|
await app.client.pause(debounceWait);
|
2020-09-17 18:05:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const clickSendRequest = async app => {
|
|
|
|
await app.client.$('.urlbar__send-btn').then(e => e.click());
|
|
|
|
};
|
|
|
|
|
|
|
|
const expect200 = async app => {
|
|
|
|
const tag = await app.client.$('.response-pane .pane__header .tag.bg-success');
|
|
|
|
await tag.waitForDisplayed();
|
|
|
|
await expect(tag.getText()).resolves.toBe('200 OK');
|
|
|
|
};
|
|
|
|
|
|
|
|
const getCsvViewer = async app => {
|
|
|
|
const csvViewer = await app.client.react$('ResponseCSVViewer');
|
|
|
|
await csvViewer.waitForDisplayed();
|
|
|
|
return csvViewer;
|
|
|
|
};
|
|
|
|
|
2020-09-21 08:45:36 +00:00
|
|
|
const getPdfCanvas = async app => {
|
|
|
|
const pdfViewer = await app.client.react$('ResponsePDFViewer');
|
|
|
|
await pdfViewer.waitForDisplayed();
|
|
|
|
const canvas = await pdfViewer.$('.S-PDF-ID canvas');
|
|
|
|
await canvas.waitForDisplayed();
|
|
|
|
return canvas;
|
|
|
|
};
|
|
|
|
|
2020-08-24 22:49:29 +00:00
|
|
|
module.exports = {
|
|
|
|
workspaceDropdownExists,
|
2020-09-17 18:05:53 +00:00
|
|
|
createNewRequest,
|
|
|
|
typeUrl,
|
|
|
|
clickSendRequest,
|
|
|
|
expect200,
|
|
|
|
getCsvViewer,
|
2020-09-21 08:45:36 +00:00
|
|
|
getPdfCanvas,
|
2020-08-24 22:49:29 +00:00
|
|
|
};
|