From 8ae5cea631a9c3097c7fbf7da6ce0cb1f347c4b4 Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 5 Dec 2020 18:49:09 +0100 Subject: [PATCH 01/41] basic jest + typescript support ref #17 --- jest.config.js | 4 ++++ package.json | 9 +++++++-- src/tests/firsttest.spec.ts | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 jest.config.js create mode 100644 src/tests/firsttest.spec.ts diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..91a2d2c --- /dev/null +++ b/jest.config.js @@ -0,0 +1,4 @@ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', +}; \ No newline at end of file diff --git a/package.json b/package.json index afc485d..8674353 100644 --- a/package.json +++ b/package.json @@ -47,14 +47,18 @@ "@types/cors": "^2.8.8", "@types/dotenv-safe": "^8.1.1", "@types/express": "^4.17.9", + "@types/jest": "^26.0.16", "@types/jsonwebtoken": "^8.5.0", "@types/multer": "^1.4.4", "@types/node": "^14.14.9", "@types/swagger-ui-express": "^4.1.2", "@types/uuid": "^8.3.0", + "axios": "^0.21.0", "dotenv-safe": "^8.2.0", + "jest": "^26.6.3", "nodemon": "^2.0.6", "sqlite3": "^5.0.0", + "ts-jest": "^26.4.4", "ts-node": "^9.0.0", "typedoc": "^0.19.2", "typescript": "^4.1.2" @@ -62,6 +66,7 @@ "scripts": { "dev": "nodemon src/app.ts", "build": "tsc", - "docs": "typedoc --out docs src" + "docs": "typedoc --out docs src", + "test": "jest" } -} \ No newline at end of file +} diff --git a/src/tests/firsttest.spec.ts b/src/tests/firsttest.spec.ts new file mode 100644 index 0000000..3e67076 --- /dev/null +++ b/src/tests/firsttest.spec.ts @@ -0,0 +1,14 @@ +import axios from 'axios'; + +describe('GET /api/openapi.json', () => { + it('is http 200', async () => { + const res = await axios.get('http://localhost:4010/api/openapi.json'); + expect(res.status).toEqual(200); + }); +}); +describe('GET /', () => { + it('is http 404', async () => { + const res = await axios.get('http://localhost:4010/', { validateStatus: undefined }); + expect(res.status).toEqual(404); + }); +}); From 431fd608a6945b0fbed932f122af5e6e5c8e8cd8 Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 5 Dec 2020 18:52:36 +0100 Subject: [PATCH 02/41] sample json validation ref #17 --- src/tests/firsttest.spec.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tests/firsttest.spec.ts b/src/tests/firsttest.spec.ts index 3e67076..13492eb 100644 --- a/src/tests/firsttest.spec.ts +++ b/src/tests/firsttest.spec.ts @@ -12,3 +12,11 @@ describe('GET /', () => { expect(res.status).toEqual(404); }); }); +describe('GET /api/teams', () => { + it('is http 200 && is json', async () => { + const res = await axios.get('http://localhost:4010/api/teams', { validateStatus: undefined }); + console.log(res.headers); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); +}); From 07e03ff04e6e51113f9dcdd9e0c2f6bde2c1b906 Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 5 Dec 2020 20:11:52 +0100 Subject: [PATCH 03/41] basic track testing ref #17 --- src/tests/tracks.spec.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/tests/tracks.spec.ts diff --git a/src/tests/tracks.spec.ts b/src/tests/tracks.spec.ts new file mode 100644 index 0000000..e9ebad7 --- /dev/null +++ b/src/tests/tracks.spec.ts @@ -0,0 +1,36 @@ +import axios from 'axios'; + +describe('GET /api/tracks', () => { + it('basic get should return 200', async () => { + const res = await axios.get('http://localhost:4010/api/tracks', { validateStatus: undefined }); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); + it('correct distance input should return 200', async () => { + const res = await axios.post('http://localhost:4010/api/tracks', { + "name": "string", + "distance": 400 + }, { validateStatus: undefined }); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('POST /api/tracks', () => { + it('illegal distance input should return 400', async () => { + const res = await axios.post('http://localhost:4010/api/tracks', { + "name": "string", + "distance": -1 + }, { validateStatus: undefined }); + expect(res.status).toEqual(400); + expect(res.headers['content-type']).toContain("application/json") + }); + it('correct distance input should return 200', async () => { + const res = await axios.post('http://localhost:4010/api/tracks', { + "name": "string", + "distance": 400 + }, { validateStatus: undefined }); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); +}); From 15e3d04215fdab899c0fc0b8aeeb77419c518f9b Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 5 Dec 2020 20:17:42 +0100 Subject: [PATCH 04/41] =?UTF-8?q?=F0=9F=9A=A7tracks.spec.ts=20-=20check=20?= =?UTF-8?q?if=20track=20was=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ref #17 --- src/tests/tracks.spec.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/tests/tracks.spec.ts b/src/tests/tracks.spec.ts index e9ebad7..6774742 100644 --- a/src/tests/tracks.spec.ts +++ b/src/tests/tracks.spec.ts @@ -2,7 +2,7 @@ import axios from 'axios'; describe('GET /api/tracks', () => { it('basic get should return 200', async () => { - const res = await axios.get('http://localhost:4010/api/tracks', { validateStatus: undefined }); + const res = await axios.get('http://localhost:4010/api/tracks'); expect(res.status).toEqual(200); expect(res.headers['content-type']).toContain("application/json") }); @@ -10,7 +10,7 @@ describe('GET /api/tracks', () => { const res = await axios.post('http://localhost:4010/api/tracks', { "name": "string", "distance": 400 - }, { validateStatus: undefined }); + }); expect(res.status).toEqual(200); expect(res.headers['content-type']).toContain("application/json") }); @@ -29,8 +29,19 @@ describe('POST /api/tracks', () => { const res = await axios.post('http://localhost:4010/api/tracks', { "name": "string", "distance": 400 - }, { validateStatus: undefined }); + }); expect(res.status).toEqual(200); expect(res.headers['content-type']).toContain("application/json") }); + it('check if track was added', async () => { + const res = await axios.get('http://localhost:4010/api/tracks'); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + let added_track = res.data[res.data.length - 1] + delete added_track.id + expect(added_track).toEqual({ + "name": "string", + "distance": 400 + }) + }); }); From a671bf8bcbfee3af07d5f4b667d5484e69eb9afe Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 5 Dec 2020 20:19:41 +0100 Subject: [PATCH 05/41] =?UTF-8?q?=F0=9F=9A=A7=20tracks.spec.ts=20-=20sampl?= =?UTF-8?q?e=20track=20adding=20+=20getting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ref #17 --- src/tests/tracks.spec.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tests/tracks.spec.ts b/src/tests/tracks.spec.ts index 6774742..a196e5b 100644 --- a/src/tests/tracks.spec.ts +++ b/src/tests/tracks.spec.ts @@ -33,6 +33,17 @@ describe('POST /api/tracks', () => { expect(res.status).toEqual(200); expect(res.headers['content-type']).toContain("application/json") }); +}); +// --------------- +describe('adding + getting tracks', () => { + it('correct distance input should return 200', async () => { + const res = await axios.post('http://localhost:4010/api/tracks', { + "name": "string", + "distance": 1000 + }); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); it('check if track was added', async () => { const res = await axios.get('http://localhost:4010/api/tracks'); expect(res.status).toEqual(200); @@ -41,7 +52,7 @@ describe('POST /api/tracks', () => { delete added_track.id expect(added_track).toEqual({ "name": "string", - "distance": 400 + "distance": 1000 }) }); }); From 4ff6f8c54007aa01b94f428eef0c6abdaa0c29ee Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 5 Dec 2020 20:32:15 +0100 Subject: [PATCH 06/41] =?UTF-8?q?=E2=9A=99=20nodemon=20config=20-=20ignore?= =?UTF-8?q?=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ref #17 --- package.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8674353..4c70efb 100644 --- a/package.json +++ b/package.json @@ -68,5 +68,12 @@ "build": "tsc", "docs": "typedoc --out docs src", "test": "jest" + }, + "nodemonConfig": { + "ignore": [ + "src/tests/*", + "docs/*" + ], + "delay": "2500" } -} +} \ No newline at end of file From 29acabfca362ea7e13f7435b171ab3ac2d12daad Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 5 Dec 2020 20:32:38 +0100 Subject: [PATCH 07/41] =?UTF-8?q?=F0=9F=A7=AAtracks.spec.ts=20-=20adding?= =?UTF-8?q?=20+=20getting=20+=20updating=20tracks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ref #17 --- src/tests/tracks.spec.ts | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/tests/tracks.spec.ts b/src/tests/tracks.spec.ts index a196e5b..bd36eaf 100644 --- a/src/tests/tracks.spec.ts +++ b/src/tests/tracks.spec.ts @@ -56,3 +56,47 @@ describe('adding + getting tracks', () => { }) }); }); +// --------------- +describe('adding + getting + updating', () => { + let added_track_id + it('correct distance input should return 200', async () => { + const res = await axios.post('http://localhost:4010/api/tracks', { + "name": "string", + "distance": 1500 + }); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); + it('get should return 200', async () => { + const res1 = await axios.get('http://localhost:4010/api/tracks'); + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + let added_track = res1.data[res1.data.length - 1] + added_track_id = added_track.id + delete added_track.id + expect(added_track).toEqual({ + "name": "string", + "distance": 1500 + }) + }) + it('get should return 200', async () => { + const res2 = await axios.put('http://localhost:4010/api/tracks/' + added_track_id, { + "id": added_track_id, + "name": "apitrack", + "distance": 5100 + }); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }) + it('get should return 200', async () => { + const res3 = await axios.get('http://localhost:4010/api/tracks'); + expect(res3.status).toEqual(200); + expect(res3.headers['content-type']).toContain("application/json") + let added_track2 = res3.data[res3.data.length - 1] + delete added_track2.id + expect(added_track2).toEqual({ + "name": "apitrack", + "distance": 5100 + }) + }); +}); From def7ca3eb218caf6cf4ed15799ee8ddf921cdc9f Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 5 Dec 2020 20:45:06 +0100 Subject: [PATCH 08/41] =?UTF-8?q?=F0=9F=A7=AAtracks.spec.ts=20-=20move=20t?= =?UTF-8?q?o=20baseurl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ref #17 --- src/tests/tracks.spec.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/tests/tracks.spec.ts b/src/tests/tracks.spec.ts index bd36eaf..3f8312a 100644 --- a/src/tests/tracks.spec.ts +++ b/src/tests/tracks.spec.ts @@ -1,13 +1,14 @@ import axios from 'axios'; +const base = "http://localhost:4010" describe('GET /api/tracks', () => { it('basic get should return 200', async () => { - const res = await axios.get('http://localhost:4010/api/tracks'); + const res = await axios.get(base + '/api/tracks'); expect(res.status).toEqual(200); expect(res.headers['content-type']).toContain("application/json") }); it('correct distance input should return 200', async () => { - const res = await axios.post('http://localhost:4010/api/tracks', { + const res = await axios.post(base + '/api/tracks', { "name": "string", "distance": 400 }); @@ -18,7 +19,7 @@ describe('GET /api/tracks', () => { // --------------- describe('POST /api/tracks', () => { it('illegal distance input should return 400', async () => { - const res = await axios.post('http://localhost:4010/api/tracks', { + const res = await axios.post(base + '/api/tracks', { "name": "string", "distance": -1 }, { validateStatus: undefined }); @@ -26,7 +27,7 @@ describe('POST /api/tracks', () => { expect(res.headers['content-type']).toContain("application/json") }); it('correct distance input should return 200', async () => { - const res = await axios.post('http://localhost:4010/api/tracks', { + const res = await axios.post(base + '/api/tracks', { "name": "string", "distance": 400 }); @@ -37,7 +38,7 @@ describe('POST /api/tracks', () => { // --------------- describe('adding + getting tracks', () => { it('correct distance input should return 200', async () => { - const res = await axios.post('http://localhost:4010/api/tracks', { + const res = await axios.post(base + '/api/tracks', { "name": "string", "distance": 1000 }); @@ -45,7 +46,7 @@ describe('adding + getting tracks', () => { expect(res.headers['content-type']).toContain("application/json") }); it('check if track was added', async () => { - const res = await axios.get('http://localhost:4010/api/tracks'); + const res = await axios.get(base + '/api/tracks'); expect(res.status).toEqual(200); expect(res.headers['content-type']).toContain("application/json") let added_track = res.data[res.data.length - 1] @@ -60,7 +61,7 @@ describe('adding + getting tracks', () => { describe('adding + getting + updating', () => { let added_track_id it('correct distance input should return 200', async () => { - const res = await axios.post('http://localhost:4010/api/tracks', { + const res = await axios.post(base + '/api/tracks', { "name": "string", "distance": 1500 }); @@ -68,7 +69,7 @@ describe('adding + getting + updating', () => { expect(res.headers['content-type']).toContain("application/json") }); it('get should return 200', async () => { - const res1 = await axios.get('http://localhost:4010/api/tracks'); + const res1 = await axios.get(base + '/api/tracks'); expect(res1.status).toEqual(200); expect(res1.headers['content-type']).toContain("application/json") let added_track = res1.data[res1.data.length - 1] @@ -80,7 +81,7 @@ describe('adding + getting + updating', () => { }) }) it('get should return 200', async () => { - const res2 = await axios.put('http://localhost:4010/api/tracks/' + added_track_id, { + const res2 = await axios.put(base + '/api/tracks/' + added_track_id, { "id": added_track_id, "name": "apitrack", "distance": 5100 @@ -89,7 +90,7 @@ describe('adding + getting + updating', () => { expect(res2.headers['content-type']).toContain("application/json") }) it('get should return 200', async () => { - const res3 = await axios.get('http://localhost:4010/api/tracks'); + const res3 = await axios.get(base + '/api/tracks'); expect(res3.status).toEqual(200); expect(res3.headers['content-type']).toContain("application/json") let added_track2 = res3.data[res3.data.length - 1] From 34567f24c3311ed6a0d5f1e0ea52eb8cbaff8904 Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 5 Dec 2020 20:45:22 +0100 Subject: [PATCH 09/41] =?UTF-8?q?=E2=9A=A1test:watch=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4c70efb..35cecc2 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,8 @@ "dev": "nodemon src/app.ts", "build": "tsc", "docs": "typedoc --out docs src", - "test": "jest" + "test": "jest", + "test:watch": "jest --watchAll" }, "nodemonConfig": { "ignore": [ From 39cefbc593a057393c59de96d2b7153adb5ea7a5 Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sun, 6 Dec 2020 10:48:25 +0100 Subject: [PATCH 10/41] =?UTF-8?q?=E2=9A=99=20use=20new=20config=20loader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ref #18 ,ref #17 --- src/tests/firsttest.spec.ts | 9 +++++---- src/tests/tracks.spec.ts | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tests/firsttest.spec.ts b/src/tests/firsttest.spec.ts index 13492eb..27c84d3 100644 --- a/src/tests/firsttest.spec.ts +++ b/src/tests/firsttest.spec.ts @@ -1,21 +1,22 @@ import axios from 'axios'; +import { config } from '../config'; +const base = "http://localhost:" + config.internal_port describe('GET /api/openapi.json', () => { it('is http 200', async () => { - const res = await axios.get('http://localhost:4010/api/openapi.json'); + const res = await axios.get(base + '/api/openapi.json'); expect(res.status).toEqual(200); }); }); describe('GET /', () => { it('is http 404', async () => { - const res = await axios.get('http://localhost:4010/', { validateStatus: undefined }); + const res = await axios.get(base + '/', { validateStatus: undefined }); expect(res.status).toEqual(404); }); }); describe('GET /api/teams', () => { it('is http 200 && is json', async () => { - const res = await axios.get('http://localhost:4010/api/teams', { validateStatus: undefined }); - console.log(res.headers); + const res = await axios.get(base + '/api/teams', { validateStatus: undefined }); expect(res.status).toEqual(200); expect(res.headers['content-type']).toContain("application/json") }); diff --git a/src/tests/tracks.spec.ts b/src/tests/tracks.spec.ts index 3f8312a..b29294c 100644 --- a/src/tests/tracks.spec.ts +++ b/src/tests/tracks.spec.ts @@ -1,5 +1,6 @@ import axios from 'axios'; -const base = "http://localhost:4010" +import { config } from '../config'; +const base = "http://localhost:" + config.internal_port describe('GET /api/tracks', () => { it('basic get should return 200', async () => { From 34fa94ea4f896ad17b6a8759f61ecb7fba095d53 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 16:10:17 +0100 Subject: [PATCH 11/41] First tests for orgs ref #17 --- src/tests/runnerGroups/org.spec.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/tests/runnerGroups/org.spec.ts diff --git a/src/tests/runnerGroups/org.spec.ts b/src/tests/runnerGroups/org.spec.ts new file mode 100644 index 0000000..e5387ea --- /dev/null +++ b/src/tests/runnerGroups/org.spec.ts @@ -0,0 +1,28 @@ +import axios from 'axios'; +import { config } from '../../config'; +const base = "http://localhost:" + config.internal_port + +describe('GET /api/organisations', () => { + it('basic get should return 200', async () => { + const res = await axios.get(base + '/api/organisations'); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('POST /api/organisation', () => { + it('creating a new org with just a name should return 200', async () => { + const res = await axios.post(base + '/api/organisation', { + "name": "test123" + }); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); + it('creating a new org with without a name should return 400', async () => { + const res = await axios.post(base + '/api/organisation', { + "name": null + }); + expect(res.status).toEqual(400); + expect(res.headers['content-type']).toContain("application/json") + }); +}); \ No newline at end of file From db5feb00cc48e475c8575f08535ceaba93883733 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 16:27:01 +0100 Subject: [PATCH 12/41] Added more basic tests for the runner orgs ref #17 --- src/tests/runnerGroups/org.spec.ts | 28 --------- src/tests/runnerGroups/org_basic.spec.ts | 80 ++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 28 deletions(-) delete mode 100644 src/tests/runnerGroups/org.spec.ts create mode 100644 src/tests/runnerGroups/org_basic.spec.ts diff --git a/src/tests/runnerGroups/org.spec.ts b/src/tests/runnerGroups/org.spec.ts deleted file mode 100644 index e5387ea..0000000 --- a/src/tests/runnerGroups/org.spec.ts +++ /dev/null @@ -1,28 +0,0 @@ -import axios from 'axios'; -import { config } from '../../config'; -const base = "http://localhost:" + config.internal_port - -describe('GET /api/organisations', () => { - it('basic get should return 200', async () => { - const res = await axios.get(base + '/api/organisations'); - expect(res.status).toEqual(200); - expect(res.headers['content-type']).toContain("application/json") - }); -}); -// --------------- -describe('POST /api/organisation', () => { - it('creating a new org with just a name should return 200', async () => { - const res = await axios.post(base + '/api/organisation', { - "name": "test123" - }); - expect(res.status).toEqual(200); - expect(res.headers['content-type']).toContain("application/json") - }); - it('creating a new org with without a name should return 400', async () => { - const res = await axios.post(base + '/api/organisation', { - "name": null - }); - expect(res.status).toEqual(400); - expect(res.headers['content-type']).toContain("application/json") - }); -}); \ No newline at end of file diff --git a/src/tests/runnerGroups/org_basic.spec.ts b/src/tests/runnerGroups/org_basic.spec.ts new file mode 100644 index 0000000..2e768c9 --- /dev/null +++ b/src/tests/runnerGroups/org_basic.spec.ts @@ -0,0 +1,80 @@ +import axios from 'axios'; +import { config } from '../../config'; +const base = "http://localhost:" + config.internal_port + +describe('GET /api/organisations', () => { + it('basic get should return 200', async () => { + const res = await axios.get(base + '/api/organisations'); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('POST /api/organisations', () => { + it('creating a new org with just a name should return 200', async () => { + const res = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); + it('creating a new org with without a name should return 400', async () => { + const res = await axios.post(base + '/api/organisations', { + "name": null + }, { validateStatus: undefined }); + expect(res.status).toEqual(400); + expect(res.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('adding + getting from all orgs', () => { + it('creating a new org with just a name should return 200', async () => { + const res = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); + it('check if org was added', async () => { + const res = await axios.get(base + '/api/organisations'); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + let added_org = res.data[res.data.length - 1] + delete added_org.id + expect(added_org).toEqual({ + "name": "test123", + "contact": null, + "address": null, + "teams": [] + }) + }); +}); +// --------------- +describe('adding + getting explicitly', () => { + let added_org_id + describe('adding + getting orgs', () => { + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + let added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('check if org was added', async () => { + const res2 = await axios.get(base + '/api/organisations/' + added_org_id); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + let added_org2 = res2.data + added_org_id = added_org2.id; + delete added_org2.id + expect(added_org2).toEqual({ + "name": "test123", + "contact": null, + "address": null, + "teams": [] + }) + }); + }); +}); From 6da7c23c04df1148ac79646c362acfaaba3ffd77 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 16:28:18 +0100 Subject: [PATCH 13/41] Renamed to better fit the content --- .../runnerGroups/{org_basic.spec.ts => org_add+get.spec.ts} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/tests/runnerGroups/{org_basic.spec.ts => org_add+get.spec.ts} (99%) diff --git a/src/tests/runnerGroups/org_basic.spec.ts b/src/tests/runnerGroups/org_add+get.spec.ts similarity index 99% rename from src/tests/runnerGroups/org_basic.spec.ts rename to src/tests/runnerGroups/org_add+get.spec.ts index 2e768c9..88423ba 100644 --- a/src/tests/runnerGroups/org_basic.spec.ts +++ b/src/tests/runnerGroups/org_add+get.spec.ts @@ -77,4 +77,4 @@ describe('adding + getting explicitly', () => { }) }); }); -}); +}); \ No newline at end of file From 0a0050368fa0e921e20efe43f653c672c7f477ae Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 17:52:04 +0100 Subject: [PATCH 14/41] Added put tests for runner orgs --- src/tests/runnerGroups/org_add+update.spec.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/tests/runnerGroups/org_add+update.spec.ts diff --git a/src/tests/runnerGroups/org_add+update.spec.ts b/src/tests/runnerGroups/org_add+update.spec.ts new file mode 100644 index 0000000..0cdcdc9 --- /dev/null +++ b/src/tests/runnerGroups/org_add+update.spec.ts @@ -0,0 +1,40 @@ +import axios from 'axios'; +import { config } from '../../config'; +const base = "http://localhost:" + config.internal_port + +// --------------- +describe('adding + updating name', () => { + let added_org_id + let added_org + describe('adding org', () => { + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('check if org was added', async () => { + const res2 = await axios.put(base + '/api/organisations/' + added_org_id, { + "id": added_org_id, + "name": "testlelele", + "contact": null, + "address": null, + "teams": [] + }); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + let added_org2 = res2.data + added_org_id = added_org2.id; + delete added_org2.id + expect(added_org2).toEqual({ + "name": "testlelele", + "contact": null, + "address": null, + "teams": [] + }) + }); + }); +}); \ No newline at end of file From 4e3b038dec481bdfef53c4cd136120b19d1b462e Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 17:56:37 +0100 Subject: [PATCH 15/41] Added bad test to the put --- src/tests/runnerGroups/org_add+update.spec.ts | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/tests/runnerGroups/org_add+update.spec.ts b/src/tests/runnerGroups/org_add+update.spec.ts index 0cdcdc9..fa2a349 100644 --- a/src/tests/runnerGroups/org_add+update.spec.ts +++ b/src/tests/runnerGroups/org_add+update.spec.ts @@ -16,13 +16,12 @@ describe('adding + updating name', () => { expect(res1.status).toEqual(200); expect(res1.headers['content-type']).toContain("application/json") }); - it('check if org was added', async () => { + it('update org', async () => { const res2 = await axios.put(base + '/api/organisations/' + added_org_id, { "id": added_org_id, "name": "testlelele", "contact": null, "address": null, - "teams": [] }); expect(res2.status).toEqual(200); expect(res2.headers['content-type']).toContain("application/json") @@ -37,4 +36,30 @@ describe('adding + updating name', () => { }) }); }); +}); +// --------------- +describe('adding + try updating id (should return 406)', () => { + let added_org_id + let added_org + describe('adding org', () => { + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('update org', async () => { + const res2 = await axios.put(base + '/api/organisations/' + added_org_id, { + "id": added_org_id + 1, + "name": "testlelele", + "contact": null, + "address": null, + }, { validateStatus: undefined }); + expect(res2.status).toEqual(406); + expect(res2.headers['content-type']).toContain("application/json") + }); + }); }); \ No newline at end of file From 13f96e319060bea8d47fd7d98ae5e7fc21ff59dd Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 18:08:45 +0100 Subject: [PATCH 16/41] Added delete test ref #17 --- src/tests/runnerGroups/org_add+delete.spec.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/tests/runnerGroups/org_add+delete.spec.ts diff --git a/src/tests/runnerGroups/org_add+delete.spec.ts b/src/tests/runnerGroups/org_add+delete.spec.ts new file mode 100644 index 0000000..10468a8 --- /dev/null +++ b/src/tests/runnerGroups/org_add+delete.spec.ts @@ -0,0 +1,39 @@ +import axios from 'axios'; +import { config } from '../../config'; +const base = "http://localhost:" + config.internal_port + +// --------------- +describe('adding + updating name', () => { + let added_org_id + let added_org + describe('adding org', () => { + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('delete', async () => { + const res2 = await axios.delete(base + '/api/organisations/' + added_org_id); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + let added_org2 = res2.data + added_org_id = added_org2.id; + delete added_org2.id + expect(added_org2).toEqual({ + "name": "test123", + "contact": null, + "address": null, + "teams": [] + }); + }); + it('check if org really was deleted', async () => { + const res3 = await axios.get(base + '/api/organisations/' + added_org_id, { validateStatus: undefined }); + expect(res3.status).toEqual(404); + expect(res3.headers['content-type']).toContain("application/json") + }); + }); +}); \ No newline at end of file From 76065538c9cf55008879bf9bbe49ede5bbd51749 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 18:14:29 +0100 Subject: [PATCH 17/41] Renamed b/c runner teams also need dedicated tests ref #17 --- src/tests/{runnerGroups => runnerOrgs}/org_add+delete.spec.ts | 0 src/tests/{runnerGroups => runnerOrgs}/org_add+get.spec.ts | 0 src/tests/{runnerGroups => runnerOrgs}/org_add+update.spec.ts | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/tests/{runnerGroups => runnerOrgs}/org_add+delete.spec.ts (100%) rename src/tests/{runnerGroups => runnerOrgs}/org_add+get.spec.ts (100%) rename src/tests/{runnerGroups => runnerOrgs}/org_add+update.spec.ts (100%) diff --git a/src/tests/runnerGroups/org_add+delete.spec.ts b/src/tests/runnerOrgs/org_add+delete.spec.ts similarity index 100% rename from src/tests/runnerGroups/org_add+delete.spec.ts rename to src/tests/runnerOrgs/org_add+delete.spec.ts diff --git a/src/tests/runnerGroups/org_add+get.spec.ts b/src/tests/runnerOrgs/org_add+get.spec.ts similarity index 100% rename from src/tests/runnerGroups/org_add+get.spec.ts rename to src/tests/runnerOrgs/org_add+get.spec.ts diff --git a/src/tests/runnerGroups/org_add+update.spec.ts b/src/tests/runnerOrgs/org_add+update.spec.ts similarity index 100% rename from src/tests/runnerGroups/org_add+update.spec.ts rename to src/tests/runnerOrgs/org_add+update.spec.ts From 862834c877c3cf38f55dccf30c08e6d937cac947 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 18:42:08 +0100 Subject: [PATCH 18/41] Added first team creation tests --- src/tests/runnerTeams/team_add+get.spec.ts | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/tests/runnerTeams/team_add+get.spec.ts diff --git a/src/tests/runnerTeams/team_add+get.spec.ts b/src/tests/runnerTeams/team_add+get.spec.ts new file mode 100644 index 0000000..69d85ed --- /dev/null +++ b/src/tests/runnerTeams/team_add+get.spec.ts @@ -0,0 +1,49 @@ +import axios from 'axios'; +import { config } from '../../config'; +const base = "http://localhost:" + config.internal_port + +describe('GET /api/teams', () => { + it('basic get should return 200', async () => { + const res = await axios.get(base + '/api/teams'); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('POST /api/teams with errors', () => { + it('creating a new org with without a team should return 400', async () => { + const res1 = await axios.post(base + '/api/teams', { + "name": "test_team" + }, { validateStatus: undefined }); + expect(res1.status).toEqual(400); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new org with without a name should return 400', async () => { + const res2 = await axios.post(base + '/api/teams', { + "name": null + }, { validateStatus: undefined }); + expect(res2.status).toEqual(400); + expect(res2.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('POST /api/teams working', () => { + let added_org_id; + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + let added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new team with a parent org should return 200', async () => { + const res2 = await axios.post(base + '/api/teams', { + "name": "test_team", + "parentGroup": added_org_id + }); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); +}); \ No newline at end of file From b4b52717fcbb40f0aaebb5c8372715e365342b8c Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 18:47:15 +0100 Subject: [PATCH 19/41] Added more negative tests for the teams ref #17 --- src/tests/runnerTeams/team_add+get.spec.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/tests/runnerTeams/team_add+get.spec.ts b/src/tests/runnerTeams/team_add+get.spec.ts index 69d85ed..79505ad 100644 --- a/src/tests/runnerTeams/team_add+get.spec.ts +++ b/src/tests/runnerTeams/team_add+get.spec.ts @@ -11,20 +11,28 @@ describe('GET /api/teams', () => { }); // --------------- describe('POST /api/teams with errors', () => { - it('creating a new org with without a team should return 400', async () => { + it('creating a new team without a name should return 400', async () => { const res1 = await axios.post(base + '/api/teams', { - "name": "test_team" + "name": null }, { validateStatus: undefined }); expect(res1.status).toEqual(400); expect(res1.headers['content-type']).toContain("application/json") }); - it('creating a new org with without a name should return 400', async () => { + it('creating a new team without a org should return 400', async () => { const res2 = await axios.post(base + '/api/teams', { - "name": null + "name": "test_team" }, { validateStatus: undefined }); expect(res2.status).toEqual(400); expect(res2.headers['content-type']).toContain("application/json") }); + it('creating a new team without a valid org should return 404', async () => { + const res3 = await axios.post(base + '/api/teams', { + "name": "test_team", + "parentGroup": -1 + }, { validateStatus: undefined }); + expect(res3.status).toEqual(404); + expect(res3.headers['content-type']).toContain("application/json") + }); }); // --------------- describe('POST /api/teams working', () => { From c3258b9304be150ae9e36153b72d86fd6f639ac1 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 19:15:54 +0100 Subject: [PATCH 20/41] Added team delete test --- src/tests/runnerTeams/team_add+delete.spec.ts | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/tests/runnerTeams/team_add+delete.spec.ts diff --git a/src/tests/runnerTeams/team_add+delete.spec.ts b/src/tests/runnerTeams/team_add+delete.spec.ts new file mode 100644 index 0000000..8e7233a --- /dev/null +++ b/src/tests/runnerTeams/team_add+delete.spec.ts @@ -0,0 +1,47 @@ +import axios from 'axios'; +import { config } from '../../config'; +const base = "http://localhost:" + config.internal_port + +// --------------- +describe('adding org', () => { + let added_org; + let added_org_id; + let added_team; + let added_team_id + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + added_org = res1.data; + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new team with a valid org should return 200', async () => { + const res2 = await axios.post(base + '/api/teams', { + "name": "test123", + "parentGroup": added_org_id + }); + added_team = res2.data; + added_team_id = added_team.id; + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('delete', async () => { + const res2 = await axios.delete(base + '/api/teams/' + added_team_id); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + let deleted_team = res2.data + delete deleted_team.id; + delete deleted_team.parentGroup; + expect(deleted_team).toEqual({ + "name": "test123", + "contact": null + }); + }); + it('check if org really was deleted', async () => { + const res3 = await axios.get(base + '/api/teams/' + added_team_id, { validateStatus: undefined }); + expect(res3.status).toEqual(404); + expect(res3.headers['content-type']).toContain("application/json") + }); +}); \ No newline at end of file From f4abbfcee4cc57ec826af594ef3bcd30868c81ab Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 19:16:10 +0100 Subject: [PATCH 21/41] Added test for getting an non-existant team --- src/tests/runnerTeams/team_add+get.spec.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tests/runnerTeams/team_add+get.spec.ts b/src/tests/runnerTeams/team_add+get.spec.ts index 79505ad..5ce61d3 100644 --- a/src/tests/runnerTeams/team_add+get.spec.ts +++ b/src/tests/runnerTeams/team_add+get.spec.ts @@ -10,6 +10,14 @@ describe('GET /api/teams', () => { }); }); // --------------- +describe('GET /api/teams/0', () => { + it('basic get should return 404', async () => { + const res = await axios.get(base + '/api/teams/0', { validateStatus: undefined }); + expect(res.status).toEqual(404); + expect(res.headers['content-type']).toContain("application/json") + }); +}); +// --------------- describe('POST /api/teams with errors', () => { it('creating a new team without a name should return 400', async () => { const res1 = await axios.post(base + '/api/teams', { From 5845a91f15b6c660fd8707aaffef212ad380d94c Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 19:20:19 +0100 Subject: [PATCH 22/41] Fixed typos --- src/tests/runnerTeams/team_add+delete.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/runnerTeams/team_add+delete.spec.ts b/src/tests/runnerTeams/team_add+delete.spec.ts index 8e7233a..0db4afa 100644 --- a/src/tests/runnerTeams/team_add+delete.spec.ts +++ b/src/tests/runnerTeams/team_add+delete.spec.ts @@ -27,7 +27,7 @@ describe('adding org', () => { expect(res2.status).toEqual(200); expect(res2.headers['content-type']).toContain("application/json") }); - it('delete', async () => { + it('delete team', async () => { const res2 = await axios.delete(base + '/api/teams/' + added_team_id); expect(res2.status).toEqual(200); expect(res2.headers['content-type']).toContain("application/json") @@ -39,7 +39,7 @@ describe('adding org', () => { "contact": null }); }); - it('check if org really was deleted', async () => { + it('check if team really was deleted', async () => { const res3 = await axios.get(base + '/api/teams/' + added_team_id, { validateStatus: undefined }); expect(res3.status).toEqual(404); expect(res3.headers['content-type']).toContain("application/json") From 6396fffc045da75d15b84de66d1029b01f736d79 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 19:20:33 +0100 Subject: [PATCH 23/41] Added test for non-existant deletion ref #17 --- src/tests/runnerOrgs/org_add+delete.spec.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/tests/runnerOrgs/org_add+delete.spec.ts b/src/tests/runnerOrgs/org_add+delete.spec.ts index 10468a8..82f6ec6 100644 --- a/src/tests/runnerOrgs/org_add+delete.spec.ts +++ b/src/tests/runnerOrgs/org_add+delete.spec.ts @@ -3,7 +3,7 @@ import { config } from '../../config'; const base = "http://localhost:" + config.internal_port // --------------- -describe('adding + updating name', () => { +describe('adding + deletion (successfull)', () => { let added_org_id let added_org describe('adding org', () => { @@ -36,4 +36,12 @@ describe('adding + updating name', () => { expect(res3.headers['content-type']).toContain("application/json") }); }); -}); \ No newline at end of file +}); +// --------------- +describe('adding + deletion (non-existant)', () => { + it('delete', async () => { + const res2 = await axios.delete(base + '/api/organisations/0', { validateStatus: undefined }); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); +}); From 80ef7e8c3ab8fc3f2db4d0463b1e5f09d5ba17d0 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 19:43:51 +0100 Subject: [PATCH 24/41] Adjustes responsecode --- src/tests/runnerOrgs/org_add+delete.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/runnerOrgs/org_add+delete.spec.ts b/src/tests/runnerOrgs/org_add+delete.spec.ts index 82f6ec6..6ac8f5a 100644 --- a/src/tests/runnerOrgs/org_add+delete.spec.ts +++ b/src/tests/runnerOrgs/org_add+delete.spec.ts @@ -41,7 +41,7 @@ describe('adding + deletion (successfull)', () => { describe('adding + deletion (non-existant)', () => { it('delete', async () => { const res2 = await axios.delete(base + '/api/organisations/0', { validateStatus: undefined }); - expect(res2.status).toEqual(200); + expect(res2.status).toEqual(204); expect(res2.headers['content-type']).toContain("application/json") }); }); From 71e5be2ba47bdfef9f1e1a705ef4014ca7b3244e Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 19:55:36 +0100 Subject: [PATCH 25/41] added non-existant deletion test for teams ref #17 --- src/tests/runnerTeams/team_add+delete.spec.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tests/runnerTeams/team_add+delete.spec.ts b/src/tests/runnerTeams/team_add+delete.spec.ts index 0db4afa..9210789 100644 --- a/src/tests/runnerTeams/team_add+delete.spec.ts +++ b/src/tests/runnerTeams/team_add+delete.spec.ts @@ -44,4 +44,11 @@ describe('adding org', () => { expect(res3.status).toEqual(404); expect(res3.headers['content-type']).toContain("application/json") }); -}); \ No newline at end of file +}); +// --------------- +describe('adding + deletion (non-existant)', () => { + it('delete', async () => { + const res2 = await axios.delete(base + '/api/teams/0', { validateStatus: undefined }); + expect(res2.status).toEqual(204); + }); +}); From 6e316a7533daca0c2045b8947ce9c0cb84253876 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 19:57:02 +0100 Subject: [PATCH 26/41] Cleanup ref #17 --- src/tests/runnerOrgs/org_add+delete.spec.ts | 53 ++++++------- src/tests/runnerOrgs/org_add+get.spec.ts | 44 +++++------ src/tests/runnerOrgs/org_add+update.spec.ts | 88 ++++++++++----------- 3 files changed, 88 insertions(+), 97 deletions(-) diff --git a/src/tests/runnerOrgs/org_add+delete.spec.ts b/src/tests/runnerOrgs/org_add+delete.spec.ts index 6ac8f5a..a3c09b8 100644 --- a/src/tests/runnerOrgs/org_add+delete.spec.ts +++ b/src/tests/runnerOrgs/org_add+delete.spec.ts @@ -6,42 +6,39 @@ const base = "http://localhost:" + config.internal_port describe('adding + deletion (successfull)', () => { let added_org_id let added_org - describe('adding org', () => { - it('creating a new org with just a name should return 200', async () => { - const res1 = await axios.post(base + '/api/organisations', { - "name": "test123" - }); - added_org = res1.data - added_org_id = added_org.id; - expect(res1.status).toEqual(200); - expect(res1.headers['content-type']).toContain("application/json") + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" }); - it('delete', async () => { - const res2 = await axios.delete(base + '/api/organisations/' + added_org_id); - expect(res2.status).toEqual(200); - expect(res2.headers['content-type']).toContain("application/json") - let added_org2 = res2.data - added_org_id = added_org2.id; - delete added_org2.id - expect(added_org2).toEqual({ - "name": "test123", - "contact": null, - "address": null, - "teams": [] - }); - }); - it('check if org really was deleted', async () => { - const res3 = await axios.get(base + '/api/organisations/' + added_org_id, { validateStatus: undefined }); - expect(res3.status).toEqual(404); - expect(res3.headers['content-type']).toContain("application/json") + added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('delete', async () => { + const res2 = await axios.delete(base + '/api/organisations/' + added_org_id); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + let added_org2 = res2.data + added_org_id = added_org2.id; + delete added_org2.id + expect(added_org2).toEqual({ + "name": "test123", + "contact": null, + "address": null, + "teams": [] }); }); + it('check if org really was deleted', async () => { + const res3 = await axios.get(base + '/api/organisations/' + added_org_id, { validateStatus: undefined }); + expect(res3.status).toEqual(404); + expect(res3.headers['content-type']).toContain("application/json") + }); }); // --------------- describe('adding + deletion (non-existant)', () => { it('delete', async () => { const res2 = await axios.delete(base + '/api/organisations/0', { validateStatus: undefined }); expect(res2.status).toEqual(204); - expect(res2.headers['content-type']).toContain("application/json") }); }); diff --git a/src/tests/runnerOrgs/org_add+get.spec.ts b/src/tests/runnerOrgs/org_add+get.spec.ts index 88423ba..fb28b62 100644 --- a/src/tests/runnerOrgs/org_add+get.spec.ts +++ b/src/tests/runnerOrgs/org_add+get.spec.ts @@ -52,29 +52,27 @@ describe('adding + getting from all orgs', () => { // --------------- describe('adding + getting explicitly', () => { let added_org_id - describe('adding + getting orgs', () => { - it('creating a new org with just a name should return 200', async () => { - const res1 = await axios.post(base + '/api/organisations', { - "name": "test123" - }); - let added_org = res1.data - added_org_id = added_org.id; - expect(res1.status).toEqual(200); - expect(res1.headers['content-type']).toContain("application/json") - }); - it('check if org was added', async () => { - const res2 = await axios.get(base + '/api/organisations/' + added_org_id); - expect(res2.status).toEqual(200); - expect(res2.headers['content-type']).toContain("application/json") - let added_org2 = res2.data - added_org_id = added_org2.id; - delete added_org2.id - expect(added_org2).toEqual({ - "name": "test123", - "contact": null, - "address": null, - "teams": [] - }) + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" }); + let added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('check if org was added', async () => { + const res2 = await axios.get(base + '/api/organisations/' + added_org_id); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + let added_org2 = res2.data + added_org_id = added_org2.id; + delete added_org2.id + expect(added_org2).toEqual({ + "name": "test123", + "contact": null, + "address": null, + "teams": [] + }) }); }); \ No newline at end of file diff --git a/src/tests/runnerOrgs/org_add+update.spec.ts b/src/tests/runnerOrgs/org_add+update.spec.ts index fa2a349..06a35f6 100644 --- a/src/tests/runnerOrgs/org_add+update.spec.ts +++ b/src/tests/runnerOrgs/org_add+update.spec.ts @@ -6,60 +6,56 @@ const base = "http://localhost:" + config.internal_port describe('adding + updating name', () => { let added_org_id let added_org - describe('adding org', () => { - it('creating a new org with just a name should return 200', async () => { - const res1 = await axios.post(base + '/api/organisations', { - "name": "test123" - }); - added_org = res1.data - added_org_id = added_org.id; - expect(res1.status).toEqual(200); - expect(res1.headers['content-type']).toContain("application/json") + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" }); - it('update org', async () => { - const res2 = await axios.put(base + '/api/organisations/' + added_org_id, { - "id": added_org_id, - "name": "testlelele", - "contact": null, - "address": null, - }); - expect(res2.status).toEqual(200); - expect(res2.headers['content-type']).toContain("application/json") - let added_org2 = res2.data - added_org_id = added_org2.id; - delete added_org2.id - expect(added_org2).toEqual({ - "name": "testlelele", - "contact": null, - "address": null, - "teams": [] - }) + added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('update org', async () => { + const res2 = await axios.put(base + '/api/organisations/' + added_org_id, { + "id": added_org_id, + "name": "testlelele", + "contact": null, + "address": null, }); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + let added_org2 = res2.data + added_org_id = added_org2.id; + delete added_org2.id + expect(added_org2).toEqual({ + "name": "testlelele", + "contact": null, + "address": null, + "teams": [] + }) }); }); // --------------- describe('adding + try updating id (should return 406)', () => { let added_org_id let added_org - describe('adding org', () => { - it('creating a new org with just a name should return 200', async () => { - const res1 = await axios.post(base + '/api/organisations', { - "name": "test123" - }); - added_org = res1.data - added_org_id = added_org.id; - expect(res1.status).toEqual(200); - expect(res1.headers['content-type']).toContain("application/json") - }); - it('update org', async () => { - const res2 = await axios.put(base + '/api/organisations/' + added_org_id, { - "id": added_org_id + 1, - "name": "testlelele", - "contact": null, - "address": null, - }, { validateStatus: undefined }); - expect(res2.status).toEqual(406); - expect(res2.headers['content-type']).toContain("application/json") + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" }); + added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('update org', async () => { + const res2 = await axios.put(base + '/api/organisations/' + added_org_id, { + "id": added_org_id + 1, + "name": "testlelele", + "contact": null, + "address": null, + }, { validateStatus: undefined }); + expect(res2.status).toEqual(406); + expect(res2.headers['content-type']).toContain("application/json") }); }); \ No newline at end of file From 105efdd4543ad14cb43a6bfb5f15f16527c8fe03 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 20:08:01 +0100 Subject: [PATCH 27/41] Added team update tests ref #17 --- src/tests/runnerTeams/team_add+update.spec.ts | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/tests/runnerTeams/team_add+update.spec.ts diff --git a/src/tests/runnerTeams/team_add+update.spec.ts b/src/tests/runnerTeams/team_add+update.spec.ts new file mode 100644 index 0000000..edd94af --- /dev/null +++ b/src/tests/runnerTeams/team_add+update.spec.ts @@ -0,0 +1,75 @@ +import axios from 'axios'; +import { config } from '../../config'; +const base = "http://localhost:" + config.internal_port + +// --------------- +describe('adding + updating name', () => { + let added_org; + let added_org_id; + let added_team; + let added_team_id + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + added_org = res1.data; + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new team with a valid org should return 200', async () => { + const res2 = await axios.post(base + '/api/teams', { + "name": "test123", + "parentGroup": added_org_id + }); + added_team = res2.data; + added_team_id = added_team.id; + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('update name', async () => { + const res3 = await axios.put(base + '/api/teams/' + added_team_id, { + "id": added_team_id, + "name": "testlelele", + "contact": null, + "parentGroup": added_org + }); + expect(res3.status).toEqual(200); + expect(res3.headers['content-type']).toContain("application/json") + let updated_team = res3.data; + added_team.name = "testlelele"; + expect(updated_team).toEqual(added_team) + }); +}); +// --------------- +describe('adding + try updating id (should return 406)', () => { + let added_org; + let added_org_id; + let added_team; + let added_team_id + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + added_org = res1.data; + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new team with a valid org should return 200', async () => { + const res2 = await axios.post(base + '/api/teams', { + "name": "test123", + "parentGroup": added_org_id + }); + added_team = res2.data; + added_team_id = added_team.id; + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('update team', async () => { + added_team.id = added_team.id + 1; + const res3 = await axios.put(base + '/api/teams/' + added_team_id, added_team, { validateStatus: undefined }); + expect(res3.status).toEqual(406); + expect(res3.headers['content-type']).toContain("application/json") + }); +}); \ No newline at end of file From 32a92b1ad712a83d9bdd901b3341815a4edece3d Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 10 Dec 2020 16:10:35 +0100 Subject: [PATCH 28/41] Added org deletion tests (orgs that still have teams) ref #17 --- src/tests/runnerOrgs/org_add+delete.spec.ts | 84 ++++++++++++++++++++- 1 file changed, 80 insertions(+), 4 deletions(-) diff --git a/src/tests/runnerOrgs/org_add+delete.spec.ts b/src/tests/runnerOrgs/org_add+delete.spec.ts index a3c09b8..f8d5824 100644 --- a/src/tests/runnerOrgs/org_add+delete.spec.ts +++ b/src/tests/runnerOrgs/org_add+delete.spec.ts @@ -2,6 +2,13 @@ import axios from 'axios'; import { config } from '../../config'; const base = "http://localhost:" + config.internal_port +// --------------- +describe('adding + deletion (non-existant)', () => { + it('delete', async () => { + const res2 = await axios.delete(base + '/api/organisations/0', { validateStatus: undefined }); + expect(res2.status).toEqual(204); + }); +}); // --------------- describe('adding + deletion (successfull)', () => { let added_org_id @@ -36,9 +43,78 @@ describe('adding + deletion (successfull)', () => { }); }); // --------------- -describe('adding + deletion (non-existant)', () => { - it('delete', async () => { - const res2 = await axios.delete(base + '/api/organisations/0', { validateStatus: undefined }); - expect(res2.status).toEqual(204); +describe('adding + deletion with teams still existing (without force)', () => { + let added_org; + let added_org_id; + let added_team; + let added_team_id + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + added_org = res1.data; + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new team with a valid org should return 200', async () => { + const res2 = await axios.post(base + '/api/teams', { + "name": "test123", + "parentGroup": added_org_id + }); + added_team = res2.data; + added_team_id = added_team.id; + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('delete org - this should fail with a 406', async () => { + const res2 = await axios.delete(base + '/api/organisations/' + added_org_id, { validateStatus: undefined }); + expect(res2.status).toEqual(406); + expect(res2.headers['content-type']).toContain("application/json") }); }); +// --------------- +describe('adding + deletion with teams still existing (with force)', () => { + let added_org; + let added_org_id; + let added_team; + let added_team_id + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + added_org = res1.data; + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new team with a valid org should return 200', async () => { + const res2 = await axios.post(base + '/api/teams', { + "name": "test123", + "parentGroup": added_org_id + }); + added_team = res2.data; + added_team_id = added_team.id; + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('delete', async () => { + const res2 = await axios.delete(base + '/api/organisations/' + added_org_id + '?force=true'); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + let added_org2 = res2.data + added_org_id = added_org2.id; + delete added_org2.id; + delete added_org2.teams; + expect(added_org2).toEqual({ + "name": "test123", + "contact": null, + "address": null + }); + }); + it('check if org really was deleted', async () => { + const res3 = await axios.get(base + '/api/organisations/' + added_org_id, { validateStatus: undefined }); + expect(res3.status).toEqual(404); + expect(res3.headers['content-type']).toContain("application/json") + }); +}); \ No newline at end of file From ff6a4eaca1d37f1d14a582d4ee4b1a0c99abd3ff Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 10 Dec 2020 16:13:05 +0100 Subject: [PATCH 29/41] Removed sqlite jurnal (however it managed to end up here) --- test.sqlite-journal | Bin 16928 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test.sqlite-journal diff --git a/test.sqlite-journal b/test.sqlite-journal deleted file mode 100644 index f0894c41fb3de142937d8312d6bb30c1f996293e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16928 zcmeI34{+Pm9mgfhvSiD)Qqt6gIH1^+BrCVYe-g**2Bc}&LQ2}^575gX$d;U%Bz9^$ z&{7JMQ(&WPjJ1Ppr5jtv4(K)x3JmDVF*tKJ9bVliS&8j_viP0@BRGb#so3i^jRw~ahRTub&5 z_JFLEahuhAjxk0XjTh3M6j@ypd4%znEcG)IvBep)<3Y*u)S&vx{TMt_I zT6b8tSfkc}wbn{myV+grAlt#F+2w3CbDY`F>|wSu(@dHfWGKr~CcxBMrY-v|J1kL4 zwZ80AXF6s&Osz2OGi^7eO&zA?ra@CRd7L~#?jv`RljI25$G^@$%|F18^Ize=$T#y# zdBXX;^AYFm>@oHTJIx+s_p#fVqfEDDuVs?nVm@qMK~0+Wm=2NC&bJceQWxbj^-d%b za%xR#SWLvzVkVwUkV^nwqj7Di0E&gRSUQ5mK>O8}Ed;BMn5XJ87yzXALWfWHawzXJUAqVfG1(7gumR{?$m;C}-6D**pv z(fIxV=zb6ImjQkl;4cCE1%N*X@ZSOaw*a38_%rryqkKg?3+SIN^6M!;_awl71Mpu1 z{BeLk0q{dbj{*Ew0DlzVzXbRr06$nXzJ~$b0f7Gk;QImoAiy60_(MhGyC2Zq zSETz{(fyB#?!Q-be^b%@*MWZa0sJ0--wp740e%<2e+uxQ0DLdN?*#ZA0KXmJKL+@1 z0N(@f9|HUb0RKL~cLV$ufbRnMcLDw#fZq)8ZvlKKz;^)rn*hHN;5PvLYXH9<;M)Oy z9l*Z|@N4;tO&6A)n2Bou{nY^92JlIMX951@C6tdW9nV$9_)25E)fjIv#+Mu8&Bl0> zF}}t4(LhWJf6hK!8@RQLK<h;~S1K$2pD$huQv${ZacZ_RaS5(0c}pxwp9| zx!bv`xd?YA=eB)hd(n2U?M7R|)@^IFS*@>GAF=MXUT!_#8no81@32p?cd*y6QT}EA zA$}LXi63C@Wwu7LWQbZH3Lqn=Gd_QybjJ(X2E61n zoWz|yl_5^4NAK~f9SvpB`$M|qBnVj#t_2}mkCzBIi8ouv5cRVGkIL#lqnJ;|H6&!c zc!?V?ISDU05iePalX$b$^NPC$*N~81jF&9INtm64*`2K|vm{OuvQ@ZNge;GfxU(#kD#o=OFHn9m3T=zPU2P0npezc zl!^I(pnM+JkDz=GFIjy2hanxn@pj<%U(oN%S`HpoEjQVB`3zoMyHMPvN;qLQxb2bma*xmm>5cD zw7)lJSgJ+?97ENyQZk`Yr-kxb$Hi189*vKSi3|#Ww%Rz#Wy++)=m>F3m6>W_wLXTT z$wWqsW*Ca9u}-Arl+%Q|R4;}QMSs!mAgTJ9drhDF90=LBZgo5(3$bKsOw0%Y^obCX zB+e29f*>D8-J#Ek8n0$tT{Wb_#}ksg zscY2*L;mLGRw)u_4L8f-NHEe83$%orLqT6KsQSD(H`uP8Rh<_Ip7Iqu!kV6$=~3g! zY#x_AP3Rr56Bt)b4LLcGpJTP*>OvP(v>+2M6-U+iH=3IG82W#8acn&A5t?IdP_uKc zpU9bwZ#0u?Ep;dB$`DdBL?Ov#2_0Ns3!#_`#zde;Z47*|~#ncb?nKC77hy{ORrS-hYb5XX`eiOgC#wW@g8 zA)96j^9!-u44^?IQ#$vMwq#P8uH=!UUQ(&cI~r~aMv;@THZc+iwEDx6Ulc{j-_jD( zCFQD8Q{j3urs`_ze9d+`8JE{fZd<4MsuSrh`9gPfB?~e*7Eh%!;AS6-OVTJxQMz1! zoEsI(R2kopOw45tq?X6T_^5uHq~xfK5@e4oOS;5YZuUe;O3CST;rwZ@Vmg%Ha81fp z4#rhmJDU}9wR69mh5qH}g1iG#eXdDgKIZ($P>i`kf4&g0@g&;bqtT=^=bOGtG@dbj z?TD&-BV|z5q!4zrl$VjpDfy)wlzf3uYoyI5#iCL)CWU<{AB(YYETTWDI7-(tTybVC z>#OS)vog$SFTazEw8gAf>96gD)1fa~(3}*kRlSQ~a?YKbbSp`n5-}wwGG9;+Z-oW9 z`P0EBWvh*GH8hZuVJ*^v(^$a`R~TzS*@A-oA8cNO_^+;}wHM**tXll)kyHJ)6h^C} z1qC@V5l64Vxs#NBMoSV)N$OGiELad|WY}6qZq(cwIxa#Z4EUyJKw>syp%!Q%M z75uj%XEw2(7lx6I9 Date: Thu, 10 Dec 2020 16:18:23 +0100 Subject: [PATCH 30/41] Added basic runner get tests ref #17 --- src/tests/runners/runner_add+get.spec.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/tests/runners/runner_add+get.spec.ts diff --git a/src/tests/runners/runner_add+get.spec.ts b/src/tests/runners/runner_add+get.spec.ts new file mode 100644 index 0000000..525acbf --- /dev/null +++ b/src/tests/runners/runner_add+get.spec.ts @@ -0,0 +1,19 @@ +import axios from 'axios'; +import { config } from '../../config'; +const base = "http://localhost:" + config.internal_port + +describe('GET /api/runners', () => { + it('basic get should return 200', async () => { + const res = await axios.get(base + '/api/runners'); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('GET /api/runners/0', () => { + it('basic get should return 404', async () => { + const res = await axios.get(base + '/api/runners/0', { validateStatus: undefined }); + expect(res.status).toEqual(404); + expect(res.headers['content-type']).toContain("application/json") + }); +}); From 47862f2e1dd3ab958b81242def40fda1fc6c8343 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 10 Dec 2020 17:41:15 +0100 Subject: [PATCH 31/41] Added runner creation tests ref #17 --- src/tests/runners/runner_add+get.spec.ts | 81 ++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/src/tests/runners/runner_add+get.spec.ts b/src/tests/runners/runner_add+get.spec.ts index 525acbf..f92ef87 100644 --- a/src/tests/runners/runner_add+get.spec.ts +++ b/src/tests/runners/runner_add+get.spec.ts @@ -17,3 +17,84 @@ describe('GET /api/runners/0', () => { expect(res.headers['content-type']).toContain("application/json") }); }); +// --------------- +describe('POST /api/runners with errors', () => { + it('creating a new runner without any parameters should return 400', async () => { + const res1 = await axios.post(base + '/api/runners', null, { validateStatus: undefined }); + expect(res1.status).toEqual(400); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new runner without a group should return 400', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "middlename": "middle", + "lastname": "last" + }, { validateStatus: undefined }); + expect(res2.status).toEqual(400); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('creating a new runner with a invalid valid group should return 404', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "middlename": "middle", + "lastname": "last", + "group": 0 + }, { validateStatus: undefined }); + expect(res2.status).toEqual(404); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('creating a new runner without a invalid phone number should return 400', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "middlename": "middle", + "lastname": "last", + "phone": "123" + }, { validateStatus: undefined }); + expect(res2.status).toEqual(400); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('creating a new runner without a invalid mail address should return 400', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "middlename": "middle", + "lastname": "last", + "email ": "123" + }, { validateStatus: undefined }); + expect(res2.status).toEqual(400); + expect(res2.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('POST /api/runners working', () => { + let added_org_id; + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + let added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new runner with only needed params should return 200', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "lastname": "last", + "group": added_org_id + }, { validateStatus: undefined }); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('creating a new runner with all non-relationship optional params should return 200', async () => { + const res3 = await axios.post(base + '/api/runners', { + "firstname": "first", + "middlename": "middle", + "lastname": "last", + "email": "test@example.com", + "phone": "+4909123123456789", + "group": added_org_id + }, { validateStatus: undefined }); + expect(res3.status).toEqual(200); + expect(res3.headers['content-type']).toContain("application/json") + }); +}); \ No newline at end of file From 49ac7be3671f5e322bd30b480f943f7464947718 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 10 Dec 2020 17:59:12 +0100 Subject: [PATCH 32/41] Moded runner get tests to a new file and added more of them ref #17 --- src/tests/runners/runner_add+get.spec.ts | 71 ++++------------ src/tests/runners/runner_add.spec.ts | 100 +++++++++++++++++++++++ 2 files changed, 114 insertions(+), 57 deletions(-) create mode 100644 src/tests/runners/runner_add.spec.ts diff --git a/src/tests/runners/runner_add+get.spec.ts b/src/tests/runners/runner_add+get.spec.ts index f92ef87..38f3508 100644 --- a/src/tests/runners/runner_add+get.spec.ts +++ b/src/tests/runners/runner_add+get.spec.ts @@ -18,55 +18,9 @@ describe('GET /api/runners/0', () => { }); }); // --------------- -describe('POST /api/runners with errors', () => { - it('creating a new runner without any parameters should return 400', async () => { - const res1 = await axios.post(base + '/api/runners', null, { validateStatus: undefined }); - expect(res1.status).toEqual(400); - expect(res1.headers['content-type']).toContain("application/json") - }); - it('creating a new runner without a group should return 400', async () => { - const res2 = await axios.post(base + '/api/runners', { - "firstname": "first", - "middlename": "middle", - "lastname": "last" - }, { validateStatus: undefined }); - expect(res2.status).toEqual(400); - expect(res2.headers['content-type']).toContain("application/json") - }); - it('creating a new runner with a invalid valid group should return 404', async () => { - const res2 = await axios.post(base + '/api/runners', { - "firstname": "first", - "middlename": "middle", - "lastname": "last", - "group": 0 - }, { validateStatus: undefined }); - expect(res2.status).toEqual(404); - expect(res2.headers['content-type']).toContain("application/json") - }); - it('creating a new runner without a invalid phone number should return 400', async () => { - const res2 = await axios.post(base + '/api/runners', { - "firstname": "first", - "middlename": "middle", - "lastname": "last", - "phone": "123" - }, { validateStatus: undefined }); - expect(res2.status).toEqual(400); - expect(res2.headers['content-type']).toContain("application/json") - }); - it('creating a new runner without a invalid mail address should return 400', async () => { - const res2 = await axios.post(base + '/api/runners', { - "firstname": "first", - "middlename": "middle", - "lastname": "last", - "email ": "123" - }, { validateStatus: undefined }); - expect(res2.status).toEqual(400); - expect(res2.headers['content-type']).toContain("application/json") - }); -}); -// --------------- -describe('POST /api/runners working', () => { +describe('GET /api/runners after adding', () => { let added_org_id; + let added_runner; it('creating a new org with just a name should return 200', async () => { const res1 = await axios.post(base + '/api/organisations', { "name": "test123" @@ -82,19 +36,22 @@ describe('POST /api/runners working', () => { "lastname": "last", "group": added_org_id }, { validateStatus: undefined }); + added_runner = res2.data; expect(res2.status).toEqual(200); expect(res2.headers['content-type']).toContain("application/json") }); - it('creating a new runner with all non-relationship optional params should return 200', async () => { - const res3 = await axios.post(base + '/api/runners', { - "firstname": "first", - "middlename": "middle", - "lastname": "last", - "email": "test@example.com", - "phone": "+4909123123456789", - "group": added_org_id - }, { validateStatus: undefined }); + it('explicit get should return 200', async () => { + const res3 = await axios.get(base + '/api/runners/' + added_runner.id, { validateStatus: undefined }); expect(res3.status).toEqual(200); expect(res3.headers['content-type']).toContain("application/json") + let gotten_runner = res3.data + expect(gotten_runner).toEqual(added_runner); + }); + it('get from all runners should return 200', async () => { + const res4 = await axios.get(base + '/api/runners/', { validateStatus: undefined }); + expect(res4.status).toEqual(200); + expect(res4.headers['content-type']).toContain("application/json") + let gotten_runner2 = res4.data[res4.data.length - 1] + expect(gotten_runner2).toEqual(added_runner); }); }); \ No newline at end of file diff --git a/src/tests/runners/runner_add.spec.ts b/src/tests/runners/runner_add.spec.ts new file mode 100644 index 0000000..f92ef87 --- /dev/null +++ b/src/tests/runners/runner_add.spec.ts @@ -0,0 +1,100 @@ +import axios from 'axios'; +import { config } from '../../config'; +const base = "http://localhost:" + config.internal_port + +describe('GET /api/runners', () => { + it('basic get should return 200', async () => { + const res = await axios.get(base + '/api/runners'); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('GET /api/runners/0', () => { + it('basic get should return 404', async () => { + const res = await axios.get(base + '/api/runners/0', { validateStatus: undefined }); + expect(res.status).toEqual(404); + expect(res.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('POST /api/runners with errors', () => { + it('creating a new runner without any parameters should return 400', async () => { + const res1 = await axios.post(base + '/api/runners', null, { validateStatus: undefined }); + expect(res1.status).toEqual(400); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new runner without a group should return 400', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "middlename": "middle", + "lastname": "last" + }, { validateStatus: undefined }); + expect(res2.status).toEqual(400); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('creating a new runner with a invalid valid group should return 404', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "middlename": "middle", + "lastname": "last", + "group": 0 + }, { validateStatus: undefined }); + expect(res2.status).toEqual(404); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('creating a new runner without a invalid phone number should return 400', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "middlename": "middle", + "lastname": "last", + "phone": "123" + }, { validateStatus: undefined }); + expect(res2.status).toEqual(400); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('creating a new runner without a invalid mail address should return 400', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "middlename": "middle", + "lastname": "last", + "email ": "123" + }, { validateStatus: undefined }); + expect(res2.status).toEqual(400); + expect(res2.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('POST /api/runners working', () => { + let added_org_id; + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + let added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new runner with only needed params should return 200', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "lastname": "last", + "group": added_org_id + }, { validateStatus: undefined }); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('creating a new runner with all non-relationship optional params should return 200', async () => { + const res3 = await axios.post(base + '/api/runners', { + "firstname": "first", + "middlename": "middle", + "lastname": "last", + "email": "test@example.com", + "phone": "+4909123123456789", + "group": added_org_id + }, { validateStatus: undefined }); + expect(res3.status).toEqual(200); + expect(res3.headers['content-type']).toContain("application/json") + }); +}); \ No newline at end of file From e223c060d4665556cf28d91a3e4fe85831e93602 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 10 Dec 2020 18:30:09 +0100 Subject: [PATCH 33/41] Fixed runner get test ref #17 --- src/tests/runners/runner_add+get.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/runners/runner_add+get.spec.ts b/src/tests/runners/runner_add+get.spec.ts index 38f3508..13d259c 100644 --- a/src/tests/runners/runner_add+get.spec.ts +++ b/src/tests/runners/runner_add+get.spec.ts @@ -51,7 +51,7 @@ describe('GET /api/runners after adding', () => { const res4 = await axios.get(base + '/api/runners/', { validateStatus: undefined }); expect(res4.status).toEqual(200); expect(res4.headers['content-type']).toContain("application/json") - let gotten_runner2 = res4.data[res4.data.length - 1] - expect(gotten_runner2).toEqual(added_runner); + let gotten_runners = res4.data + expect(gotten_runners).toContainEqual(added_runner); }); }); \ No newline at end of file From d2e0384f3cf0d159f1d531f4ac89fae8ae697da9 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 10 Dec 2020 18:30:26 +0100 Subject: [PATCH 34/41] Added runner deletion tests ref #17 --- src/tests/runners/runner_add+delete.spec.ts | 46 +++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/tests/runners/runner_add+delete.spec.ts diff --git a/src/tests/runners/runner_add+delete.spec.ts b/src/tests/runners/runner_add+delete.spec.ts new file mode 100644 index 0000000..b1239e4 --- /dev/null +++ b/src/tests/runners/runner_add+delete.spec.ts @@ -0,0 +1,46 @@ +import axios from 'axios'; +import { config } from '../../config'; +const base = "http://localhost:" + config.internal_port + +describe('adding + deletion (non-existant)', () => { + it('delete', async () => { + const res2 = await axios.delete(base + '/api/runners/0', { validateStatus: undefined }); + expect(res2.status).toEqual(204); + }); +}); +// --------------- +describe('add+delete', () => { + let added_org_id; + let added_runner; + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + let added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new runner with only needed params should return 200', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "lastname": "last", + "group": added_org_id + }, { validateStatus: undefined }); + added_runner = res2.data; + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('delete runner', async () => { + const res3 = await axios.delete(base + '/api/runners/' + added_runner.id); + expect(res3.status).toEqual(200); + expect(res3.headers['content-type']).toContain("application/json") + let deleted_runner = res3.data + expect(deleted_runner).toEqual(added_runner); + }); + it('check if team really was deleted', async () => { + const res4 = await axios.get(base + '/api/runners/' + added_runner.id, { validateStatus: undefined }); + expect(res4.status).toEqual(404); + expect(res4.headers['content-type']).toContain("application/json") + }); +}); \ No newline at end of file From 64725d9e7a75e3768ba1912989a94ac1ec741fb9 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 10 Dec 2020 18:39:40 +0100 Subject: [PATCH 35/41] Added basic update test --- src/tests/runners/runner_add+update.spec.ts | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/tests/runners/runner_add+update.spec.ts diff --git a/src/tests/runners/runner_add+update.spec.ts b/src/tests/runners/runner_add+update.spec.ts new file mode 100644 index 0000000..1d16a79 --- /dev/null +++ b/src/tests/runners/runner_add+update.spec.ts @@ -0,0 +1,38 @@ +import axios from 'axios'; +import { config } from '../../config'; +const base = "http://localhost:" + config.internal_port + + +describe('Update runner name after adding', () => { + let added_org_id; + let added_runner; + let updated_runner; + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + let added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new runner with only needed params should return 200', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "lastname": "last", + "group": added_org_id + }, { validateStatus: undefined }); + added_runner = res2.data; + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('valid update should return 200', async () => { + let runnercopy = added_runner + runnercopy.firstname = "second" + const res3 = await axios.put(base + '/api/runners/' + added_runner.id, runnercopy, { validateStatus: undefined }); + expect(res3.status).toEqual(200); + expect(res3.headers['content-type']).toContain("application/json") + updated_runner = res3.data + expect(updated_runner).toEqual(runnercopy); + }); +}); \ No newline at end of file From c20f01f485897ca3f6e5a4936525fc7266ec020c Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 10 Dec 2020 19:48:03 +0100 Subject: [PATCH 36/41] Added runner update tests --- src/tests/runners/runner_add+update.spec.ts | 107 ++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/src/tests/runners/runner_add+update.spec.ts b/src/tests/runners/runner_add+update.spec.ts index 1d16a79..2450876 100644 --- a/src/tests/runners/runner_add+update.spec.ts +++ b/src/tests/runners/runner_add+update.spec.ts @@ -35,4 +35,111 @@ describe('Update runner name after adding', () => { updated_runner = res3.data expect(updated_runner).toEqual(runnercopy); }); +}); +// --------------- +describe('Update runner group after adding', () => { + let added_org_id; + let added_org_2; + let added_runner; + let updated_runner; + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + let added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new runner with only needed params should return 200', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "lastname": "last", + "group": added_org_id + }, { validateStatus: undefined }); + added_runner = res2.data; + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('creating a new org with just a name should return 200', async () => { + const res3 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + added_org_2 = res3.data + delete added_org_2.address; + delete added_org_2.contact; + delete added_org_2.teams; + expect(res3.status).toEqual(200); + expect(res3.headers['content-type']).toContain("application/json") + }); + it('valid update should return 200', async () => { + added_runner.group = added_org_2; + const res3 = await axios.put(base + '/api/runners/' + added_runner.id, added_runner, { validateStatus: undefined }); + expect(res3.status).toEqual(200); + expect(res3.headers['content-type']).toContain("application/json") + updated_runner = res3.data + expect(updated_runner).toEqual(added_runner); + }); +}); +// --------------- +describe('Update runner id after adding(should fail)', () => { + let added_org_id; + let added_runner; + let added_runner_id; + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + let added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new runner with only needed params should return 200', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "lastname": "last", + "group": added_org_id + }, { validateStatus: undefined }); + added_runner = res2.data; + added_runner_id = added_runner.id; + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('invalid update should return 406', async () => { + added_runner.id++; + const res3 = await axios.put(base + '/api/runners/' + added_runner_id, added_runner, { validateStatus: undefined }); + expect(res3.status).toEqual(406); + expect(res3.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('Update runner group with invalid group after adding', () => { + let added_org; + let added_runner; + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + added_org = res1.data + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new runner with only needed params should return 200', async () => { + const res2 = await axios.post(base + '/api/runners', { + "firstname": "first", + "lastname": "last", + "group": added_org.id + }, { validateStatus: undefined }); + added_runner = res2.data; + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('invalid update should return 404', async () => { + added_org.id++; + added_runner.group = added_org; + const res3 = await axios.put(base + '/api/runners/' + added_runner.id, added_runner, { validateStatus: undefined }); + expect(res3.status).toEqual(404); + expect(res3.headers['content-type']).toContain("application/json") + }); }); \ No newline at end of file From 6e12b014e706b96e3e3b1f2d39276f417a537157 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 10 Dec 2020 19:48:50 +0100 Subject: [PATCH 37/41] future proved the group update failture ref #17 --- src/tests/runners/runner_add+update.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/runners/runner_add+update.spec.ts b/src/tests/runners/runner_add+update.spec.ts index 2450876..97ccf2a 100644 --- a/src/tests/runners/runner_add+update.spec.ts +++ b/src/tests/runners/runner_add+update.spec.ts @@ -136,7 +136,7 @@ describe('Update runner group with invalid group after adding', () => { expect(res2.headers['content-type']).toContain("application/json") }); it('invalid update should return 404', async () => { - added_org.id++; + added_org.id = 0; added_runner.group = added_org; const res3 = await axios.put(base + '/api/runners/' + added_runner.id, added_runner, { validateStatus: undefined }); expect(res3.status).toEqual(404); From 92dee666ee842eafa010cb19484e850be01daacb Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 10 Dec 2020 19:53:19 +0100 Subject: [PATCH 38/41] Added team update test ref #17 --- src/tests/runnerTeams/team_add+update.spec.ts | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/tests/runnerTeams/team_add+update.spec.ts b/src/tests/runnerTeams/team_add+update.spec.ts index edd94af..117fefe 100644 --- a/src/tests/runnerTeams/team_add+update.spec.ts +++ b/src/tests/runnerTeams/team_add+update.spec.ts @@ -72,4 +72,45 @@ describe('adding + try updating id (should return 406)', () => { expect(res3.status).toEqual(406); expect(res3.headers['content-type']).toContain("application/json") }); +}); +// --------------- +describe('add+update parent org (valid)', () => { + let added_org; + let added_org2; + let added_team; + let added_team_id + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + added_org = res1.data; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('creating a new team with a valid org should return 200', async () => { + const res2 = await axios.post(base + '/api/teams', { + "name": "test123", + "parentGroup": added_org.id + }); + added_team = res2.data; + added_team_id = added_team.id; + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }); + it('creating a new org with just a name should return 200', async () => { + const res3 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + added_org2 = res3.data; + expect(res3.status).toEqual(200); + expect(res3.headers['content-type']).toContain("application/json") + }); + it('update team', async () => { + added_team.parentGroup = added_org2; + const res4 = await axios.put(base + '/api/teams/' + added_team_id, added_team, { validateStatus: undefined }); + let updated_team = res4.data; + expect(res4.status).toEqual(200); + expect(res4.headers['content-type']).toContain("application/json") + expect(updated_team).toEqual(added_team) + }); }); \ No newline at end of file From 6eee80d3577d5da218ace78710904dc8523ebfe3 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 10 Dec 2020 20:08:20 +0100 Subject: [PATCH 39/41] Runner update tests now run clean ref #17 --- src/tests/runnerTeams/team_add+update.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tests/runnerTeams/team_add+update.spec.ts b/src/tests/runnerTeams/team_add+update.spec.ts index 117fefe..10b6c0c 100644 --- a/src/tests/runnerTeams/team_add+update.spec.ts +++ b/src/tests/runnerTeams/team_add+update.spec.ts @@ -111,6 +111,9 @@ describe('add+update parent org (valid)', () => { let updated_team = res4.data; expect(res4.status).toEqual(200); expect(res4.headers['content-type']).toContain("application/json") + delete added_org2.address; + delete added_org2.contact; + delete added_org2.teams; expect(updated_team).toEqual(added_team) }); }); \ No newline at end of file From d295100a48b46aaa1b2f085464ae282e9d626c10 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 10 Dec 2020 20:32:57 +0100 Subject: [PATCH 40/41] refactoring: cleaned up the names ref #17 --- .../{org_add+get.spec.ts => org_add.spec.ts} | 8 -------- ..._add+delete.spec.ts => org_delete.spec.ts} | 0 src/tests/runnerOrgs/org_get.spec.ts | 19 +++++++++++++++++++ ..._add+update.spec.ts => org_update.spec.ts} | 0 ...{team_add+get.spec.ts => team_add.spec.ts} | 0 ...add+delete.spec.ts => team_delete.spec.ts} | 0 src/tests/runnerTeams/team_get.spec.ts | 19 +++++++++++++++++++ ...add+update.spec.ts => team_update.spec.ts} | 0 ...d+delete.spec.ts => runner_delete.spec.ts} | 0 ...ner_add+get.spec.ts => runner_get.spec.ts} | 0 ...d+update.spec.ts => runner_update.spec.ts} | 0 11 files changed, 38 insertions(+), 8 deletions(-) rename src/tests/runnerOrgs/{org_add+get.spec.ts => org_add.spec.ts} (89%) rename src/tests/runnerOrgs/{org_add+delete.spec.ts => org_delete.spec.ts} (100%) create mode 100644 src/tests/runnerOrgs/org_get.spec.ts rename src/tests/runnerOrgs/{org_add+update.spec.ts => org_update.spec.ts} (100%) rename src/tests/runnerTeams/{team_add+get.spec.ts => team_add.spec.ts} (100%) rename src/tests/runnerTeams/{team_add+delete.spec.ts => team_delete.spec.ts} (100%) create mode 100644 src/tests/runnerTeams/team_get.spec.ts rename src/tests/runnerTeams/{team_add+update.spec.ts => team_update.spec.ts} (100%) rename src/tests/runners/{runner_add+delete.spec.ts => runner_delete.spec.ts} (100%) rename src/tests/runners/{runner_add+get.spec.ts => runner_get.spec.ts} (100%) rename src/tests/runners/{runner_add+update.spec.ts => runner_update.spec.ts} (100%) diff --git a/src/tests/runnerOrgs/org_add+get.spec.ts b/src/tests/runnerOrgs/org_add.spec.ts similarity index 89% rename from src/tests/runnerOrgs/org_add+get.spec.ts rename to src/tests/runnerOrgs/org_add.spec.ts index fb28b62..eaf7b94 100644 --- a/src/tests/runnerOrgs/org_add+get.spec.ts +++ b/src/tests/runnerOrgs/org_add.spec.ts @@ -2,14 +2,6 @@ import axios from 'axios'; import { config } from '../../config'; const base = "http://localhost:" + config.internal_port -describe('GET /api/organisations', () => { - it('basic get should return 200', async () => { - const res = await axios.get(base + '/api/organisations'); - expect(res.status).toEqual(200); - expect(res.headers['content-type']).toContain("application/json") - }); -}); -// --------------- describe('POST /api/organisations', () => { it('creating a new org with just a name should return 200', async () => { const res = await axios.post(base + '/api/organisations', { diff --git a/src/tests/runnerOrgs/org_add+delete.spec.ts b/src/tests/runnerOrgs/org_delete.spec.ts similarity index 100% rename from src/tests/runnerOrgs/org_add+delete.spec.ts rename to src/tests/runnerOrgs/org_delete.spec.ts diff --git a/src/tests/runnerOrgs/org_get.spec.ts b/src/tests/runnerOrgs/org_get.spec.ts new file mode 100644 index 0000000..3e899f7 --- /dev/null +++ b/src/tests/runnerOrgs/org_get.spec.ts @@ -0,0 +1,19 @@ +import axios from 'axios'; +import { config } from '../../config'; +const base = "http://localhost:" + config.internal_port + +describe('GET /api/organisations', () => { + it('basic get should return 200', async () => { + const res = await axios.get(base + '/api/organisations'); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('GET /api/organisations/0', () => { + it('basic get should return 404', async () => { + const res = await axios.get(base + '/api/runners/0', { validateStatus: undefined }); + expect(res.status).toEqual(404); + expect(res.headers['content-type']).toContain("application/json") + }); +}); \ No newline at end of file diff --git a/src/tests/runnerOrgs/org_add+update.spec.ts b/src/tests/runnerOrgs/org_update.spec.ts similarity index 100% rename from src/tests/runnerOrgs/org_add+update.spec.ts rename to src/tests/runnerOrgs/org_update.spec.ts diff --git a/src/tests/runnerTeams/team_add+get.spec.ts b/src/tests/runnerTeams/team_add.spec.ts similarity index 100% rename from src/tests/runnerTeams/team_add+get.spec.ts rename to src/tests/runnerTeams/team_add.spec.ts diff --git a/src/tests/runnerTeams/team_add+delete.spec.ts b/src/tests/runnerTeams/team_delete.spec.ts similarity index 100% rename from src/tests/runnerTeams/team_add+delete.spec.ts rename to src/tests/runnerTeams/team_delete.spec.ts diff --git a/src/tests/runnerTeams/team_get.spec.ts b/src/tests/runnerTeams/team_get.spec.ts new file mode 100644 index 0000000..f30b230 --- /dev/null +++ b/src/tests/runnerTeams/team_get.spec.ts @@ -0,0 +1,19 @@ +import axios from 'axios'; +import { config } from '../../config'; +const base = "http://localhost:" + config.internal_port + +describe('GET /api/teams', () => { + it('basic get should return 200', async () => { + const res = await axios.get(base + '/api/teams'); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); +}); +// --------------- +describe('GET /api/teams/0', () => { + it('basic get should return 404', async () => { + const res = await axios.get(base + '/api/teams/0', { validateStatus: undefined }); + expect(res.status).toEqual(404); + expect(res.headers['content-type']).toContain("application/json") + }); +}); \ No newline at end of file diff --git a/src/tests/runnerTeams/team_add+update.spec.ts b/src/tests/runnerTeams/team_update.spec.ts similarity index 100% rename from src/tests/runnerTeams/team_add+update.spec.ts rename to src/tests/runnerTeams/team_update.spec.ts diff --git a/src/tests/runners/runner_add+delete.spec.ts b/src/tests/runners/runner_delete.spec.ts similarity index 100% rename from src/tests/runners/runner_add+delete.spec.ts rename to src/tests/runners/runner_delete.spec.ts diff --git a/src/tests/runners/runner_add+get.spec.ts b/src/tests/runners/runner_get.spec.ts similarity index 100% rename from src/tests/runners/runner_add+get.spec.ts rename to src/tests/runners/runner_get.spec.ts diff --git a/src/tests/runners/runner_add+update.spec.ts b/src/tests/runners/runner_update.spec.ts similarity index 100% rename from src/tests/runners/runner_add+update.spec.ts rename to src/tests/runners/runner_update.spec.ts From 5a27689e80a54c424c3ce260e40d2af2a64e52d9 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 10 Dec 2020 20:33:36 +0100 Subject: [PATCH 41/41] new get test ref #17 --- src/tests/runnerOrgs/org_add.spec.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tests/runnerOrgs/org_add.spec.ts b/src/tests/runnerOrgs/org_add.spec.ts index eaf7b94..fb28b62 100644 --- a/src/tests/runnerOrgs/org_add.spec.ts +++ b/src/tests/runnerOrgs/org_add.spec.ts @@ -2,6 +2,14 @@ import axios from 'axios'; import { config } from '../../config'; const base = "http://localhost:" + config.internal_port +describe('GET /api/organisations', () => { + it('basic get should return 200', async () => { + const res = await axios.get(base + '/api/organisations'); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); +}); +// --------------- describe('POST /api/organisations', () => { it('creating a new org with just a name should return 200', async () => { const res = await axios.post(base + '/api/organisations', {