mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
8585eea9e6
* now with 100% fat free cancellation Co-authored-by: James Gatz <jamesgatzos@gmail.com> * unblock electron 15 * fix cookielist and temp fix curl types * fix types * fix inso * default to verbose inso test * implement readdata function * fix test * revert test changes * isomorphic cancel * reduce typing issues * curl types * turns out the tests were wrong * handle errors * remove unused inso mock * remove request delay * fix lint and add logs * Revert "remove request delay" This reverts commit f07d8c90a7a7279ca10f8a8de1ea0c82caa06390. * simplify and add cancel fallback * skip cancel test * playwright is fast and insomnia is slow * trailing spaces are serious yo * cancel is flake town * hmm * unblock nunjucks and storeTimeline * fix nunjucks tests * preload writeFile * oops forgot to remove the reload * debugging CI takes all day, log stuff and pray * also warn if nunjucks is being lame * Stop using environment variables * revert debugging logs Co-authored-by: James Gatz <jamesgatzos@gmail.com> Co-authored-by: David Marby <david@dmarby.se>
86 lines
4.0 KiB
TypeScript
86 lines
4.0 KiB
TypeScript
import { expect } from '@playwright/test';
|
|
|
|
import { loadFixture } from '../playwright/paths';
|
|
import { test } from '../playwright/test';
|
|
|
|
test('can send requests', async ({ app, page }) => {
|
|
test.slow(process.platform === 'darwin' || process.platform === 'win32', 'Slow app start on these platforms');
|
|
const statusTag = page.locator('[data-testid="response-status-tag"]:visible');
|
|
const responseBody = page.locator('[data-testid="CodeEditor"]:visible', {
|
|
has: page.locator('.CodeMirror-activeline'),
|
|
});
|
|
|
|
await page.click('[data-testid="project"]');
|
|
await page.click('text=Create');
|
|
|
|
const text = await loadFixture('smoke-test-collection.yaml');
|
|
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);
|
|
|
|
await page.click('button:has-text("Clipboard")');
|
|
await page.click('text=CollectionSmoke testsjust now');
|
|
|
|
await page.click('button:has-text("GETsend JSON request")');
|
|
await page.click('text=http://127.0.0.1:4010/pets/1Send >> button');
|
|
await expect(statusTag).toContainText('200 OK');
|
|
await expect(responseBody).toContainText('"id": "1"');
|
|
await page.click('button:has-text("Preview")');
|
|
await page.click('button:has-text("Raw Data")');
|
|
await expect(responseBody).toContainText('{"id":"1"}');
|
|
|
|
await page.click('button:has-text("GETsends dummy.csv request and shows rich response")');
|
|
await page.click('text=http://127.0.0.1:4010/file/dummy.csvSend >> button');
|
|
await expect(statusTag).toContainText('200 OK');
|
|
await page.click('button:has-text("Preview")');
|
|
await page.click('button:has-text("Raw Data")');
|
|
await expect(responseBody).toContainText('a,b,c');
|
|
|
|
await page.click('button:has-text("GETsends dummy.xml request and shows raw response")');
|
|
await page.click('text=http://127.0.0.1:4010/file/dummy.xmlSend >> button');
|
|
await expect(statusTag).toContainText('200 OK');
|
|
await expect(responseBody).toContainText('xml version="1.0"');
|
|
await expect(responseBody).toContainText('<LoginResult>');
|
|
|
|
await page.click('button:has-text("GETsends dummy.pdf request and shows rich response")');
|
|
await page.click('text=http://127.0.0.1:4010/file/dummy.pdfSend >> button');
|
|
await expect(statusTag).toContainText('200 OK');
|
|
await page.click('button:has-text("Preview")');
|
|
await page.click('button:has-text("Raw Data")');
|
|
await expect(responseBody).toContainText('PDF-1.4');
|
|
|
|
await page.click('button:has-text("GETsends request with basic authentication")');
|
|
await page.click('text=http://127.0.0.1:4010/auth/basicSend >> button');
|
|
await expect(statusTag).toContainText('200 OK');
|
|
await expect(responseBody).toContainText('basic auth received');
|
|
|
|
await page.click('button:has-text("GETsends request with cookie and get cookie in response")');
|
|
await page.click('text=http://127.0.0.1:4010/cookiesSend >> button');
|
|
await expect(statusTag).toContainText('200 OK');
|
|
await page.click('[data-testid="response-pane"] >> [role="tab"]:has-text("Timeline")');
|
|
await expect(responseBody).toContainText('Set-Cookie: insomnia-test-cookie=value123');
|
|
});
|
|
|
|
// This feature is unsafe to place beside other tests, cancelling a request can cause network code to block
|
|
// related to https://linear.app/insomnia/issue/INS-973
|
|
test('can cancel requests', async ({ app, page }) => {
|
|
await page.click('[data-testid="project"]');
|
|
await page.click('text=Create');
|
|
|
|
const text = await loadFixture('smoke-test-collection.yaml');
|
|
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);
|
|
|
|
await page.click('button:has-text("Clipboard")');
|
|
await page.click('text=CollectionSmoke testsjust now');
|
|
|
|
await page.click('button:has-text("GETdelayed request")');
|
|
await page.click('text=http://127.0.0.1:4010/delay/seconds/20Send >> button');
|
|
|
|
await page.click('[data-testid="response-pane"] button:has-text("Cancel Request")');
|
|
await page.click('text=Request was cancelled');
|
|
});
|
|
|
|
test('url field is focused for first time users', async ({ page }) => {
|
|
const urlInput = ':nth-match(textarea, 2)';
|
|
const locator = page.locator(urlInput);
|
|
await expect(locator).toBeFocused();
|
|
});
|