Skip to content

Commit 425d078

Browse files
committed
finalized: added comments, TODOs, and suggestions for future devs working in the testing suites
1 parent 03b256f commit 425d078

16 files changed

+187
-25
lines changed

__tests__/composerTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React from 'react';
33
import ProtocolSelect from '../src/client/components/composer/NewRequest/ProtocolSelect.jsx';
44

5-
// Commented out this file since it is using Enzyme, which has been falling out of favor
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
66
// TODO: for the next tester, recommended to migrate to React Testing Library
77

88
// import { configure, shallow } from 'enzyme';

__tests__/httpTest.js

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

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+
38
describe('REST API Requests', () => {
49
let state;
510
beforeEach(() => {
@@ -104,9 +109,13 @@ describe('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+
});

test/openAPITestDefinition.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Sample API
4+
description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
5+
version: 0.1.9
6+
servers:
7+
- url: http://api.example.com/v1
8+
description: Optional server description, e.g. Main (production) server
9+
- url: http://staging-api.example.com
10+
description: Optional server description, e.g. Internal staging server for testing
11+
paths:
12+
/users/{userId}:
13+
get:
14+
summary: Returns a user by ID.
15+
parameters:
16+
- name: userId
17+
in: path
18+
required: true
19+
description: The ID of the user to return.
20+
schema:
21+
type: integer
22+
format: int64
23+
minimum: 1
24+
responses:
25+
'200':
26+
description: A user object.
27+
content:
28+
application/json:
29+
schema:
30+
type: object
31+
properties:
32+
id:
33+
type: integer
34+
format: int64
35+
example: 4
36+
name:
37+
type: string
38+
example: Jessica Smith
39+
'400':
40+
description: The specified user ID is invalid (not a number).
41+
'404':
42+
description: A user with the specified ID was not found.
43+
default:
44+
description: Unexpected error

test/subSuites/appOpens.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Test to see if the Electron application opens and runs properly, with proper windows and
2+
// major component names
3+
14
const fs = require('fs-extra');
25
const {_electron: electron} = require('playwright');
36
const pwTest = require('@playwright/test');

test/subSuites/graphqlTest.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Test GraphQL protocol by introspecting and querying both public and local GraphQL APIs
2+
// TODO: possibly remove our own server from this testing suite and go with a public API.
3+
// Tests may fail due to the user's computer and this testing suite becomes heavier
4+
// with a mock server.
5+
16
const graphqlServer = require('../graphqlServer');
27
const {_electron: electron} = require('playwright');
38
const chai = require('chai')

test/subSuites/graphqlTestingTest.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Confirm testing of request/response works for GraphQL
2+
13
const graphqlServer = require('../graphqlServer');
24
const {_electron: electron} = require('playwright');
35
const chai = require('chai')
@@ -126,9 +128,6 @@ module.exports = () => {
126128
const scriptBody = await codeMirror2.locator('.cm-content');
127129

128130
try {
129-
// for (let i = 0; i < 100; i += 1) {
130-
// await scriptBody.press('Backspace');
131-
// }
132131
scriptBody.fill('')
133132
await scriptBody.fill(script);
134133
} catch (err) {

test/subSuites/grpcTest.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// gRPC tests using "hw2.proto" file to set up gRPC in grpcServer
2+
// TODO: possibly remove our own server from this testing suite and go with a public API.
3+
// Tests may fail due to the user's computer and this testing suite becomes heavier
4+
// with a mock server.
5+
16
const grpcServer = require('../grpcServer.js');
27
const graphqlServer = require('../graphqlServer');
38
const {_electron: electron} = require('playwright');

test/subSuites/grpcTestingTest.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Confirm testing of request/response works for grpc
2+
13
const grpcServer = require('../grpcServer.js');
24
const {_electron: electron} = require('playwright');
35
const chai = require('chai')
@@ -113,9 +115,6 @@ module.exports = () => {
113115
const scriptBody = await codeMirror2.locator('.cm-content');
114116

115117
try {
116-
// for (let i = 0; i < 100; i += 1) {
117-
// await scriptBody.press('Backspace');
118-
// }
119118
scriptBody.fill('')
120119
await scriptBody.fill(script);
121120
} catch (err) {

test/subSuites/httpTest.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// http tests using local server and public API
2+
// TODO: Please note, this is only testing HTTP currently. HTTP2 testing is non-existent and should be added
3+
// TODO: possibly remove our own server from this testing suite and go with a public API.
4+
// Tests may fail due to the user's computer and this testing suite becomes heavier
5+
// with a mock server.
6+
17
const {_electron: electron} = require('playwright');
28
const chai = require('chai')
39
const expect = chai.expect
@@ -83,14 +89,8 @@ module.exports = () => {
8389
const restBody = await codeMirror.locator('.cm-content');
8490

8591
try {
86-
// for (let i = 0; i < 100; i += 1) {
87-
// await restBody.press('Backspace');
88-
// }
8992
restBody.fill('')
9093
await restBody.fill(body);
91-
// for (let i = 0; i < 6; i += 1) {
92-
// await restBody.press('Delete');
93-
// }
9494
} catch (err) {
9595
console.error(err);
9696
}

0 commit comments

Comments
 (0)