Skip to content

Commit 039c121

Browse files
authored
E2e/mock-test-fixture (#7086)
* fix export * add fixture * use fixture
1 parent 8f1a503 commit 039c121

3 files changed

Lines changed: 82 additions & 2 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
_type: export
2+
__export_format: 4
3+
__export_date: 2024-02-13T08:30:28.222Z
4+
__export_source: insomnia.desktop.app:v8.6.1
5+
resources:
6+
- _id: wrk_916200a8d0c547e8acd3cbe7f61eace2
7+
type: Workspace
8+
parentId: proj_81ab89da399f466e9b3d32f8ec92b8c8
9+
modified: 1707812060949
10+
created: 1707812060949
11+
name: My API Mock
12+
description: ""
13+
scope: mock-server
14+
_type: workspace
15+
- _id: mock_07f41ce980d9410f9634e9ae1e404cab
16+
type: MockServer
17+
parentId: wrk_916200a8d0c547e8acd3cbe7f61eace2
18+
modified: 1707812060951
19+
created: 1707812060951
20+
name: My API Mock
21+
url: http://localhost:8080
22+
useInsomniaCloud: true
23+
_type: mock
24+
- _id: mock-route_4923148ad44e4426ba09347b0b732d7e
25+
type: MockRoute
26+
parentId: mock_07f41ce980d9410f9634e9ae1e404cab
27+
modified: 1707812450193
28+
created: 1707812109633
29+
body: '{"message":"welcome"}'
30+
headers:
31+
- id: pair_b466a74db8ed40fcbbe8f84136f204f8
32+
name: X-Mockbin-Test
33+
value: "true"
34+
description: ""
35+
statusCode: 200
36+
statusText: ""
37+
name: /
38+
mimeType: application/json
39+
method: GET
40+
_type: mock_route
41+
- _id: mock-route_3ed9f6dc6b4840d1b82ce047da2fdad2
42+
type: MockRoute
43+
parentId: mock_07f41ce980d9410f9634e9ae1e404cab
44+
modified: 1707812454502
45+
created: 1707812408451
46+
body: '{"uptime":12345678}'
47+
headers:
48+
- id: pair_d0a6e2d6a3614e05943cf156e52134d8
49+
name: X-Mockbin-Test
50+
value: test
51+
description: ""
52+
statusCode: 200
53+
statusText: ""
54+
name: /healthcheck
55+
mimeType: application/json
56+
method: GET
57+
_type: mock_route
58+
- _id: mock-route_9df5850642c741eca8b52b0491827b9e
59+
type: MockRoute
60+
parentId: mock_07f41ce980d9410f9634e9ae1e404cab
61+
modified: 1707812514106
62+
created: 1707812462239
63+
body: '{"message":"email is required"}'
64+
headers: []
65+
statusCode: 401
66+
statusText: ""
67+
name: /unauthorized
68+
mimeType: application/json
69+
method: GET
70+
_type: mock_route

packages/insomnia-smoke-test/tests/smoke/mock.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
import { loadFixture } from '../../playwright/paths';
12
import { test } from '../../playwright/test';
23

3-
test('can make a mock route', async ({ page }) => {
4+
test('can make a mock route', async ({ app, page }) => {
45
test.slow(process.platform === 'darwin' || process.platform === 'win32', 'Slow app start on these platforms');
6+
const text = await loadFixture('smoke-test-collection.yaml');
7+
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);
8+
9+
await page.getByRole('button', { name: 'Create in project' }).click();
10+
await page.getByRole('menuitemradio', { name: 'Import' }).click();
11+
await page.locator('[data-test-id="import-from-clipboard"]').click();
12+
await page.getByRole('button', { name: 'Scan' }).click();
13+
await page.getByRole('dialog').getByRole('button', { name: 'Import' }).click();
14+
515
await page.getByLabel('New Mock Server').click();
616
await page.getByRole('button', { name: 'Create', exact: true }).click();
717
await page.getByRole('button', { name: 'New Mock Route' }).click();

packages/insomnia/src/common/export.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ export const exportMockServerToFile = async (workspace: Workspace) => {
465465
return;
466466
}
467467
try {
468-
const stringifiedExport = await exportMockServer(workspace, 'json');
468+
const stringifiedExport = await exportMockServer(workspace, selectedFormat);
469469
writeExportedFileToFileSystem(fileName, stringifiedExport, err => err && console.warn('Export failed', err));
470470
window.main.trackSegmentEvent({ event: SegmentEvent.dataExport, properties: { type: selectedFormat, scope: 'mock-server' } });
471471
} catch (err) {

0 commit comments

Comments
 (0)