diff --git a/.travis.yml b/.travis.yml index c150993057..66cadafc86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,9 @@ env: - DISABLE_REQUEST_LOGGING=true matrix: - TEST="lint" - - TEST="test:api-v3:unit" REQUIRES_SERVER=true COVERAGE=true + - TEST="test:api:unit" REQUIRES_SERVER=true COVERAGE=true - TEST="test:api-v3:integration" REQUIRES_SERVER=true COVERAGE=true + - TEST="test:api-v4:integration" REQUIRES_SERVER=true COVERAGE=true - TEST="test:sanity" - TEST="test:content" COVERAGE=true - TEST="test:common" COVERAGE=true diff --git a/gulp/gulp-tests.js b/gulp/gulp-tests.js index d805765b86..1d68278a2c 100644 --- a/gulp/gulp-tests.js +++ b/gulp/gulp-tests.js @@ -165,9 +165,9 @@ gulp.task('test:content:safe', gulp.series('test:prepare:build', (cb) => { pipe(runner); })); -gulp.task('test:api-v3:unit', (done) => { +gulp.task('test:api:unit', (done) => { let runner = exec( - testBin('node_modules/.bin/istanbul cover --dir coverage/api-v3-unit node_modules/mocha/bin/_mocha -- test/api/v3/unit --recursive --require ./test/helpers/start-server'), + testBin('node_modules/.bin/istanbul cover --dir coverage/api-unit node_modules/mocha/bin/_mocha -- test/api/unit --recursive --require ./test/helpers/start-server'), (err) => { if (err) { process.exit(1); @@ -179,8 +179,8 @@ gulp.task('test:api-v3:unit', (done) => { pipe(runner); }); -gulp.task('test:api-v3:unit:watch', () => { - return gulp.watch(['website/server/libs/*', 'test/api/v3/unit/**/*', 'website/server/controllers/**/*'], gulp.series('test:api-v3:unit', done => done())); +gulp.task('test:api:unit:watch', () => { + return gulp.watch(['website/server/libs/*', 'test/api/v3/unit/**/*', 'website/server/controllers/**/*'], gulp.series('test:api:unit', done => done())); }); gulp.task('test:api-v3:integration', (done) => { @@ -215,17 +215,43 @@ gulp.task('test:api-v3:integration:separate-server', (done) => { pipe(runner); }); +gulp.task('test:api-v4:integration', (done) => { + let runner = exec( + testBin('node_modules/.bin/istanbul cover --dir coverage/api-v4-integration --report lcovonly node_modules/mocha/bin/_mocha -- test/api/v4 --recursive --require ./test/helpers/start-server'), + {maxBuffer: 500 * 1024}, + (err) => { + if (err) { + process.exit(1); + } + done(); + } + ); + + pipe(runner); +}); + +gulp.task('test:api-v4:integration:separate-server', (done) => { + let runner = exec( + testBin('mocha test/api/v4 --recursive --require ./test/helpers/start-server', 'LOAD_SERVER=0'), + {maxBuffer: 500 * 1024}, + (err) => done(err) + ); + + pipe(runner); +}); + gulp.task('test', gulp.series( 'test:sanity', 'test:content', 'test:common', - 'test:api-v3:unit', + 'test:api:unit', 'test:api-v3:integration', + 'test:api-v4:integration', done => done() )); gulp.task('test:api-v3', gulp.series( - 'test:api-v3:unit', + 'test:api:unit', 'test:api-v3:integration', done => done() -)); +)); \ No newline at end of file diff --git a/package.json b/package.json index 64cf00d042..56e3a07009 100644 --- a/package.json +++ b/package.json @@ -121,9 +121,11 @@ "test": "npm run lint && gulp test && gulp apidoc", "test:build": "gulp test:prepare:build", "test:api-v3": "gulp test:api-v3", - "test:api-v3:unit": "gulp test:api-v3:unit", + "test:api:unit": "gulp test:api:unit", "test:api-v3:integration": "gulp test:api-v3:integration", "test:api-v3:integration:separate-server": "NODE_ENV=test gulp test:api-v3:integration:separate-server", + "test:api-v4:integration": "gulp test:api-v4:integration", + "test:api-v4:integration:separate-server": "NODE_ENV=test gulp test:api-v4:integration:separate-server", "test:sanity": "istanbul cover --dir coverage/sanity --report lcovonly node_modules/mocha/bin/_mocha -- test/sanity --recursive", "test:common": "istanbul cover --dir coverage/common --report lcovonly node_modules/mocha/bin/_mocha -- test/common --recursive", "test:content": "istanbul cover --dir coverage/content --report lcovonly node_modules/mocha/bin/_mocha -- test/content --recursive", diff --git a/test/api/v3/unit/libs/analyticsService.test.js b/test/api/unit/libs/analyticsService.test.js similarity index 99% rename from test/api/v3/unit/libs/analyticsService.test.js rename to test/api/unit/libs/analyticsService.test.js index 4276abf576..28607d65af 100644 --- a/test/api/v3/unit/libs/analyticsService.test.js +++ b/test/api/unit/libs/analyticsService.test.js @@ -1,5 +1,5 @@ /* eslint-disable camelcase */ -import analyticsService from '../../../../../website/server/libs/analyticsService'; +import analyticsService from '../../../../website/server/libs/analyticsService'; import Amplitude from 'amplitude'; import { Visitor } from 'universal-analytics'; diff --git a/test/api/v3/unit/libs/apiError.js b/test/api/unit/libs/apiError.js similarity index 93% rename from test/api/v3/unit/libs/apiError.js rename to test/api/unit/libs/apiError.js index 014374a68a..fda9b1788b 100644 --- a/test/api/v3/unit/libs/apiError.js +++ b/test/api/unit/libs/apiError.js @@ -1,4 +1,4 @@ -import apiError from '../../../../../website/server/libs/apiError'; +import apiError from '../../../../website/server/libs/apiError'; describe('API Messages', () => { const message = 'Only public guilds support pagination.'; diff --git a/test/api/v3/unit/libs/baseModel.test.js b/test/api/unit/libs/baseModel.test.js similarity index 97% rename from test/api/v3/unit/libs/baseModel.test.js rename to test/api/unit/libs/baseModel.test.js index 676366d42f..a9c826bfa5 100644 --- a/test/api/v3/unit/libs/baseModel.test.js +++ b/test/api/unit/libs/baseModel.test.js @@ -1,4 +1,4 @@ -import baseModel from '../../../../../website/server/libs/baseModel'; +import baseModel from '../../../../website/server/libs/baseModel'; import mongoose from 'mongoose'; describe('Base model plugin', () => { diff --git a/test/api/v3/unit/libs/collectionManipulators.test.js b/test/api/unit/libs/collectionManipulators.test.js similarity index 97% rename from test/api/v3/unit/libs/collectionManipulators.test.js rename to test/api/unit/libs/collectionManipulators.test.js index 2736b37502..3d4fb70d6d 100644 --- a/test/api/v3/unit/libs/collectionManipulators.test.js +++ b/test/api/unit/libs/collectionManipulators.test.js @@ -1,7 +1,7 @@ import mongoose from 'mongoose'; import { removeFromArray, -} from '../../../../../website/server/libs/collectionManipulators'; +} from '../../../../website/server/libs/collectionManipulators'; describe('Collection Manipulators', () => { describe('removeFromArray', () => { diff --git a/test/api/v3/unit/libs/cron.test.js b/test/api/unit/libs/cron.test.js similarity index 99% rename from test/api/v3/unit/libs/cron.test.js rename to test/api/unit/libs/cron.test.js index b5b16af5fb..a0136056fb 100644 --- a/test/api/v3/unit/libs/cron.test.js +++ b/test/api/unit/libs/cron.test.js @@ -2,15 +2,15 @@ import moment from 'moment'; import nconf from 'nconf'; import requireAgain from 'require-again'; -import { recoverCron, cron } from '../../../../../website/server/libs/cron'; -import { model as User } from '../../../../../website/server/models/user'; -import * as Tasks from '../../../../../website/server/models/task'; -import common from '../../../../../website/common'; -import analytics from '../../../../../website/server/libs/analyticsService'; +import { recoverCron, cron } from '../../../../website/server/libs/cron'; +import { model as User } from '../../../../website/server/models/user'; +import * as Tasks from '../../../../website/server/models/task'; +import common from '../../../../website/common'; +import analytics from '../../../../website/server/libs/analyticsService'; // const scoreTask = common.ops.scoreTask; -let pathToCronLib = '../../../../../website/server/libs/cron'; +let pathToCronLib = '../../../../website/server/libs/cron'; describe('cron', () => { let clock = null; diff --git a/test/api/v3/unit/libs/email.test.js b/test/api/unit/libs/email.test.js similarity index 96% rename from test/api/v3/unit/libs/email.test.js rename to test/api/unit/libs/email.test.js index 8ad0ae6844..fe2fafd08e 100644 --- a/test/api/v3/unit/libs/email.test.js +++ b/test/api/unit/libs/email.test.js @@ -3,9 +3,9 @@ import got from 'got'; import nconf from 'nconf'; import nodemailer from 'nodemailer'; import requireAgain from 'require-again'; -import logger from '../../../../../website/server/libs/logger'; -import { TAVERN_ID } from '../../../../../website/server/models/group'; -import { defer } from '../../../../helpers/api-unit.helper'; +import logger from '../../../../website/server/libs/logger'; +import { TAVERN_ID } from '../../../../website/server/models/group'; +import { defer } from '../../../helpers/api-unit.helper'; function getUser () { return { @@ -33,7 +33,7 @@ function getUser () { } describe('emails', () => { - let pathToEmailLib = '../../../../../website/server/libs/email'; + let pathToEmailLib = '../../../../website/server/libs/email'; describe('sendEmail', () => { let sendMailSpy; diff --git a/test/api/v3/unit/libs/encryption.test.js b/test/api/unit/libs/encryption.test.js similarity index 84% rename from test/api/v3/unit/libs/encryption.test.js rename to test/api/unit/libs/encryption.test.js index 0396fded1c..60522d1927 100644 --- a/test/api/v3/unit/libs/encryption.test.js +++ b/test/api/unit/libs/encryption.test.js @@ -1,7 +1,7 @@ import { encrypt, decrypt, -} from '../../../../../website/server/libs/encryption'; +} from '../../../../website/server/libs/encryption'; describe('encryption', () => { it('can encrypt and decrypt', () => { diff --git a/test/api/v3/unit/libs/errors.test.js b/test/api/unit/libs/errors.test.js similarity index 98% rename from test/api/v3/unit/libs/errors.test.js rename to test/api/unit/libs/errors.test.js index d1c1c1e758..74d6a224fc 100644 --- a/test/api/v3/unit/libs/errors.test.js +++ b/test/api/unit/libs/errors.test.js @@ -5,7 +5,7 @@ import { BadRequest, InternalServerError, NotFound, -} from '../../../../../website/server/libs/errors'; +} from '../../../../website/server/libs/errors'; describe('Custom Errors', () => { describe('CustomError', () => { diff --git a/test/api/v3/unit/libs/i18n.test.js b/test/api/unit/libs/i18n.test.js similarity index 94% rename from test/api/v3/unit/libs/i18n.test.js rename to test/api/unit/libs/i18n.test.js index 9e31b1a406..472256ce88 100644 --- a/test/api/v3/unit/libs/i18n.test.js +++ b/test/api/unit/libs/i18n.test.js @@ -2,7 +2,7 @@ import { translations, localePath, langCodes, -} from '../../../../../website/server/libs/i18n'; +} from '../../../../website/server/libs/i18n'; import fs from 'fs'; import path from 'path'; diff --git a/test/api/v3/unit/libs/logger.js b/test/api/unit/libs/logger.js similarity index 97% rename from test/api/v3/unit/libs/logger.js rename to test/api/unit/libs/logger.js index a02e58509f..bf6f2a2f9f 100644 --- a/test/api/v3/unit/libs/logger.js +++ b/test/api/unit/libs/logger.js @@ -1,8 +1,8 @@ import winston from 'winston'; -import logger from '../../../../../website/server/libs/logger'; +import logger from '../../../../website/server/libs/logger'; import { NotFound, -} from '../../../../../website/server/libs//errors'; +} from '../../../../website/server/libs//errors'; describe('logger', () => { let logSpy; diff --git a/test/api/v3/unit/libs/password.test.js b/test/api/unit/libs/password.test.js similarity index 98% rename from test/api/v3/unit/libs/password.test.js rename to test/api/unit/libs/password.test.js index aa7316ba68..a325538c5a 100644 --- a/test/api/v3/unit/libs/password.test.js +++ b/test/api/unit/libs/password.test.js @@ -2,11 +2,11 @@ import { encrypt, -} from '../../../../../website/server/libs/encryption'; +} from '../../../../website/server/libs/encryption'; import moment from 'moment'; import { generateUser, -} from '../../../../helpers/api-integration/v3'; +} from '../../../helpers/api-integration/v3'; import { sha1Encrypt as sha1EncryptPassword, sha1MakeSalt, @@ -15,7 +15,7 @@ import { compare, convertToBcrypt, validatePasswordResetCodeAndFindUser, -} from '../../../../../website/server/libs/password'; +} from '../../../../website/server/libs/password'; describe('Password Utilities', () => { describe('compare', () => { diff --git a/test/api/v3/unit/libs/payments/amazon/cancel.test.js b/test/api/unit/libs/payments/amazon/cancel.test.js similarity index 94% rename from test/api/v3/unit/libs/payments/amazon/cancel.test.js rename to test/api/unit/libs/payments/amazon/cancel.test.js index 7d4c020727..bade9a6add 100644 --- a/test/api/v3/unit/libs/payments/amazon/cancel.test.js +++ b/test/api/unit/libs/payments/amazon/cancel.test.js @@ -2,11 +2,11 @@ import moment from 'moment'; import { generateGroup, -} from '../../../../../../helpers/api-unit.helper.js'; -import { model as User } from '../../../../../../../website/server/models/user'; -import amzLib from '../../../../../../../website/server/libs/payments/amazon'; -import payments from '../../../../../../../website/server/libs/payments/payments'; -import common from '../../../../../../../website/common'; +} from '../../../../../helpers/api-unit.helper.js'; +import { model as User } from '../../../../../../website/server/models/user'; +import amzLib from '../../../../../../website/server/libs/payments/amazon'; +import payments from '../../../../../../website/server/libs/payments/payments'; +import common from '../../../../../../website/common'; import { createNonLeaderGroupMember } from '../paymentHelpers'; const i18n = common.i18n; diff --git a/test/api/v3/unit/libs/payments/amazon/checkout.test.js b/test/api/unit/libs/payments/amazon/checkout.test.js similarity index 94% rename from test/api/v3/unit/libs/payments/amazon/checkout.test.js rename to test/api/unit/libs/payments/amazon/checkout.test.js index 7748f2b532..e9224c481b 100644 --- a/test/api/v3/unit/libs/payments/amazon/checkout.test.js +++ b/test/api/unit/libs/payments/amazon/checkout.test.js @@ -1,7 +1,7 @@ -import { model as User } from '../../../../../../../website/server/models/user'; -import amzLib from '../../../../../../../website/server/libs/payments/amazon'; -import payments from '../../../../../../../website/server/libs/payments/payments'; -import common from '../../../../../../../website/common'; +import { model as User } from '../../../../../../website/server/models/user'; +import amzLib from '../../../../../../website/server/libs/payments/amazon'; +import payments from '../../../../../../website/server/libs/payments/payments'; +import common from '../../../../../../website/common'; const i18n = common.i18n; diff --git a/test/api/v3/unit/libs/payments/amazon/subscribe.test.js b/test/api/unit/libs/payments/amazon/subscribe.test.js similarity index 94% rename from test/api/v3/unit/libs/payments/amazon/subscribe.test.js rename to test/api/unit/libs/payments/amazon/subscribe.test.js index ad35f16ea9..aa60291c5d 100644 --- a/test/api/v3/unit/libs/payments/amazon/subscribe.test.js +++ b/test/api/unit/libs/payments/amazon/subscribe.test.js @@ -2,12 +2,12 @@ import cc from 'coupon-code'; import { generateGroup, -} from '../../../../../../helpers/api-unit.helper.js'; -import { model as User } from '../../../../../../../website/server/models/user'; -import { model as Coupon } from '../../../../../../../website/server/models/coupon'; -import amzLib from '../../../../../../../website/server/libs/payments/amazon'; -import payments from '../../../../../../../website/server/libs/payments/payments'; -import common from '../../../../../../../website/common'; +} from '../../../../../helpers/api-unit.helper.js'; +import { model as User } from '../../../../../../website/server/models/user'; +import { model as Coupon } from '../../../../../../website/server/models/coupon'; +import amzLib from '../../../../../../website/server/libs/payments/amazon'; +import payments from '../../../../../../website/server/libs/payments/payments'; +import common from '../../../../../../website/common'; const i18n = common.i18n; diff --git a/test/api/v3/unit/libs/payments/amazon/upgrade-groupplan.test.js b/test/api/unit/libs/payments/amazon/upgrade-groupplan.test.js similarity index 84% rename from test/api/v3/unit/libs/payments/amazon/upgrade-groupplan.test.js rename to test/api/unit/libs/payments/amazon/upgrade-groupplan.test.js index 44d994daab..bc9f9a76c4 100644 --- a/test/api/v3/unit/libs/payments/amazon/upgrade-groupplan.test.js +++ b/test/api/unit/libs/payments/amazon/upgrade-groupplan.test.js @@ -2,11 +2,11 @@ import uuid from 'uuid'; import { generateGroup, -} from '../../../../../../helpers/api-unit.helper.js'; -import { model as User } from '../../../../../../../website/server/models/user'; -import { model as Group } from '../../../../../../../website/server/models/group'; -import amzLib from '../../../../../../../website/server/libs/payments/amazon'; -import payments from '../../../../../../../website/server/libs/payments/payments'; +} from '../../../../../helpers/api-unit.helper.js'; +import { model as User } from '../../../../../../website/server/models/user'; +import { model as Group } from '../../../../../../website/server/models/group'; +import amzLib from '../../../../../../website/server/libs/payments/amazon'; +import payments from '../../../../../../website/server/libs/payments/payments'; describe('#upgradeGroupPlan', () => { let spy, data, user, group, uuidString; diff --git a/test/api/v3/unit/libs/payments/apple.test.js b/test/api/unit/libs/payments/apple.test.js similarity index 96% rename from test/api/v3/unit/libs/payments/apple.test.js rename to test/api/unit/libs/payments/apple.test.js index d88967634d..f61998d04b 100644 --- a/test/api/v3/unit/libs/payments/apple.test.js +++ b/test/api/unit/libs/payments/apple.test.js @@ -1,10 +1,10 @@ /* eslint-disable camelcase */ -import iapModule from '../../../../../../website/server/libs/inAppPurchases'; -import payments from '../../../../../../website/server/libs/payments/payments'; -import applePayments from '../../../../../../website/server/libs/payments/apple'; -import iap from '../../../../../../website/server/libs/inAppPurchases'; -import {model as User} from '../../../../../../website/server/models/user'; -import common from '../../../../../../website/common'; +import iapModule from '../../../../../website/server/libs/inAppPurchases'; +import payments from '../../../../../website/server/libs/payments/payments'; +import applePayments from '../../../../../website/server/libs/payments/apple'; +import iap from '../../../../../website/server/libs/inAppPurchases'; +import {model as User} from '../../../../../website/server/models/user'; +import common from '../../../../../website/common'; import moment from 'moment'; const i18n = common.i18n; diff --git a/test/api/v3/unit/libs/payments/google.test.js b/test/api/unit/libs/payments/google.test.js similarity index 95% rename from test/api/v3/unit/libs/payments/google.test.js rename to test/api/unit/libs/payments/google.test.js index 5c2f8f3a29..d9fa56b988 100644 --- a/test/api/v3/unit/libs/payments/google.test.js +++ b/test/api/unit/libs/payments/google.test.js @@ -1,10 +1,10 @@ /* eslint-disable camelcase */ -import iapModule from '../../../../../../website/server/libs/inAppPurchases'; -import payments from '../../../../../../website/server/libs/payments/payments'; -import googlePayments from '../../../../../../website/server/libs/payments/google'; -import iap from '../../../../../../website/server/libs/inAppPurchases'; -import {model as User} from '../../../../../../website/server/models/user'; -import common from '../../../../../../website/common'; +import iapModule from '../../../../../website/server/libs/inAppPurchases'; +import payments from '../../../../../website/server/libs/payments/payments'; +import googlePayments from '../../../../../website/server/libs/payments/google'; +import iap from '../../../../../website/server/libs/inAppPurchases'; +import {model as User} from '../../../../../website/server/models/user'; +import common from '../../../../../website/common'; import moment from 'moment'; const i18n = common.i18n; diff --git a/test/api/v3/unit/libs/payments/group-plans/group-payments-cancel.test.js b/test/api/unit/libs/payments/group-plans/group-payments-cancel.test.js similarity index 95% rename from test/api/v3/unit/libs/payments/group-plans/group-payments-cancel.test.js rename to test/api/unit/libs/payments/group-plans/group-payments-cancel.test.js index ffb569e53b..65d78399eb 100644 --- a/test/api/v3/unit/libs/payments/group-plans/group-payments-cancel.test.js +++ b/test/api/unit/libs/payments/group-plans/group-payments-cancel.test.js @@ -1,13 +1,13 @@ import moment from 'moment'; -import * as sender from '../../../../../../../website/server/libs/email'; -import * as api from '../../../../../../../website/server/libs/payments/payments'; -import { model as User } from '../../../../../../../website/server/models/user'; -import { model as Group } from '../../../../../../../website/server/models/group'; +import * as sender from '../../../../../../website/server/libs/email'; +import * as api from '../../../../../../website/server/libs/payments/payments'; +import { model as User } from '../../../../../../website/server/models/user'; +import { model as Group } from '../../../../../../website/server/models/group'; import { generateGroup, -} from '../../../../../../helpers/api-unit.helper.js'; -import i18n from '../../../../../../../website/common/script/i18n'; +} from '../../../../../helpers/api-unit.helper.js'; +import i18n from '../../../../../../website/common/script/i18n'; describe('Canceling a subscription for group', () => { let plan, group, user, data; diff --git a/test/api/v3/unit/libs/payments/group-plans/group-payments-create.test.js b/test/api/unit/libs/payments/group-plans/group-payments-create.test.js similarity index 98% rename from test/api/v3/unit/libs/payments/group-plans/group-payments-create.test.js rename to test/api/unit/libs/payments/group-plans/group-payments-create.test.js index 8ff7e5d7c3..1ce795d527 100644 --- a/test/api/v3/unit/libs/payments/group-plans/group-payments-create.test.js +++ b/test/api/unit/libs/payments/group-plans/group-payments-create.test.js @@ -2,16 +2,16 @@ import moment from 'moment'; import stripeModule from 'stripe'; import nconf from 'nconf'; -import * as sender from '../../../../../../../website/server/libs/email'; -import * as api from '../../../../../../../website/server/libs/payments/payments'; -import amzLib from '../../../../../../../website/server/libs/payments/amazon'; -import paypalPayments from '../../../../../../../website/server/libs/payments/paypal'; -import stripePayments from '../../../../../../../website/server/libs/payments/stripe'; -import { model as User } from '../../../../../../../website/server/models/user'; -import { model as Group } from '../../../../../../../website/server/models/group'; +import * as sender from '../../../../../../website/server/libs/email'; +import * as api from '../../../../../../website/server/libs/payments/payments'; +import amzLib from '../../../../../../website/server/libs/payments/amazon'; +import paypalPayments from '../../../../../../website/server/libs/payments/paypal'; +import stripePayments from '../../../../../../website/server/libs/payments/stripe'; +import { model as User } from '../../../../../../website/server/models/user'; +import { model as Group } from '../../../../../../website/server/models/group'; import { generateGroup, -} from '../../../../../../helpers/api-unit.helper.js'; +} from '../../../../../helpers/api-unit.helper.js'; describe('Purchasing a group plan for group', () => { const EMAIL_TEMPLATE_SUBSCRIPTION_TYPE_GOOGLE = 'Google_subscription'; diff --git a/test/api/v3/unit/libs/payments/paymentHelpers.js b/test/api/unit/libs/payments/paymentHelpers.js similarity index 67% rename from test/api/v3/unit/libs/payments/paymentHelpers.js rename to test/api/unit/libs/payments/paymentHelpers.js index 99069a8f49..6ea70a5504 100644 --- a/test/api/v3/unit/libs/payments/paymentHelpers.js +++ b/test/api/unit/libs/payments/paymentHelpers.js @@ -1,4 +1,4 @@ -import { model as User } from '../../../../../../website/server/models/user'; +import { model as User } from '../../../../../website/server/models/user'; export async function createNonLeaderGroupMember (group) { let nonLeader = new User(); diff --git a/test/api/v3/unit/libs/payments/payments.test.js b/test/api/unit/libs/payments/payments.test.js similarity index 97% rename from test/api/v3/unit/libs/payments/payments.test.js rename to test/api/unit/libs/payments/payments.test.js index 41a080c577..c63bd89823 100644 --- a/test/api/v3/unit/libs/payments/payments.test.js +++ b/test/api/unit/libs/payments/payments.test.js @@ -1,14 +1,14 @@ import moment from 'moment'; -import * as sender from '../../../../../../website/server/libs/email'; -import * as api from '../../../../../../website/server/libs/payments/payments'; -import analytics from '../../../../../../website/server/libs/analyticsService'; -import notifications from '../../../../../../website/server/libs/pushNotifications'; -import { model as User } from '../../../../../../website/server/models/user'; -import { translate as t } from '../../../../../helpers/api-v3-integration.helper'; +import * as sender from '../../../../../website/server/libs/email'; +import * as api from '../../../../../website/server/libs/payments/payments'; +import analytics from '../../../../../website/server/libs/analyticsService'; +import notifications from '../../../../../website/server/libs/pushNotifications'; +import { model as User } from '../../../../../website/server/models/user'; +import { translate as t } from '../../../../helpers/api-integration/v3'; import { generateGroup, -} from '../../../../../helpers/api-unit.helper.js'; +} from '../../../../helpers/api-unit.helper.js'; describe('payments/index', () => { let user, group, data, plan; diff --git a/test/api/v3/unit/libs/payments/paypal/checkout-success.test.js b/test/api/unit/libs/payments/paypal/checkout-success.test.js similarity index 91% rename from test/api/v3/unit/libs/payments/paypal/checkout-success.test.js rename to test/api/unit/libs/payments/paypal/checkout-success.test.js index a006fe4882..79568c7abf 100644 --- a/test/api/v3/unit/libs/payments/paypal/checkout-success.test.js +++ b/test/api/unit/libs/payments/paypal/checkout-success.test.js @@ -1,7 +1,7 @@ /* eslint-disable camelcase */ -import paypalPayments from '../../../../../../../website/server/libs/payments/paypal'; -import payments from '../../../../../../../website/server/libs/payments/payments'; -import { model as User } from '../../../../../../../website/server/models/user'; +import paypalPayments from '../../../../../../website/server/libs/payments/paypal'; +import payments from '../../../../../../website/server/libs/payments/payments'; +import { model as User } from '../../../../../../website/server/models/user'; describe('checkout success', () => { const subKey = 'basic_3mo'; diff --git a/test/api/v3/unit/libs/payments/paypal/checkout.test.js b/test/api/unit/libs/payments/paypal/checkout.test.js similarity index 93% rename from test/api/v3/unit/libs/payments/paypal/checkout.test.js rename to test/api/unit/libs/payments/paypal/checkout.test.js index f02b9ff39e..469330cd5d 100644 --- a/test/api/v3/unit/libs/payments/paypal/checkout.test.js +++ b/test/api/unit/libs/payments/paypal/checkout.test.js @@ -1,9 +1,9 @@ /* eslint-disable camelcase */ import nconf from 'nconf'; -import paypalPayments from '../../../../../../../website/server/libs/payments/paypal'; -import { model as User } from '../../../../../../../website/server/models/user'; -import common from '../../../../../../../website/common'; +import paypalPayments from '../../../../../../website/server/libs/payments/paypal'; +import { model as User } from '../../../../../../website/server/models/user'; +import common from '../../../../../../website/common'; const BASE_URL = nconf.get('BASE_URL'); const i18n = common.i18n; diff --git a/test/api/v3/unit/libs/payments/paypal/ipn.test.js b/test/api/unit/libs/payments/paypal/ipn.test.js similarity index 88% rename from test/api/v3/unit/libs/payments/paypal/ipn.test.js rename to test/api/unit/libs/payments/paypal/ipn.test.js index 0f0468308d..007ba794b4 100644 --- a/test/api/v3/unit/libs/payments/paypal/ipn.test.js +++ b/test/api/unit/libs/payments/paypal/ipn.test.js @@ -1,10 +1,10 @@ /* eslint-disable camelcase */ -import paypalPayments from '../../../../../../../website/server/libs/payments/paypal'; -import payments from '../../../../../../../website/server/libs/payments/payments'; +import paypalPayments from '../../../../../../website/server/libs/payments/paypal'; +import payments from '../../../../../../website/server/libs/payments/payments'; import { generateGroup, -} from '../../../../../../helpers/api-unit.helper.js'; -import { model as User } from '../../../../../../../website/server/models/user'; +} from '../../../../../helpers/api-unit.helper.js'; +import { model as User } from '../../../../../../website/server/models/user'; describe('ipn', () => { const subKey = 'basic_3mo'; diff --git a/test/api/v3/unit/libs/payments/paypal/subscribe-cancel.test.js b/test/api/unit/libs/payments/paypal/subscribe-cancel.test.js similarity index 92% rename from test/api/v3/unit/libs/payments/paypal/subscribe-cancel.test.js rename to test/api/unit/libs/payments/paypal/subscribe-cancel.test.js index 01fa114d70..7bbb3806ef 100644 --- a/test/api/v3/unit/libs/payments/paypal/subscribe-cancel.test.js +++ b/test/api/unit/libs/payments/paypal/subscribe-cancel.test.js @@ -1,11 +1,11 @@ /* eslint-disable camelcase */ -import paypalPayments from '../../../../../../../website/server/libs/payments/paypal'; -import payments from '../../../../../../../website/server/libs/payments/payments'; +import paypalPayments from '../../../../../../website/server/libs/payments/paypal'; +import payments from '../../../../../../website/server/libs/payments/payments'; import { generateGroup, -} from '../../../../../../helpers/api-unit.helper.js'; -import { model as User } from '../../../../../../../website/server/models/user'; -import common from '../../../../../../../website/common'; +} from '../../../../../helpers/api-unit.helper.js'; +import { model as User } from '../../../../../../website/server/models/user'; +import common from '../../../../../../website/common'; import { createNonLeaderGroupMember } from '../paymentHelpers'; const i18n = common.i18n; diff --git a/test/api/v3/unit/libs/payments/paypal/subscribe-success.test.js b/test/api/unit/libs/payments/paypal/subscribe-success.test.js similarity index 85% rename from test/api/v3/unit/libs/payments/paypal/subscribe-success.test.js rename to test/api/unit/libs/payments/paypal/subscribe-success.test.js index aa33429b5e..ad03248227 100644 --- a/test/api/v3/unit/libs/payments/paypal/subscribe-success.test.js +++ b/test/api/unit/libs/payments/paypal/subscribe-success.test.js @@ -1,11 +1,11 @@ /* eslint-disable camelcase */ -import paypalPayments from '../../../../../../../website/server/libs/payments/paypal'; -import payments from '../../../../../../../website/server/libs/payments/payments'; +import paypalPayments from '../../../../../../website/server/libs/payments/paypal'; +import payments from '../../../../../../website/server/libs/payments/payments'; import { generateGroup, -} from '../../../../../../helpers/api-unit.helper.js'; -import { model as User } from '../../../../../../../website/server/models/user'; -import common from '../../../../../../../website/common'; +} from '../../../../../helpers/api-unit.helper.js'; +import { model as User } from '../../../../../../website/server/models/user'; +import common from '../../../../../../website/common'; describe('subscribeSuccess', () => { const subKey = 'basic_3mo'; diff --git a/test/api/v3/unit/libs/payments/paypal/subscribe.test.js b/test/api/unit/libs/payments/paypal/subscribe.test.js similarity index 93% rename from test/api/v3/unit/libs/payments/paypal/subscribe.test.js rename to test/api/unit/libs/payments/paypal/subscribe.test.js index cc7660a5f9..961882ed10 100644 --- a/test/api/v3/unit/libs/payments/paypal/subscribe.test.js +++ b/test/api/unit/libs/payments/paypal/subscribe.test.js @@ -2,9 +2,9 @@ import moment from 'moment'; import cc from 'coupon-code'; -import paypalPayments from '../../../../../../../website/server/libs/payments/paypal'; -import { model as Coupon } from '../../../../../../../website/server/models/coupon'; -import common from '../../../../../../../website/common'; +import paypalPayments from '../../../../../../website/server/libs/payments/paypal'; +import { model as Coupon } from '../../../../../../website/server/models/coupon'; +import common from '../../../../../../website/common'; const i18n = common.i18n; diff --git a/test/api/v3/unit/libs/payments/stripe/cancel-subscription.test.js b/test/api/unit/libs/payments/stripe/cancel-subscription.test.js similarity index 92% rename from test/api/v3/unit/libs/payments/stripe/cancel-subscription.test.js rename to test/api/unit/libs/payments/stripe/cancel-subscription.test.js index ca3a92b721..4542455d99 100644 --- a/test/api/v3/unit/libs/payments/stripe/cancel-subscription.test.js +++ b/test/api/unit/libs/payments/stripe/cancel-subscription.test.js @@ -2,11 +2,11 @@ import stripeModule from 'stripe'; import { generateGroup, -} from '../../../../../../helpers/api-unit.helper.js'; -import { model as User } from '../../../../../../../website/server/models/user'; -import stripePayments from '../../../../../../../website/server/libs/payments/stripe'; -import payments from '../../../../../../../website/server/libs/payments/payments'; -import common from '../../../../../../../website/common'; +} from '../../../../../helpers/api-unit.helper.js'; +import { model as User } from '../../../../../../website/server/models/user'; +import stripePayments from '../../../../../../website/server/libs/payments/stripe'; +import payments from '../../../../../../website/server/libs/payments/payments'; +import common from '../../../../../../website/common'; const i18n = common.i18n; diff --git a/test/api/v3/unit/libs/payments/stripe/checkout-subscription.test.js b/test/api/unit/libs/payments/stripe/checkout-subscription.test.js similarity index 94% rename from test/api/v3/unit/libs/payments/stripe/checkout-subscription.test.js rename to test/api/unit/libs/payments/stripe/checkout-subscription.test.js index 7154ef4655..f17f5c7da5 100644 --- a/test/api/v3/unit/libs/payments/stripe/checkout-subscription.test.js +++ b/test/api/unit/libs/payments/stripe/checkout-subscription.test.js @@ -3,12 +3,12 @@ import cc from 'coupon-code'; import { generateGroup, -} from '../../../../../../helpers/api-unit.helper.js'; -import { model as User } from '../../../../../../../website/server/models/user'; -import { model as Coupon } from '../../../../../../../website/server/models/coupon'; -import stripePayments from '../../../../../../../website/server/libs/payments/stripe'; -import payments from '../../../../../../../website/server/libs/payments/payments'; -import common from '../../../../../../../website/common'; +} from '../../../../../helpers/api-unit.helper.js'; +import { model as User } from '../../../../../../website/server/models/user'; +import { model as Coupon } from '../../../../../../website/server/models/coupon'; +import stripePayments from '../../../../../../website/server/libs/payments/stripe'; +import payments from '../../../../../../website/server/libs/payments/payments'; +import common from '../../../../../../website/common'; const i18n = common.i18n; diff --git a/test/api/v3/unit/libs/payments/stripe/checkout.test.js b/test/api/unit/libs/payments/stripe/checkout.test.js similarity index 93% rename from test/api/v3/unit/libs/payments/stripe/checkout.test.js rename to test/api/unit/libs/payments/stripe/checkout.test.js index faba2dd5ef..c45e311873 100644 --- a/test/api/v3/unit/libs/payments/stripe/checkout.test.js +++ b/test/api/unit/libs/payments/stripe/checkout.test.js @@ -1,9 +1,9 @@ import stripeModule from 'stripe'; -import { model as User } from '../../../../../../../website/server/models/user'; -import stripePayments from '../../../../../../../website/server/libs/payments/stripe'; -import payments from '../../../../../../../website/server/libs/payments/payments'; -import common from '../../../../../../../website/common'; +import { model as User } from '../../../../../../website/server/models/user'; +import stripePayments from '../../../../../../website/server/libs/payments/stripe'; +import payments from '../../../../../../website/server/libs/payments/payments'; +import common from '../../../../../../website/common'; const i18n = common.i18n; diff --git a/test/api/v3/unit/libs/payments/stripe/edit-subscription.test.js b/test/api/unit/libs/payments/stripe/edit-subscription.test.js similarity index 93% rename from test/api/v3/unit/libs/payments/stripe/edit-subscription.test.js rename to test/api/unit/libs/payments/stripe/edit-subscription.test.js index 7ee538a12f..59c8c52701 100644 --- a/test/api/v3/unit/libs/payments/stripe/edit-subscription.test.js +++ b/test/api/unit/libs/payments/stripe/edit-subscription.test.js @@ -2,10 +2,10 @@ import stripeModule from 'stripe'; import { generateGroup, -} from '../../../../../../helpers/api-unit.helper.js'; -import { model as User } from '../../../../../../../website/server/models/user'; -import stripePayments from '../../../../../../../website/server/libs/payments/stripe'; -import common from '../../../../../../../website/common'; +} from '../../../../../helpers/api-unit.helper.js'; +import { model as User } from '../../../../../../website/server/models/user'; +import stripePayments from '../../../../../../website/server/libs/payments/stripe'; +import common from '../../../../../../website/common'; const i18n = common.i18n; diff --git a/test/api/v3/unit/libs/payments/stripe/handle-webhook.test.js b/test/api/unit/libs/payments/stripe/handle-webhook.test.js similarity index 95% rename from test/api/v3/unit/libs/payments/stripe/handle-webhook.test.js rename to test/api/unit/libs/payments/stripe/handle-webhook.test.js index 54f6ae72e3..8cedb56c26 100644 --- a/test/api/v3/unit/libs/payments/stripe/handle-webhook.test.js +++ b/test/api/unit/libs/payments/stripe/handle-webhook.test.js @@ -2,12 +2,12 @@ import stripeModule from 'stripe'; import { generateGroup, -} from '../../../../../../helpers/api-unit.helper.js'; -import { model as User } from '../../../../../../../website/server/models/user'; -import stripePayments from '../../../../../../../website/server/libs/payments/stripe'; -import payments from '../../../../../../../website/server/libs/payments/payments'; -import common from '../../../../../../../website/common'; -import logger from '../../../../../../../website/server/libs/logger'; +} from '../../../../../helpers/api-unit.helper.js'; +import { model as User } from '../../../../../../website/server/models/user'; +import stripePayments from '../../../../../../website/server/libs/payments/stripe'; +import payments from '../../../../../../website/server/libs/payments/payments'; +import common from '../../../../../../website/common'; +import logger from '../../../../../../website/server/libs/logger'; import { v4 as uuid } from 'uuid'; import moment from 'moment'; diff --git a/test/api/v3/unit/libs/payments/stripe/upgrade-group-plan.test.js b/test/api/unit/libs/payments/stripe/upgrade-group-plan.test.js similarity index 79% rename from test/api/v3/unit/libs/payments/stripe/upgrade-group-plan.test.js rename to test/api/unit/libs/payments/stripe/upgrade-group-plan.test.js index 0e2c5edef0..5ef7e9a3af 100644 --- a/test/api/v3/unit/libs/payments/stripe/upgrade-group-plan.test.js +++ b/test/api/unit/libs/payments/stripe/upgrade-group-plan.test.js @@ -2,11 +2,11 @@ import stripeModule from 'stripe'; import { generateGroup, -} from '../../../../../../helpers/api-unit.helper.js'; -import { model as User } from '../../../../../../../website/server/models/user'; -import { model as Group } from '../../../../../../../website/server/models/group'; -import stripePayments from '../../../../../../../website/server/libs/payments/stripe'; -import payments from '../../../../../../../website/server/libs/payments/payments'; +} from '../../../../../helpers/api-unit.helper.js'; +import { model as User } from '../../../../../../website/server/models/user'; +import { model as Group } from '../../../../../../website/server/models/group'; +import stripePayments from '../../../../../../website/server/libs/payments/stripe'; +import payments from '../../../../../../website/server/libs/payments/payments'; describe('Stripe - Upgrade Group Plan', () => { const stripe = stripeModule('test'); diff --git a/test/api/v3/unit/libs/preening.test.js b/test/api/unit/libs/preening.test.js similarity index 93% rename from test/api/v3/unit/libs/preening.test.js rename to test/api/unit/libs/preening.test.js index a6ffef1e70..9f5dacbf14 100644 --- a/test/api/v3/unit/libs/preening.test.js +++ b/test/api/unit/libs/preening.test.js @@ -1,7 +1,7 @@ -import { preenHistory } from '../../../../../website/server/libs/preening'; +import { preenHistory } from '../../../../website/server/libs/preening'; import moment from 'moment'; import sinon from 'sinon'; // eslint-disable-line no-shadow -import { generateHistory } from '../../../../helpers/api-unit.helper.js'; +import { generateHistory } from '../../../helpers/api-unit.helper.js'; describe('preenHistory', () => { let clock; diff --git a/test/api/v3/unit/libs/pushNotifications.js b/test/api/unit/libs/pushNotifications.js similarity index 94% rename from test/api/v3/unit/libs/pushNotifications.js rename to test/api/unit/libs/pushNotifications.js index f033d958ff..41696859b3 100644 --- a/test/api/v3/unit/libs/pushNotifications.js +++ b/test/api/unit/libs/pushNotifications.js @@ -1,4 +1,4 @@ -import { model as User } from '../../../../../website/server/models/user'; +import { model as User } from '../../../../website/server/models/user'; import requireAgain from 'require-again'; import pushNotify from 'push-notify'; import nconf from 'nconf'; @@ -7,7 +7,7 @@ import gcmLib from 'node-gcm'; // works with FCM notifications too describe('pushNotifications', () => { let user; let sendPushNotification; - let pathToPushNotifications = '../../../../../website/server/libs/pushNotifications'; + let pathToPushNotifications = '../../../../website/server/libs/pushNotifications'; let fcmSendSpy; let apnSendSpy; diff --git a/test/api/v3/unit/libs/setupNconf.test.js b/test/api/unit/libs/setupNconf.test.js similarity index 93% rename from test/api/v3/unit/libs/setupNconf.test.js rename to test/api/unit/libs/setupNconf.test.js index afe000d969..33101e40af 100644 --- a/test/api/v3/unit/libs/setupNconf.test.js +++ b/test/api/unit/libs/setupNconf.test.js @@ -1,4 +1,4 @@ -import setupNconf from '../../../../../website/server/libs/setupNconf'; +import setupNconf from '../../../../website/server/libs/setupNconf'; import path from 'path'; import nconf from 'nconf'; diff --git a/test/api/v3/unit/libs/slack.js b/test/api/unit/libs/slack.js similarity index 92% rename from test/api/v3/unit/libs/slack.js rename to test/api/unit/libs/slack.js index 9a6d183d33..4f63a5dcd9 100644 --- a/test/api/v3/unit/libs/slack.js +++ b/test/api/unit/libs/slack.js @@ -1,9 +1,9 @@ /* eslint-disable camelcase */ import { IncomingWebhook } from '@slack/client'; import requireAgain from 'require-again'; -import slack from '../../../../../website/server/libs/slack'; -import logger from '../../../../../website/server/libs/logger'; -import { TAVERN_ID } from '../../../../../website/server/models/group'; +import slack from '../../../../website/server/libs/slack'; +import logger from '../../../../website/server/libs/logger'; +import { TAVERN_ID } from '../../../../website/server/models/group'; import nconf from 'nconf'; import moment from 'moment'; @@ -112,7 +112,7 @@ describe('slack', () => { it('noops if no flagging url is provided', () => { sandbox.stub(nconf, 'get').withArgs('SLACK:FLAGGING_URL').returns(''); sandbox.stub(logger, 'error'); - let reRequiredSlack = requireAgain('../../../../../website/server/libs/slack'); + let reRequiredSlack = requireAgain('../../../../website/server/libs/slack'); expect(logger.error).to.be.calledOnce; diff --git a/test/api/v3/unit/libs/taskManager.js b/test/api/unit/libs/taskManager.js similarity index 96% rename from test/api/v3/unit/libs/taskManager.js rename to test/api/unit/libs/taskManager.js index 14dc8feb49..262b3058de 100644 --- a/test/api/v3/unit/libs/taskManager.js +++ b/test/api/unit/libs/taskManager.js @@ -3,13 +3,13 @@ import { getTasks, syncableAttrs, moveTask, -} from '../../../../../website/server/libs/taskManager'; -import i18n from '../../../../../website/common/script/i18n'; +} from '../../../../website/server/libs/taskManager'; +import i18n from '../../../../website/common/script/i18n'; import { generateUser, generateGroup, generateChallenge, -} from '../../../../helpers/api-unit.helper.js'; +} from '../../../helpers/api-unit.helper.js'; describe('taskManager', () => { let user, group, challenge; diff --git a/test/api/v3/unit/libs/webhooks.test.js b/test/api/unit/libs/webhooks.test.js similarity index 98% rename from test/api/v3/unit/libs/webhooks.test.js rename to test/api/unit/libs/webhooks.test.js index a426da76a6..d1bc9c52ff 100644 --- a/test/api/v3/unit/libs/webhooks.test.js +++ b/test/api/unit/libs/webhooks.test.js @@ -6,14 +6,14 @@ import { taskActivityWebhook, questActivityWebhook, userActivityWebhook, -} from '../../../../../website/server/libs/webhook'; +} from '../../../../website/server/libs/webhook'; import { model as User, -} from '../../../../../website/server/models/user'; +} from '../../../../website/server/models/user'; import { generateUser, -} from '../../../../helpers/api-unit.helper.js'; -import { defer } from '../../../../helpers/api-unit.helper'; +} from '../../../helpers/api-unit.helper.js'; +import { defer } from '../../../helpers/api-unit.helper'; describe('webhooks', () => { let webhooks, user; diff --git a/test/api/v3/unit/middlewares/analytics.test.js b/test/api/unit/middlewares/analytics.test.js similarity index 86% rename from test/api/v3/unit/middlewares/analytics.test.js rename to test/api/unit/middlewares/analytics.test.js index c55b212698..dce6bab20d 100644 --- a/test/api/v3/unit/middlewares/analytics.test.js +++ b/test/api/unit/middlewares/analytics.test.js @@ -3,14 +3,14 @@ import { generateRes, generateReq, generateNext, -} from '../../../../helpers/api-unit.helper'; -import analyticsService from '../../../../../website/server/libs/analyticsService'; +} from '../../../helpers/api-unit.helper'; +import analyticsService from '../../../../website/server/libs/analyticsService'; import nconf from 'nconf'; import requireAgain from 'require-again'; describe('analytics middleware', () => { let res, req, next; - let pathToAnalyticsMiddleware = '../../../../../website/server/middlewares/analytics'; + let pathToAnalyticsMiddleware = '../../../../website/server/middlewares/analytics'; beforeEach(() => { res = generateRes(); diff --git a/test/api/v3/unit/middlewares/auth.test.js b/test/api/unit/middlewares/auth.test.js similarity index 92% rename from test/api/v3/unit/middlewares/auth.test.js rename to test/api/unit/middlewares/auth.test.js index ac1903c984..25ba3d17ea 100644 --- a/test/api/v3/unit/middlewares/auth.test.js +++ b/test/api/unit/middlewares/auth.test.js @@ -1,8 +1,8 @@ import { generateRes, generateReq, -} from '../../../../helpers/api-unit.helper'; -import { authWithHeaders as authWithHeadersFactory } from '../../../../../website/server/middlewares/auth'; +} from '../../../helpers/api-unit.helper'; +import { authWithHeaders as authWithHeadersFactory } from '../../../../website/server/middlewares/auth'; describe('auth middleware', () => { let res, req, user; diff --git a/test/api/v3/unit/middlewares/cors.test.js b/test/api/unit/middlewares/cors.test.js similarity index 91% rename from test/api/v3/unit/middlewares/cors.test.js rename to test/api/unit/middlewares/cors.test.js index 8cf6dbc3ff..1d5b111dd4 100644 --- a/test/api/v3/unit/middlewares/cors.test.js +++ b/test/api/unit/middlewares/cors.test.js @@ -3,8 +3,8 @@ import { generateRes, generateReq, generateNext, -} from '../../../../helpers/api-unit.helper'; -import cors from '../../../../../website/server/middlewares/cors'; +} from '../../../helpers/api-unit.helper'; +import cors from '../../../../website/server/middlewares/cors'; describe('cors middleware', () => { let res, req, next; diff --git a/test/api/v3/unit/middlewares/cronMiddleware.js b/test/api/unit/middlewares/cronMiddleware.js similarity index 94% rename from test/api/v3/unit/middlewares/cronMiddleware.js rename to test/api/unit/middlewares/cronMiddleware.js index e18301b91b..28d4135e25 100644 --- a/test/api/v3/unit/middlewares/cronMiddleware.js +++ b/test/api/unit/middlewares/cronMiddleware.js @@ -3,14 +3,14 @@ import { generateReq, generateTodo, generateDaily, -} from '../../../../helpers/api-unit.helper'; -import cronMiddleware from '../../../../../website/server/middlewares/cron'; +} from '../../../helpers/api-unit.helper'; +import cronMiddleware from '../../../../website/server/middlewares/cron'; import moment from 'moment'; -import { model as User } from '../../../../../website/server/models/user'; -import { model as Group } from '../../../../../website/server/models/group'; -import * as Tasks from '../../../../../website/server/models/task'; -import analyticsService from '../../../../../website/server/libs/analyticsService'; -import * as cronLib from '../../../../../website/server/libs/cron'; +import { model as User } from '../../../../website/server/models/user'; +import { model as Group } from '../../../../website/server/models/group'; +import * as Tasks from '../../../../website/server/models/task'; +import analyticsService from '../../../../website/server/libs/analyticsService'; +import * as cronLib from '../../../../website/server/libs/cron'; import { v4 as generateUUID } from 'uuid'; const CRON_TIMEOUT_WAIT = new Date(60 * 60 * 1000).getTime(); diff --git a/test/api/v3/unit/middlewares/ensureAccessRight.test.js b/test/api/unit/middlewares/ensureAccessRight.test.js similarity index 81% rename from test/api/v3/unit/middlewares/ensureAccessRight.test.js rename to test/api/unit/middlewares/ensureAccessRight.test.js index 6406dd3c9b..1938546c9c 100644 --- a/test/api/v3/unit/middlewares/ensureAccessRight.test.js +++ b/test/api/unit/middlewares/ensureAccessRight.test.js @@ -3,11 +3,11 @@ import { generateRes, generateReq, generateNext, -} from '../../../../helpers/api-unit.helper'; -import i18n from '../../../../../website/common/script/i18n'; -import { ensureAdmin, ensureSudo } from '../../../../../website/server/middlewares/ensureAccessRight'; -import { NotAuthorized } from '../../../../../website/server/libs/errors'; -import apiError from '../../../../../website/server/libs/apiError'; +} from '../../../helpers/api-unit.helper'; +import i18n from '../../../../website/common/script/i18n'; +import { ensureAdmin, ensureSudo } from '../../../../website/server/middlewares/ensureAccessRight'; +import { NotAuthorized } from '../../../../website/server/libs/errors'; +import apiError from '../../../../website/server/libs/apiError'; describe('ensure access middlewares', () => { let res, req, next; diff --git a/test/api/v3/unit/middlewares/ensureDevelpmentMode.js b/test/api/unit/middlewares/ensureDevelpmentMode.js similarity index 79% rename from test/api/v3/unit/middlewares/ensureDevelpmentMode.js rename to test/api/unit/middlewares/ensureDevelpmentMode.js index c753740204..0e1140c961 100644 --- a/test/api/v3/unit/middlewares/ensureDevelpmentMode.js +++ b/test/api/unit/middlewares/ensureDevelpmentMode.js @@ -3,9 +3,9 @@ import { generateRes, generateReq, generateNext, -} from '../../../../helpers/api-unit.helper'; -import ensureDevelpmentMode from '../../../../../website/server/middlewares/ensureDevelpmentMode'; -import { NotFound } from '../../../../../website/server/libs/errors'; +} from '../../../helpers/api-unit.helper'; +import ensureDevelpmentMode from '../../../../website/server/middlewares/ensureDevelpmentMode'; +import { NotFound } from '../../../../website/server/libs/errors'; import nconf from 'nconf'; describe('developmentMode middleware', () => { diff --git a/test/api/v3/unit/middlewares/errorHandler.test.js b/test/api/unit/middlewares/errorHandler.test.js similarity index 91% rename from test/api/v3/unit/middlewares/errorHandler.test.js rename to test/api/unit/middlewares/errorHandler.test.js index cc63924ff1..7611b2c418 100644 --- a/test/api/v3/unit/middlewares/errorHandler.test.js +++ b/test/api/unit/middlewares/errorHandler.test.js @@ -2,17 +2,17 @@ import { generateRes, generateReq, generateNext, -} from '../../../../helpers/api-unit.helper'; +} from '../../../helpers/api-unit.helper'; -import errorHandler from '../../../../../website/server/middlewares/errorHandler'; -import responseMiddleware from '../../../../../website/server/middlewares/response'; +import errorHandler from '../../../../website/server/middlewares/errorHandler'; +import responseMiddleware from '../../../../website/server/middlewares/response'; import { getUserLanguage, attachTranslateFunction, -} from '../../../../../website/server/middlewares/language'; +} from '../../../../website/server/middlewares/language'; -import { BadRequest } from '../../../../../website/server/libs/errors'; -import logger from '../../../../../website/server/libs/logger'; +import { BadRequest } from '../../../../website/server/libs/errors'; +import logger from '../../../../website/server/libs/logger'; describe('errorHandler', () => { let res, req, next; diff --git a/test/api/v3/unit/middlewares/language.test.js b/test/api/unit/middlewares/language.test.js similarity index 96% rename from test/api/v3/unit/middlewares/language.test.js rename to test/api/unit/middlewares/language.test.js index 5a1136bd0c..8c93bc2b5e 100644 --- a/test/api/v3/unit/middlewares/language.test.js +++ b/test/api/unit/middlewares/language.test.js @@ -2,13 +2,13 @@ import { generateRes, generateReq, generateNext, -} from '../../../../helpers/api-unit.helper'; +} from '../../../helpers/api-unit.helper'; import { getUserLanguage, attachTranslateFunction, -} from '../../../../../website/server/middlewares/language'; -import common from '../../../../../website/common'; -import { model as User } from '../../../../../website/server/models/user'; +} from '../../../../website/server/middlewares/language'; +import common from '../../../../website/common'; +import { model as User } from '../../../../website/server/models/user'; const i18n = common.i18n; diff --git a/test/api/v3/unit/middlewares/maintenanceMode.test.js b/test/api/unit/middlewares/maintenanceMode.test.js similarity index 92% rename from test/api/v3/unit/middlewares/maintenanceMode.test.js rename to test/api/unit/middlewares/maintenanceMode.test.js index 566d572206..df5736bd38 100644 --- a/test/api/v3/unit/middlewares/maintenanceMode.test.js +++ b/test/api/unit/middlewares/maintenanceMode.test.js @@ -2,13 +2,13 @@ import { generateRes, generateReq, generateNext, -} from '../../../../helpers/api-unit.helper'; +} from '../../../helpers/api-unit.helper'; import nconf from 'nconf'; import requireAgain from 'require-again'; describe('maintenance mode middleware', () => { let res, req, next; - let pathToMaintenanceModeMiddleware = '../../../../../website/server/middlewares/maintenanceMode'; + let pathToMaintenanceModeMiddleware = '../../../../website/server/middlewares/maintenanceMode'; beforeEach(() => { res = generateRes(); diff --git a/test/api/v3/unit/middlewares/redirects.js b/test/api/unit/middlewares/redirects.js similarity index 97% rename from test/api/v3/unit/middlewares/redirects.js rename to test/api/unit/middlewares/redirects.js index 184d60b706..d93ed5345c 100644 --- a/test/api/v3/unit/middlewares/redirects.js +++ b/test/api/unit/middlewares/redirects.js @@ -2,13 +2,13 @@ import { generateRes, generateReq, generateNext, -} from '../../../../helpers/api-unit.helper'; +} from '../../../helpers/api-unit.helper'; import nconf from 'nconf'; import requireAgain from 'require-again'; describe('redirects middleware', () => { let res, req, next; - let pathToRedirectsMiddleware = '../../../../../website/server/middlewares/redirects'; + let pathToRedirectsMiddleware = '../../../../website/server/middlewares/redirects'; beforeEach(() => { res = generateRes(); diff --git a/test/api/v3/unit/middlewares/response.js b/test/api/unit/middlewares/response.js similarity index 94% rename from test/api/v3/unit/middlewares/response.js rename to test/api/unit/middlewares/response.js index 88dcbb7cc8..2ffc8c6675 100644 --- a/test/api/v3/unit/middlewares/response.js +++ b/test/api/unit/middlewares/response.js @@ -2,9 +2,9 @@ import { generateRes, generateReq, generateNext, -} from '../../../../helpers/api-unit.helper'; -import responseMiddleware from '../../../../../website/server/middlewares/response'; -import packageInfo from '../../../../../package.json'; +} from '../../../helpers/api-unit.helper'; +import responseMiddleware from '../../../../website/server/middlewares/response'; +import packageInfo from '../../../../package.json'; describe('response middleware', () => { let res, req, next; diff --git a/test/api/v3/unit/models/challenge.test.js b/test/api/unit/models/challenge.test.js similarity index 96% rename from test/api/v3/unit/models/challenge.test.js rename to test/api/unit/models/challenge.test.js index a27d8b65a7..cb4b5562e5 100644 --- a/test/api/v3/unit/models/challenge.test.js +++ b/test/api/unit/models/challenge.test.js @@ -1,8 +1,8 @@ -import { model as Challenge } from '../../../../../website/server/models/challenge'; -import { model as Group } from '../../../../../website/server/models/group'; -import { model as User } from '../../../../../website/server/models/user'; -import * as Tasks from '../../../../../website/server/models/task'; -import common from '../../../../../website/common/'; +import { model as Challenge } from '../../../../website/server/models/challenge'; +import { model as Group } from '../../../../website/server/models/group'; +import { model as User } from '../../../../website/server/models/user'; +import * as Tasks from '../../../../website/server/models/task'; +import common from '../../../../website/common/'; import { each, find } from 'lodash'; describe('Challenge Model', () => { diff --git a/test/api/v3/unit/models/group.test.js b/test/api/unit/models/group.test.js similarity index 99% rename from test/api/v3/unit/models/group.test.js rename to test/api/unit/models/group.test.js index 82547341a6..3b5a053725 100644 --- a/test/api/v3/unit/models/group.test.js +++ b/test/api/unit/models/group.test.js @@ -1,23 +1,23 @@ import moment from 'moment'; import { v4 as generateUUID } from 'uuid'; import validator from 'validator'; -import { sleep } from '../../../../helpers/api-unit.helper'; +import { sleep } from '../../../helpers/api-unit.helper'; import { SPAM_MESSAGE_LIMIT, SPAM_MIN_EXEMPT_CONTRIB_LEVEL, SPAM_WINDOW_LENGTH, INVITES_LIMIT, model as Group, -} from '../../../../../website/server/models/group'; -import { model as User } from '../../../../../website/server/models/user'; -import { quests as questScrolls } from '../../../../../website/common/script/content'; +} from '../../../../website/server/models/group'; +import { model as User } from '../../../../website/server/models/user'; +import { quests as questScrolls } from '../../../../website/common/script/content'; import { groupChatReceivedWebhook, questActivityWebhook, -} from '../../../../../website/server/libs/webhook'; -import * as email from '../../../../../website/server/libs/email'; -import { TAVERN_ID } from '../../../../../website/common/script/'; -import shared from '../../../../../website/common'; +} from '../../../../website/server/libs/webhook'; +import * as email from '../../../../website/server/libs/email'; +import { TAVERN_ID } from '../../../../website/common/script/'; +import shared from '../../../../website/common'; describe('Group Model', () => { let party, questLeader, participatingMember, nonParticipatingMember, undecidedMember; diff --git a/test/api/v3/unit/models/group_tasks.test.js b/test/api/unit/models/group_tasks.test.js similarity index 97% rename from test/api/v3/unit/models/group_tasks.test.js rename to test/api/unit/models/group_tasks.test.js index 76e7666c96..21cfd9ef2b 100644 --- a/test/api/v3/unit/models/group_tasks.test.js +++ b/test/api/unit/models/group_tasks.test.js @@ -1,7 +1,7 @@ -import { model as Challenge } from '../../../../../website/server/models/challenge'; -import { model as Group } from '../../../../../website/server/models/group'; -import { model as User } from '../../../../../website/server/models/user'; -import * as Tasks from '../../../../../website/server/models/task'; +import { model as Challenge } from '../../../../website/server/models/challenge'; +import { model as Group } from '../../../../website/server/models/group'; +import { model as User } from '../../../../website/server/models/user'; +import * as Tasks from '../../../../website/server/models/task'; import { each, find, findIndex } from 'lodash'; describe('Group Task Methods', () => { diff --git a/test/api/v3/unit/models/task.test.js b/test/api/unit/models/task.test.js similarity index 90% rename from test/api/v3/unit/models/task.test.js rename to test/api/unit/models/task.test.js index fc3ab9a513..d925073945 100644 --- a/test/api/v3/unit/models/task.test.js +++ b/test/api/unit/models/task.test.js @@ -1,10 +1,10 @@ -import { model as Challenge } from '../../../../../website/server/models/challenge'; -import { model as Group } from '../../../../../website/server/models/group'; -import { model as User } from '../../../../../website/server/models/user'; -import * as Tasks from '../../../../../website/server/models/task'; -import { InternalServerError } from '../../../../../website/server/libs/errors'; +import { model as Challenge } from '../../../../website/server/models/challenge'; +import { model as Group } from '../../../../website/server/models/group'; +import { model as User } from '../../../../website/server/models/user'; +import * as Tasks from '../../../../website/server/models/task'; +import { InternalServerError } from '../../../../website/server/libs/errors'; import { each } from 'lodash'; -import { generateHistory } from '../../../../helpers/api-unit.helper.js'; +import { generateHistory } from '../../../helpers/api-unit.helper.js'; describe('Task Model', () => { let guild, leader, challenge, task; diff --git a/test/api/v3/unit/models/user.test.js b/test/api/unit/models/user.test.js similarity index 98% rename from test/api/v3/unit/models/user.test.js rename to test/api/unit/models/user.test.js index 2a3e7e6ad6..825dee32c4 100644 --- a/test/api/v3/unit/models/user.test.js +++ b/test/api/unit/models/user.test.js @@ -1,7 +1,7 @@ import moment from 'moment'; -import { model as User } from '../../../../../website/server/models/user'; -import { model as Group } from '../../../../../website/server/models/group'; -import common from '../../../../../website/common'; +import { model as User } from '../../../../website/server/models/user'; +import { model as Group } from '../../../../website/server/models/group'; +import common from '../../../../website/common'; describe('User Model', () => { it('keeps user._tmp when calling .toJSON', () => { diff --git a/test/api/v3/unit/models/userNotification.test.js b/test/api/unit/models/userNotification.test.js similarity index 89% rename from test/api/v3/unit/models/userNotification.test.js rename to test/api/unit/models/userNotification.test.js index 0bd87f4bcb..81140a9c26 100644 --- a/test/api/v3/unit/models/userNotification.test.js +++ b/test/api/unit/models/userNotification.test.js @@ -1,4 +1,4 @@ -import { model as UserNotification } from '../../../../../website/server/models/userNotification'; +import { model as UserNotification } from '../../../../website/server/models/userNotification'; describe('UserNotification Model', () => { context('convertNotificationsToSafeJson', () => { diff --git a/test/api/v3/unit/models/webhook.test.js b/test/api/unit/models/webhook.test.js similarity index 97% rename from test/api/v3/unit/models/webhook.test.js rename to test/api/unit/models/webhook.test.js index b3cb23c44e..06d69a256d 100644 --- a/test/api/v3/unit/models/webhook.test.js +++ b/test/api/unit/models/webhook.test.js @@ -1,7 +1,7 @@ -import { model as Webhook } from '../../../../../website/server/models/webhook'; -import { BadRequest } from '../../../../../website/server/libs/errors'; +import { model as Webhook } from '../../../../website/server/models/webhook'; +import { BadRequest } from '../../../../website/server/libs/errors'; import { v4 as generateUUID } from 'uuid'; -import apiError from '../../../../../website/server/libs/apiError'; +import apiError from '../../../../website/server/libs/apiError'; describe('Webhook Model', () => { context('Instance Methods', () => { diff --git a/test/api/v3/integration/challenges/DELETE-challenges_challengeId.test.js b/test/api/v3/integration/challenges/DELETE-challenges_challengeId.test.js index e7263cbd59..15d8751e5a 100644 --- a/test/api/v3/integration/challenges/DELETE-challenges_challengeId.test.js +++ b/test/api/v3/integration/challenges/DELETE-challenges_challengeId.test.js @@ -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', () => { diff --git a/test/api/v3/integration/challenges/GET-challenges_challengeId.test.js b/test/api/v3/integration/challenges/GET-challenges_challengeId.test.js index 21b8e92494..049506570e 100644 --- a/test/api/v3/integration/challenges/GET-challenges_challengeId.test.js +++ b/test/api/v3/integration/challenges/GET-challenges_challengeId.test.js @@ -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', () => { diff --git a/test/api/v3/integration/challenges/GET-challenges_challengeId_export_csv.test.js b/test/api/v3/integration/challenges/GET-challenges_challengeId_export_csv.test.js index f39a148be0..b9bf69b1c6 100644 --- a/test/api/v3/integration/challenges/GET-challenges_challengeId_export_csv.test.js +++ b/test/api/v3/integration/challenges/GET-challenges_challengeId_export_csv.test.js @@ -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', () => { diff --git a/test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js b/test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js index 9d56bb53c3..71aa643869 100644 --- a/test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js +++ b/test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js @@ -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', () => { diff --git a/test/api/v3/integration/challenges/GET-challenges_challengeId_members_memberId.test.js b/test/api/v3/integration/challenges/GET-challenges_challengeId_members_memberId.test.js index 5154cdcaad..47a7adbf39 100644 --- a/test/api/v3/integration/challenges/GET-challenges_challengeId_members_memberId.test.js +++ b/test/api/v3/integration/challenges/GET-challenges_challengeId_members_memberId.test.js @@ -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', () => { diff --git a/test/api/v3/integration/challenges/GET-challenges_group_groupid.test.js b/test/api/v3/integration/challenges/GET-challenges_group_groupid.test.js index 6521d34677..8ad7b76ed8 100644 --- a/test/api/v3/integration/challenges/GET-challenges_group_groupid.test.js +++ b/test/api/v3/integration/challenges/GET-challenges_group_groupid.test.js @@ -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', () => { diff --git a/test/api/v3/integration/challenges/GET-challenges_user.test.js b/test/api/v3/integration/challenges/GET-challenges_user.test.js index cbcacfe3a7..e1b1c32143 100644 --- a/test/api/v3/integration/challenges/GET-challenges_user.test.js +++ b/test/api/v3/integration/challenges/GET-challenges_user.test.js @@ -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', () => { diff --git a/test/api/v3/integration/challenges/POST-challenges.test.js b/test/api/v3/integration/challenges/POST-challenges.test.js index 1fbd0fd768..c70b41806f 100644 --- a/test/api/v3/integration/challenges/POST-challenges.test.js +++ b/test/api/v3/integration/challenges/POST-challenges.test.js @@ -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', () => { diff --git a/test/api/v3/integration/challenges/POST-challenges_challengeId_join.test.js b/test/api/v3/integration/challenges/POST-challenges_challengeId_join.test.js index 734a578d1e..6c403d05ad 100644 --- a/test/api/v3/integration/challenges/POST-challenges_challengeId_join.test.js +++ b/test/api/v3/integration/challenges/POST-challenges_challengeId_join.test.js @@ -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', () => { diff --git a/test/api/v3/integration/challenges/POST-challenges_challengeId_leave.test.js b/test/api/v3/integration/challenges/POST-challenges_challengeId_leave.test.js index dd81daf75d..080f7a92ef 100644 --- a/test/api/v3/integration/challenges/POST-challenges_challengeId_leave.test.js +++ b/test/api/v3/integration/challenges/POST-challenges_challengeId_leave.test.js @@ -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', () => { diff --git a/test/api/v3/integration/challenges/POST-challenges_challengeId_winner_winnerId.test.js b/test/api/v3/integration/challenges/POST-challenges_challengeId_winner_winnerId.test.js index 43187b9c61..41c655b88c 100644 --- a/test/api/v3/integration/challenges/POST-challenges_challengeId_winner_winnerId.test.js +++ b/test/api/v3/integration/challenges/POST-challenges_challengeId_winner_winnerId.test.js @@ -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', () => { diff --git a/test/api/v3/integration/challenges/POST_challenges_id_clone.test.js b/test/api/v3/integration/challenges/POST_challenges_id_clone.test.js index 04e12049cd..3f2abd8a0b 100644 --- a/test/api/v3/integration/challenges/POST_challenges_id_clone.test.js +++ b/test/api/v3/integration/challenges/POST_challenges_id_clone.test.js @@ -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 () => { diff --git a/test/api/v3/integration/challenges/PUT-challenges_challengeId.test.js b/test/api/v3/integration/challenges/PUT-challenges_challengeId.test.js index dce90f0cbd..fc3155c6e0 100644 --- a/test/api/v3/integration/challenges/PUT-challenges_challengeId.test.js +++ b/test/api/v3/integration/challenges/PUT-challenges_challengeId.test.js @@ -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; diff --git a/test/api/v3/integration/chat/DELETE-chat_id.test.js b/test/api/v3/integration/chat/DELETE-chat_id.test.js index 2f79150ae2..929ec790b6 100644 --- a/test/api/v3/integration/chat/DELETE-chat_id.test.js +++ b/test/api/v3/integration/chat/DELETE-chat_id.test.js @@ -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', () => { diff --git a/test/api/v3/integration/chat/GET-chat.test.js b/test/api/v3/integration/chat/GET-chat.test.js index 710686d7cf..e3a9d17548 100644 --- a/test/api/v3/integration/chat/GET-chat.test.js +++ b/test/api/v3/integration/chat/GET-chat.test.js @@ -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; diff --git a/test/api/v3/integration/chat/POST-chat.flag.test.js b/test/api/v3/integration/chat/POST-chat.flag.test.js index d2e01398b5..762899f052 100644 --- a/test/api/v3/integration/chat/POST-chat.flag.test.js +++ b/test/api/v3/integration/chat/POST-chat.flag.test.js @@ -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', () => { diff --git a/test/api/v3/integration/chat/POST-chat.like.test.js b/test/api/v3/integration/chat/POST-chat.like.test.js index d7ae6047df..a6dfb7d795 100644 --- a/test/api/v3/integration/chat/POST-chat.like.test.js +++ b/test/api/v3/integration/chat/POST-chat.like.test.js @@ -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', () => { diff --git a/test/api/v3/integration/chat/POST-chat.test.js b/test/api/v3/integration/chat/POST-chat.test.js index 194008bb4b..6a675aab97 100644 --- a/test/api/v3/integration/chat/POST-chat.test.js +++ b/test/api/v3/integration/chat/POST-chat.test.js @@ -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, diff --git a/test/api/v3/integration/chat/POST-chat_seen.test.js b/test/api/v3/integration/chat/POST-chat_seen.test.js index b247af13b0..6bd3f87b23 100644 --- a/test/api/v3/integration/chat/POST-chat_seen.test.js +++ b/test/api/v3/integration/chat/POST-chat_seen.test.js @@ -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', () => { diff --git a/test/api/v3/integration/chat/POST-groups_id_chat_id_clear_flags.test.js b/test/api/v3/integration/chat/POST-groups_id_chat_id_clear_flags.test.js index 35a2878847..89e5b133b7 100644 --- a/test/api/v3/integration/chat/POST-groups_id_chat_id_clear_flags.test.js +++ b/test/api/v3/integration/chat/POST-groups_id_chat_id_clear_flags.test.js @@ -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'; diff --git a/test/api/v3/integration/content/GET-content.test.js b/test/api/v3/integration/content/GET-content.test.js index 1489738577..a9f9ce5ee9 100644 --- a/test/api/v3/integration/content/GET-content.test.js +++ b/test/api/v3/integration/content/GET-content.test.js @@ -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', () => { diff --git a/test/api/v3/integration/coupons/GET-coupons.test.js b/test/api/v3/integration/coupons/GET-coupons.test.js index 2e31669c70..9eecfe681c 100644 --- a/test/api/v3/integration/coupons/GET-coupons.test.js +++ b/test/api/v3/integration/coupons/GET-coupons.test.js @@ -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/', () => { diff --git a/test/api/v3/integration/coupons/POST-coupons_enter_code.test.js b/test/api/v3/integration/coupons/POST-coupons_enter_code.test.js index e1f9db3583..be3f982617 100644 --- a/test/api/v3/integration/coupons/POST-coupons_enter_code.test.js +++ b/test/api/v3/integration/coupons/POST-coupons_enter_code.test.js @@ -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; diff --git a/test/api/v3/integration/coupons/POST-coupons_generate_event.test.js b/test/api/v3/integration/coupons/POST-coupons_generate_event.test.js index 6b533b76d6..1fe9af0d7a 100644 --- a/test/api/v3/integration/coupons/POST-coupons_generate_event.test.js +++ b/test/api/v3/integration/coupons/POST-coupons_generate_event.test.js @@ -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'; diff --git a/test/api/v3/integration/coupons/POST-coupons_validate_code.test.js b/test/api/v3/integration/coupons/POST-coupons_validate_code.test.js index 9d433813ea..52d85c6210 100644 --- a/test/api/v3/integration/coupons/POST-coupons_validate_code.test.js +++ b/test/api/v3/integration/coupons/POST-coupons_validate_code.test.js @@ -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(); diff --git a/test/api/v3/integration/dataexport/GET-export_avatar-memberId.html.test.js b/test/api/v3/integration/dataexport/GET-export_avatar-memberId.html.test.js index 03e2d906bf..0b24bb02bd 100644 --- a/test/api/v3/integration/dataexport/GET-export_avatar-memberId.html.test.js +++ b/test/api/v3/integration/dataexport/GET-export_avatar-memberId.html.test.js @@ -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', () => { diff --git a/test/api/v3/integration/dataexport/GET-export_history.csv.test.js b/test/api/v3/integration/dataexport/GET-export_history.csv.test.js index 1b2b7e8a0d..5f49213038 100644 --- a/test/api/v3/integration/dataexport/GET-export_history.csv.test.js +++ b/test/api/v3/integration/dataexport/GET-export_history.csv.test.js @@ -1,6 +1,6 @@ import { generateUser, -} from '../../../../helpers/api-v3-integration.helper'; +} from '../../../../helpers/api-integration/v3'; import { updateDocument, } from '../../../../helpers/mongo'; diff --git a/test/api/v3/integration/dataexport/GET-export_inbox.html.test.js b/test/api/v3/integration/dataexport/GET-export_inbox.html.test.js index aade366802..61c4e6b933 100644 --- a/test/api/v3/integration/dataexport/GET-export_inbox.html.test.js +++ b/test/api/v3/integration/dataexport/GET-export_inbox.html.test.js @@ -1,6 +1,6 @@ import { generateUser, -} from '../../../../helpers/api-v3-integration.helper'; +} from '../../../../helpers/api-integration/v3'; describe('GET /export/inbox.html', () => { let user; diff --git a/test/api/v3/integration/dataexport/GET-export_userdata.json.test.js b/test/api/v3/integration/dataexport/GET-export_userdata.json.test.js index d8152f1209..38fbf6435f 100644 --- a/test/api/v3/integration/dataexport/GET-export_userdata.json.test.js +++ b/test/api/v3/integration/dataexport/GET-export_userdata.json.test.js @@ -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 () => { diff --git a/test/api/v3/integration/dataexport/GET-export_userdata.xml.test.js b/test/api/v3/integration/dataexport/GET-export_userdata.xml.test.js index db198b6eee..5973f439f7 100644 --- a/test/api/v3/integration/dataexport/GET-export_userdata.xml.test.js +++ b/test/api/v3/integration/dataexport/GET-export_userdata.xml.test.js @@ -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'; diff --git a/test/api/v3/integration/debug/POST-debug_addHourglass.test.js b/test/api/v3/integration/debug/POST-debug_addHourglass.test.js index 767fa840f2..d528f79a81 100644 --- a/test/api/v3/integration/debug/POST-debug_addHourglass.test.js +++ b/test/api/v3/integration/debug/POST-debug_addHourglass.test.js @@ -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; diff --git a/test/api/v3/integration/debug/POST-debug_addTenGems.test.js b/test/api/v3/integration/debug/POST-debug_addTenGems.test.js index d1a3b39eb2..faaa2cbd10 100644 --- a/test/api/v3/integration/debug/POST-debug_addTenGems.test.js +++ b/test/api/v3/integration/debug/POST-debug_addTenGems.test.js @@ -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; diff --git a/test/api/v3/integration/debug/POST-debug_make-admin.test.js b/test/api/v3/integration/debug/POST-debug_make-admin.test.js index 0696b6469f..311d477994 100644 --- a/test/api/v3/integration/debug/POST-debug_make-admin.test.js +++ b/test/api/v3/integration/debug/POST-debug_make-admin.test.js @@ -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; diff --git a/test/api/v3/integration/debug/POST-debug_modify-inventory.test.js b/test/api/v3/integration/debug/POST-debug_modify-inventory.test.js index 7047150477..cadb9e2b18 100644 --- a/test/api/v3/integration/debug/POST-debug_modify-inventory.test.js +++ b/test/api/v3/integration/debug/POST-debug_modify-inventory.test.js @@ -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; diff --git a/test/api/v3/integration/debug/POST-debug_quest-progress.test.js b/test/api/v3/integration/debug/POST-debug_quest-progress.test.js index 90c14c4470..7234395c6f 100644 --- a/test/api/v3/integration/debug/POST-debug_quest-progress.test.js +++ b/test/api/v3/integration/debug/POST-debug_quest-progress.test.js @@ -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; diff --git a/test/api/v3/integration/debug/POST-debug_set-cron.test.js b/test/api/v3/integration/debug/POST-debug_set-cron.test.js index 10fe75fa14..254bca2d1a 100644 --- a/test/api/v3/integration/debug/POST-debug_set-cron.test.js +++ b/test/api/v3/integration/debug/POST-debug_set-cron.test.js @@ -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; diff --git a/test/api/v3/integration/emails/GET-email-unsubscribe.test.js b/test/api/v3/integration/emails/GET-email-unsubscribe.test.js index cda83e78e3..fcd26b7904 100644 --- a/test/api/v3/integration/emails/GET-email-unsubscribe.test.js +++ b/test/api/v3/integration/emails/GET-email-unsubscribe.test.js @@ -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'; diff --git a/test/api/v3/integration/groups/GET-group-plans.test.js b/test/api/v3/integration/groups/GET-group-plans.test.js index 353a591d4e..a56c01087d 100644 --- a/test/api/v3/integration/groups/GET-group-plans.test.js +++ b/test/api/v3/integration/groups/GET-group-plans.test.js @@ -1,7 +1,7 @@ import { generateUser, generateGroup, -} from '../../../../helpers/api-v3-integration.helper'; +} from '../../../../helpers/api-integration/v3'; describe('GET /group-plans', () => { let user; diff --git a/test/api/v3/integration/groups/GET-groups.test.js b/test/api/v3/integration/groups/GET-groups.test.js index 9b41fcb53a..080ceeaceb 100644 --- a/test/api/v3/integration/groups/GET-groups.test.js +++ b/test/api/v3/integration/groups/GET-groups.test.js @@ -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'; diff --git a/test/api/v3/integration/groups/GET-groups_groupId_invites.test.js b/test/api/v3/integration/groups/GET-groups_groupId_invites.test.js index abef14c57c..cb132d9b11 100644 --- a/test/api/v3/integration/groups/GET-groups_groupId_invites.test.js +++ b/test/api/v3/integration/groups/GET-groups_groupId_invites.test.js @@ -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', () => { diff --git a/test/api/v3/integration/groups/GET-groups_groupId_members.test.js b/test/api/v3/integration/groups/GET-groups_groupId_members.test.js index 99be54d4a9..d2f321c1fa 100644 --- a/test/api/v3/integration/groups/GET-groups_groupId_members.test.js +++ b/test/api/v3/integration/groups/GET-groups_groupId_members.test.js @@ -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'; diff --git a/test/api/v3/integration/groups/GET-groups_id.test.js b/test/api/v3/integration/groups/GET-groups_id.test.js index ec8da5e1bd..9b9aba0e6f 100644 --- a/test/api/v3/integration/groups/GET-groups_id.test.js +++ b/test/api/v3/integration/groups/GET-groups_id.test.js @@ -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 { diff --git a/test/api/v3/integration/groups/POST-group_remove_manager.test.js b/test/api/v3/integration/groups/POST-group_remove_manager.test.js index 1a1c412a90..0d426b27ae 100644 --- a/test/api/v3/integration/groups/POST-group_remove_manager.test.js +++ b/test/api/v3/integration/groups/POST-group_remove_manager.test.js @@ -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', () => { diff --git a/test/api/v3/integration/groups/POST-groups.test.js b/test/api/v3/integration/groups/POST-groups.test.js index 6d262162c2..9eeb6d0589 100644 --- a/test/api/v3/integration/groups/POST-groups.test.js +++ b/test/api/v3/integration/groups/POST-groups.test.js @@ -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; diff --git a/test/api/v3/integration/groups/POST-groups_groupId_join.test.js b/test/api/v3/integration/groups/POST-groups_groupId_join.test.js index 9a795b2c5d..a3d88d82a4 100644 --- a/test/api/v3/integration/groups/POST-groups_groupId_join.test.js +++ b/test/api/v3/integration/groups/POST-groups_groupId_join.test.js @@ -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', () => { diff --git a/test/api/v3/integration/groups/POST-groups_groupId_leave.js b/test/api/v3/integration/groups/POST-groups_groupId_leave.js index fd19052a17..eab4442224 100644 --- a/test/api/v3/integration/groups/POST-groups_groupId_leave.js +++ b/test/api/v3/integration/groups/POST-groups_groupId_leave.js @@ -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, diff --git a/test/api/v3/integration/groups/POST-groups_groupId_reject.test.js b/test/api/v3/integration/groups/POST-groups_groupId_reject.test.js index 7f1e31df85..59d8645d01 100644 --- a/test/api/v3/integration/groups/POST-groups_groupId_reject.test.js +++ b/test/api/v3/integration/groups/POST-groups_groupId_reject.test.js @@ -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', () => { diff --git a/test/api/v3/integration/groups/POST-groups_id_removeMember.test.js b/test/api/v3/integration/groups/POST-groups_id_removeMember.test.js index 97819e7a41..b29902bc20 100644 --- a/test/api/v3/integration/groups/POST-groups_id_removeMember.test.js +++ b/test/api/v3/integration/groups/POST-groups_id_removeMember.test.js @@ -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', () => { diff --git a/test/api/v3/integration/groups/POST-groups_invite.test.js b/test/api/v3/integration/groups/POST-groups_invite.test.js index 7b5c602e48..31f9964298 100644 --- a/test/api/v3/integration/groups/POST-groups_invite.test.js +++ b/test/api/v3/integration/groups/POST-groups_invite.test.js @@ -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'; diff --git a/test/api/v3/integration/groups/POST-groups_manager.test.js b/test/api/v3/integration/groups/POST-groups_manager.test.js index b6b90f7ceb..8730ea8c95 100644 --- a/test/api/v3/integration/groups/POST-groups_manager.test.js +++ b/test/api/v3/integration/groups/POST-groups_manager.test.js @@ -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; diff --git a/test/api/v3/integration/groups/PUT-groups.test.js b/test/api/v3/integration/groups/PUT-groups.test.js index 0cf30b5d03..9dc00cb891 100644 --- a/test/api/v3/integration/groups/PUT-groups.test.js +++ b/test/api/v3/integration/groups/PUT-groups.test.js @@ -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; diff --git a/test/api/v3/integration/hall/GET-hall_heroes.test.js b/test/api/v3/integration/hall/GET-hall_heroes.test.js index a2b87ff689..f0fa59ad6b 100644 --- a/test/api/v3/integration/hall/GET-hall_heroes.test.js +++ b/test/api/v3/integration/hall/GET-hall_heroes.test.js @@ -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 () => { diff --git a/test/api/v3/integration/hall/GET-hall_heroes_heroId.test.js b/test/api/v3/integration/hall/GET-hall_heroes_heroId.test.js index 2bf1a0a017..b687ee0ed9 100644 --- a/test/api/v3/integration/hall/GET-hall_heroes_heroId.test.js +++ b/test/api/v3/integration/hall/GET-hall_heroes_heroId.test.js @@ -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', () => { diff --git a/test/api/v3/integration/hall/GET-hall_patrons.test.js b/test/api/v3/integration/hall/GET-hall_patrons.test.js index 9599daef89..85acd568e2 100644 --- a/test/api/v3/integration/hall/GET-hall_patrons.test.js +++ b/test/api/v3/integration/hall/GET-hall_patrons.test.js @@ -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', () => { diff --git a/test/api/v3/integration/hall/PUT-hall_heores_heroId.test.js b/test/api/v3/integration/hall/PUT-hall_heores_heroId.test.js index edfb9015be..53a138c8bb 100644 --- a/test/api/v3/integration/hall/PUT-hall_heores_heroId.test.js +++ b/test/api/v3/integration/hall/PUT-hall_heores_heroId.test.js @@ -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', () => { diff --git a/test/api/v3/integration/members/GET-achievements.test.js b/test/api/v3/integration/members/GET-achievements.test.js index cb7930adba..9f46780b3e 100644 --- a/test/api/v3/integration/members/GET-achievements.test.js +++ b/test/api/v3/integration/members/GET-achievements.test.js @@ -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', () => { diff --git a/test/api/v3/integration/members/GET-members_id.test.js b/test/api/v3/integration/members/GET-members_id.test.js index 729ea92e3c..7a4f23fb80 100644 --- a/test/api/v3/integration/members/GET-members_id.test.js +++ b/test/api/v3/integration/members/GET-members_id.test.js @@ -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'; diff --git a/test/api/v3/integration/members/GET-objections_interaction.test.js b/test/api/v3/integration/members/GET-objections_interaction.test.js index cab90bdacd..5c7a8c0677 100644 --- a/test/api/v3/integration/members/GET-objections_interaction.test.js +++ b/test/api/v3/integration/members/GET-objections_interaction.test.js @@ -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', () => { diff --git a/test/api/v3/integration/members/POST-send_private_message.test.js b/test/api/v3/integration/members/POST-send_private_message.test.js index 0e484dc68f..7e9c22f925 100644 --- a/test/api/v3/integration/members/POST-send_private_message.test.js +++ b/test/api/v3/integration/members/POST-send_private_message.test.js @@ -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', () => { diff --git a/test/api/v3/integration/members/POST-transfer_gems.test.js b/test/api/v3/integration/members/POST-transfer_gems.test.js index a56540867b..0b5b0cfa93 100644 --- a/test/api/v3/integration/members/POST-transfer_gems.test.js +++ b/test/api/v3/integration/members/POST-transfer_gems.test.js @@ -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) { diff --git a/test/api/v3/integration/news/GET-news.test.js b/test/api/v3/integration/news/GET-news.test.js index b09d408706..8de8afbc05 100644 --- a/test/api/v3/integration/news/GET-news.test.js +++ b/test/api/v3/integration/news/GET-news.test.js @@ -1,6 +1,6 @@ import { requester, -} from '../../../../helpers/api-v3-integration.helper'; +} from '../../../../helpers/api-integration/v3'; describe('GET /news', () => { let api; diff --git a/test/api/v3/integration/news/POST-news_tell_me_later.test.js b/test/api/v3/integration/news/POST-news_tell_me_later.test.js index 491a33f210..bd1cdfb147 100644 --- a/test/api/v3/integration/news/POST-news_tell_me_later.test.js +++ b/test/api/v3/integration/news/POST-news_tell_me_later.test.js @@ -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; diff --git a/test/api/v3/integration/notifications/POST-notifications_notificationId_read.test.js b/test/api/v3/integration/notifications/POST-notifications_notificationId_read.test.js index ea353aa32b..91e4d6ac9b 100644 --- a/test/api/v3/integration/notifications/POST-notifications_notificationId_read.test.js +++ b/test/api/v3/integration/notifications/POST-notifications_notificationId_read.test.js @@ -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', () => { diff --git a/test/api/v3/integration/notifications/POST-notifications_notificationId_see.test.js b/test/api/v3/integration/notifications/POST-notifications_notificationId_see.test.js index 0b448f10fd..5b570b82d4 100644 --- a/test/api/v3/integration/notifications/POST-notifications_notificationId_see.test.js +++ b/test/api/v3/integration/notifications/POST-notifications_notificationId_see.test.js @@ -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', () => { diff --git a/test/api/v3/integration/notifications/POST-notifications_read.test.js b/test/api/v3/integration/notifications/POST-notifications_read.test.js index 55a9d3350b..d07fe36686 100644 --- a/test/api/v3/integration/notifications/POST-notifications_read.test.js +++ b/test/api/v3/integration/notifications/POST-notifications_read.test.js @@ -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', () => { diff --git a/test/api/v3/integration/notifications/POST_notifications_see.test.js b/test/api/v3/integration/notifications/POST_notifications_see.test.js index d09d9bde07..2f67a5e149 100644 --- a/test/api/v3/integration/notifications/POST_notifications_see.test.js +++ b/test/api/v3/integration/notifications/POST_notifications_see.test.js @@ -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', () => { diff --git a/test/api/v3/integration/qrcodes/GET-qrcodes_user.test.js b/test/api/v3/integration/qrcodes/GET-qrcodes_user.test.js index 505840a48f..df5df6604b 100644 --- a/test/api/v3/integration/qrcodes/GET-qrcodes_user.test.js +++ b/test/api/v3/integration/qrcodes/GET-qrcodes_user.test.js @@ -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'; diff --git a/test/api/v3/integration/quests/POST-groups_groupId_quests_accept.test.js b/test/api/v3/integration/quests/POST-groups_groupId_quests_accept.test.js index 1a9f8ef5dd..ceae749907 100644 --- a/test/api/v3/integration/quests/POST-groups_groupId_quests_accept.test.js +++ b/test/api/v3/integration/quests/POST-groups_groupId_quests_accept.test.js @@ -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', () => { diff --git a/test/api/v3/integration/quests/POST-groups_groupId_quests_force-start.test.js b/test/api/v3/integration/quests/POST-groups_groupId_quests_force-start.test.js index d67d08b161..f8ac9bb5ad 100644 --- a/test/api/v3/integration/quests/POST-groups_groupId_quests_force-start.test.js +++ b/test/api/v3/integration/quests/POST-groups_groupId_quests_force-start.test.js @@ -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', () => { diff --git a/test/api/v3/integration/quests/POST-groups_groupId_quests_invite.test.js b/test/api/v3/integration/quests/POST-groups_groupId_quests_invite.test.js index 011039f675..f614969330 100644 --- a/test/api/v3/integration/quests/POST-groups_groupId_quests_invite.test.js +++ b/test/api/v3/integration/quests/POST-groups_groupId_quests_invite.test.js @@ -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'; diff --git a/test/api/v3/integration/quests/POST-groups_groupid_quests_abort.test.js b/test/api/v3/integration/quests/POST-groups_groupid_quests_abort.test.js index d90e4c7b0a..834be404b6 100644 --- a/test/api/v3/integration/quests/POST-groups_groupid_quests_abort.test.js +++ b/test/api/v3/integration/quests/POST-groups_groupid_quests_abort.test.js @@ -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'; diff --git a/test/api/v3/integration/quests/POST-groups_groupid_quests_cancel.test.js b/test/api/v3/integration/quests/POST-groups_groupid_quests_cancel.test.js index 3a5afe4254..40e7d1a498 100644 --- a/test/api/v3/integration/quests/POST-groups_groupid_quests_cancel.test.js +++ b/test/api/v3/integration/quests/POST-groups_groupid_quests_cancel.test.js @@ -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', () => { diff --git a/test/api/v3/integration/quests/POST-groups_groupid_quests_leave.test.js b/test/api/v3/integration/quests/POST-groups_groupid_quests_leave.test.js index 8a2870681d..9475af23c5 100644 --- a/test/api/v3/integration/quests/POST-groups_groupid_quests_leave.test.js +++ b/test/api/v3/integration/quests/POST-groups_groupid_quests_leave.test.js @@ -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', () => { diff --git a/test/api/v3/integration/quests/POST-groups_groupid_quests_reject.test.js b/test/api/v3/integration/quests/POST-groups_groupid_quests_reject.test.js index c02fa79c51..0975db52ef 100644 --- a/test/api/v3/integration/quests/POST-groups_groupid_quests_reject.test.js +++ b/test/api/v3/integration/quests/POST-groups_groupid_quests_reject.test.js @@ -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'; diff --git a/test/api/v3/integration/status/GET-status.test.js b/test/api/v3/integration/status/GET-status.test.js index 1d4d33a7d7..38fbcb69dd 100644 --- a/test/api/v3/integration/status/GET-status.test.js +++ b/test/api/v3/integration/status/GET-status.test.js @@ -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 () => { diff --git a/test/api/v3/integration/tasks/POST-tasks_user.test.js b/test/api/v3/integration/tasks/POST-tasks_user.test.js index 29469f78df..22297da8ff 100644 --- a/test/api/v3/integration/tasks/POST-tasks_user.test.js +++ b/test/api/v3/integration/tasks/POST-tasks_user.test.js @@ -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', () => { diff --git a/test/api/v3/integration/tasks/challenges/POST-tasks_challenge_id.test.js b/test/api/v3/integration/tasks/challenges/POST-tasks_challenge_id.test.js index afe68c28bb..c28fe15a6f 100644 --- a/test/api/v3/integration/tasks/challenges/POST-tasks_challenge_id.test.js +++ b/test/api/v3/integration/tasks/challenges/POST-tasks_challenge_id.test.js @@ -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'; diff --git a/test/api/v3/integration/tasks/groups/POST-tasks_group_id.test.js b/test/api/v3/integration/tasks/groups/POST-tasks_group_id.test.js index 5b38eec50f..b14f32eb91 100644 --- a/test/api/v3/integration/tasks/groups/POST-tasks_group_id.test.js +++ b/test/api/v3/integration/tasks/groups/POST-tasks_group_id.test.js @@ -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', () => { diff --git a/test/api/v3/integration/tasks/groups/POST-tasks_group_id_assign_user_id.test.js b/test/api/v3/integration/tasks/groups/POST-tasks_group_id_assign_user_id.test.js index 22029de3e8..852f94bc86 100644 --- a/test/api/v3/integration/tasks/groups/POST-tasks_group_id_assign_user_id.test.js +++ b/test/api/v3/integration/tasks/groups/POST-tasks_group_id_assign_user_id.test.js @@ -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'; diff --git a/test/api/v3/integration/tasks/groups/POST-tasks_move_taskId_to_position.test.js b/test/api/v3/integration/tasks/groups/POST-tasks_move_taskId_to_position.test.js index 24085cfb58..cefef5c832 100644 --- a/test/api/v3/integration/tasks/groups/POST-tasks_move_taskId_to_position.test.js +++ b/test/api/v3/integration/tasks/groups/POST-tasks_move_taskId_to_position.test.js @@ -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; diff --git a/test/api/v3/integration/tasks/groups/POST-tasks_task_id_unassign.test.js b/test/api/v3/integration/tasks/groups/POST-tasks_task_id_unassign.test.js index 1605819ec6..4c82c2e895 100644 --- a/test/api/v3/integration/tasks/groups/POST-tasks_task_id_unassign.test.js +++ b/test/api/v3/integration/tasks/groups/POST-tasks_task_id_unassign.test.js @@ -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'; diff --git a/test/api/v3/integration/user/auth/PUT-user_update_email.test.js b/test/api/v3/integration/user/auth/PUT-user_update_email.test.js index d61a71c130..c3f306843f 100644 --- a/test/api/v3/integration/user/auth/PUT-user_update_email.test.js +++ b/test/api/v3/integration/user/auth/PUT-user_update_email.test.js @@ -1,7 +1,7 @@ import { generateUser, translate as t, -} from '../../../../../helpers/api-v3-integration.helper'; +} from '../../../../../helpers/api-integration/v3'; import { bcryptCompare, sha1MakeSalt, diff --git a/test/api/v3/integration/user/auth/PUT-user_update_password.test.js b/test/api/v3/integration/user/auth/PUT-user_update_password.test.js index 1cba7feb4f..81d03047b0 100644 --- a/test/api/v3/integration/user/auth/PUT-user_update_password.test.js +++ b/test/api/v3/integration/user/auth/PUT-user_update_password.test.js @@ -1,7 +1,7 @@ import { generateUser, translate as t, -} from '../../../../../helpers/api-v3-integration.helper'; +} from '../../../../../helpers/api-integration/v3'; import { bcryptCompare, sha1MakeSalt, diff --git a/test/api/v3/integration/user/auth/PUT-user_update_username.test.js b/test/api/v3/integration/user/auth/PUT-user_update_username.test.js index 85a9c37395..7fd8df6192 100644 --- a/test/api/v3/integration/user/auth/PUT-user_update_username.test.js +++ b/test/api/v3/integration/user/auth/PUT-user_update_username.test.js @@ -1,7 +1,7 @@ import { generateUser, translate as t, -} from '../../../../../helpers/api-v3-integration.helper'; +} from '../../../../../helpers/api-integration/v3'; import { bcryptCompare, sha1MakeSalt, diff --git a/test/api/v3/integration/world-state/GET-world-state.test.js b/test/api/v3/integration/world-state/GET-world-state.test.js index b2989110b8..4d8e7fbbbd 100644 --- a/test/api/v3/integration/world-state/GET-world-state.test.js +++ b/test/api/v3/integration/world-state/GET-world-state.test.js @@ -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 () => { diff --git a/test/api/v4/inbox/GET-inbox_messages.test.js b/test/api/v4/inbox/GET-inbox_messages.test.js new file mode 100644 index 0000000000..efb2f68ffb --- /dev/null +++ b/test/api/v4/inbox/GET-inbox_messages.test.js @@ -0,0 +1,38 @@ +import { + generateUser, +} from '../../../helpers/api-integration/v4'; + +describe('GET /inbox/messages', () => { + let user; + let otherUser; + + before(async () => { + [user, otherUser] = await Promise.all([generateUser(), generateUser()]); + + await otherUser.post('/members/send-private-message', { + toUserId: user.id, + message: 'first', + }); + await user.post('/members/send-private-message', { + toUserId: otherUser.id, + message: 'second', + }); + await otherUser.post('/members/send-private-message', { + toUserId: user.id, + message: 'third', + }); + + await user.sync(); + }); + + it('returns the user inbox messages as an array of ordered messages (from most to least recent)', async () => { + const messages = await user.get('/inbox/messages'); + + expect(messages.length).to.equal(3); + expect(messages.length).to.equal(Object.keys(user.inbox.messages).length); + + expect(messages[0].text).to.equal('third'); + expect(messages[1].text).to.equal('second'); + expect(messages[2].text).to.equal('first'); + }); +}); \ No newline at end of file diff --git a/test/helpers/api-integration/v3/external-server.js b/test/helpers/api-integration/external-server.js similarity index 100% rename from test/helpers/api-integration/v3/external-server.js rename to test/helpers/api-integration/external-server.js diff --git a/test/helpers/api-integration/requester.js b/test/helpers/api-integration/requester.js index 4e1336ab94..2b18de8bac 100644 --- a/test/helpers/api-integration/requester.js +++ b/test/helpers/api-integration/requester.js @@ -84,7 +84,7 @@ function _parseRes (res) { if (apiVersion === 'v2') { return res.body; - } else if (apiVersion === 'v3') { + } else if (apiVersion === 'v3' || apiVersion === 'v4') { if (res.body.message) { return { data: res.body.data, @@ -104,7 +104,7 @@ function _parseError (err) { code: err.status, text: err.response.body.err, }; - } else if (apiVersion === 'v3') { + } else if (apiVersion === 'v3' || apiVersion === 'v4') { parsedError = { code: err.status, error: err.response.body.error, diff --git a/test/helpers/api-integration/v3/index.js b/test/helpers/api-integration/v3/index.js index fd33cfd032..8ec89f9313 100644 --- a/test/helpers/api-integration/v3/index.js +++ b/test/helpers/api-integration/v3/index.js @@ -4,7 +4,7 @@ import { requester } from '../requester'; requester.setApiVersion('v3'); export { requester }; -import server from './external-server'; +import server from '../external-server'; export { server }; export { translate } from '../../translate'; diff --git a/test/helpers/api-integration/v4/index.js b/test/helpers/api-integration/v4/index.js new file mode 100644 index 0000000000..ff8d48e5ec --- /dev/null +++ b/test/helpers/api-integration/v4/index.js @@ -0,0 +1,13 @@ +/* eslint-disable no-use-before-define */ +// Import requester function, set it up for v4, export it +import { requester } from '../requester'; +requester.setApiVersion('v4'); +export { requester }; + +import server from '../external-server'; +export { server }; + +export { translate } from '../../translate'; +export { checkExistence, getProperty, resetHabiticaDB } from '../../mongo'; +export * from './object-generators'; +export { sleep } from '../../sleep'; diff --git a/test/helpers/api-integration/v4/object-generators.js b/test/helpers/api-integration/v4/object-generators.js new file mode 100644 index 0000000000..4e177ace00 --- /dev/null +++ b/test/helpers/api-integration/v4/object-generators.js @@ -0,0 +1,158 @@ +import { + times, +} from 'lodash'; +import { v4 as generateUUID } from 'uuid'; +import { ApiUser, ApiGroup, ApiChallenge } from '../api-classes'; +import { requester } from '../requester'; +import * as Tasks from '../../../../website/server/models/task'; + +// Creates a new user and returns it +// If you need the user to have specific requirements, +// such as a balance > 0, just pass in the adjustment +// to the update object. If you want to adjust a nested +// parameter, such as the number of wolf eggs the user has, +// , you can do so by passing in the full path as a string: +// { 'items.eggs.Wolf': 10 } +export async function generateUser (update = {}) { + let username = (Date.now() + generateUUID()).substring(0, 20); + let password = 'password'; + let email = `${username}@example.com`; + + let user = await requester().post('/user/auth/local/register', { + username, + email, + password, + confirmPassword: password, + }); + + let apiUser = new ApiUser(user); + + await apiUser.update(update); + + return apiUser; +} + +export async function generateHabit (update = {}) { + let type = 'habit'; + let task = new Tasks[type](update); + await task.save({ validateBeforeSave: false }); + return task; +} + +export async function generateDaily (update = {}) { + let type = 'daily'; + let task = new Tasks[type](update); + await task.save({ validateBeforeSave: false }); + return task; +} + +export async function generateReward (update = {}) { + let type = 'reward'; + let task = new Tasks[type](update); + await task.save({ validateBeforeSave: false }); + return task; +} + +export async function generateTodo (update = {}) { + let type = 'todo'; + let task = new Tasks[type](update); + await task.save({ validateBeforeSave: false }); + return task; +} + +// Generates a new group. Requires a user object, which +// will will become the groups leader. Takes a details argument +// for the initial group creation and an update argument which +// will update the group via the db +export async function generateGroup (leader, details = {}, update = {}) { + details.type = details.type || 'party'; + details.privacy = details.privacy || 'private'; + details.name = details.name || 'test group'; + + let group = await leader.post('/groups', details); + let apiGroup = new ApiGroup(group); + + await apiGroup.update(update); + + return apiGroup; +} + +// This is generate group + the ability to create +// real users to populate it. The settings object +// takes in: +// members: Number - the number of group members to create. Defaults to 0. +// inivtes: Number - the number of users to create and invite to the group. Defaults to 0. +// groupDetails: Object - how to initialize the group +// leaderDetails: Object - defaults for the leader, defaults with a gem balance so the user +// can create the group +// +// Returns an object with +// members: an array of user objects that correspond to the members of the group +// invitees: an array of user objects that correspond to the invitees of the group +// leader: the leader user object +// group: the group object +export async function createAndPopulateGroup (settings = {}) { + let numberOfMembers = settings.members || 0; + let numberOfInvites = settings.invites || 0; + let groupDetails = settings.groupDetails; + let leaderDetails = settings.leaderDetails || { balance: 10 }; + + let groupLeader = await generateUser(leaderDetails); + let group = await generateGroup(groupLeader, groupDetails); + + const groupMembershipTypes = { + party: { 'party._id': group._id}, + guild: { guilds: [group._id] }, + }; + + let members = await Promise.all( + times(numberOfMembers, () => { + return generateUser(groupMembershipTypes[group.type]); + }) + ); + + await group.update({ memberCount: numberOfMembers + 1}); + + let invitees = await Promise.all( + times(numberOfInvites, () => { + return generateUser(); + }) + ); + + let invitationPromises = invitees.map((invitee) => { + return groupLeader.post(`/groups/${group._id}/invite`, { + uuids: [invitee._id], + }); + }); + + await Promise.all(invitationPromises); + + await Promise.all(invitees.map((invitee) => invitee.sync())); + + return { + groupLeader, + group, + members, + invitees, + }; +} + +// Generates a new challenge. Requires an ApiUser object and a +// group-like object (can just be {_id: 'your-group-id'}). The group +// will will become the group that owns the challenge. It takes an +// optional details argument for the initial challenge creation and an +// optional update argument which will update the challenge via the db +export async function generateChallenge (challengeCreator, group, details = {}, update = {}) { + details.group = group._id; + details.name = details.name || 'a challenge'; + details.shortName = details.shortName || 'aChallenge'; + details.prize = details.prize || 0; + details.official = details.official || false; + + let challenge = await challengeCreator.post('/challenges', details); + let apiChallenge = new ApiChallenge(challenge); + + await apiChallenge.update(update); + + return apiChallenge; +} diff --git a/test/helpers/api-v3-integration.helper.js b/test/helpers/api-v3-integration.helper.js deleted file mode 100644 index 4f703efdd6..0000000000 --- a/test/helpers/api-v3-integration.helper.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./api-integration/v3'); diff --git a/website/server/controllers/api-v4/README.md b/website/server/controllers/api-v4/README.md new file mode 100644 index 0000000000..47c4719c26 --- /dev/null +++ b/website/server/controllers/api-v4/README.md @@ -0,0 +1 @@ +See https://github.com/HabitRPG/habitica/pull/10453 \ No newline at end of file diff --git a/website/server/controllers/api-v4/inbox.js b/website/server/controllers/api-v4/inbox.js new file mode 100644 index 0000000000..f2684d9e9b --- /dev/null +++ b/website/server/controllers/api-v4/inbox.js @@ -0,0 +1,29 @@ +import { authWithHeaders } from '../../middlewares/auth'; +import { toArray, orderBy } from 'lodash'; + +let api = {}; + +/* NOTE most inbox routes are either in the user or members controller */ + +/** + * @api {get} /api/v3/inbox/messages Get inbox messages for a user + * @apiPrivate + * @apiName GetInboxMessages + * @apiGroup Inbox + * @apiDescription Get inbox messages for a user + * + * @apiSuccess {Array} data An array of inbox messages + */ +api.getInboxMessages = { + method: 'GET', + url: '/inbox/messages', + middlewares: [authWithHeaders()], + async handler (req, res) { + const messagesObj = res.locals.user.inbox.messages; + const messagesArray = orderBy(toArray(messagesObj), ['timestamp'], ['desc']); + + res.respond(200, messagesArray); + }, +}; + +module.exports = api; diff --git a/website/server/libs/routes.js b/website/server/libs/routes.js index 2583a6e226..5d9864940b 100644 --- a/website/server/libs/routes.js +++ b/website/server/libs/routes.js @@ -9,10 +9,13 @@ import { let _wrapAsyncFn = fn => (...args) => fn(...args).catch(args[2]); let noop = (req, res, next) => next(); -module.exports.readController = function readController (router, controller) { +module.exports.readController = function readController (router, controller, overrides = []) { _.each(controller, (action) => { let {method, url, middlewares = [], handler} = action; + // Allow to specify a list of routes (METHOD + URL) to skip + if (overrides.indexOf(`${method}-${url}`) !== -1) return; + // If an authentication middleware is used run getUserLanguage after it, otherwise before // for cron instead use it only if an authentication middleware is present let authMiddlewareIndex = _.findIndex(middlewares, middleware => { @@ -44,7 +47,7 @@ module.exports.readController = function readController (router, controller) { }); }; -module.exports.walkControllers = function walkControllers (router, filePath) { +module.exports.walkControllers = function walkControllers (router, filePath, overrides) { fs .readdirSync(filePath) .forEach(fileName => { @@ -52,7 +55,7 @@ module.exports.walkControllers = function walkControllers (router, filePath) { walkControllers(router, `${filePath}${fileName}/`); } else if (fileName.match(/\.js$/)) { let controller = require(filePath + fileName); // eslint-disable-line global-require - module.exports.readController(router, controller); + module.exports.readController(router, controller, overrides); } }); }; diff --git a/website/server/middlewares/appRoutes.js b/website/server/middlewares/appRoutes.js new file mode 100644 index 0000000000..f735771cef --- /dev/null +++ b/website/server/middlewares/appRoutes.js @@ -0,0 +1,44 @@ +import express from 'express'; +import expressValidator from 'express-validator'; +import analytics from './analytics'; +import setupBody from './setupBody'; +import routes from '../libs/routes'; +import path from 'path'; + +const API_V3_CONTROLLERS_PATH = path.join(__dirname, '/../controllers/api-v3/'); +const API_V4_CONTROLLERS_PATH = path.join(__dirname, '/../controllers/api-v4/'); +const TOP_LEVEL_CONTROLLERS_PATH = path.join(__dirname, '/../controllers/top-level/'); + +const app = express(); + +// re-set the view options because they are not inherited from the top level app +app.set('view engine', 'pug'); +app.set('views', `${__dirname}/../../views`); + +app.use(expressValidator()); +app.use(analytics); +app.use(setupBody); + +const topLevelRouter = express.Router(); // eslint-disable-line new-cap + +routes.walkControllers(topLevelRouter, TOP_LEVEL_CONTROLLERS_PATH); +app.use('/', topLevelRouter); + +const v3Router = express.Router(); // eslint-disable-line new-cap +routes.walkControllers(v3Router, API_V3_CONTROLLERS_PATH); +app.use('/api/v3', v3Router); + +// API v4 proxies API v3 routes by default. +// It can also disable or override v3 routes + +// A list of v3 routes in the format METHOD-URL to skip +const v4RouterOverrides = [ + // 'GET-/status', Example to override the GET /status api call +]; + +const v4Router = express.Router(); // eslint-disable-line new-cap +routes.walkControllers(v4Router, API_V3_CONTROLLERS_PATH, v4RouterOverrides); +routes.walkControllers(v4Router, API_V4_CONTROLLERS_PATH); +app.use('/api/v4', v4Router); + +module.exports = app; diff --git a/website/server/middlewares/index.js b/website/server/middlewares/index.js index 501a8c3546..9c9318cb65 100644 --- a/website/server/middlewares/index.js +++ b/website/server/middlewares/index.js @@ -21,7 +21,7 @@ import { } from './redirects'; import v1 from './v1'; import v2 from './v2'; -import v3 from './v3'; +import appRoutes from './appRoutes'; import responseHandler from './response'; import { attachTranslateFunction, @@ -89,12 +89,11 @@ module.exports = function attachMiddlewares (app, server) { } app.use('/api/v2', v2); app.use('/api/v1', v1); - app.use(v3); // the main app, also setup top-level routes + app.use(appRoutes); // the main app, also setup top-level routes staticMiddleware(app); app.use(notFoundHandler); // Error handler middleware, define as the last one. - // Used for v3 and v1, v2 will keep using its own error handler app.use(errorHandler); }; diff --git a/website/server/middlewares/v3.js b/website/server/middlewares/v3.js deleted file mode 100644 index 1829c41af4..0000000000 --- a/website/server/middlewares/v3.js +++ /dev/null @@ -1,30 +0,0 @@ -import express from 'express'; -import expressValidator from 'express-validator'; -import analytics from './analytics'; -import setupBody from './setupBody'; -import routes from '../libs/routes'; -import path from 'path'; - -const API_CONTROLLERS_PATH = path.join(__dirname, '/../controllers/api-v3/'); -const TOP_LEVEL_CONTROLLERS_PATH = path.join(__dirname, '/../controllers/top-level/'); - -const v3app = express(); - -// re-set the view options because they are not inherited from the top level app -v3app.set('view engine', 'pug'); -v3app.set('views', `${__dirname}/../../views`); - -v3app.use(expressValidator()); -v3app.use(analytics); -v3app.use(setupBody); - -const topLevelRouter = express.Router(); // eslint-disable-line new-cap - -routes.walkControllers(topLevelRouter, TOP_LEVEL_CONTROLLERS_PATH); -v3app.use('/', topLevelRouter); - -const v3Router = express.Router(); // eslint-disable-line new-cap -routes.walkControllers(v3Router, API_CONTROLLERS_PATH); -v3app.use('/api/v3', v3Router); - -module.exports = v3app;