mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
v3: fix tavern during tests
This commit is contained in:
@@ -25,27 +25,50 @@ export async function resetHabiticaDB () {
|
|||||||
mongoose.connection.db.dropDatabase((dbErr) => {
|
mongoose.connection.db.dropDatabase((dbErr) => {
|
||||||
if (dbErr) return reject(dbErr);
|
if (dbErr) return reject(dbErr);
|
||||||
let groups = mongoose.connection.db.collection('groups');
|
let groups = mongoose.connection.db.collection('groups');
|
||||||
|
let users = mongoose.connection.db.collection('users');
|
||||||
|
|
||||||
// For some mysterious reason after a dropDatabase there can still be a group...
|
users.count({_id: '7bde7864-ebc5-4ee2-a4b7-1070d464cdb0'}, (err, count) => {
|
||||||
groups.count({_id: TAVERN_ID}, (err, count) => {
|
|
||||||
if (err) return reject(err);
|
if (err) return reject(err);
|
||||||
if (count > 0) return resolve();
|
if (count > 0) return resolve();
|
||||||
|
|
||||||
|
// create the leader for the tavern
|
||||||
|
users.insertOne({
|
||||||
|
_id: '7bde7864-ebc5-4ee2-a4b7-1070d464cdb0',
|
||||||
|
apiToken: TAVERN_ID,
|
||||||
|
auth: {
|
||||||
|
local: {
|
||||||
|
username: 'username',
|
||||||
|
lowerCaseUsername: 'username',
|
||||||
|
email: 'username@email.com',
|
||||||
|
salt: 'salt',
|
||||||
|
hashed_password: 'hashed_password', // eslint-disable-line camelcase
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, (insertErr) => {
|
||||||
|
if (insertErr) return reject(insertErr);
|
||||||
|
|
||||||
|
// For some mysterious reason after a dropDatabase there can still be a group...
|
||||||
|
groups.count({_id: TAVERN_ID}, (err2, count2) => {
|
||||||
|
if (err2) return reject(err2);
|
||||||
|
if (count2 > 0) return resolve();
|
||||||
|
|
||||||
groups.insertOne({
|
groups.insertOne({
|
||||||
_id: TAVERN_ID,
|
_id: TAVERN_ID,
|
||||||
chat: [],
|
chat: [],
|
||||||
leader: '9',
|
leader: '7bde7864-ebc5-4ee2-a4b7-1070d464cdb0', // Siena Leslie
|
||||||
name: 'HabitRPG',
|
name: 'HabitRPG',
|
||||||
type: 'guild',
|
type: 'guild',
|
||||||
privacy: 'public',
|
privacy: 'public',
|
||||||
}, (insertErr) => {
|
}, (insertErr2) => {
|
||||||
if (insertErr) return reject(insertErr);
|
if (insertErr2) return reject(insertErr2);
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateDocument (collectionName, doc, update) {
|
export async function updateDocument (collectionName, doc, update) {
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ api.joinGroup = {
|
|||||||
let user = res.locals.user;
|
let user = res.locals.user;
|
||||||
let inviter;
|
let inviter;
|
||||||
|
|
||||||
req.checkParams('groupId', res.t('groupIdRequired')).notEmpty().isUUID();
|
req.checkParams('groupId', res.t('groupIdRequired')).notEmpty(); // .isUUID(); can't be used because it would block 'habitrpg' or 'party'
|
||||||
|
|
||||||
let validationErrors = req.validationErrors();
|
let validationErrors = req.validationErrors();
|
||||||
if (validationErrors) throw validationErrors;
|
if (validationErrors) throw validationErrors;
|
||||||
@@ -302,7 +302,7 @@ api.rejectGroupInvite = {
|
|||||||
async handler (req, res) {
|
async handler (req, res) {
|
||||||
let user = res.locals.user;
|
let user = res.locals.user;
|
||||||
|
|
||||||
req.checkParams('groupId', res.t('groupIdRequired')).notEmpty().isUUID();
|
req.checkParams('groupId', res.t('groupIdRequired')).notEmpty(); // .isUUID(); can't be used because it would block 'habitrpg' or 'party'
|
||||||
|
|
||||||
let validationErrors = req.validationErrors();
|
let validationErrors = req.validationErrors();
|
||||||
if (validationErrors) throw validationErrors;
|
if (validationErrors) throw validationErrors;
|
||||||
|
|||||||
Reference in New Issue
Block a user