mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
Move api tests to v2 namespace
This commit is contained in:
@@ -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];
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -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;
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../helpers/api.helper';
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
import {
|
||||
find,
|
||||
each
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../helpers/api.helper';
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
|
||||
describe('POST /groups', () => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../helpers/api.helper';
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
|
||||
describe('POST /groups/:id', () => {
|
||||
|
||||
@@ -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', () => {
|
||||
@@ -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', () => {
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../helpers/api.helper';
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
|
||||
describe('POST /groups/:id/removeMember', () => {
|
||||
|
||||
@@ -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;
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../helpers/api.helper';
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
|
||||
describe('GET /groups/:id/chat', () => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../helpers/api.helper';
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
|
||||
describe('POST /groups/:id/chat', () => {
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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', () => {
|
||||
@@ -1,4 +1,4 @@
|
||||
import {requester} from '../../helpers/api.helper';
|
||||
import {requester} from '../../../helpers/api-integration.helper';
|
||||
|
||||
describe('Status', () => {
|
||||
|
||||
@@ -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;
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
} from '../../helpers/api.helper';
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
|
||||
describe('GET /user', () => {
|
||||
let user;
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
} from '../../helpers/api.helper';
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
|
||||
describe('GET /user/tags', () => {
|
||||
let api, user;
|
||||
@@ -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;
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../helpers/api.helper';
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
|
||||
import { each } from 'lodash';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
} from '../../../helpers/api.helper';
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
import { each } from 'lodash';
|
||||
|
||||
describe('GET /user/anonymized', () => {
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../helpers/api.helper';
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
|
||||
import { each } from 'lodash';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
} from '../../../helpers/api.helper';
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
|
||||
describe('POST /user/pushDevice', () => {
|
||||
let api;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../helpers/api.helper';
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
|
||||
describe('POST /user/tasks', () => {
|
||||
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user