mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Add Bulk Feed via query parameter (#12384)
* Update feed.js New Tests for bulk feeding * Update POST-user_feed_pet_food.test.js Added test for bulk-feeding * Update user.js Added 'query paramter' for bulk feeding * Update pets.json Added "tooMuchFood" for bulk feeding pets * Update feed.js Added query parameter option for bulk feeding pets. * Update feed.js fixing lint (bulk feeding) * Update POST-user_feed_pet_food.test.js adjustments for testing bulk feeding * Update feed.js Bulk feeding amount as integer * Update pets.json added invalidAmount for bulk feeding * Update feed.js Bulk feeding Error handling * Update feed.js Bulk - feed no hardcoded values * Update pets.json Get rid of my german accent.
This commit is contained in:
@@ -41,6 +41,29 @@ describe('POST /user/feed/:pet/:food', () => {
|
||||
expect(user.items.pets['Wolf-Base']).to.equal(7);
|
||||
});
|
||||
|
||||
it('bulk feeding pet with non-preferred food', async () => {
|
||||
await user.update({
|
||||
'items.pets.Wolf-Base': 5,
|
||||
'items.food.Milk': 3,
|
||||
});
|
||||
|
||||
const food = content.food.Milk;
|
||||
const pet = content.petInfo['Wolf-Base'];
|
||||
|
||||
const res = await user.post('/user/feed/Wolf-Base/Milk?amount=2');
|
||||
await user.sync();
|
||||
expect(res).to.eql({
|
||||
data: user.items.pets['Wolf-Base'],
|
||||
message: t('messageDontEnjoyFood', {
|
||||
egg: pet.text(),
|
||||
foodText: food.textThe(),
|
||||
}),
|
||||
});
|
||||
|
||||
expect(user.items.food.Milk).to.eql(1);
|
||||
expect(user.items.pets['Wolf-Base']).to.equal(9);
|
||||
});
|
||||
|
||||
context('sending user activity webhooks', () => {
|
||||
before(async () => {
|
||||
await server.start();
|
||||
@@ -77,5 +100,33 @@ describe('POST /user/feed/:pet/:food', () => {
|
||||
expect(body.pet).to.eql('Wolf-Base');
|
||||
expect(body.message).to.eql(res.message);
|
||||
});
|
||||
|
||||
it('sends user activity webhook (mount raised after full bulk feeding)', async () => {
|
||||
const uuid = generateUUID();
|
||||
|
||||
await user.post('/user/webhook', {
|
||||
url: `http://localhost:${server.port}/webhooks/${uuid}`,
|
||||
type: 'userActivity',
|
||||
enabled: true,
|
||||
options: {
|
||||
mountRaised: true,
|
||||
},
|
||||
});
|
||||
|
||||
await user.update({
|
||||
'items.pets.Wolf-Base': 47,
|
||||
'items.food.Milk': 3,
|
||||
});
|
||||
const res = await user.post('/user/feed/Wolf-Base/Milk?amount=2');
|
||||
|
||||
await sleep();
|
||||
|
||||
const body = server.getWebhookData(uuid);
|
||||
|
||||
expect(user.achievements.allYourBase).to.not.equal(true);
|
||||
expect(body.type).to.eql('mountRaised');
|
||||
expect(body.pet).to.eql('Wolf-Base');
|
||||
expect(body.message).to.eql(res.message);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user