API v4 (WIP) (#10453)

API v4
This commit is contained in:
Matteo Pagliazzi
2018-06-18 14:40:25 +02:00
committed by GitHub
parent 97a069642d
commit 8be9964483
158 changed files with 631 additions and 348 deletions
@@ -5,7 +5,7 @@ import {
sleep,
checkExistence,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('DELETE /challenges/:challengeId', () => {
@@ -3,7 +3,7 @@ import {
createAndPopulateGroup,
generateChallenge,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('GET /challenges/:challengeId', () => {
@@ -4,7 +4,7 @@ import {
generateChallenge,
translate as t,
sleep,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('GET /challenges/:challengeId/export/csv', () => {
@@ -3,7 +3,7 @@ import {
generateGroup,
generateChallenge,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('GET /challenges/:challengeId/members', () => {
@@ -3,7 +3,7 @@ import {
generateChallenge,
generateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('GET /challenges/:challengeId/members/:memberId', () => {
@@ -3,7 +3,7 @@ import {
generateChallenge,
createAndPopulateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { TAVERN_ID } from '../../../../../website/common/script/constants';
describe('GET challenges/groups/:groupId', () => {
@@ -2,7 +2,7 @@ import {
generateUser,
generateChallenge,
createAndPopulateGroup,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('GET challenges/user', () => {
context('no official challenges', () => {
@@ -2,7 +2,7 @@ import {
generateUser,
createAndPopulateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /challenges', () => {
@@ -3,7 +3,7 @@ import {
generateChallenge,
createAndPopulateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /challenges/:challengeId/join', () => {
@@ -3,7 +3,7 @@ import {
generateChallenge,
createAndPopulateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /challenges/:challengeId/leave', () => {
@@ -5,7 +5,7 @@ import {
sleep,
checkExistence,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /challenges/:challengeId/winner/:winnerId', () => {
@@ -1,7 +1,7 @@
import {
generateUser,
generateGroup,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /challenges/:challengeId/clone', () => {
it('clones a challenge', async () => {
@@ -3,7 +3,7 @@ import {
generateChallenge,
createAndPopulateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('PUT /challenges/:challengeId', () => {
let privateGuild, user, nonMember, challenge, member;
@@ -2,7 +2,7 @@ import {
createAndPopulateGroup,
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('DELETE /groups/:groupId/chat/:chatId', () => {
@@ -2,7 +2,7 @@ import {
generateUser,
generateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('GET /groups/:groupId/chat', () => {
let user;
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { find } from 'lodash';
describe('POST /chat/:chatId/flag', () => {
@@ -1,7 +1,7 @@
import {
createAndPopulateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { find } from 'lodash';
describe('POST /chat/:chatId/like', () => {
@@ -4,7 +4,7 @@ import {
translate as t,
sleep,
server,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import {
SPAM_MESSAGE_LIMIT,
SPAM_MIN_EXEMPT_CONTRIB_LEVEL,
@@ -1,7 +1,7 @@
import {
createAndPopulateGroup,
sleep,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /groups/:id/chat/seen', () => {
context('Guild', () => {
@@ -2,7 +2,7 @@ import {
createAndPopulateGroup,
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import config from '../../../../../config.json';
import { v4 as generateUUID } from 'uuid';
@@ -1,7 +1,7 @@
import {
requester,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import i18n from '../../../../../website/common/script/i18n';
describe('GET /content', () => {
@@ -1,7 +1,7 @@
import {
generateUser,
resetHabiticaDB,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import apiError from '../../../../../website/server/libs/apiError';
describe('GET /coupons/', () => {
@@ -2,7 +2,7 @@ import {
generateUser,
translate as t,
resetHabiticaDB,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /coupons/enter/:code', () => {
let user;
@@ -2,7 +2,7 @@ import {
generateUser,
translate as t,
resetHabiticaDB,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import couponCode from 'coupon-code';
import apiError from '../../../../../website/server/libs/apiError';
@@ -2,7 +2,7 @@ import {
generateUser,
requester,
resetHabiticaDB,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /coupons/validate/:code', () => {
let api = requester();
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
xdescribe('GET /export/avatar-:memberId.html', () => {
@@ -1,6 +1,6 @@
import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import {
updateDocument,
} from '../../../../helpers/mongo';
@@ -1,6 +1,6 @@
import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('GET /export/inbox.html', () => {
let user;
@@ -1,6 +1,6 @@
import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('GET /export/userdata.json', () => {
it('should return a valid JSON file with user data', async () => {
@@ -1,6 +1,6 @@
import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import xml2js from 'xml2js';
import util from 'util';
@@ -1,7 +1,7 @@
import nconf from 'nconf';
import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /debug/add-hourglass', () => {
let userToGetHourGlass;
@@ -1,7 +1,7 @@
import nconf from 'nconf';
import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /debug/add-ten-gems', () => {
let userToGainTenGems;
@@ -1,7 +1,7 @@
import nconf from 'nconf';
import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /debug/make-admin (pended for v3 prod testing)', () => {
let user;
@@ -3,7 +3,7 @@
import nconf from 'nconf';
import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /debug/modify-inventory', () => {
let user, originalItems;
@@ -1,7 +1,7 @@
import nconf from 'nconf';
import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /debug/quest-progress', () => {
let user;
@@ -1,7 +1,7 @@
import nconf from 'nconf';
import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /debug/set-cron', () => {
let user;
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { encrypt } from '../../../../../website/server/libs/encryption';
import { v4 as generateUUID } from 'uuid';
@@ -1,7 +1,7 @@
import {
generateUser,
generateGroup,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('GET /group-plans', () => {
let user;
@@ -3,7 +3,7 @@ import {
resetHabiticaDB,
generateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import {
TAVERN_ID,
} from '../../../../../website/server/models/group';
@@ -2,7 +2,7 @@ import {
generateUser,
generateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('GET /groups/:groupId/invites', () => {
@@ -2,7 +2,7 @@ import {
generateUser,
generateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import common from '../../../../../website/common';
@@ -2,7 +2,7 @@ import {
generateUser,
createAndPopulateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import {
@@ -1,7 +1,7 @@
import {
createAndPopulateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { find } from 'lodash';
describe('POST /group/:groupId/remove-manager', () => {
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /group', () => {
let user;
@@ -3,7 +3,7 @@ import {
createAndPopulateGroup,
checkExistence,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /group/:groupId/join', () => {
@@ -5,7 +5,7 @@ import {
sleep,
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import {
each,
@@ -2,7 +2,7 @@ import {
generateUser,
createAndPopulateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /group/:groupId/reject-invite', () => {
context('Rejecting a public guild invite', () => {
@@ -3,7 +3,7 @@ import {
createAndPopulateGroup,
translate as t,
sleep,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import * as email from '../../../../../website/server/libs/email';
describe('POST /groups/:groupId/removeMember/:memberId', () => {
@@ -2,7 +2,7 @@ import {
generateUser,
generateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import nconf from 'nconf';
@@ -2,7 +2,7 @@ import {
generateUser,
createAndPopulateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /group/:groupId/add-manager', () => {
let leader, nonLeader, groupToUpdate;
@@ -2,7 +2,7 @@ import {
createAndPopulateGroup,
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('PUT /group', () => {
let leader, nonLeader, groupToUpdate, adminUser;
@@ -1,7 +1,7 @@
import {
generateUser,
resetHabiticaDB,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('GET /hall/heroes', () => {
it('returns all heroes sorted by -contributor.level and with correct fields', async () => {
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('GET /heroes/:heroId', () => {
@@ -2,7 +2,7 @@ import {
generateUser,
translate as t,
resetHabiticaDB,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { times } from 'lodash';
describe('GET /hall/patrons', () => {
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('PUT /heroes/:heroId', () => {
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('GET /members/:memberId/achievements', () => {
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import common from '../../../../../website/common';
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('GET /members/:toUserId/objections/:interaction', () => {
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /members/send-private-message', () => {
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
function findMessage (messages, receiverId) {
@@ -1,6 +1,6 @@
import {
requester,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('GET /news', () => {
let api;
@@ -1,6 +1,6 @@
import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('POST /news/tell-me-later', () => {
let user;
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /notifications/:notificationId/read', () => {
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /notifications/:notificationId/see', () => {
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /notifications/read', () => {
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /notifications/see', () => {
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import superagent from 'superagent';
import nconf from 'nconf';
@@ -3,7 +3,7 @@ import {
translate as t,
generateUser,
sleep,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { model as Chat } from '../../../../../website/server/models/chat';
describe('POST /groups/:groupId/quests/accept', () => {
@@ -3,7 +3,7 @@ import {
translate as t,
generateUser,
sleep,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { model as Chat } from '../../../../../website/server/models/chat';
describe('POST /groups/:groupId/quests/force-start', () => {
@@ -2,7 +2,7 @@ import {
createAndPopulateGroup,
translate as t,
sleep,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import { quests as questScrolls } from '../../../../../website/common/script/content';
import { model as Chat } from '../../../../../website/server/models/chat';
@@ -2,7 +2,7 @@ import {
createAndPopulateGroup,
translate as t,
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import { model as Group } from '../../../../../website/server/models/group';
@@ -2,7 +2,7 @@ import {
createAndPopulateGroup,
translate as t,
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /groups/:groupId/quests/cancel', () => {
@@ -2,7 +2,7 @@ import {
createAndPopulateGroup,
translate as t,
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /groups/:groupId/quests/leave', () => {
@@ -3,7 +3,7 @@ import {
translate as t,
generateUser,
sleep,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import { model as Chat } from '../../../../../website/server/models/chat';
@@ -1,6 +1,6 @@
import {
requester,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('GET /status', () => {
it('returns status: up', async () => {
@@ -3,7 +3,7 @@ import {
sleep,
translate as t,
server,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /tasks/user', () => {
@@ -3,7 +3,7 @@ import {
generateGroup,
generateChallenge,
translate as t,
} from '../../../../../helpers/api-v3-integration.helper';
} from '../../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import { find } from 'lodash';
@@ -2,7 +2,7 @@ import {
generateUser,
createAndPopulateGroup,
translate as t,
} from '../../../../../helpers/api-v3-integration.helper';
} from '../../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('POST /tasks/group/:groupid', () => {
@@ -2,7 +2,7 @@ import {
generateUser,
createAndPopulateGroup,
translate as t,
} from '../../../../../helpers/api-v3-integration.helper';
} from '../../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import { find } from 'lodash';
@@ -1,7 +1,7 @@
import {
generateUser,
generateGroup,
} from '../../../../../helpers/api-v3-integration.helper';
} from '../../../../../helpers/api-integration/v3';
describe('POST group-tasks/:taskId/move/to/:position', () => {
let user, guild;
@@ -2,7 +2,7 @@ import {
generateUser,
createAndPopulateGroup,
translate as t,
} from '../../../../../helpers/api-v3-integration.helper';
} from '../../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
import { find } from 'lodash';
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../../helpers/api-v3-integration.helper';
} from '../../../../../helpers/api-integration/v3';
import {
bcryptCompare,
sha1MakeSalt,
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../../helpers/api-v3-integration.helper';
} from '../../../../../helpers/api-integration/v3';
import {
bcryptCompare,
sha1MakeSalt,
@@ -1,7 +1,7 @@
import {
generateUser,
translate as t,
} from '../../../../../helpers/api-v3-integration.helper';
} from '../../../../../helpers/api-integration/v3';
import {
bcryptCompare,
sha1MakeSalt,
@@ -3,7 +3,7 @@ import { updateDocument } from '../../../../helpers/mongo';
import {
requester,
resetHabiticaDB,
} from '../../../../helpers/api-v3-integration.helper';
} from '../../../../helpers/api-integration/v3';
describe('GET /world-state', () => {
before(async () => {