mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
aeafe4a7c9
* 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)
105 lines
2.9 KiB
JavaScript
105 lines
2.9 KiB
JavaScript
import faker from 'faker';
|
|
|
|
export const workspaceDropdownExists = async (app, workspaceName = 'Insomnia') => {
|
|
await app.client.waitUntilTextExists('.workspace-dropdown', workspaceName);
|
|
};
|
|
|
|
export const clickWorkspaceDropdown = async app => {
|
|
const dropdown = await app.client.react$('WorkspaceDropdown');
|
|
await dropdown.click();
|
|
return dropdown;
|
|
};
|
|
|
|
export const createNewRequest = async (app, name) => {
|
|
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');
|
|
|
|
const requestName = `${name}-${faker.lorem.slug()}`;
|
|
await input.waitUntil(() => input.isFocused());
|
|
await input.keys(requestName);
|
|
|
|
await app.client
|
|
.$('.modal .modal__footer')
|
|
.then(e => e.$('button=Create'))
|
|
.then(e => e.click());
|
|
|
|
await waitUntilRequestIsActive(app, requestName);
|
|
};
|
|
|
|
const waitUntilRequestIsActive = async (app, name) => {
|
|
const request = await app.client.react$('SidebarRequestRow', {
|
|
props: { isActive: true, request: { name } },
|
|
});
|
|
|
|
await request.waitForDisplayed();
|
|
};
|
|
|
|
export const clickFolderByName = async (app, name) => {
|
|
const folder = await app.client.react$('SidebarRequestGroupRow', {
|
|
props: { requestGroup: { name } },
|
|
});
|
|
|
|
await folder.waitForClickable();
|
|
await folder.click();
|
|
};
|
|
|
|
export const clickRequestByName = async (app, name) => {
|
|
const folder = await app.client.react$('SidebarRequestRow', {
|
|
props: { request: { name } },
|
|
});
|
|
|
|
await folder.waitForClickable();
|
|
await folder.click();
|
|
};
|
|
|
|
export const typeInUrlBar = async (app, url) => {
|
|
const urlEditor = await app.client.react$('RequestUrlBar');
|
|
await urlEditor.waitForExist();
|
|
await urlEditor.click();
|
|
await urlEditor.keys(url);
|
|
};
|
|
|
|
export const clickSendRequest = async app => {
|
|
await app.client
|
|
.react$('RequestUrlBar')
|
|
.then(e => e.$('.urlbar__send-btn'))
|
|
.then(e => e.click());
|
|
|
|
// Wait for spinner to show
|
|
const spinner = await app.client.react$('ResponseTimer');
|
|
await spinner.waitForDisplayed();
|
|
|
|
// Wait for spinner to hide
|
|
await spinner.waitForDisplayed({ reverse: true });
|
|
};
|
|
|
|
export 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');
|
|
};
|
|
|
|
export const getCsvViewer = async app => {
|
|
const csvViewer = await app.client.react$('ResponseCSVViewer');
|
|
await csvViewer.waitForDisplayed();
|
|
return csvViewer;
|
|
};
|
|
|
|
export 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;
|
|
};
|