Skip to content

Commit 0f975fb

Browse files
committed
Merge branch 'dev' into README/ethan
2 parents 76124ea + 5a8c9ea commit 0f975fb

File tree

173 files changed

+3152
-5110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+3152
-5110
lines changed

__tests__/businessReducer.js

Lines changed: 245 additions & 83 deletions
Large diffs are not rendered by default.

__tests__/composerTests.js

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,59 @@
11
/* eslint-disable react/jsx-props-no-spreading */
22
import React from 'react';
3-
import { configure, shallow } from 'enzyme';
4-
import Adapter from 'enzyme-adapter-react-16';
53
import ProtocolSelect from '../src/client/components/composer/NewRequest/ProtocolSelect.jsx';
64

7-
configure({ adapter: new Adapter() });
5+
// Commented out this file since it is using Enzyme, which has been falling out of favor and currently does not work for this app version
6+
// TODO: for the next tester, recommended to migrate to React Testing Library
87

9-
describe('GraphQL Composer', () => {
10-
const state = {
11-
currentTab: 'First Tab',
12-
reqResArray: [],
13-
history: [],
14-
warningMessage: '',
15-
newRequestFields: {
16-
method: 'GET',
17-
protocol: '',
18-
url: '',
19-
graphQL: false,
20-
},
21-
newRequestHeaders: {
22-
headersArr: [],
23-
count: 0,
24-
},
25-
newRequestCookies: {
26-
cookiesArr: [],
27-
count: 0,
28-
},
29-
newRequestBody: {
30-
bodyContent: '',
31-
bodyType: 'raw',
32-
rawType: 'text/plain',
33-
JSONFormatted: true,
34-
bodyVariables: '',
35-
},
36-
};
37-
describe('Setting GQL fields, headers, and body', () => {
38-
describe('ProtocolSelect', () => {
39-
let wrapper;
40-
const props = {
41-
currentProtocol: '',
42-
onChangeHandler: jest.fn(),
43-
graphQL: false,
44-
};
8+
// import { configure, shallow } from 'enzyme';
9+
// import Adapter from 'enzyme-adapter-react-16';
4510

46-
beforeAll(() => {
47-
wrapper = shallow(<ProtocolSelect {...props} />);
48-
});
11+
// configure({ adapter: new Adapter() });
4912

50-
it('Renders a <div>', () => {
51-
expect(wrapper.type()).toEqual('div');
52-
});
53-
});
54-
});
55-
});
13+
// describe('GraphQL Composer', () => {
14+
// const state = {
15+
// currentTab: 'First Tab',
16+
// reqResArray: [],
17+
// history: [],
18+
// warningMessage: '',
19+
// newRequestFields: {
20+
// method: 'GET',
21+
// protocol: '',
22+
// url: '',
23+
// graphQL: false,
24+
// },
25+
// newRequestHeaders: {
26+
// headersArr: [],
27+
// count: 0,
28+
// },
29+
// newRequestCookies: {
30+
// cookiesArr: [],
31+
// count: 0,
32+
// },
33+
// newRequestBody: {
34+
// bodyContent: '',
35+
// bodyType: 'raw',
36+
// rawType: 'text/plain',
37+
// JSONFormatted: true,
38+
// bodyVariables: '',
39+
// },
40+
// };
41+
// describe('Setting GQL fields, headers, and body', () => {
42+
// describe('ProtocolSelect', () => {
43+
// let wrapper;
44+
// const props = {
45+
// currentProtocol: '',
46+
// onChangeHandler: jest.fn(),
47+
// graphQL: false,
48+
// };
49+
50+
// beforeAll(() => {
51+
// wrapper = shallow(<ProtocolSelect {...props} />);
52+
// });
53+
54+
// it('Renders a <div>', () => {
55+
// expect(wrapper.type()).toEqual('div');
56+
// });
57+
// });
58+
// });
59+
// });

__tests__/dbTests.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,3 @@ describe('db test', () => {
5252
});
5353
});
5454
});
55-
// describe("collection tests", () => {});
56-
// });

__tests__/httpTest.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import ReqResCtrl from '../src/client/controllers/reqResController';
22

3-
xdescribe('REST API Requests', () => {
3+
// TODO: Integration tests with the actual API. The controller calls api.send and api.recieve
4+
// without attachement to the API, the tests in this file don't perform anything.
5+
// Additionally, add a testing file for graphQLController. This is currently untested
6+
// and is a dependency for reqResController.
7+
8+
describe('REST API Requests', () => {
49
let state;
510
beforeEach(() => {
611
state = {
@@ -104,9 +109,13 @@ xdescribe('REST API Requests', () => {
104109
tab: 'First Tab',
105110
};
106111

107-
ReqResCtrl.openReqRes(request);
112+
state = ReqResCtrl.openReqRes(request);
108113
const response = state.reqResArray[0];
109114
expect(response.toEqual('hello'));
110115
});
116+
117+
it('should toggle select all',()=>{
118+
expect(ReqResCtrl.toggleSelectAll()).not.toThrowError;
119+
})
111120
});
112121
});

__tests__/openAPIParserTest.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
import openapiParserFunc from '../main_process/openapiParser'
5+
6+
// TODO: Test actual contents of the parser
7+
8+
describe('openAPI Parser tests',()=>{
9+
const file = fs.readFileSync(path.resolve(__dirname + '/../test/openAPITestDefinition.yaml'))
10+
11+
it('should be able to parse a yaml file',()=>{
12+
const { openapiMetadata, openapiReqArray } = openapiParserFunc(String(file))
13+
expect(openapiMetadata).toBeDefined();
14+
expect(openapiReqArray).toBeDefined();
15+
})
16+
17+
it('should error on undefined input',()=>{
18+
expect(openapiParserFunc(null)).toThrow(ReferenceError);
19+
})
20+
});

__tests__/uiReducer.js

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
import uiReducer from '../src/client/reducers/ui';
1+
import reducer,{
2+
setSidebarActiveTab,
3+
setWorkspaceActiveTab,
4+
setResponsePaneActiveTab,
5+
toggleDarkMode,
6+
} from '../src/client/features/ui/uiSlice.ts';
27

38
describe('UI Reducer', () => {
49
let state;
510

611
beforeEach(() => {
712
state = {
8-
composerDisplay: 'Request',
13+
isDark: false,
914
sidebarActiveTab: 'composer',
1015
workspaceActiveTab: 'workspace',
1116
responsePaneActiveTab: 'events',
@@ -14,22 +19,57 @@ describe('UI Reducer', () => {
1419

1520
describe('default state', () => {
1621
it('should return a default state when given an undefined input', () => {
17-
expect(uiReducer(undefined, { type: undefined })).toEqual(state);
22+
expect(reducer(undefined, { type: undefined })).toEqual(state);
1823
});
1924
it('should return default state with unrecognized action types', () => {
20-
expect(uiReducer(undefined, { type: 'BAD_TYPE' })).toEqual(state);
25+
expect(reducer(undefined, { type: 'BAD_TYPE' })).toEqual(state);
26+
});
27+
});
28+
29+
describe('Set sidebar active tab', () => {
30+
const action = {
31+
payload: 'the active sidebar tab is this one!',
32+
};
33+
34+
it('sets the sidebar active tab', () => {
35+
const { sidebarActiveTab } = reducer(state, setSidebarActiveTab(action.payload));
36+
expect(sidebarActiveTab).toEqual(action.payload);
37+
});
38+
});
39+
40+
describe('Set workspace active tab', () => {
41+
const action = {
42+
payload: 'the active workspace tab is this one!',
43+
};
44+
45+
it('sets the workspace active tab', () => {
46+
const { workspaceActiveTab } = reducer(state, setWorkspaceActiveTab(action.payload));
47+
expect(workspaceActiveTab).toEqual(action.payload);
2148
});
2249
});
2350

24-
describe('should handle SET_COMPOSER_DISPLAY', () => {
51+
describe('Set response pane active tab', () => {
2552
const action = {
26-
type: 'SET_COMPOSER_DISPLAY',
27-
payload: 'warning',
53+
payload: 'the active response pane tab is this one!',
2854
};
2955

30-
it('should update the composerDisplay', () => {
31-
const { composerDisplay } = uiReducer(state, action);
32-
expect(composerDisplay).toEqual(action.payload);
56+
it('sets the response pane active tab', () => {
57+
const { responsePaneActiveTab } = reducer(state, setResponsePaneActiveTab(action.payload));
58+
expect(responsePaneActiveTab).toEqual(action.payload);
3359
});
3460
});
61+
62+
describe('Toggle dark mode', () => {
63+
const action = {
64+
payload: true,
65+
};
66+
67+
it('Toggles dark mode', () => {
68+
const newState = reducer(state, toggleDarkMode(false));
69+
expect(newState.isDark).toEqual(false);
70+
const { isDark } = reducer(newState, toggleDarkMode(action.payload));
71+
expect(isDark).toEqual(true);
72+
});
73+
});
74+
3575
});

main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ function createWindow() {
117117
mainWindow = new BrowserWindow({
118118
width: 2000,
119119
height: 1000,
120-
minWidth: 1304,
121-
minHeight: 700,
120+
minWidth: 1000,
121+
minHeight: 600,
122122
backgroundColor: '-webkit-linear-gradient(top, #3dadc2 0%,#2f4858 100%)',
123123
show: false,
124124
webPreferences: {

0 commit comments

Comments
 (0)