diff --git a/tasks/gulp-tests.js b/tasks/gulp-tests.js index 6cd40918b2..530f519a59 100644 --- a/tasks/gulp-tests.js +++ b/tasks/gulp-tests.js @@ -15,7 +15,7 @@ let server; const TEST_DB_URI = `mongodb://localhost/${TEST_DB}` -const API_TEST_COMMAND = 'mocha test/api --recursive --compilers js:babel/register'; +const API_V2_TEST_COMMAND = 'mocha test/api/v2 --recursive --compilers js:babel/register'; const LEGACY_API_TEST_COMMAND = 'mocha test/api-legacy'; const COMMON_TEST_COMMAND = 'mocha test/common --compilers coffee:coffee-script'; const CONTENT_TEST_COMMAND = 'mocha test/content --compilers js:babel/register'; @@ -293,12 +293,16 @@ gulp.task('test:e2e:safe', ['test:prepare', 'test:prepare:server'], (cb) => { }); }); -gulp.task('test:api', ['test:prepare:server'], (done) => { +gulp.task('test:api-v2', ['test:prepare:server'], (done) => { + runIntegrationTestsWithMocha('./test/api/v2/**/*.js') +}); + +function runIntegrationTestsWithMocha(files) { require('../test/helpers/globals.helper'); awaitPort(TEST_SERVER_PORT).then(() => { let mocha = new Mocha({reporter: 'spec'}); - let tests = glob('./test/api/**/*.js'); + let tests = glob(files); tests.forEach((test) => { delete require.cache[resolve(test)]; @@ -313,17 +317,17 @@ gulp.task('test:api', ['test:prepare:server'], (done) => { done(); }); }); -}); +} -gulp.task('test:api:watch', ['test:prepare:server'], () => { +gulp.task('test:api-v2:watch', ['test:prepare:server'], () => { process.env.RUN_INTEGRATION_TEST_FOREVER = true; gulp.watch(['website/src/**', 'test/api/**'], ['test:api']); }); -gulp.task('test:api:safe', ['test:prepare:server'], (done) => { +gulp.task('test:api-v2:safe', ['test:prepare:server'], (done) => { awaitPort(TEST_SERVER_PORT).then(() => { let runner = exec( - testBin(API_TEST_COMMAND), + testBin(API_V2_TEST_COMMAND), (err, stdout, stderr) => { testResults.push({ suite: 'API Specs\t', @@ -345,7 +349,7 @@ gulp.task('test', [ 'test:server_side:safe', 'test:karma:safe', 'test:api-legacy:safe', - 'test:api:safe', + 'test:api-v2:safe', ], () => { let totals = [0,0,0]; diff --git a/test/api/README.md b/test/api/v2/README.md similarity index 97% rename from test/api/README.md rename to test/api/v2/README.md index 5751dfb26a..118f17078a 100644 --- a/test/api/README.md +++ b/test/api/v2/README.md @@ -19,15 +19,15 @@ $ npm install -g gulp To run the api tests, make sure the mongo db is up and running and then type this on the command line: ```bash -$ gulp test:api +$ gulp test:api-v2 ``` It may take a little while to get going, since it requires the web server to start up before the tests can run. -You can also run a watch command for the api tests. This will allow the tests to re-run automatically when you make changes in the `/test/api/` or `/website/src/` directories. +You can also run a watch command for the api tests. This will allow the tests to re-run automatically when you make changes in the `/test/api/v2/`. ```bash -$ gulp test:api:watch +$ gulp test:api-v2:watch ``` One caveat. If you have a severe syntax error in your files, the tests may fail to run, but they won't alert you that they are not running. If you ever find your test hanging for a while, run this to get the stackstrace. Once you've fixed the problem, you can resume running the watch comand. diff --git a/test/api/groups/GET-groups.test.js b/test/api/v2/groups/GET-groups.test.js similarity index 98% rename from test/api/groups/GET-groups.test.js rename to test/api/v2/groups/GET-groups.test.js index 86be49a810..191afea663 100644 --- a/test/api/groups/GET-groups.test.js +++ b/test/api/v2/groups/GET-groups.test.js @@ -3,7 +3,7 @@ import { generateUser, resetHabiticaDB, requester, -} from '../../helpers/api.helper'; +} from '../../../helpers/api-integration.helper'; describe('GET /groups', () => { const NUMBER_OF_PUBLIC_GUILDS = 3; diff --git a/test/api/groups/GET-groups_id.test.js b/test/api/v2/groups/GET-groups_id.test.js similarity index 99% rename from test/api/groups/GET-groups_id.test.js rename to test/api/v2/groups/GET-groups_id.test.js index 786bc45b83..0840d79f32 100644 --- a/test/api/groups/GET-groups_id.test.js +++ b/test/api/v2/groups/GET-groups_id.test.js @@ -3,7 +3,7 @@ import { generateUser, requester, translate as t, -} from '../../helpers/api.helper'; +} from '../../../helpers/api-integration.helper'; import { find, each diff --git a/test/api/groups/POST-groups.test.js b/test/api/v2/groups/POST-groups.test.js similarity index 98% rename from test/api/groups/POST-groups.test.js rename to test/api/v2/groups/POST-groups.test.js index 71d241a7c6..2fb70e0a7a 100644 --- a/test/api/groups/POST-groups.test.js +++ b/test/api/v2/groups/POST-groups.test.js @@ -3,7 +3,7 @@ import { generateUser, requester, translate as t, -} from '../../helpers/api.helper'; +} from '../../../helpers/api-integration.helper'; describe('POST /groups', () => { diff --git a/test/api/groups/POST-groups_id.test.js b/test/api/v2/groups/POST-groups_id.test.js similarity index 97% rename from test/api/groups/POST-groups_id.test.js rename to test/api/v2/groups/POST-groups_id.test.js index 603d0fe6a6..d71f37a076 100644 --- a/test/api/groups/POST-groups_id.test.js +++ b/test/api/v2/groups/POST-groups_id.test.js @@ -3,7 +3,7 @@ import { generateUser, requester, translate as t, -} from '../../helpers/api.helper'; +} from '../../../helpers/api-integration.helper'; describe('POST /groups/:id', () => { diff --git a/test/api/groups/POST-groups_id_join.test.js b/test/api/v2/groups/POST-groups_id_join.test.js similarity index 98% rename from test/api/groups/POST-groups_id_join.test.js rename to test/api/v2/groups/POST-groups_id_join.test.js index 1d3ab95dca..ce00136f19 100644 --- a/test/api/groups/POST-groups_id_join.test.js +++ b/test/api/v2/groups/POST-groups_id_join.test.js @@ -3,7 +3,7 @@ import { generateUser, requester, translate as t, -} from '../../helpers/api.helper'; +} from '../../../helpers/api-integration.helper'; import { each, find } from 'lodash'; describe('POST /groups/:id/join', () => { diff --git a/test/api/groups/POST-groups_id_leave.test.js b/test/api/v2/groups/POST-groups_id_leave.test.js similarity index 98% rename from test/api/groups/POST-groups_id_leave.test.js rename to test/api/v2/groups/POST-groups_id_leave.test.js index e895f56f61..408d7ca024 100644 --- a/test/api/groups/POST-groups_id_leave.test.js +++ b/test/api/v2/groups/POST-groups_id_leave.test.js @@ -4,7 +4,7 @@ import { generateUser, requester, translate as t, -} from '../../helpers/api.helper'; +} from '../../../helpers/api-integration.helper'; import { find } from 'lodash'; describe('POST /groups/:id/leave', () => { diff --git a/test/api/groups/POST-groups_id_removeMember.test.js b/test/api/v2/groups/POST-groups_id_removeMember.test.js similarity index 96% rename from test/api/groups/POST-groups_id_removeMember.test.js rename to test/api/v2/groups/POST-groups_id_removeMember.test.js index 2806e54fc5..541f2fd736 100644 --- a/test/api/groups/POST-groups_id_removeMember.test.js +++ b/test/api/v2/groups/POST-groups_id_removeMember.test.js @@ -4,7 +4,7 @@ import { generateUser, requester, translate as t, -} from '../../helpers/api.helper'; +} from '../../../helpers/api-integration.helper'; describe('POST /groups/:id/removeMember', () => { diff --git a/test/api/groups/chat/DELETE-groups_id_chat.test.js b/test/api/v2/groups/chat/DELETE-groups_id_chat.test.js similarity index 95% rename from test/api/groups/chat/DELETE-groups_id_chat.test.js rename to test/api/v2/groups/chat/DELETE-groups_id_chat.test.js index aee50ed3f3..10e79e3963 100644 --- a/test/api/groups/chat/DELETE-groups_id_chat.test.js +++ b/test/api/v2/groups/chat/DELETE-groups_id_chat.test.js @@ -3,7 +3,7 @@ import { generateUser, requester, translate as t, -} from '../../../helpers/api.helper'; +} from '../../../../helpers/api-integration.helper'; describe('DELETE /groups/:id/chat', () => { let api, group, message, user; diff --git a/test/api/groups/chat/GET-groups_id_chat.test.js b/test/api/v2/groups/chat/GET-groups_id_chat.test.js similarity index 95% rename from test/api/groups/chat/GET-groups_id_chat.test.js rename to test/api/v2/groups/chat/GET-groups_id_chat.test.js index 99c19f5fca..1d750e5e7e 100644 --- a/test/api/groups/chat/GET-groups_id_chat.test.js +++ b/test/api/v2/groups/chat/GET-groups_id_chat.test.js @@ -3,7 +3,7 @@ import { generateUser, requester, translate as t, -} from '../../../helpers/api.helper'; +} from '../../../../helpers/api-integration.helper'; describe('GET /groups/:id/chat', () => { diff --git a/test/api/groups/chat/POST-groups_id_chat.test.js b/test/api/v2/groups/chat/POST-groups_id_chat.test.js similarity index 95% rename from test/api/groups/chat/POST-groups_id_chat.test.js rename to test/api/v2/groups/chat/POST-groups_id_chat.test.js index 82fac690f3..6a4f3a0c05 100644 --- a/test/api/groups/chat/POST-groups_id_chat.test.js +++ b/test/api/v2/groups/chat/POST-groups_id_chat.test.js @@ -3,7 +3,7 @@ import { generateUser, requester, translate as t, -} from '../../../helpers/api.helper'; +} from '../../../../helpers/api-integration.helper'; describe('POST /groups/:id/chat', () => { diff --git a/test/api/groups/chat/POST-groups_id_chat_id_flag.test.js b/test/api/v2/groups/chat/POST-groups_id_chat_id_flag.test.js similarity index 97% rename from test/api/groups/chat/POST-groups_id_chat_id_flag.test.js rename to test/api/v2/groups/chat/POST-groups_id_chat_id_flag.test.js index 16ab13f429..e6154a1fba 100644 --- a/test/api/groups/chat/POST-groups_id_chat_id_flag.test.js +++ b/test/api/v2/groups/chat/POST-groups_id_chat_id_flag.test.js @@ -3,7 +3,7 @@ import { generateUser, requester, translate as t, -} from '../../../helpers/api.helper'; +} from '../../../../helpers/api-integration.helper'; describe('POST /groups/:id/chat/:id/flag', () => { diff --git a/test/api/groups/chat/POST-groups_id_chat_id_like.test.js b/test/api/v2/groups/chat/POST-groups_id_chat_id_like.test.js similarity index 98% rename from test/api/groups/chat/POST-groups_id_chat_id_like.test.js rename to test/api/v2/groups/chat/POST-groups_id_chat_id_like.test.js index 654a030629..a3604a0443 100644 --- a/test/api/groups/chat/POST-groups_id_chat_id_like.test.js +++ b/test/api/v2/groups/chat/POST-groups_id_chat_id_like.test.js @@ -3,7 +3,7 @@ import { generateUser, requester, translate as t, -} from '../../../helpers/api.helper'; +} from '../../../../helpers/api-integration.helper'; describe('POST /groups/:id/chat/:id/like', () => { diff --git a/test/api/register/POST-register.test.js b/test/api/v2/register/POST-register.test.js similarity index 98% rename from test/api/register/POST-register.test.js rename to test/api/v2/register/POST-register.test.js index bb87eea1ff..19c9b3e341 100644 --- a/test/api/register/POST-register.test.js +++ b/test/api/v2/register/POST-register.test.js @@ -2,7 +2,7 @@ import { generateUser, requester, translate as t, -} from '../../helpers/api.helper'; +} from '../../../helpers/api-integration.helper'; import {v4 as generateRandomUserName} from 'uuid'; describe('POST /register', () => { diff --git a/test/api/status/GET-status.test.js b/test/api/v2/status/GET-status.test.js similarity index 75% rename from test/api/status/GET-status.test.js rename to test/api/v2/status/GET-status.test.js index 86979c42cb..d5b5c2513f 100644 --- a/test/api/status/GET-status.test.js +++ b/test/api/v2/status/GET-status.test.js @@ -1,4 +1,4 @@ -import {requester} from '../../helpers/api.helper'; +import {requester} from '../../../helpers/api-integration.helper'; describe('Status', () => { diff --git a/test/api/user/DELETE-user.test.js b/test/api/v2/user/DELETE-user.test.js similarity index 97% rename from test/api/user/DELETE-user.test.js rename to test/api/v2/user/DELETE-user.test.js index c69c398e5f..eb7bc2b047 100644 --- a/test/api/user/DELETE-user.test.js +++ b/test/api/v2/user/DELETE-user.test.js @@ -4,7 +4,7 @@ import { generateUser, requester, translate as t, -} from '../../helpers/api.helper'; +} from '../../../helpers/api-integration.helper'; describe('DELETE /user', () => { let api, user; diff --git a/test/api/user/GET-user.test.js b/test/api/v2/user/GET-user.test.js similarity index 93% rename from test/api/user/GET-user.test.js rename to test/api/v2/user/GET-user.test.js index 30d903d022..d370f4cb0a 100644 --- a/test/api/user/GET-user.test.js +++ b/test/api/v2/user/GET-user.test.js @@ -1,7 +1,7 @@ import { generateUser, requester, -} from '../../helpers/api.helper'; +} from '../../../helpers/api-integration.helper'; describe('GET /user', () => { let user; diff --git a/test/api/user/GET-user_tags.test.js b/test/api/v2/user/GET-user_tags.test.js similarity index 87% rename from test/api/user/GET-user_tags.test.js rename to test/api/v2/user/GET-user_tags.test.js index c76d5f66e4..e652a8fcf1 100644 --- a/test/api/user/GET-user_tags.test.js +++ b/test/api/v2/user/GET-user_tags.test.js @@ -1,7 +1,7 @@ import { generateUser, requester, -} from '../../helpers/api.helper'; +} from '../../../helpers/api-integration.helper'; describe('GET /user/tags', () => { let api, user; diff --git a/test/api/user/GET-user_tags_id.test.js b/test/api/v2/user/GET-user_tags_id.test.js similarity index 92% rename from test/api/user/GET-user_tags_id.test.js rename to test/api/v2/user/GET-user_tags_id.test.js index 5bcbead2f0..e7678caec0 100644 --- a/test/api/user/GET-user_tags_id.test.js +++ b/test/api/v2/user/GET-user_tags_id.test.js @@ -2,7 +2,7 @@ import { generateUser, requester, translate as t, -} from '../../helpers/api.helper'; +} from '../../../helpers/api-integration.helper'; describe('GET /user/tags/id', () => { let api, user; diff --git a/test/api/user/PUT-user.test.js b/test/api/v2/user/PUT-user.test.js similarity index 97% rename from test/api/user/PUT-user.test.js rename to test/api/v2/user/PUT-user.test.js index 836e97920b..87a8898008 100644 --- a/test/api/user/PUT-user.test.js +++ b/test/api/v2/user/PUT-user.test.js @@ -2,7 +2,7 @@ import { generateUser, requester, translate as t, -} from '../../helpers/api.helper'; +} from '../../../helpers/api-integration.helper'; import { each } from 'lodash'; diff --git a/test/api/user/anonymized/GET-user_anonymized.test.js b/test/api/v2/user/anonymized/GET-user_anonymized.test.js similarity index 98% rename from test/api/user/anonymized/GET-user_anonymized.test.js rename to test/api/v2/user/anonymized/GET-user_anonymized.test.js index 7c8037eb9b..b4cb5cb2b0 100644 --- a/test/api/user/anonymized/GET-user_anonymized.test.js +++ b/test/api/v2/user/anonymized/GET-user_anonymized.test.js @@ -1,7 +1,7 @@ import { generateUser, requester, -} from '../../../helpers/api.helper'; +} from '../../../../helpers/api-integration.helper'; import { each } from 'lodash'; describe('GET /user/anonymized', () => { diff --git a/test/api/user/batch-update/POST-user_batch-update.test.js b/test/api/v2/user/batch-update/POST-user_batch-update.test.js similarity index 97% rename from test/api/user/batch-update/POST-user_batch-update.test.js rename to test/api/v2/user/batch-update/POST-user_batch-update.test.js index 23e6be52fe..c1b1e499b4 100644 --- a/test/api/user/batch-update/POST-user_batch-update.test.js +++ b/test/api/v2/user/batch-update/POST-user_batch-update.test.js @@ -2,7 +2,7 @@ import { generateUser, requester, translate as t, -} from '../../../helpers/api.helper'; +} from '../../../../helpers/api-integration.helper'; import { each } from 'lodash'; diff --git a/test/api/user/pushDevice/POST-pushDevice.test.js b/test/api/v2/user/pushDevice/POST-pushDevice.test.js similarity index 90% rename from test/api/user/pushDevice/POST-pushDevice.test.js rename to test/api/v2/user/pushDevice/POST-pushDevice.test.js index 072f0ff3f9..1b5ae41681 100644 --- a/test/api/user/pushDevice/POST-pushDevice.test.js +++ b/test/api/v2/user/pushDevice/POST-pushDevice.test.js @@ -1,7 +1,7 @@ import { generateUser, requester, -} from '../../../helpers/api.helper'; +} from '../../../../helpers/api-integration.helper'; describe('POST /user/pushDevice', () => { let api; diff --git a/test/api/user/tasks/DELETE-tasks_id.test.js b/test/api/v2/user/tasks/DELETE-tasks_id.test.js similarity index 95% rename from test/api/user/tasks/DELETE-tasks_id.test.js rename to test/api/v2/user/tasks/DELETE-tasks_id.test.js index 3a13a6e3c5..72c18f6b6c 100644 --- a/test/api/user/tasks/DELETE-tasks_id.test.js +++ b/test/api/v2/user/tasks/DELETE-tasks_id.test.js @@ -2,7 +2,7 @@ import { generateUser, requester, translate as t, -} from '../../../helpers/api.helper'; +} from '../../../../helpers/api-integration.helper'; describe('DELETE /user/tasks/:id', () => { let api, user, task; diff --git a/test/api/user/tasks/GET-tasks.test.js b/test/api/v2/user/tasks/GET-tasks.test.js similarity index 91% rename from test/api/user/tasks/GET-tasks.test.js rename to test/api/v2/user/tasks/GET-tasks.test.js index c58e8d11ef..6c70bdd554 100644 --- a/test/api/user/tasks/GET-tasks.test.js +++ b/test/api/v2/user/tasks/GET-tasks.test.js @@ -2,7 +2,7 @@ import { generateUser, requester, translate as t, -} from '../../../helpers/api.helper'; +} from '../../../../helpers/api-integration.helper'; describe('GET /user/tasks/', () => { let api, user; diff --git a/test/api/user/tasks/GET-tasks_id.test.js b/test/api/v2/user/tasks/GET-tasks_id.test.js similarity index 95% rename from test/api/user/tasks/GET-tasks_id.test.js rename to test/api/v2/user/tasks/GET-tasks_id.test.js index d321b66666..d3242ab40e 100644 --- a/test/api/user/tasks/GET-tasks_id.test.js +++ b/test/api/v2/user/tasks/GET-tasks_id.test.js @@ -2,7 +2,7 @@ import { generateUser, requester, translate as t, -} from '../../../helpers/api.helper'; +} from '../../../../helpers/api-integration.helper'; describe('GET /user/tasks/:id', () => { let api, user, task; diff --git a/test/api/user/tasks/POST-tasks.test.js b/test/api/v2/user/tasks/POST-tasks.test.js similarity index 97% rename from test/api/user/tasks/POST-tasks.test.js rename to test/api/v2/user/tasks/POST-tasks.test.js index 556e4f37af..1f7a837990 100644 --- a/test/api/user/tasks/POST-tasks.test.js +++ b/test/api/v2/user/tasks/POST-tasks.test.js @@ -2,7 +2,7 @@ import { generateUser, requester, translate as t, -} from '../../../helpers/api.helper'; +} from '../../../../helpers/api-integration.helper'; describe('POST /user/tasks', () => { diff --git a/test/api/user/tasks/PUT-tasks_id.test.js b/test/api/v2/user/tasks/PUT-tasks_id.test.js similarity index 97% rename from test/api/user/tasks/PUT-tasks_id.test.js rename to test/api/v2/user/tasks/PUT-tasks_id.test.js index 0fa32b3546..14ed0262ba 100644 --- a/test/api/user/tasks/PUT-tasks_id.test.js +++ b/test/api/v2/user/tasks/PUT-tasks_id.test.js @@ -2,7 +2,7 @@ import { generateUser, requester, translate as t, -} from '../../../helpers/api.helper'; +} from '../../../../helpers/api-integration.helper'; describe('PUT /user/tasks/:id', () => { let api, user, task; diff --git a/test/helpers/api.helper.js b/test/helpers/api-integration.helper.js similarity index 100% rename from test/helpers/api.helper.js rename to test/helpers/api-integration.helper.js