Skip to content

Commit cd1a340

Browse files
Merge pull request #57 from topcoder-platform/automated-postman-testing
Initial PoC for automated Postman E2E testing
2 parents 2dda7e3 + 1ed8a02 commit cd1a340

23 files changed

+3009
-31
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ workflows:
7777
context : org-global
7878
filters:
7979
branches:
80-
only: master
80+
only: master

.circleci/postman.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: 2
2+
jobs:
3+
Run-Newman-Test:
4+
docker:
5+
- image: circleci/node:12
6+
- image: tray/dynamodb-local
7+
command: "-inMemory -port 7777"
8+
- image: elasticsearch:6.8.13
9+
environment:
10+
discovery.type: "single-node"
11+
steps:
12+
- checkout
13+
- setup_remote_docker
14+
- run:
15+
name: 'newman test'
16+
command: |
17+
npm i
18+
cd local
19+
cd ..
20+
npm run create-tables:test
21+
cd mock
22+
(npm run mock-challenge-api&)
23+
(NODE_ENV=test npm start&)
24+
npm run test:newman
25+
workflows:
26+
version: 2
27+
Newman_Test:
28+
jobs:
29+
- Run-Newman-Test:
30+
context : org-global
31+
filters:
32+
branches:
33+
only:
34+
- automated-postman-testing

PoC-test.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Postman PoC test
2+
## Prerequisite
3+
- start db and es:
4+
```bash
5+
$ cd resources-api/local
6+
$ docker-compose up
7+
```
8+
- create tables:
9+
```bash
10+
$ cd resources-api
11+
12+
# NOTE:
13+
# if tables and data already exist, please run first
14+
15+
# $ npm run drop-tables:test
16+
17+
# to drop data and tables
18+
19+
$ npm run create-tables:test
20+
```
21+
- start mock challenge api:
22+
```
23+
$ cd resources-api/mock
24+
$ npm run mock-challenge-api
25+
```
26+
- start app
27+
```bash
28+
$ cd resources-api
29+
$ source env.sh # set env variables
30+
$ NODE_ENV=test npm start
31+
```
32+
33+
## newman test
34+
```bash
35+
$ npm run test:newman
36+
```
37+
38+
## Postman test
39+
Please refer to: https://drive.google.com/file/d/1VcTtNwI5_TXgnEKT4TruqG0Z-ts0J83G/view?usp=sharing
40+
41+
42+
## Postman mock server
43+
E2E tests use nock to mock `BUSAPI_URL`, where postman mock server could be used to replace nock.
44+
Please refer to: https://drive.google.com/file/d/1GXMzyqpzwix-LDBwieiRFfpJlJxrTIgI/view?usp=sharing

ReadMe.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,7 @@ npm run e2e
184184
## Verification
185185

186186
Refer to the verification document `Verification.md`
187+
188+
## Postman PoC test
189+
190+
Refer to the PoC test document [**PoC-test.md**](PoC-test.md)

config/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
module.exports = {
66
TERMS_API_URL: 'http://localhost:4000/v5/terms',
7-
BUSAPI_URL: 'http://localhost:4000/v5',
7+
BUSAPI_URL: 'https://65279208-4c97-4d1a-a925-041b2433787a.mock.pstmn.io/v5',
88
CHALLENGE_PHASES_API_URL: 'http://localhost:4000/v5/challenge-phases',
99
DYNAMODB: {
1010
AWS_ACCESS_KEY_ID: 'FAKE_ACCESS_KEY',

env.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
export AUTH0_CLIENT_ID=
4+
5+
export AUTH0_CLIENT_SECRET=
6+
7+
export AUTH0_AUDIENCE=https://m2m.topcoder-dev.com/

0 commit comments

Comments
 (0)