mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
fix tests failures (#8422)
* fix tests failures * make sure _meta is not public * fix typo * fix typo
This commit is contained in:
parent
4bf4c3a6c2
commit
68f4275c44
8 changed files with 36 additions and 5 deletions
|
|
@ -158,6 +158,10 @@ describe('POST /groups/:groupId/quests/accept', () => {
|
|||
await questingGroup.sync();
|
||||
expect(questingGroup.chat[0].text).to.exist;
|
||||
expect(questingGroup.chat[0]._meta).to.exist;
|
||||
expect(questingGroup.chat[0]._meta).to.have.all.keys(['participatingMembers']);
|
||||
|
||||
let returnedGroup = await leader.get(`/groups/${questingGroup._id}`);
|
||||
expect(returnedGroup.chat[0]._meta).to.be.undefined;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -243,6 +243,10 @@ describe('POST /groups/:groupId/quests/force-start', () => {
|
|||
|
||||
expect(questingGroup.chat[0].text).to.exist;
|
||||
expect(questingGroup.chat[0]._meta).to.exist;
|
||||
expect(questingGroup.chat[0]._meta).to.have.all.keys(['participatingMembers']);
|
||||
|
||||
let returnedGroup = await leader.get(`/groups/${questingGroup._id}`);
|
||||
expect(returnedGroup.chat[0]._meta).to.be.undefined;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -203,6 +203,10 @@ describe('POST /groups/:groupId/quests/invite/:questKey', () => {
|
|||
|
||||
expect(group.chat[0].text).to.exist;
|
||||
expect(group.chat[0]._meta).to.exist;
|
||||
expect(group.chat[0]._meta).to.have.all.keys(['participatingMembers']);
|
||||
|
||||
let returnedGroup = await groupLeader.get(`/groups/${group._id}`);
|
||||
expect(returnedGroup.chat[0]._meta).to.be.undefined;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -86,11 +86,12 @@ describe('POST /groups/:groupId/quests/abort', () => {
|
|||
});
|
||||
|
||||
it('aborts a quest', async () => {
|
||||
sandbox.stub(Group.prototype, 'sendChat');
|
||||
await leader.post(`/groups/${questingGroup._id}/quests/invite/${PET_QUEST}`);
|
||||
await partyMembers[0].post(`/groups/${questingGroup._id}/quests/accept`);
|
||||
await partyMembers[1].post(`/groups/${questingGroup._id}/quests/accept`);
|
||||
|
||||
let stub = sandbox.stub(Group.prototype, 'sendChat');
|
||||
|
||||
let res = await leader.post(`/groups/${questingGroup._id}/quests/abort`);
|
||||
await Promise.all([
|
||||
leader.sync(),
|
||||
|
|
@ -127,6 +128,7 @@ describe('POST /groups/:groupId/quests/abort', () => {
|
|||
});
|
||||
expect(Group.prototype.sendChat).to.be.calledOnce;
|
||||
expect(Group.prototype.sendChat).to.be.calledWithMatch(/aborted the party quest Wail of the Whale.`/);
|
||||
Group.prototype.sendChat.restore();
|
||||
|
||||
stub.restore();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -189,6 +189,10 @@ describe('POST /groups/:groupId/quests/reject', () => {
|
|||
|
||||
expect(questingGroup.chat[0].text).to.exist;
|
||||
expect(questingGroup.chat[0]._meta).to.exist;
|
||||
expect(questingGroup.chat[0]._meta).to.have.all.keys(['participatingMembers']);
|
||||
|
||||
let returnedGroup = await leader.get(`/groups/${questingGroup._id}`);
|
||||
expect(returnedGroup.chat[0]._meta).to.be.undefined;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -170,15 +170,19 @@ describe('Group Model', () => {
|
|||
});
|
||||
|
||||
context('Boss Quests', () => {
|
||||
let sendChatStub;
|
||||
|
||||
beforeEach(async () => {
|
||||
party.quest.key = 'whale';
|
||||
|
||||
await party.startQuest(questLeader);
|
||||
await party.save();
|
||||
|
||||
sandbox.stub(Group.prototype, 'sendChat');
|
||||
sendChatStub = sandbox.stub(Group.prototype, 'sendChat');
|
||||
});
|
||||
|
||||
afterEach(() => sendChatStub.restore());
|
||||
|
||||
it('applies user\'s progress to quest boss hp', async () => {
|
||||
await Group.processQuestProgress(participatingMember, progress);
|
||||
|
||||
|
|
@ -322,15 +326,19 @@ describe('Group Model', () => {
|
|||
});
|
||||
|
||||
context('Collection Quests', () => {
|
||||
let sendChatStub;
|
||||
|
||||
beforeEach(async () => {
|
||||
party.quest.key = 'atom1';
|
||||
|
||||
await party.startQuest(questLeader);
|
||||
await party.save();
|
||||
|
||||
sandbox.stub(Group.prototype, 'sendChat');
|
||||
sendChatStub = sandbox.stub(Group.prototype, 'sendChat');
|
||||
});
|
||||
|
||||
afterEach(() => sendChatStub.restore());
|
||||
|
||||
it('applies user\'s progress to found quest items', async () => {
|
||||
await Group.processQuestProgress(participatingMember, progress);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
.row
|
||||
.sixteen.wide.column
|
||||
.ui.secondary.menu
|
||||
router-link.item(:to="{name: 'inventory'}")
|
||||
router-link.item(:to="{name: 'inventory'}", exact)
|
||||
span(v-once) {{ $t('inventory') }}
|
||||
router-link.item(:to="{name: 'equipment'}")
|
||||
span(v-once) {{ $t('equipment') }}
|
||||
|
|
|
|||
|
|
@ -268,12 +268,14 @@ schema.statics.getGroups = async function getGroups (options = {}) {
|
|||
// When converting to json remove chat messages with more than 1 flag and remove all flags info
|
||||
// unless the user is an admin
|
||||
// Not putting into toJSON because there we can't access user
|
||||
// It also removes the _meta field that can be stored inside a chat message
|
||||
schema.statics.toJSONCleanChat = function groupToJSONCleanChat (group, user) {
|
||||
let toJSON = group.toJSON();
|
||||
|
||||
if (!user.contributor.admin) {
|
||||
_.remove(toJSON.chat, chatMsg => {
|
||||
chatMsg.flags = {};
|
||||
if (chatMsg._meta) chatMsg._meta = undefined;
|
||||
return chatMsg.flagCount >= 2;
|
||||
});
|
||||
}
|
||||
|
|
@ -391,6 +393,9 @@ export function chatDefaults (msg, user) {
|
|||
|
||||
schema.methods.sendChat = function sendChat (message, user, metaData) {
|
||||
let newMessage = chatDefaults(message, user);
|
||||
|
||||
// Optional data stored in the chat message but not returned
|
||||
// to the users that can be stored for debugging purposes
|
||||
if (metaData) {
|
||||
newMessage._meta = metaData;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue