From f635f178da0e3a8668053f86677c81fff34e7400 Mon Sep 17 00:00:00 2001 From: SabreCat Date: Wed, 14 Nov 2018 13:07:44 +0000 Subject: [PATCH] fix(tests): correct expects --- .../GET-challenges_challengeId.test.js | 40 +++++++ ...GET-challenges_challengeId_members.test.js | 34 +++++- .../GET-challenges_group_groupid.test.js | 112 ++++++++++++++++++ .../challenges/GET-challenges_user.test.js | 40 +++++++ .../POST-challenges_challengeId_join.test.js | 8 ++ .../PUT-challenges_challengeId.test.js | 8 ++ .../groups/GET-groups_groupId_invites.test.js | 12 +- .../groups/GET-groups_groupId_members.test.js | 16 ++- .../groups/POST-groups_invite.test.js | 4 +- .../members/GET-members_id.test.js | 2 +- 10 files changed, 262 insertions(+), 14 deletions(-) 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 6a9cd684293..6fd12c110b7 100644 --- a/test/api/v3/integration/challenges/GET-challenges_challengeId.test.js +++ b/test/api/v3/integration/challenges/GET-challenges_challengeId.test.js @@ -47,6 +47,14 @@ describe('GET /challenges/:challengeId', () => { _id: groupLeader._id, id: groupLeader._id, profile: {name: groupLeader.profile.name}, + auth: { + local: { + username: groupLeader.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); expect(chal.group).to.eql({ _id: group._id, @@ -105,6 +113,14 @@ describe('GET /challenges/:challengeId', () => { _id: challengeLeader._id, id: challengeLeader._id, profile: {name: challengeLeader.profile.name}, + auth: { + local: { + username: challengeLeader.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); expect(chal.group).to.eql({ _id: group._id, @@ -131,6 +147,14 @@ describe('GET /challenges/:challengeId', () => { _id: challengeLeader._id, id: challengeLeader._id, profile: {name: challengeLeader.profile.name}, + auth: { + local: { + username: challengeLeader.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); }); }); @@ -179,6 +203,14 @@ describe('GET /challenges/:challengeId', () => { _id: challengeLeader._id, id: challengeLeader._id, profile: {name: challengeLeader.profile.name}, + auth: { + local: { + username: challengeLeader.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); expect(chal.group).to.eql({ _id: group._id, @@ -205,6 +237,14 @@ describe('GET /challenges/:challengeId', () => { _id: challengeLeader._id, id: challengeLeader._id, profile: {name: challengeLeader.profile.name}, + auth: { + local: { + username: challengeLeader.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); }); }); 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 2b0e006d387..2cc7aab5a39 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 @@ -60,6 +60,14 @@ describe('GET /challenges/:challengeId/members', () => { _id: groupLeader._id, id: groupLeader._id, profile: {name: groupLeader.profile.name}, + auth: { + local: { + username: groupLeader.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); }); @@ -73,8 +81,16 @@ describe('GET /challenges/:challengeId/members', () => { _id: leader._id, id: leader._id, profile: {name: leader.profile.name}, + auth: { + local: { + username: leader.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); - expect(res[0]).to.have.all.keys(['_id', 'id', 'profile']); + expect(res[0]).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']); expect(res[0].profile).to.have.all.keys(['name']); }); @@ -88,8 +104,16 @@ describe('GET /challenges/:challengeId/members', () => { _id: anotherUser._id, id: anotherUser._id, profile: {name: anotherUser.profile.name}, + auth: { + local: { + username: anotherUser.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); - expect(res[0]).to.have.all.keys(['_id', 'id', 'profile']); + expect(res[0]).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']); expect(res[0].profile).to.have.all.keys(['name']); }); @@ -107,7 +131,7 @@ describe('GET /challenges/:challengeId/members', () => { let res = await user.get(`/challenges/${challenge._id}/members?includeAllMembers=not-true`); expect(res.length).to.equal(30); res.forEach(member => { - expect(member).to.have.all.keys(['_id', 'id', 'profile']); + expect(member).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']); expect(member.profile).to.have.all.keys(['name']); }); }); @@ -126,7 +150,7 @@ describe('GET /challenges/:challengeId/members', () => { let res = await user.get(`/challenges/${challenge._id}/members`); expect(res.length).to.equal(30); res.forEach(member => { - expect(member).to.have.all.keys(['_id', 'id', 'profile']); + expect(member).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']); expect(member.profile).to.have.all.keys(['name']); }); }); @@ -145,7 +169,7 @@ describe('GET /challenges/:challengeId/members', () => { let res = await user.get(`/challenges/${challenge._id}/members?includeAllMembers=true`); expect(res.length).to.equal(32); res.forEach(member => { - expect(member).to.have.all.keys(['_id', 'id', 'profile']); + expect(member).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']); expect(member.profile).to.have.all.keys(['name']); }); }); 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 8ad7b76ed8c..beb3b8a5416 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 @@ -39,6 +39,14 @@ describe('GET challenges/groups/:groupId', () => { _id: publicGuild.leader._id, id: publicGuild.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); expect(foundChallenge2).to.exist; @@ -46,6 +54,14 @@ describe('GET challenges/groups/:groupId', () => { _id: publicGuild.leader._id, id: publicGuild.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); }); @@ -58,6 +74,14 @@ describe('GET challenges/groups/:groupId', () => { _id: publicGuild.leader._id, id: publicGuild.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); expect(foundChallenge2).to.exist; @@ -65,6 +89,14 @@ describe('GET challenges/groups/:groupId', () => { _id: publicGuild.leader._id, id: publicGuild.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); }); @@ -125,6 +157,14 @@ describe('GET challenges/groups/:groupId', () => { _id: privateGuild.leader._id, id: privateGuild.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); expect(foundChallenge2).to.exist; @@ -132,6 +172,14 @@ describe('GET challenges/groups/:groupId', () => { _id: privateGuild.leader._id, id: privateGuild.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); }); }); @@ -235,6 +283,14 @@ describe('GET challenges/groups/:groupId', () => { _id: party.leader._id, id: party.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); expect(foundChallenge2).to.exist; @@ -242,6 +298,14 @@ describe('GET challenges/groups/:groupId', () => { _id: party.leader._id, id: party.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); }); @@ -254,6 +318,14 @@ describe('GET challenges/groups/:groupId', () => { _id: party.leader._id, id: party.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); expect(foundChallenge2).to.exist; @@ -261,6 +333,14 @@ describe('GET challenges/groups/:groupId', () => { _id: party.leader._id, id: party.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); }); }); @@ -288,6 +368,14 @@ describe('GET challenges/groups/:groupId', () => { _id: user._id, id: user._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); expect(foundChallenge2).to.exist; @@ -295,6 +383,14 @@ describe('GET challenges/groups/:groupId', () => { _id: user._id, id: user._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); }); @@ -307,6 +403,14 @@ describe('GET challenges/groups/:groupId', () => { _id: user._id, id: user._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); expect(foundChallenge2).to.exist; @@ -314,6 +418,14 @@ describe('GET challenges/groups/:groupId', () => { _id: user._id, id: user._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); }); }); 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 e1b1c321438..7f3cdbd55c4 100644 --- a/test/api/v3/integration/challenges/GET-challenges_user.test.js +++ b/test/api/v3/integration/challenges/GET-challenges_user.test.js @@ -40,6 +40,14 @@ describe('GET challenges/user', () => { _id: publicGuild.leader._id, id: publicGuild.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); expect(foundChallenge.group).to.eql({ _id: publicGuild._id, @@ -62,6 +70,14 @@ describe('GET challenges/user', () => { _id: publicGuild.leader._id, id: publicGuild.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); expect(foundChallenge1.group).to.eql({ _id: publicGuild._id, @@ -79,6 +95,14 @@ describe('GET challenges/user', () => { _id: publicGuild.leader._id, id: publicGuild.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); expect(foundChallenge2.group).to.eql({ _id: publicGuild._id, @@ -101,6 +125,14 @@ describe('GET challenges/user', () => { _id: publicGuild.leader._id, id: publicGuild.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); expect(foundChallenge1.group).to.eql({ _id: publicGuild._id, @@ -118,6 +150,14 @@ describe('GET challenges/user', () => { _id: publicGuild.leader._id, id: publicGuild.leader._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); expect(foundChallenge2.group).to.eql({ _id: publicGuild._id, 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 1ca9a434c34..188bde9f233 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 @@ -79,6 +79,14 @@ describe('POST /challenges/:challengeId/join', () => { _id: groupLeader._id, id: groupLeader._id, profile: {name: groupLeader.profile.name}, + auth: { + local: { + username: groupLeader.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); expect(res.name).to.equal(challenge.name); }); 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 fc3155c6e0b..88a78697c25 100644 --- a/test/api/v3/integration/challenges/PUT-challenges_challengeId.test.js +++ b/test/api/v3/integration/challenges/PUT-challenges_challengeId.test.js @@ -79,6 +79,14 @@ describe('PUT /challenges/:challengeId', () => { _id: member._id, id: member._id, profile: {name: member.profile.name}, + auth: { + local: { + username: member.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); expect(res.name).to.equal('New Challenge Name'); expect(res.description).to.equal('New challenge description.'); 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 06cbf4974a4..00111d1ba8f 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 @@ -50,6 +50,14 @@ describe('GET /groups/:groupId/invites', () => { _id: invited._id, id: invited._id, profile: {name: invited.profile.name}, + auth: { + local: { + username: invited.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); }); @@ -58,7 +66,7 @@ describe('GET /groups/:groupId/invites', () => { let invited = await generateUser(); await user.post(`/groups/${group._id}/invite`, {uuids: [invited._id]}); let res = await user.get('/groups/party/invites'); - expect(res[0]).to.have.all.keys(['_id', 'id', 'profile']); + expect(res[0]).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']); expect(res[0].profile).to.have.all.keys(['name']); }); @@ -76,7 +84,7 @@ describe('GET /groups/:groupId/invites', () => { let res = await leader.get(`/groups/${group._id}/invites`); expect(res.length).to.equal(30); res.forEach(member => { - expect(member).to.have.all.keys(['_id', 'id', 'profile']); + expect(member).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']); expect(member.profile).to.have.all.keys(['name']); }); }).timeout(10000); 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 cbbe45b5466..71cfb0b4e19 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 @@ -56,13 +56,21 @@ describe('GET /groups/:groupId/members', () => { _id: user._id, id: user._id, profile: {name: user.profile.name}, + auth: { + local: { + username: user.auth.local.username, + } + }, + flags: { + verifiedUsername: true, + }, }); }); it('populates only some fields', async () => { await generateGroup(user, {type: 'party', name: generateUUID()}); let res = await user.get('/groups/party/members'); - expect(res[0]).to.have.all.keys(['_id', 'id', 'profile']); + expect(res[0]).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']); expect(res[0].profile).to.have.all.keys(['name']); }); @@ -74,7 +82,7 @@ describe('GET /groups/:groupId/members', () => { '_id', 'id', 'preferences', 'profile', 'stats', 'achievements', 'party', 'backer', 'contributor', 'auth', 'items', 'inbox', 'loginIncentives', 'flags', ]); - expect(Object.keys(memberRes.auth)).to.eql(['timestamps']); + expect(Object.keys(memberRes.auth)).to.eql(['local', 'timestamps']); expect(Object.keys(memberRes.preferences).sort()).to.eql([ 'size', 'hair', 'skin', 'shirt', 'chair', 'costume', 'sleep', 'background', 'tasks', 'disableClasses', @@ -95,7 +103,7 @@ describe('GET /groups/:groupId/members', () => { '_id', 'id', 'preferences', 'profile', 'stats', 'achievements', 'party', 'backer', 'contributor', 'auth', 'items', 'inbox', 'loginIncentives', 'flags', ]); - expect(Object.keys(memberRes.auth)).to.eql(['timestamps']); + expect(Object.keys(memberRes.auth)).to.eql(['local', 'timestamps']); expect(Object.keys(memberRes.preferences).sort()).to.eql([ 'size', 'hair', 'skin', 'shirt', 'chair', 'costume', 'sleep', 'background', 'tasks', 'disableClasses', @@ -120,7 +128,7 @@ describe('GET /groups/:groupId/members', () => { let res = await user.get('/groups/party/members'); expect(res.length).to.equal(30); res.forEach(member => { - expect(member).to.have.all.keys(['_id', 'id', 'profile']); + expect(member).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']); expect(member.profile).to.have.all.keys(['name']); }); }); 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 ef223de87a2..56f82367521 100644 --- a/test/api/v3/integration/groups/POST-groups_invite.test.js +++ b/test/api/v3/integration/groups/POST-groups_invite.test.js @@ -160,7 +160,7 @@ describe('Post /groups/:groupId/invite', () => { .to.eventually.be.rejected.and.eql({ code: 400, error: 'BadRequest', - message: t('inviteMissingUuid'), + message: t('inviteMustNotBeEmpty'), }); }); @@ -295,7 +295,7 @@ describe('Post /groups/:groupId/invite', () => { .to.eventually.be.rejected.and.eql({ code: 400, error: 'BadRequest', - message: t('inviteMissingEmail'), + message: t('inviteMustNotBeEmpty'), }); }); 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 1dca0284b90..f93ea284989 100644 --- a/test/api/v3/integration/members/GET-members_id.test.js +++ b/test/api/v3/integration/members/GET-members_id.test.js @@ -34,7 +34,7 @@ describe('GET /members/:memberId', () => { '_id', 'id', 'preferences', 'profile', 'stats', 'achievements', 'party', 'backer', 'contributor', 'auth', 'items', 'inbox', 'loginIncentives', 'flags', ]); - expect(Object.keys(memberRes.auth)).to.eql(['timestamps']); + expect(Object.keys(memberRes.auth)).to.eql(['local', 'timestamps']); expect(Object.keys(memberRes.preferences).sort()).to.eql([ 'size', 'hair', 'skin', 'shirt', 'chair', 'costume', 'sleep', 'background', 'tasks', 'disableClasses',