chore: Improvements to playwright smoke checks (#4480)

* Enable playwright parallelism

Plus, move the cancel request test into its own separate test to reduce flakiness.

* Change num of playwright workers on GH actions back to 1

* Change 200 OK assertion

+ Add assertions to PDF canvas

+ Add assertion to Raw Data preview.

* Add assertions to response body elements

* Undo parallel suite for app.test.ts

* Remove parallelism workers from playwright.config.ts

* Code review improvements

Co-Authored-By: Jack Kavanagh <3679927+jackkav@users.noreply.github.com>
Co-Authored-By: James Gatz <jamesgatzos@gmail.com>

* Code review improvements

Co-Authored-By: Jack Kavanagh <3679927+jackkav@users.noreply.github.com>
Co-Authored-By: James Gatz <jamesgatzos@gmail.com>

Co-authored-by: Jack Kavanagh <3679927+jackkav@users.noreply.github.com>
Co-authored-by: James Gatz <jamesgatzos@gmail.com>
This commit is contained in:
Filipe Freire 2022-02-17 17:27:29 +00:00 committed by GitHub
parent 47db0e3557
commit e31307c61e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 66 additions and 29 deletions

View File

@ -16,7 +16,7 @@ interface PaneBodyProps {
}
export const Pane: React.FC<PaneProps> = ({ className, type, children }) => (
<section className={classnames(`${type}-pane`, 'theme--pane', 'pane', className)}>
<section className={classnames(`${type}-pane`, 'theme--pane', 'pane', className)} data-testid={`${type}-pane`}>
{children}
</section>
);

View File

@ -54,6 +54,7 @@ export const StatusTag: FC<Props> = memo(({ statusMessage, statusCode, small, to
className={classnames('tag', colorClass, {
'tag--small': small,
})}
data-testid="response-status-tag"
>
<Tooltip message={description} position="bottom" delay={tooltipDelay}>
<strong>{statusCodeToDisplay}</strong>{' '}

View File

@ -19,5 +19,8 @@ const config: PlaywrightTestConfig = {
forbidOnly: !!process.env.CI,
outputDir: 'screenshots',
testDir: 'tests',
expect: {
timeout: process.env.CI ? 25 * 1000 : 10 * 1000,
},
};
export default config;

View File

@ -3,13 +3,63 @@ import { expect } from '@playwright/test';
import { loadFixture } from '../playwright/paths';
import { test } from '../playwright/test';
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();
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(.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');
});
test('can send requests', async ({ app, page }) => {
// This feature is unsafe to place beside other tests, cancelling a request causes node-libcurl 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');
@ -23,27 +73,10 @@ test('can send requests', async ({ app, page }) => {
await page.click('text=http://127.0.0.1:4010/delay/seconds/20Send >> button');
await page.click('text=Loading...Cancel Request >> button');
await page.click('text=Request was cancelled');
await page.click('button:has-text("GETsend JSON request")');
await page.click('text=http://127.0.0.1:4010/pets/1Send >> button');
await page.click('text=200 OK');
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 page.click('text=200 OK');
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 page.click('text=200 OK');
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 page.click('text=200 OK');
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 page.click('text=200 OK');
// Send request, check if no cookie was sent (server will reply with received cookies + a new cookie as response)
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 page.click('text=undefined');
// Send request, check if new cookie sent by server in previous request is now also sent
await page.click('text=http://127.0.0.1:4010/cookiesSend >> button');
await page.click('text=insomnia-test-cookie=value123');
});
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();
});