mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-10-27 11:12:28 +01:00
* Links stay white on hover * Fixed task icon color * Disabled plus button when needed * Fixed difficulty color * Fixed task reward color * Updated create styles * Fixed group plan link * Fixed second group test modal * Added login incentives * Fixed group notification clear * Show baily correctly * Styled armoire notification * Fixed contributor achievement styles * Fixed death * Fixed drop styles * Fixed invited friend modal * Fixed joined challenge achievement style * Fixed joined guild style * Fixed level up styles * Updated low health styles * Fixed bailey styles * Updated quest completed * Added soem conditionals to hide modals * Added rebirth styles * Fixed rebirth enable styles * Fixed streak styles * Fixed testing modals * Fixed ultimate gear achievement * Fixed won challenge * Set user to welcomed if created on mobile * Removed old default tasks * Began adding more options to avatar * Added change class * Inbox to messages * Moved profile to menu * Added user modal for viewing a user and send message * Fixed conversations * Fixed lint * Fixed challenges sending to server * Added challenge progress view * Fixed group sync after pay * Fixed some group accepting features * Fixed initial chat loading * Fixed some exitence errors * Added user names to assigned * Added upgrade link * Began adding new payment flow * Added default tasks * Updated avatar styles * Updated tutorial styles * Rebuilt notifications and styles * Updated upload script * Fixed lint * Added default tasks back to mobile and added updated tests * More test fixes
98 lines
3.7 KiB
JavaScript
98 lines
3.7 KiB
JavaScript
import {
|
|
generateUser,
|
|
generateHabit,
|
|
generateDaily,
|
|
generateReward,
|
|
} from '../../../../helpers/api-integration/v3';
|
|
import common from '../../../../../website/common';
|
|
import { v4 as generateUUID } from 'uuid';
|
|
|
|
describe('GET /user/anonymized', () => {
|
|
let user;
|
|
let endpoint = '/user/anonymized';
|
|
|
|
before(async () => {
|
|
user = await generateUser();
|
|
await user.update({
|
|
newMessages: ['some', 'new', 'messages'],
|
|
'profile.name': 'profile',
|
|
'purchased.plan': 'purchased plan',
|
|
contributor: 'contributor',
|
|
invitations: 'invitations',
|
|
'items.special.nyeReceived': 'some',
|
|
'items.special.valentineReceived': 'some',
|
|
webhooks: [{url: 'https://somurl.com'}],
|
|
'achievements.challenges': 'some',
|
|
'inbox.messages': [{ text: 'some text' }],
|
|
tags: [{ name: 'some name', challenge: 'some challenge' }],
|
|
});
|
|
|
|
await generateHabit({ userId: user._id });
|
|
await generateHabit({ userId: user._id, text: generateUUID() });
|
|
let daily = await generateDaily({ userId: user._id, checklist: [{ completed: false, text: 'this-text' }] });
|
|
expect(daily.checklist[0].text.substr(0, 5)).to.not.eql('item ');
|
|
await generateReward({ userId: user._id, text: 'some text 4' });
|
|
|
|
expect(user.newMessages).to.exist;
|
|
expect(user.profile).to.exist;
|
|
expect(user.purchased.plan).to.exist;
|
|
expect(user.contributor).to.exist;
|
|
expect(user.invitations).to.exist;
|
|
expect(user.items.special.nyeReceived).to.exist;
|
|
expect(user.items.special.valentineReceived).to.exist;
|
|
expect(user.webhooks).to.exist;
|
|
expect(user.achievements.challenges).to.exist;
|
|
expect(user.inbox.messages[0].text).to.exist;
|
|
expect(user.inbox.messages[0].text).to.not.eql('inbox message text');
|
|
expect(user.tags[0].name).to.exist;
|
|
expect(user.tags[0].name).to.not.eql('tag');
|
|
expect(user.tags[0].challenge).to.not.eql('challenge');
|
|
});
|
|
|
|
it('returns the authenticated user', async () => {
|
|
let returnedUser = await user.get(endpoint);
|
|
returnedUser = returnedUser.user;
|
|
expect(returnedUser._id).to.equal(user._id);
|
|
});
|
|
|
|
it('does not return private paths (and apiToken)', async () => {
|
|
let returnedUser = await user.get(endpoint);
|
|
let tasks2 = returnedUser.tasks;
|
|
returnedUser = returnedUser.user;
|
|
expect(returnedUser.auth.local).to.not.exist;
|
|
expect(returnedUser.apiToken).to.not.exist;
|
|
expect(returnedUser.stats.maxHealth).to.eql(common.maxHealth);
|
|
expect(returnedUser.stats.toNextLevel).to.eql(common.tnl(user.stats.lvl));
|
|
expect(returnedUser.stats.maxMP).to.eql(30); // TODO why 30?
|
|
expect(returnedUser.newMessages).to.not.exist;
|
|
expect(returnedUser.profile).to.not.exist;
|
|
expect(returnedUser.purchased.plan).to.not.exist;
|
|
expect(returnedUser.contributor).to.not.exist;
|
|
expect(returnedUser.invitations).to.not.exist;
|
|
expect(returnedUser.items.special.nyeReceived).to.not.exist;
|
|
expect(returnedUser.items.special.valentineReceived).to.not.exist;
|
|
expect(returnedUser.webhooks).to.not.exist;
|
|
expect(returnedUser.achievements.challenges).to.not.exist;
|
|
_.forEach(returnedUser.inbox.messages, (msg) => {
|
|
expect(msg.text).to.eql('inbox message text');
|
|
});
|
|
_.forEach(returnedUser.tags, (tag) => {
|
|
expect(tag.name).to.eql('tag');
|
|
expect(tag.challenge).to.eql('challenge');
|
|
});
|
|
// tasks
|
|
expect(tasks2).to.exist;
|
|
expect(tasks2.length).to.eql(5);
|
|
expect(tasks2[0].checklist).to.exist;
|
|
_.forEach(tasks2, (task) => {
|
|
expect(task.text).to.eql('task text');
|
|
expect(task.notes).to.eql('task notes');
|
|
if (task.checklist) {
|
|
_.forEach(task.checklist, (c) => {
|
|
expect(c.text.substr(0, 5)).to.eql('item ');
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|