2022-01-26 12:31:01 +00:00
|
|
|
import { expect } from '@playwright/test';
|
|
|
|
|
2022-10-11 08:56:12 +00:00
|
|
|
import { loadFixture } from '../../playwright/paths';
|
2023-08-28 13:53:37 +00:00
|
|
|
import { test } from '../../playwright/test';;
|
2021-12-17 12:05:14 +00:00
|
|
|
|
2022-01-24 09:26:53 +00:00
|
|
|
test('can send requests', async ({ app, page }) => {
|
2022-02-17 17:27:29 +00:00
|
|
|
test.slow(process.platform === 'darwin' || process.platform === 'win32', 'Slow app start on these platforms');
|
|
|
|
const statusTag = page.locator('[data-testid="response-status-tag"]:visible');
|
2022-02-24 10:11:46 +00:00
|
|
|
const responseBody = page.locator('[data-testid="CodeEditor"]:visible', {
|
|
|
|
has: page.locator('.CodeMirror-activeline'),
|
|
|
|
});
|
2022-02-17 17:27:29 +00:00
|
|
|
|
2021-12-17 12:05:14 +00:00
|
|
|
const text = await loadFixture('smoke-test-collection.yaml');
|
2022-01-24 09:26:53 +00:00
|
|
|
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);
|
2021-12-17 12:05:14 +00:00
|
|
|
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByRole('button', { name: 'Create in project' }).click();
|
|
|
|
await page.getByRole('menuitemradio', { name: 'Import' }).click();
|
2023-03-31 10:53:22 +00:00
|
|
|
await page.getByText('Clipboard').click();
|
|
|
|
await page.getByRole('button', { name: 'Scan' }).click();
|
2023-06-27 18:46:43 +00:00
|
|
|
await page.getByRole('dialog').getByRole('button', { name: 'Import' }).click();
|
2023-08-18 09:19:35 +00:00
|
|
|
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByRole('button', { name: 'Workspace actions menu button' }).click();
|
2023-08-18 09:19:35 +00:00
|
|
|
await page.getByRole('menuitem', { name: 'Export' }).click();
|
|
|
|
await page.getByRole('dialog').getByRole('checkbox').nth(1).uncheck();
|
|
|
|
await page.getByRole('button', { name: 'Export' }).click();
|
|
|
|
await page.getByText('Which format would you like to export as?').click();
|
|
|
|
await page.locator('.app').press('Escape');
|
|
|
|
|
2023-06-27 15:43:51 +00:00
|
|
|
await page.getByText('CollectionSmoke testsjust now').click();
|
2022-01-19 11:35:03 +00:00
|
|
|
|
2023-08-22 16:12:29 +00:00
|
|
|
await page.getByLabel('Create in collection').click();
|
|
|
|
await page.getByRole('menuitemradio', { name: 'From Curl' }).click();
|
2023-08-25 15:18:48 +00:00
|
|
|
const curl = 'curl --request POST --url http://mockbin.org/status/200';
|
|
|
|
await page.locator('.CodeMirror textarea').fill(curl);
|
|
|
|
await page.getByRole('dialog').getByRole('button', { name: 'Import' }).click();
|
2023-08-16 09:45:20 +00:00
|
|
|
|
|
|
|
await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click();
|
|
|
|
await expect(statusTag).toContainText('200 OK');
|
|
|
|
|
2023-08-22 16:12:29 +00:00
|
|
|
await page.getByLabel('Request Collection').getByRole('row', { name: 'send JSON request' }).click();
|
2023-07-19 09:58:37 +00:00
|
|
|
await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click();
|
2022-02-17 17:27:29 +00:00
|
|
|
await expect(statusTag).toContainText('200 OK');
|
|
|
|
await expect(responseBody).toContainText('"id": "1"');
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('button', { name: 'Preview' }).click();
|
|
|
|
await page.getByRole('menuitem', { name: 'Raw Data' }).click();
|
2022-02-17 17:27:29 +00:00
|
|
|
await expect(responseBody).toContainText('{"id":"1"}');
|
|
|
|
|
2023-08-22 16:12:29 +00:00
|
|
|
await page.getByLabel('Request Collection').getByRole('row', { name: 'connects to event stream and shows ping response' }).click();
|
2023-07-19 09:58:37 +00:00
|
|
|
await page.getByTestId('request-pane').getByRole('button', { name: 'Connect' }).click();
|
|
|
|
await expect(statusTag).toContainText('200 OK');
|
|
|
|
await page.getByRole('tab', { name: 'Timeline' }).click();
|
|
|
|
await expect(responseBody).toContainText('Connected to 127.0.0.1');
|
|
|
|
await page.getByTestId('request-pane').getByRole('button', { name: 'Disconnect' }).click();
|
|
|
|
|
2023-08-22 16:12:29 +00:00
|
|
|
await page.getByLabel('Request Collection').getByRole('row', { name: 'sends dummy.csv request and shows rich response' }).click();
|
2023-07-19 09:58:37 +00:00
|
|
|
await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click();
|
2022-02-17 17:27:29 +00:00
|
|
|
await expect(statusTag).toContainText('200 OK');
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('button', { name: 'Preview' }).click();
|
|
|
|
await page.getByRole('menuitem', { name: 'Raw Data' }).click();
|
2022-02-17 17:27:29 +00:00
|
|
|
await expect(responseBody).toContainText('a,b,c');
|
|
|
|
|
2023-08-22 16:12:29 +00:00
|
|
|
await page.getByLabel('Request Collection').getByRole('row', { name: 'sends dummy.xml request and shows raw response' }).click();
|
2023-07-19 09:58:37 +00:00
|
|
|
await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click();
|
2022-02-17 17:27:29 +00:00
|
|
|
await expect(statusTag).toContainText('200 OK');
|
|
|
|
await expect(responseBody).toContainText('xml version="1.0"');
|
|
|
|
await expect(responseBody).toContainText('<LoginResult>');
|
|
|
|
|
2023-08-22 16:12:29 +00:00
|
|
|
await page.getByLabel('Request Collection').getByRole('row', { name: 'sends dummy.pdf request and shows rich response' }).click();
|
2023-07-19 09:58:37 +00:00
|
|
|
await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click();
|
2022-02-17 17:27:29 +00:00
|
|
|
await expect(statusTag).toContainText('200 OK');
|
2023-01-27 09:28:00 +00:00
|
|
|
// TODO(filipe): re-add a check for the preview that is less flaky
|
|
|
|
await page.getByRole('tab', { name: 'Timeline' }).click();
|
|
|
|
await page.locator('pre').filter({ hasText: '< Content-Type: application/pdf' }).click();
|
2022-02-17 17:27:29 +00:00
|
|
|
|
2023-08-22 16:12:29 +00:00
|
|
|
await page.getByLabel('Request Collection').getByRole('row', { name: 'sends request with basic authentication' }).click();
|
2023-07-19 09:58:37 +00:00
|
|
|
await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click();
|
2022-02-17 17:27:29 +00:00
|
|
|
await expect(statusTag).toContainText('200 OK');
|
|
|
|
await expect(responseBody).toContainText('basic auth received');
|
2022-02-04 12:20:21 +00:00
|
|
|
|
2023-08-22 16:12:29 +00:00
|
|
|
await page.getByLabel('Request Collection').getByRole('row', { name: 'sends request with cookie and get cookie in response' }).click();
|
2023-07-19 09:58:37 +00:00
|
|
|
await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click();
|
2022-02-17 17:27:29 +00:00
|
|
|
await expect(statusTag).toContainText('200 OK');
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('tab', { name: 'Timeline' }).click();
|
2022-02-17 17:27:29 +00:00
|
|
|
await expect(responseBody).toContainText('Set-Cookie: insomnia-test-cookie=value123');
|
|
|
|
});
|
|
|
|
|
2022-03-03 13:42:04 +00:00
|
|
|
// This feature is unsafe to place beside other tests, cancelling a request can cause network code to block
|
2022-02-17 17:27:29 +00:00
|
|
|
// related to https://linear.app/insomnia/issue/INS-973
|
|
|
|
test('can cancel requests', async ({ app, page }) => {
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByRole('button', { name: 'Create in project' }).click();
|
2022-02-17 17:27:29 +00:00
|
|
|
|
|
|
|
const text = await loadFixture('smoke-test-collection.yaml');
|
|
|
|
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);
|
|
|
|
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByRole('menuitemradio', { name: 'Import' }).click();
|
2023-03-31 10:53:22 +00:00
|
|
|
await page.getByText('Clipboard').click();
|
|
|
|
await page.getByRole('button', { name: 'Scan' }).click();
|
2023-06-27 18:46:43 +00:00
|
|
|
await page.getByRole('dialog').getByRole('button', { name: 'Import' }).click();
|
2023-06-27 15:43:51 +00:00
|
|
|
await page.getByText('CollectionSmoke testsjust now').click();
|
2022-02-17 17:27:29 +00:00
|
|
|
|
2023-08-22 16:12:29 +00:00
|
|
|
await page.getByLabel('Request Collection').getByRole('row', { name: 'delayed request' }).click();
|
2023-07-19 09:58:37 +00:00
|
|
|
await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click();
|
2022-03-03 13:42:04 +00:00
|
|
|
|
2023-01-20 14:49:52 +00:00
|
|
|
await page.getByRole('button', { name: 'Cancel Request' }).click();
|
2022-02-17 17:27:29 +00:00
|
|
|
await page.click('text=Request was cancelled');
|
|
|
|
});
|