mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
[INS-2082] Add prerelease tests for Design interactions (#5415)
* initial commit * Add prerelease tests for Unit Test feature * Add test to import oa3 spec into design doc
This commit is contained in:
parent
c7eeaa3a6c
commit
943c28cc12
@ -1,5 +1,6 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
description: this is an example description in an OpenAPI Doc
|
||||
title: Smoke Test API server
|
||||
version: 1.0.0
|
||||
servers:
|
||||
|
114
packages/insomnia-smoke-test/fixtures/unit-test.yaml
Normal file
114
packages/insomnia-smoke-test/fixtures/unit-test.yaml
Normal file
@ -0,0 +1,114 @@
|
||||
_type: export
|
||||
__export_format: 4
|
||||
__export_date: 2022-11-21T14:14:03.301Z
|
||||
__export_source: insomnia.desktop.app:v2022.7.0-beta.5
|
||||
resources:
|
||||
- _id: req_c54dc17f938c4b018c0e0f1f64e0ad73
|
||||
parentId: wrk_2863ca2fd18d40efac9fe80a23c7533b
|
||||
modified: 1669039727273
|
||||
created: 1669039715014
|
||||
url: localhost:4010/not-found
|
||||
name: request B
|
||||
description: ""
|
||||
method: GET
|
||||
body: {}
|
||||
parameters: []
|
||||
headers: []
|
||||
authentication: {}
|
||||
metaSortKey: -1669039715014
|
||||
isPrivate: false
|
||||
settingStoreCookies: true
|
||||
settingSendCookies: true
|
||||
settingDisableRenderRequestBody: false
|
||||
settingEncodeUrl: true
|
||||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
_type: request
|
||||
- _id: wrk_2863ca2fd18d40efac9fe80a23c7533b
|
||||
parentId: null
|
||||
modified: 1669039672707
|
||||
created: 1669039672707
|
||||
name: unit-test.yaml
|
||||
description: ""
|
||||
scope: design
|
||||
_type: workspace
|
||||
- _id: req_17ca8bbd46374144a089f891e32842d6
|
||||
parentId: wrk_2863ca2fd18d40efac9fe80a23c7533b
|
||||
modified: 1669039709867
|
||||
created: 1669039678415
|
||||
url: localhost:4010
|
||||
name: request A
|
||||
description: ""
|
||||
method: GET
|
||||
body:
|
||||
mimeType: application/json
|
||||
text: |-
|
||||
{
|
||||
"test": 123
|
||||
}
|
||||
parameters: []
|
||||
headers:
|
||||
- name: Content-Type
|
||||
value: application/json
|
||||
authentication: {}
|
||||
metaSortKey: -1669039678415
|
||||
isPrivate: false
|
||||
settingStoreCookies: true
|
||||
settingSendCookies: true
|
||||
settingDisableRenderRequestBody: false
|
||||
settingEncodeUrl: true
|
||||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
_type: request
|
||||
- _id: env_b01fdb83e35f3937f7d22870371ebdee5c15f190
|
||||
parentId: wrk_2863ca2fd18d40efac9fe80a23c7533b
|
||||
modified: 1669039672710
|
||||
created: 1669039672710
|
||||
name: Base Environment
|
||||
data: {}
|
||||
dataPropertyOrder: null
|
||||
color: null
|
||||
isPrivate: false
|
||||
metaSortKey: 1669039672710
|
||||
_type: environment
|
||||
- _id: jar_b01fdb83e35f3937f7d22870371ebdee5c15f190
|
||||
parentId: wrk_2863ca2fd18d40efac9fe80a23c7533b
|
||||
modified: 1669039672710
|
||||
created: 1669039672710
|
||||
name: Default Jar
|
||||
cookies: []
|
||||
_type: cookie_jar
|
||||
- _id: spc_556f1031c81a4e7c998ea93d89781416
|
||||
parentId: wrk_2863ca2fd18d40efac9fe80a23c7533b
|
||||
modified: 1669039672707
|
||||
created: 1669039672707
|
||||
fileName: unit-test.yaml
|
||||
contents: ""
|
||||
contentType: yaml
|
||||
_type: api_spec
|
||||
- _id: uts_d950d2775c194d66b0339bf01435a965
|
||||
parentId: wrk_2863ca2fd18d40efac9fe80a23c7533b
|
||||
modified: 1669039741641
|
||||
created: 1669039741641
|
||||
name: Existing Test Suite
|
||||
_type: unit_test_suite
|
||||
- _id: ut_20534ebe980c46228c25b665422263ea
|
||||
parentId: uts_d950d2775c194d66b0339bf01435a965
|
||||
modified: 1669039779620
|
||||
created: 1669039749000
|
||||
requestId: req_17ca8bbd46374144a089f891e32842d6
|
||||
name: Request A is found
|
||||
code: |-
|
||||
const response1 = await insomnia.send();
|
||||
expect(response1.status).to.equal(200);
|
||||
_type: unit_test
|
||||
- _id: ut_38716a279d4945de952d74cd9d2012b6
|
||||
parentId: uts_d950d2775c194d66b0339bf01435a965
|
||||
modified: 1669039788840
|
||||
created: 1669039754892
|
||||
requestId: req_c54dc17f938c4b018c0e0f1f64e0ad73
|
||||
name: Request B is not found
|
||||
code: |-
|
||||
const response1 = await insomnia.send();
|
||||
expect(response1.status).to.equal(404);
|
||||
_type: unit_test
|
@ -0,0 +1,99 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadFixture } from '../../playwright/paths';
|
||||
import { test } from '../../playwright/test';
|
||||
|
||||
test.describe('Design interactions', async () => {
|
||||
|
||||
test.fixme('Requests are auto-generated when switching tabs', async ({ page }) => {
|
||||
// TODO(filipe) - this is currently not working
|
||||
await page.click('[data-testid="project"] >> text=Insomnia');
|
||||
await expect(true).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Can import an OpenAPI 3 spec into a Design Document', async ({ app, page }) => {
|
||||
// Setup
|
||||
await page.click('[data-testid="project"] >> text=Insomnia');
|
||||
await page.click('text=Create');
|
||||
const text = await loadFixture('openapi3.yaml');
|
||||
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);
|
||||
await page.click('button:has-text("Clipboard")');
|
||||
await page.click('div[role="dialog"] button:has-text("New")');
|
||||
await page.click('div[role="dialog"] >> text=Design Document');
|
||||
await page.click('text=DocumentSmoke Test API server 1.0.0v1.0.0OpenAPI 3.0.0just now');
|
||||
|
||||
// Renders the spec code and preview
|
||||
const codeEditor = page.locator('.pane-one');
|
||||
await expect(codeEditor).toContainText('openapi: 3.0.0');
|
||||
const specPreview = page.locator('.information-container');
|
||||
await expect(specPreview).toContainText('this is an example description in an OpenAPI Doc');
|
||||
|
||||
// Created requests from spec
|
||||
await page.locator('text=Debug').click();
|
||||
await expect(page.locator('.app')).toContainText('File');
|
||||
await expect(page.locator('.app')).toContainText('Misc');
|
||||
await expect(page.locator('.app')).toContainText('Auth');
|
||||
|
||||
// Created Environment from spec
|
||||
await page.click('#wrapper button:has-text("OpenAPI env")');
|
||||
await page.click('button:has-text("Manage Environments")');
|
||||
await page.click('text=/.*"localhost:4010".*/');
|
||||
});
|
||||
|
||||
test.fixme('Can filter values in Design sidebar', async ({ page }) => {
|
||||
// TODO(filipe) implement in another PR
|
||||
await page.click('[data-testid="project"] >> text=Insomnia');
|
||||
await expect(true).toBeTruthy();
|
||||
});
|
||||
|
||||
test.fixme('[INS-567] Requests are not duplicated when switching between tabs', async ({ page }) => {
|
||||
// TODO(filipe) implement in another PR
|
||||
await page.click('[data-testid="project"] >> text=Insomnia');
|
||||
await expect(true).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Unit Test interactions', async ({ app, page }) => {
|
||||
// Setup
|
||||
await page.click('[data-testid="project"] >> text=Insomnia');
|
||||
await page.click('text=Create');
|
||||
const text = await loadFixture('unit-test.yaml');
|
||||
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);
|
||||
await page.click('button:has-text("Clipboard")');
|
||||
await page.click('text=unit-test.yamljust now');
|
||||
|
||||
// Switch to Test tab
|
||||
await page.click('a:has-text("Test")');
|
||||
|
||||
// Run tests and check results
|
||||
await page.click('#wrapper >> text=Run Tests');
|
||||
await expect(page.locator('.app')).toContainText('Request A is found');
|
||||
await expect(page.locator('.app')).toContainText('Request B is not found');
|
||||
await expect(page.locator('.app')).toContainText('Tests Passed 2/2');
|
||||
|
||||
// Create a new test suite
|
||||
await page.click('text=New Test Suite');
|
||||
await page.click('text=Create Suite');
|
||||
await page.click('button:has-text("New Suite")');
|
||||
|
||||
// Add a new test
|
||||
await page.locator('text=New Test').nth(1).click();
|
||||
await page.click('div[role="dialog"] button:has-text("New Test")');
|
||||
await page.locator('select[name="request"]').selectOption('req_17ca8bbd46374144a089f891e32842d6');
|
||||
|
||||
await page.click('#wrapper >> text=Run Tests');
|
||||
await expect(page.locator('.app')).toContainText('Tests Passed 1/1');
|
||||
|
||||
// Rename a test
|
||||
// TODO(filipe) - add this in another PR
|
||||
|
||||
// Rename a test suite
|
||||
await page.click('button:has-text("Existing Test Suite")');
|
||||
await page.click('span:has-text("Existing Test Suite")');
|
||||
await page.locator('text=New TestRun Tests >> input[type="text"]').fill('Renamed');
|
||||
await page.locator('text=New TestRun Tests >> input[type="text"]').press('Enter');
|
||||
await page.click('button:has-text("Renamed")');
|
||||
|
||||
// Use autocomplete inside the test code
|
||||
// TODO(filipe) - add this in another PR
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user