Compare commits

..

291 Commits

Author SHA1 Message Date
Sabe Jones
1a0721c078 3.62.0 2016-12-17 02:17:50 +00:00
Sabe Jones
6b6b548ac5 chore(sprites): compile 2016-12-17 02:16:01 +00:00
Sabe Jones
30f3d786bb feat(event): Winter Wonderland 2016-2017 (#8290) 2016-12-16 17:49:22 -08:00
padm0
07bbba6789 newly designed peppermint panda mount. Original images were incorrect drawings. fixes #7982 (#8286) 2016-12-16 16:53:09 -08:00
padm0
6afb2bd0d4 adjust positioning on mounts fixes #7982 (#8285)
* adjust positioning on mounts fixes #7982

* fixing background on peppermint flying pig
2016-12-16 16:46:37 -08:00
Jaka Kranjc
f1a3bd5001 transferGems: use receiver language translation for PM strings #7722 (#8173)
* transferGems: use receiver language translation for PM strings #7722

* chore(test): DRY up transfer gems test

* chore(test): Allow check for language in translation assertion

* chore(test): Add test that member locales are used in transfer gems msg

* sendMessage: optionally take also the message in sender's language

when present, it is stored in the sender's inbox instead of the version
in the target language.

* transferGems: prepare pm in both languages #7722

* sendMessage: take an object for the second parameter instead

* payments: made two more gift strings translatable

* buyGems: send both translations for gifted gems

* buyGems: send push notifications in target user's locale

* createSubscription: send both translations for gifted subs

* createSubscription: send push notifications in target user's locale

* transferGems: send push notifications in target user's locale

* tests: adjust payment tests for translation changes

* added function doc for sendMessage

* tests: added bilingual test for buyGems
2016-12-15 18:36:54 -06:00
Sabe Jones
3f6a13d209 fix(achievements): don't show unobtainable boss quests 2016-12-16 00:04:46 +00:00
Sabe Jones
3658e41fec fix(jade): eliminate space warning, for real 2016-12-15 21:42:00 +00:00
Sabe Jones
c69d5c7ae6 fix(achievements): don't return undefined 2016-12-15 21:35:21 +00:00
Sabe Jones
747f9e6a99 fix(achievements): show boolean pet cheevos
Also fixes a spacing issue that threw Jade warnings.
2016-12-15 21:03:55 +00:00
Matteo Pagliazzi
7755ab090b chore(i18n): update locales 2016-12-15 21:57:45 +01:00
Travis
9ed17df1e3 Updating group.removeMember api to send an email for rescinded party invite (#8280)
* feature: updating group.removeMember api to send an email to a user when an invite was rescinded or when no message was provided by the performing user.

* Adding validation that the email is being sent to the right user.

* fixing linting error
2016-12-15 20:47:18 +01:00
Sabe Jones
faeb040a83 fix(achievements): show Rebirths count 2016-12-15 17:49:15 +00:00
Sabe Jones
0a1ae1375e fix(achievements): camelcase altPath 2016-12-15 17:43:54 +00:00
Sabe Jones
9756030fa2 3.61.0 2016-12-15 17:35:51 +00:00
Sabe Jones
c66172b74b chore(sprites): compile
and update Bailey date
2016-12-15 16:50:09 +00:00
Sabe Jones
281f6d1806 Holly Potions (#8281)
* feat(content): Wonderland 2016 gear strings

* feat(content): Holly Potions
and string data for Winter Wonderland and December subscriber gear

* fix(event): correct winter availability

* refactor(canBuy): concise return logic

* chore(news): Bailey
2016-12-15 08:36:28 -08:00
Matteo Pagliazzi
237095d109 Notifications: remove timestamps (#8287)
* user notifications: make updatedAt public

* notifications: disable timestamps
2016-12-15 17:33:24 +01:00
Travis
fa788f49fc Preventing users from buying already gifted subscriber items (#7734)
* Adding the unopened mystery items to the call to get not obtained subscriber items. closes #7712

* refactoring according to pr

* Refactoring according to pr. moved time-travelers to it's own file and added new tests.
2016-12-15 10:00:49 -06:00
Kaitlin Hipkin
0817cf96e1 Achievement list renovation & Achievements API (#7904)
* pull apart achievements into different subcategories

* achievs previously hidden to others if unachieved are now always shown

* achievs previously always hidden if unachieved are now always shown

* pull apart ultimate gear achievs

* add achiev wrapper mixin

* add achiev mixin for simple counts

* add achiev mixin for singular/plural achievs

* add simpleAchiev mixin and support attributes

* always hide potentially unearnable achievs if unearned

* contributor achiev now uses string interpolation for readMore link

* transition to basic achiev grid layout

* fix npc achievement img bug introduced in c90f7e2

* move surveys and contributor achievs into special section so it is never empty

* double size of achievs in achievs grid

* achievs in grid are muted if unachieved (includes recompiled sprites)

* fix streak notification strings

* add counts to achievement badges for applicable achieved achievs

* list achievements by api

* fix achievement strings in new api

* unearned achievs now use dedicated (WIP) 'unearned' badge instead of muted versions of the normal badges

* fix & cleanup achievements api

* extract generation of the achievements result to a class

* clean up achievement counter css using existing classes

* simplify exports of new achievementBuilder lib

* remove class logic from achievementBuilder lib

* move achievs to common, add rebirth achiev logic, misc fixes

* replace achievs jade logic with results of api call

* fix linting errors

* achievs lib now returns achievs object subdivided by type (basic/seasonal/special

* add tests for new achievs lib

* fix linting errors

* update controllers and views for updated achievs lib

* add indices to achievements to preserve intended order

* move achiev popovers to left

* rename achievs lib to achievements

* adjust positioning of achieve popovers now that stats and achievs pages
are separate

* fix: achievements api correctly decides whether to append extra string for master and triadBingo achievs

* revert compiled sprites so they don't bog down the PR

* pull out achievs api integration tests

* parameterize ultimate gear achievements' text string

* break out static achievement data from user-specific data

* reorg content.achievements to add achiev data in related chunks

* cleanup, respond to feedback

* improve api documentation

* fix merge issues

* Helped Habit Grow --> Helped Habitica Grow

* achievement popovers are muted if the achiev is unearned

* fix singular achievement labels / achievement popover on click

* update apidoc for achievements (description, param-type, successExample, error-types)

* fix whitespace issues in members.js

* move html to a variable

* updated json example

* fix syntax after merge
2016-12-13 12:48:18 -06:00
Matteo Pagliazzi
97e1d75dce 3.60.0 2016-12-12 22:04:34 +01:00
Matteo Pagliazzi
52bf20c27d upgrade shrinkwrap 2016-12-12 22:01:39 +01:00
Matteo Pagliazzi
5dbaf39aba Node 6 and NPM 4 (#8081)
* upgrade node to version 6

* upgrade npm to v4

* update shrinkwrap

* use npm 4 in travis

* use mongoose 4.6.4

* update shrinkwrap

* fix async test and upgrade mongoose

* fix amazon test

* remove debugging code

* working tests with separate server

* update coupon code

* mupdate mongoose

* nvm: relax node version in .nvmrc
2016-12-12 21:51:53 +01:00
Sabe Jones
66d402c985 3.59.1 2016-12-12 20:33:12 +00:00
Sabe Jones
8048146223 chore(news): Bailey 2016-12-12 20:17:58 +00:00
Matteo Pagliazzi
e2c07e458d client: fix action name 2016-12-12 21:05:51 +01:00
padm0
90a9e8e192 Fixing 112016 mystery set. (#8276) 2016-12-12 09:13:59 -08:00
Keith Holliday
f8039f48a6 Styled merch button to have highlight (#8273) 2016-12-10 22:09:06 -06:00
PowerlinxJetfire
04337f8e83 Fix filter buttons when windows resizes fixes (partially) #7772 (#8258)
* Reloads the quest panel solving issue #7697

* Revert "Reloads the quest panel solving issue #7697"

This reverts commit 0d58fb0fd3.

* fix overlapping filter buttons when windows resizes

This fixes one of the two causes of issue #7772.
https://github.com/HabitRPG/habitica/issues/7772
2016-12-10 22:08:26 -06:00
Keith Holliday
45297f8bf9 Merge pull request #8256 from a2lin/equipment_search
Adds a free-text filter (search) to the equipment page.
2016-12-10 16:28:11 -06:00
Keith Holliday
6f112c29f2 Merge pull request #8268 from Tallestthomas/develop
Show link leading to the Food Preferences Wiki page.
2016-12-10 14:41:17 -06:00
Keith Holliday
4d1edb363c Merge pull request #8243 from 15313-platypi/develop
Quest Panel Reload (Issue #7697)
2016-12-10 14:34:43 -06:00
Alexander Lin
4e303cc592 Clean up code 2016-12-10 02:15:30 -08:00
Travis
798a975185 fix: confirm no user objects reference a group before deleting it when the member count reaches 0 (#8267)
* fix: confirm no user objects reference a group before deleting it when the member count reaches 0

* Updating mongo queries to return promises and use the select statement.
2016-12-09 12:14:25 -08:00
Keith Holliday
eb2b46fc5d Merge pull request #8269 from Hus274/8265
Adding a merchandise link to the marketplace selector
2016-12-09 11:57:36 -08:00
Keith Holliday
29854d3bdb Merge pull request #8271 from Hus274/8266
Adding habitica mugs to the static merchandise page
2016-12-09 11:54:45 -08:00
Sabe Jones
f8751b002c fix(subs): record creation for gifts 2016-12-09 19:52:17 +00:00
Travis
cd545e08d5 Implementing retries on failed user updates when finishing a quest (#8251)
* Implementing retries on failed user updates when finishing a quest. fixes #8035

* Refactoring mongo db retries to use the same as code path as original call and moving retries to count based over time based.

* Adding tests for retry logic and updating retries to happen recursively

* Moving callbacks to promises and other tweaks according to pr.

* Chaging mongoose promise to use .catch() functionality

* If all retries fail, the system will now throw an error instead of returning an error message.
2016-12-09 11:30:17 -08:00
Travis Husman
f69bb4f023 Adding habitica mugs to the static/merch page. fixes #8266 2016-12-09 10:35:00 -08:00
Tom Rasmussen
847081d2b2 Removed extra newlines 2016-12-09 12:01:05 -05:00
Travis Husman
8112d46ea4 Removing line break 2016-12-09 07:32:40 -08:00
Travis Husman
d13bded647 Updating the merchandise link to look like a list item. 2016-12-09 07:31:48 -08:00
Matteo Pagliazzi
1de4ab3612 client: namespaces for actions and getteters 2016-12-08 23:01:59 -08:00
Keith Holliday
f9f22f313f Merge pull request #8261 from b9chris/develop
Fix a bug where 1005-768 the avatars and health bar get covered up.
2016-12-08 18:50:18 -08:00
Sabe Jones
f57eed85a8 3.59.0 2016-12-09 02:42:13 +00:00
Sabe Jones
10dd3318ab fix(subs): append Gift for troubleshooting clarity 2016-12-09 02:35:51 +00:00
tallestthomas
cbef83c14a Removed yarn.lock and added it to the .gitignore 2016-12-08 21:31:14 -05:00
Sabe Jones
59709a8590 chore(sprites): compile
and Bailey
2016-12-09 02:30:39 +00:00
Sabe Jones
f85f2a0c6d Gift Subscriptions Promo (#8270)
* WIP(promo): buy-1-get-1 subs

* WIP(subscriptions): Slack integration

* feat(Slack): notify on sub buy
2016-12-08 18:08:56 -08:00
Travis Husman
605a5a1d5c Adding a merchandise link to the marketplace selector. fixes #8265 2016-12-08 08:19:13 -08:00
tallestthomas
2d5d786c8e Added pet food link to pets.json and jade template (issue #8023) 2016-12-08 11:05:22 -05:00
Travis
5efe5b7b10 updating dragon mount images to all align. fixes #8253 (#8259) 2016-12-08 19:52:12 +10:00
Alexander Lin
3e92bb22fa Refactor, add spec tests for equipment search 2016-12-08 00:08:18 -08:00
Sabe Jones
1249b9d410 feat(content): Dec 2016 pets 2016-12-07 20:57:25 +00:00
Keith Holliday
197aafe092 Updated the button stlyes to make them closer (#8260) 2016-12-07 11:47:24 -08:00
tallestthomas
79829ca128 Added link to pet food wiki (#8023) 2016-12-07 10:30:29 -05:00
Chris Moschini
adaa1d9a3e Fix a bug where 1005-768 the avatars and health bar get covered up. 2016-12-07 08:55:36 -05:00
Matteo Pagliazzi
3e6691dbbb client: test: getters 2016-12-06 18:53:03 -08:00
Matteo Pagliazzi
046761b9aa client: reorganize filters and add tests 2016-12-06 18:27:49 -08:00
Matteo Pagliazzi
0b0466b960 client: reorganize actions 2016-12-06 17:11:40 -08:00
Matteo Pagliazzi
f8d4a2bd6b client: update blue and yellow colors 2016-12-06 14:05:01 -08:00
Matteo Pagliazzi
1af59a3770 client: move files again to fix tests 2016-12-06 13:17:23 -08:00
Matteo Pagliazzi
bbcb13c91b client: reorganize store files 2016-12-06 12:47:47 -08:00
Matteo Pagliazzi
d27dc46c50 chore(i18n): update locales 2016-12-05 16:13:45 -08:00
Alexander Lin
679459b83b Adds free-text filter to equipment page
Closes #8241
2016-12-05 01:06:56 -08:00
Blade Barringer
5a619773d5 chore(i18n): update locales 2016-12-05 01:12:42 -06:00
Marcel Oyuela-Bonzani
ad76ab1315 Triple Equals sign 2016-12-04 13:40:46 -05:00
Marcel Oyuela-Bonzani
15eb8db925 Fix for issue noted. 2016-12-04 04:31:04 -05:00
MathWhiz
a0e92c5605 change stable text (#8247) 2016-12-04 17:37:23 +10:00
Chris
eac3e36c07 changed favicon - fixes #7720 (#8252)
* changed favicon

* Revert "changed favicon"

This reverts commit f28b9eb738.

* Changed Favicon

 fixes #7720
2016-12-04 17:30:35 +10:00
Alys
0b8def555b make default profile name more descriptive (ref dca958f2e2) 2016-12-04 13:43:49 +10:00
Alys
5f5fa5c2eb rename Library of Shared Lists guild to Library of Tasks and Challenges 2016-12-04 12:49:43 +10:00
Sabe Jones
1eac8bbbbe fix(migration): correct comments 2016-12-02 09:48:26 -06:00
Alys
49c7580cd4 3.58.1 2016-12-02 19:41:31 +10:00
Matteo Pagliazzi
dca958f2e2 make sure entire user is loaded when saved 2016-12-02 10:20:54 +01:00
Sabe Jones
eae5f0d605 fix(sprites): staff position 2016-12-02 00:08:44 +00:00
Sabe Jones
6ab091645c 3.58.0 2016-12-01 21:44:23 +00:00
Sabe Jones
d66041c280 chore(sprites): compile 2016-12-01 21:43:46 +00:00
Sabe Jones
de070a450a feat(content): BGs and Armoire 2016-12 2016-12-01 21:22:22 +00:00
Sabe Jones
eaaab35f31 fix(stats): back & body works
Also adds December Take This migration
2016-12-01 18:49:40 +00:00
Travis
6a63f080ad New feature that notifies a user when their group invite is accepted. (#8244)
* New notification feature that notifies a user when their group invite is accepted. fixes #7788

* Updating to a modal instead of a popup notification

* Making a generic modal template and using it for notifications of group invitation acceptance.

* Working with paglias's comments for doing translation server side.

* Final changes based on pr comments.
2016-12-01 19:04:57 +01:00
Myles Louis Dakan
c42f81b629 changed quest images for egg and knight1 (#8245) 2016-12-01 10:58:38 -06:00
Sabe Jones
9a78a7b896 fix(npcs): remove foamy Daniel 2016-12-01 15:44:08 +00:00
Alys
8b70721137 change date for latest Bailey from 11/24 to 11/30 2016-12-01 20:51:36 +10:00
Alys
44ffbd716d make gem cap reset message more accurate for when you're reading it at the start of a month 2016-12-01 20:15:13 +10:00
Sabe Jones
5bfc3a5ff4 3.57.2 2016-11-30 21:07:17 +00:00
Sabe Jones
0ba5df4164 chore(news): Last Chance Bailey 2016-11-30 20:43:55 +00:00
Sabe Jones
52a59c8192 Revert "Display first login incentive reward when bailey is dismissed (#8234)"
This reverts commit ac732b2c85.
2016-11-30 20:42:39 +00:00
Matteo Pagliazzi
c1a860494d chore(i18n): update locales 2016-11-30 14:08:34 +01:00
Keith Holliday
395dafa127 Merge pull request #8242 from TheHollidayInn/login-incentives-remove-multiple-notifications
Login incentives remove multiple notifications
2016-11-29 09:51:34 -06:00
Keith Holliday
bab41647f5 Fixed lint issues 2016-11-29 09:18:07 -06:00
Keith Holliday
8582a67308 Fixed broken tests and style changes 2016-11-29 08:53:36 -06:00
Marcel Oyuela-Bonzani
0d58fb0fd3 Reloads the quest panel solving issue #7697 2016-11-28 22:29:20 -05:00
Keith Holliday
1d2482f8bc Fixed linting issues 2016-11-28 21:24:25 -06:00
Keith Holliday
f4cf906127 Added remove when previous login incentive notifications exist 2016-11-28 21:19:53 -06:00
Sabe Jones
559f9b1825 3.57.1 2016-11-28 21:40:34 +00:00
Sabe Jones
c7039bc9ea fix(incentives): pixel paws, purple background
Also turns off automatic Base Turkey pet award for new users.
2016-11-28 20:57:35 +00:00
Matteo Pagliazzi
f929d36e1a chore(i18n): update locales 2016-11-28 19:43:06 +01:00
Keith Holliday
254d1a3465 Merge pull request #8237 from TheHollidayInn/login-progress-counter-fix
Fixed login counter on the first day
2016-11-26 17:36:01 -06:00
Alys
442aae8a35 fix spelling mistake in Check-In Incentives social media messages (consitent > consistent) 2016-11-27 07:29:47 +10:00
Keith Holliday
bcb0ed0a5c Fixed login counter on the first day 2016-11-26 10:30:09 -06:00
Alys
a48b8f0e34 add whitespace between GP and XP amount and label in quest modals 2016-11-26 18:32:37 +10:00
Alyssa Batula
7eeeda2aae Send a message to the party chat when a quest is aborted, fixes #4879 (#8150)
* Send a message to the party chat when a quest is aborted

* Added test cases for sending a message to party when quest is aborted

* Restore Group.prototype.sendChat after aborted quest test
2016-11-26 17:48:42 +10:00
Sabe Jones
a5ad9c30f0 fix(mobile): temp remove new unlock styles 2016-11-24 06:06:11 +00:00
Keith Holliday
ac732b2c85 Display first login incentive reward when bailey is dismissed (#8234) 2016-11-23 21:44:11 -06:00
Sabe Jones
a56b2d68fb 3.57.0 2016-11-24 02:05:03 +00:00
Sabe Jones
25b0ff38c4 Login Incentives (#8230)
* feat(incentives): login bennies WIP

* feat(content): incentive prize content WIP

* fix(content): placeholders pass tests

* WIP(content): Bard instrument placeholder

* feat(content): Incentives build

* chore(sprites): compile
and fix some strings

* WIP(incentives): quests and backgrounds

* fix(quests): correct buy/launch handling

* [WIP] Incentives rewarding (#8226)

* Added login incentive rewards

* Updated incentive rewards

* Added incentive modal and updated notification structure

* Added analytics to sleeping

* Added login incentives to user analytics

* Fixed unit tests and ensured that prizes are incremented and not replaced

* Updated style of daily login incentive modal

* Added rewards modal

* Added translations

* Added loigin incentive ui elements to profile

* Updated login incentives structure and abstracted to common.content

* Added dynamic display for login incentives on profile

* Added purple potion image

* Updated daily login modal

* Fixed progress calculation

* Added bard gear

* Updated login incentive rewards

* Fixed styles and text

* Added multiple read for notifications

* Fixed lint issues

* Fixed styles and added 50 limit

* Updated quest keys

* Added login incentives reward page

* Fixed tests

* Fixed linting and tests

* Read named notifications route. Add image for backgrounds

* Fixed style issues and added tranlsations to login incentive notification

* Hided abiltiy to purchase incentive backgrounds and added message to detail how to unlock

* Updated awarded message

* Fixed text and updated progress counter to display better

* Fixed purple potion reward text

* Fixed check in backgrouns reward text

* fix(quest): pass tests

* Added display of multiple rewards

* Updated modal styles

* Fixed neagtive 50 issue

* Remvoed total count from daily login incentives modal

* Fixed magic paw display

* fix(awards): give bunnies again

* WIP(incentives): more progress on BG shop

* fix(incentives): actually award backgrounds

* fix(incentives): more BG fixy

* fix(backgrounds): don't gem-buy checkin bgs

* Added dust bunny notification

* fix(incentives): don't redisplay bunny award

* chore(news): Bailey
and different promo sprite
2016-11-23 19:34:09 -06:00
Sabe Jones
dcc06931cc fix(test): disable unreliable XML test 2016-11-23 23:16:16 +00:00
Matteo Pagliazzi
bc3ebbd095 pin mongoose 2016-11-23 21:22:35 +01:00
Matteo Pagliazzi
e5b9581743 update vue 2016-11-23 20:02:35 +01:00
Matteo Pagliazzi
4b9fe49e3a skip randomly failing test 2016-11-23 14:46:23 +01:00
Alys
ab4c8b0a46 delete broken newsArchive translation and link from Whats New page to fix https://github.com/HabitRPG/habitica/pull/8216#issuecomment-262430401 2016-11-23 21:39:14 +10:00
Sabe Jones
f6c26fe869 3.56.0 2016-11-23 02:05:23 +00:00
Sabe Jones
80e9735b28 Turkey Day 2016 (#8231)
* feat(event): Turkey Day 2016

* fix(test): allow for free pet
2016-11-22 20:00:10 -06:00
Matteo Pagliazzi
aa6f188bd9 new client: remove comments 2016-11-22 13:49:35 +01:00
MathWhiz
e8b7660376 Add Costume Info to member modal (#7768)
* Add localization strings

* Change name of Equipment section

* Add costume section to member modal

* Add costume section to member modal

* Add current pet and current mount info

* Reorder Sections and Separate Active Mounts/Pets

* switch ng-show with ng-if

* Add `noActiveMount` to pets.json

* Breaking Stuff

* Add petservices.js to the manifest

* Remove Extra Parenthesis

* Progress towards backgrounds

* Add semicolons

* Add background information

* Add all methods in petServices to userCtrl and memberModalCtrl

* Add avatar settings

* Add semicolons

* Revert "Add avatar settings"

This reverts commit 6e8cca9736.

* Remove active-pet-and-mount

* Remove Content from memberModalCtrl

* Update costumeServices.js

* Make costumeservices.js more readable

* Update costumeServices.js

* Update costumeService logic

* Remove unused strings

* Fix include statements

* move service

* Update pet/mount logic

* fixes

* Fix background logic
2016-11-21 21:19:13 +10:00
Mich Elliott
7d76622410 Remove white backgrounds from mount sprites (#8217)
* Remove white background from single mount sprite

* Remove white background on ~40 mount sprites
2016-11-21 07:48:41 +10:00
MathWhiz
928e5f66c4 Add translation link to news (#8216)
* Add translation link to news

* Add newsArchive string

* Translate news archive link
2016-11-20 14:22:59 +10:00
MathWhiz
6a343535c0 Remove party joined option (#8212)
* Remove party joined option

* Make default sort sort by profile name

* Remove extraneous comment
2016-11-20 14:08:18 +10:00
Alys
f58f6acb44 correct apidoc comments for updating and deleting a tag 2016-11-19 12:37:21 +10:00
Matteo Pagliazzi
64754777ed New Client: working navigation (#8131)
* initial work

* new client: working navigation and tasks showing up

* finish header menu and add avatar component

* fix sprites in new client

* initial header version

* initial styling for top menu

* more progress on the header menu

* almost complete menu and avatar

* correctly apply active class for /social and /help

* fix header colors and simplify css

* switch from Roboto to native fonts

* remove small avatar and add viewport

* fixes

* fix user menu with and progress bars

* fix avatar rendeting

* move bars colors to theme

* add site overrides

* fix tests

* shrinkwrap

* fix sprites path

* another try at fixing the sprites path

* another try at fixing the sprites path
2016-11-18 19:20:25 +01:00
Sabe Jones
3b5e4b6d84 3.55.0 2016-11-17 22:26:26 +00:00
Sabe Jones
9383578cb8 chore(news): Bailey 2016-11-17 21:29:26 +00:00
Sabe Jones
474672ec64 Merge pull request #8225 from HabitRPG/sabrecat/hairstyles
New Hairstyles
2016-11-17 15:20:55 -06:00
Keith Holliday
25c6691793 Added party sync and request sync events (#8223)
* Added party sync and request sync events

* Changed party member sync to be handled locally

* Optimized assignment to only use member variables

* Removed party sync event
2016-11-17 20:10:33 +01:00
Keith Holliday
3ea7b72024 Passed language param to text functions (#8220) 2016-11-17 19:32:07 +01:00
Sabe Jones
2d6f05a9a4 fix(hairstyles): base layer above bangs 2016-11-17 17:49:35 +00:00
Sabe Jones
28637286d6 fix(sprites): remove base outlines 2016-11-17 17:49:35 +00:00
Sabe Jones
874887b790 fix(hair): exclusivity and canvas tweaks 2016-11-17 17:49:34 +00:00
Sabe Jones
c977e5ebb5 fix(sprites): adjust Y position 2016-11-17 17:49:34 +00:00
Sabe Jones
f040e668f3 chore(sprites): add 2016-11-17 17:49:34 +00:00
Sabe Jones
55a15f938c feat(customize): new hairstyles 2016-11-17 17:45:31 +00:00
shalott
8c4f35daf4 Fixing test failure
This test seems to occasionally start failing (another coder reported the same thing happening to them in the blacksmiths’ guild) because the order in which the tasks are created can sometimes not match the order in the array. So I have sorted the tasks array after creation by the task name to ensure a consistent ordering, and slightly reordered the expect statements to match.
2016-11-16 21:52:23 +01:00
Matteo Pagliazzi
8f38ce3424 do not give _id to purchased.plan 2016-11-16 21:44:47 +01:00
Arashi007
b8f57a74d0 Added Airu's Theme (#8204)
* Airu's Theme
* Delete Minus_Habit.ogg
* Delete Minus_Habit.mp3
* Add files via upload
2016-11-16 20:11:22 +10:00
Sabe Jones
7ed26c0dbe 3.54.0 2016-11-16 02:12:33 +00:00
Sabe Jones
e8f5b26d4d chore(sprites): compile
and Bailey
2016-11-16 02:04:10 +00:00
Sabe Jones
0273648b6b Merge pull request #8221 from HabitRPG/sabrecat/pets-201611
Ferret Pet
2016-11-15 19:48:33 -06:00
Sabe Jones
b6fdac8885 feat(quest): Ferret Pet 2016-11-15 22:14:12 +00:00
Sabe Jones
00e6389672 3.53.5 2016-11-15 04:21:46 +00:00
Blade Barringer
e02c669b61 Move hr to prevent UserID comment from showing (#8214) 2016-11-14 21:59:31 -06:00
Blade Barringer
f0cb7c6bf3 Comment out group task fetching 2016-11-14 21:42:23 -06:00
Sabe Jones
571ef0b309 fix(news): add date 2016-11-15 03:34:50 +00:00
Blade Barringer
74328d1bcc chore(i18n): update locales 2016-11-14 21:33:01 -06:00
Sabe Jones
d34a9d828c Removed task get approvals request (#8218) 2016-11-14 21:09:36 -06:00
Keith Holliday
2fd35b3a40 Removed task get approvals request 2016-11-14 21:05:54 -06:00
Sabe Jones
e27512f626 3.53.4 2016-11-15 00:46:15 +00:00
Sabe Jones
dbf9cb3b4e chore(news): misc Bailey 2016-11-15 00:27:40 +00:00
AccioBooks
34c1245519 Move hr to prevent UserID comment from showing 2016-11-14 10:58:03 -06:00
Keith Holliday
f602bfe438 Removed group subscription options (#8211) 2016-11-13 20:24:59 +01:00
Alys
9aa4b8aa64 add 'month' to gift subscription message - fixes https://github.com/HabitRPG/habitica/issues/7747
I haven't pluralised this by using "month(s)", because the phrase "a 3 month subscription" is acceptable in English. Translators may use pluralisation as desired, although note that the same wording will be used for 1 month subscriptions.
2016-11-13 20:40:01 +10:00
Alys
5a150ebc5b change '/group/' to '/groups/' in docs for /api/v3/challenges/groups/:groupId 2016-11-13 17:43:52 +10:00
Keith Holliday
cbe1892b50 Added note sync when user adds task to challenge, tests, and fixed challenge tests (#8200) 2016-11-12 23:48:22 +01:00
Keith Holliday
13df60e0dd Group approval ui (#8184)
* Added all ui components back

* Added group ui items back and initial group approval directive

* Added ability to mark tasks as requires approval. Added approvals ctrl. Added get approvals method to tasks service

* Added approval list view with approving functionality

* Added error to produce message when task requests approval

* Added notification display for group approvals

* Fixed notification read and adding task

* Fixed syncing with group approval required

* Added group id to notifications for redirect on client side

* Fixed approval request tests

* Fixed linting issues

* Removed expectation from beforeEach

* Moved string to locale

* Added eslint ignore

* Updated notification for group approved, added new icons, and updated styles

* Hid group plan ui
2016-11-12 23:47:45 +01:00
Blade Barringer
3ff7692528 chore(i18n): update locales 2016-11-11 08:08:46 -06:00
Sabe Jones
111bba84dc feat(content): 2016-11 pet quest strings 2016-11-10 23:12:42 +00:00
Keith Holliday
b0d2b72b88 Updated buy special item to use function call wrapper (#8203) 2016-11-10 21:36:49 +01:00
Sabe Jones
696317ea8a fix(quests): Basilist error with no party 2016-11-07 15:30:44 +00:00
Sabe Jones
593178a46a fix(sprites): copy corrected Ian to prod path
fixes #7867 (again)
2016-11-07 15:20:04 +00:00
MathWhiz
f8fe16482d Unsubscribe documentation
closes #8187
2016-11-06 21:41:12 -06:00
Romeeka Gayhart
5108480ec5 Get skipped/pending unit tests working for revive (#8193) 2016-11-06 21:17:52 -06:00
Sabe Jones
95968b1b1c 3.53.3 2016-11-06 22:05:28 +00:00
Sabe Jones
566569af98 fix(event): end Fall Fest f'real 2016-11-06 21:36:52 +00:00
Alys
6693e9fca9 replace candy food with normal food and enhance canBuy / canDrop code (#8194)
* change food to normal; add variables to choose type of food; add canBuy, canDrop to cake

* reinstate ability to control canBuy and canDrop separately
2016-11-06 15:33:19 -06:00
Romeeka Gayhart
431bde56d2 Convert test UUID to string to avoid test error (#8195) 2016-11-05 23:53:11 -04:00
Sabe Jones
7cf17c0e63 3.53.2 2016-11-04 21:15:10 +00:00
Sabe Jones
49561bfc8c fix(test): accommodate changing seasons 2016-11-04 20:38:29 +00:00
Sabe Jones
8cbbb58e78 chore(event): end Fall Fest 2016-11-04 20:20:53 +00:00
Sabe Jones
905549e379 3.53.1 2016-11-04 19:23:55 +00:00
Sabe Jones
5d45c7209a chore(news): blog Bailey 2016-11-04 19:02:29 +00:00
Rick Kasten
371cddfe17 Updated bossColl1, bossColl1Broken (#8148) 2016-11-04 19:38:12 +10:00
AccioBooks
fcfac30caa Api doc status (#8165)
* Add example

* Update example
2016-11-03 08:31:30 -05:00
Corinna Jaschek
b094fb1e52 added message for challenges that could not be found - fixes #5538
closes #8176
2016-11-03 07:52:43 -05:00
Keith Holliday
a2dd82b6db Hid nav bar (#8181) 2016-11-02 21:58:17 -05:00
Sabe Jones
e6071610e4 fix(migration): revert bogus connect info 2016-11-03 00:29:57 +00:00
Sabe Jones
bdd0e2bb79 3.53.0 2016-11-03 00:12:32 +00:00
Sabe Jones
054a9a6f2b chore(sprites): compile 2016-11-02 23:29:12 +00:00
Sabe Jones
35b9ed6273 backgrounds and Armoire 2016-11 (#8178)
* feat(content): backgrounds and Armoire 2016-11

* chore(event): November Take This migration

* chore(news): Bailey
2016-11-02 18:27:32 -05:00
Keith Holliday
e65277baa5 Added check to ensure config is defined (#8180) 2016-11-02 18:27:22 -05:00
Amanda Furrow
421bd8624c Add flagger language to flag message sent to slack
closes #8179
fixes #8140
2016-11-02 17:28:44 -05:00
Blade Barringer
4562c6422a chore(i18n): update locales 2016-11-02 17:20:46 -05:00
Matteo Pagliazzi
a5cd9f2473 Merge branch 'TheHollidayInn-group-tasks-approval2' into develop 2016-11-01 21:55:32 +01:00
Matteo Pagliazzi
18bbdfa84b Merge branch 'group-tasks-approval' of https://github.com/TheHollidayInn/habitrpg into TheHollidayInn-group-tasks-approval2 2016-11-01 21:55:18 +01:00
Keith Holliday
d8c37f6e2d Group plan subscription (#8153)
* Added payment to groups and pay with group plan with Stripe

* Added edit card for Stripe

* Added stripe cancel

* Added subscribe with Amazon payments

* Added Amazon cancel for group subscription

* Added group subscription with paypal

* Added paypal cancel

* Added ipn cancel for Group plan

* Added a subscription tab and hid only the task tab when group is not subscribed

* Fixed linting issues

* Fixed tests

* Added payment unit tests

* Added back refresh after stripe payment

* Fixed style issues

* Limited grouop query fields and checked access

* Abstracted subscription schema

* Added year group plan and more access checks

* Maded purchase fields private

* Removed id and timestampes

* Added else checks to ensure user subscription is not altered. Removed active field from group model

* Added toJSONTransform function

* Moved plan active check to other toJson function

* Added check to see if purchaed has been populated

* Added purchase details to private

* Added correct data usage when paying for group sub
2016-11-01 21:51:30 +01:00
Sabe Jones
7f38c61c70 3.52.0 2016-10-31 19:02:24 +00:00
Sabe Jones
1c018cedb1 chore(event): sprites and news 2016-10-31 18:45:39 +00:00
Sabe Jones
80892bd6a8 feat(event): JackOLantern ladder (#8174) 2016-10-31 08:14:06 -05:00
Keith Holliday
6801dae75d Fixed history test 2016-10-30 03:23:01 -05:00
Keith Holliday
59e1de6771 Moved approval to subdoc 2016-10-29 14:19:16 -05:00
Keith Holliday
5b240a1950 Updated notification name and other minor fixes 2016-10-29 14:19:16 -05:00
Keith Holliday
3ec3722038 Moved approval fields to group subdoc 2016-10-29 14:19:16 -05:00
Keith Holliday
d798ebadfe Fixed line endings 2016-10-29 14:19:16 -05:00
Keith Holliday
6cbddef627 Added get approvals route 2016-10-29 14:19:16 -05:00
Keith Holliday
016de411c9 Added notifications 2016-10-29 14:19:16 -05:00
Keith Holliday
2173f53883 Added fields for more approver details 2016-10-29 14:19:15 -05:00
Keith Holliday
f2e5bc52e5 Added requested approval fields and logic 2016-10-29 14:19:15 -05:00
Keith Holliday
393a9290e9 Added approval test and fixed line endings 2016-10-29 14:19:15 -05:00
Keith Holliday
ad5045bc09 Added git score approved task test 2016-10-29 14:19:15 -05:00
Keith Holliday
9b515ebdd1 Added task approve route 2016-10-29 14:19:15 -05:00
Keith Holliday
97bf9ee8e8 Added inital group task approval 2016-10-29 14:19:15 -05:00
Blade Barringer
f5ba636579 chore(i18n): update locales 2016-10-27 22:03:58 -05:00
Sabe Jones
4dd7e49552 3.51.1 2016-10-27 20:44:17 +00:00
Sabe Jones
d2f673ef1e chore(news): Blog Bailey 2016-10-27 19:58:43 +00:00
Sabe Jones
e198dd551a feat(content): strings for BGs/Armoire 2016-11 2016-10-26 20:28:44 +00:00
Travis
0bfc9d9516 fix: allows user to save an alias and checklistCollapsed properties of a challenge task. fixes #7875 (#8170) 2016-10-25 21:47:49 -05:00
Sabe Jones
d4e20ee4aa 3.51.0 2016-10-25 21:56:09 +00:00
Sabe Jones
a751a367fc chore(sprites): compile 2016-10-25 21:55:40 +00:00
Sabe Jones
d323be19c6 Mystery Items 2016/10 (#8169)
* feat(content): mystery items 2016-10

* chore(news): Bailey 2016-10-25
Also ends the Enchanted Armoire A/B test.

* fix(armoire): failing tests from A/B conclusion
2016-10-25 16:16:00 -05:00
AccioBooks
be3f61a94b Remove cookies on clearing browser data (#8135)
* remove cookies

* update cookie removal

* Remove + and add link

* Fix tests

* Add condition

* update strings
2016-10-25 19:53:56 +10:00
Alys
f1bb2db73b fix wrong variable name in Polish questDamage string
The translators have been notified that it needs to be fixed in Transifex before the next migration of strings back to GitHub.
2016-10-23 09:54:18 +10:00
Matteo Pagliazzi
a622344d44 3.50.0 2016-10-22 18:12:09 +02:00
Blade Barringer
e279a3550b chore(travis): start API tests earlier 2016-10-22 08:14:10 -05:00
Blade Barringer
70aab3059c fix(client): bump version of ngInfinitScroll
v1.0.0 could not be found in bower registry
2016-10-22 08:14:09 -05:00
Blade Barringer
c264e37182 chore(travis): pend grunt build task
chore(travis): Move test prep to gulpfile
2016-10-22 08:14:07 -05:00
Blade Barringer
b31bc15493 chore(travis): Add grunt-cli pkg 2016-10-22 08:14:06 -05:00
Blade Barringer
ba19c00617 Setup up non-API tests to not need server and mongo running
chore(travis): Build files before running tests

chore(travis): require server for api tests
2016-10-22 08:14:00 -05:00
Blade Barringer
93aa92de7c chore(travis): Split up build tasks 2016-10-20 22:14:37 -05:00
Blade Barringer
d021680945 chore(travis): Remove grunt and mocha install step 2016-10-20 22:05:21 -05:00
Blade Barringer
f9595af8a5 Re-enable armoire tests 2016-10-20 22:04:24 -05:00
Alyssa Batula
d2756278c3 Only unequip Gen 1 pets/mounts when releasing pets/mounts, fixes #5366 (#8119)
* Only unequip Gen 1 pets/mounts when releasing pets/mounts

* Changed mount declaration to match releasePets

* Check if a pet/mount is a drop type instead of checking for its name in the list of pets

* Changed references to pet and mount to petInfo and mountInfo for consistency with releasePets and releaseMounts

* Test that releasePets, releaseMounts, and releaseBoth do not unequip quest pets

* Fixed test names, and tests verify that a pet/mount is/is not a drop pet/mount on release

* Removed unneeded comments
2016-10-20 22:00:15 -05:00
Blade Barringer
2e2dc179c4 chore: pend armoire test 2016-10-20 19:30:22 -05:00
Alys
acf7b811ab fix wrong variable name in French questTaskDamage string
The translators have been notified that it needs to be fixed in Transifex.
2016-10-21 08:24:36 +10:00
Blade Barringer
d5170251c0 fix: remove unneeded Math.random test 2016-10-20 17:11:28 -05:00
Sabe Jones
c9ba9054e3 chore(npm): shrinkwrap 2016-10-20 03:44:13 +00:00
MathWhiz
d4aac1ee4b Documentation - coupon
closes #8109
2016-10-19 21:31:07 -05:00
Blade Barringer
9615a332a5 fix(client): Allow member hp to be clickable
fixes #8016
closes #8155
2016-10-19 21:01:35 -05:00
Blade Barringer
417455e5ef Merge branch 'snyk-community-snyk-community-patch-1' into develop 2016-10-19 17:42:20 -05:00
Blade Barringer
136502a110 chore: update express 2016-10-19 17:41:58 -05:00
Blade Barringer
425887c1e4 chore(i18n): update locales 2016-10-19 17:40:26 -05:00
Sabe Jones
cfa8a5190f 3.49.0 2016-10-19 19:43:47 +00:00
Sabe Jones
df5be81706 chore(sprites): compile 2016-10-19 19:10:39 +00:00
Sabe Jones
08b3491047 Taskwoods Quest Line (#8156)
* feat(content): Gold Quest 2016-10

* chore(news): Bailey
2016-10-19 14:04:34 -05:00
Snyk Community
e73c3147c1 Fix for the ReDOS vulnerability
habitica is currently affected by the high-severity [ReDOS vulnerability](https://snyk.io/vuln/npm:tough-cookie:20160722). 

Vulnerable module: `tough-cookie`
Introduced through: ` request`

This PR fixes the ReDOS vulnerability by upgrading ` request` to version 2.74.0

Check out the [Snyk test report](https://snyk.io/test/github/HabitRPG/habitica) to review other vulnerabilities that affect this repo. 

[Watch the repo](https://snyk.io/add) to 
* get alerts if newly disclosed vulnerabilities affect this repo in the future. 
* generate pull requests with the fixes you want, or let us do the work: when a newly disclosed vulnerability affects you, we'll submit a fix to you right away. 

Stay secure, 
The Snyk team
2016-10-19 17:50:16 +03:00
Alys
a43254000e change Indulgence Armadillo to Indulgent Armadillo
reference for Habitica admins: https://habitica.slack.com/archives/general/p1476655925000002
2016-10-18 17:39:52 +10:00
Blade Barringer
4e3c984baf chore(i18n): update locales 2016-10-17 17:14:59 -05:00
Sabe Jones
c112e923f1 feat(content): Strings October 2016 2016-10-17 20:32:50 +00:00
Blade Barringer
540353f024 fix(client): Correct broken image on "how it works" page 2016-10-17 07:33:02 -05:00
AccioBooks
2b9b5e369e /static/features TLC (#8021)
* Fix grammatical errors / stylistical changes

* Apps and Extentions

* and

* Sections -> Sectors

* Grammatical / Stylistic Changes

* remove extraneous .row

* add breaks in final marketing para

* revert features.jade

* Move period
2016-10-17 07:32:25 -05:00
Thomas Gamble
cb38475765 delete unread messages when a user leaves a group
closes #7955
closes #7965
2016-10-16 22:01:34 -05:00
Kees Cook
8bb92577b0 quest progress reporting whitespace fixes (#8106)
Notifications of other things (HP, GP, etc) have a regular format of
"+/- NUM THING". For example:

  function gp(val, bonus) {
    _notify(_sign(val) + " " + coins(val - bonus), 'gp');
  }

However, the recent quest collection/damage notifications do not. This
attempts to regularize the reporting by adding in the "missing" space.

Signed-off-by: Kees Cook <kees@outflux.net>
2016-10-16 21:16:42 -05:00
Blade Barringer
fb26cbd26d Merge pull request #8110 from Hus274/7814
Removing links to outdated tutorials
2016-10-16 21:02:29 -05:00
Blade Barringer
a0de5cd8f8 Merge pull request #8139 from bcpletcher/develop
Cleaned up some CSS
2016-10-16 20:59:22 -05:00
Blade Barringer
9fe10b1818 Merge pull request #8143 from dumindux/Issue-8115
changed gemCost to include the amount of gems
2016-10-16 20:58:48 -05:00
Dumindu Karunathilaka
d8dd39422a changed gemCost to include the amount of gems 2016-10-15 18:10:22 +05:30
Benjamin Pletcher
3f9b710773 Cleaned up some CSS 2016-10-13 21:51:55 -04:00
Sabe Jones
8a8bab4be1 chore(npm): update shrinkwrap 2016-10-13 23:30:10 +00:00
Sabe Jones
2a0747ed72 3.48.0 2016-10-13 23:23:34 +00:00
Sabe Jones
a5196e94f6 chore(news): Bailey 2016-10-13 2016-10-13 23:04:32 +00:00
Sabe Jones
009ab26711 Add special spells to Seasonal Shop API (#8138)
* WIP(shops): add spells to Seasonal API

* refactor(shops): remove superfluous if

* feat(shops): handle spell purchasing

* fix(test): proper required fields check
Also corrects a linting error.

* refactor(shops): use constants
2016-10-13 17:53:02 -05:00
Blade Barringer
3fabf3391f chore(docs): Remove uneeded links in data export docs 2016-10-12 22:43:23 -05:00
Blade Barringer
8020990264 chore(i18n): update locales 2016-10-12 20:28:32 -05:00
Blade Barringer
a2cfeafc02 fix(client): ctrl-enter can be used to send chat
fixes #8122
2016-10-12 20:24:48 -05:00
Matteo Pagliazzi
d04a4fb1ed amazon: fix cancelling subscription: use correct path 2016-10-12 19:33:14 +02:00
Matteo Pagliazzi
aeb86db306 3.47.2 2016-10-12 18:45:00 +02:00
Matteo Pagliazzi
49960c0e32 amazon: fix cancelling subscription 2016-10-12 18:44:06 +02:00
Blade Barringer
932cb5cf6a 3.47.1 2016-10-12 08:07:47 -05:00
MathWhiz
74d6e77504 chore(docs): refine dataexport docs
closes #8120
2016-10-12 08:06:54 -05:00
Blade Barringer
8400f1786b Merge pull request #8125 from DrStrangepork/travis-ci
Changed travis-ci URL to https://travis-ci.org/HabitRPG/habitica
2016-10-12 07:37:11 -05:00
Blade Barringer
d7bd5dd9f8 chore(i18n): update locales 2016-10-12 07:36:50 -05:00
Rick Kasten
3288b0de33 Changed travis-ci URL to https://travis-ci.org/HabitRPG/habitica 2016-10-12 04:52:50 -04:00
Phillip Thelen
c025ffbd10 Fix wrong identifier for old android IAP (#8121) 2016-10-12 09:12:58 +02:00
Blade Barringer
afb5b473a3 chore(docs): Add global definitions for param types 2016-10-11 21:35:58 -05:00
Blade Barringer
aeee29f5fa chore(i18n): update locales 2016-10-11 18:04:25 -05:00
Sabe Jones
0cca2a07a2 fix(news): typo 2016-10-11 22:58:10 +00:00
Sabe Jones
55d94c129a 3.47.0 2016-10-11 21:19:41 +00:00
Sabe Jones
358e1aed22 chore(sprites): compile 2016-10-11 21:00:55 +00:00
Sabe Jones
36241f061f chore(news): Bailey 2016-10-11 2016-10-11 20:59:02 +00:00
Matteo Pagliazzi
b6201a3b75 amplitude: only log generic error message 2016-10-11 22:49:54 +02:00
Matteo Pagliazzi
005f74d918 Merge branch 'vIiRuS-iap' into develop 2016-10-11 21:29:52 +02:00
Matteo Pagliazzi
926e188017 fix eslint errors 2016-10-11 21:29:35 +02:00
Matteo Pagliazzi
94da808279 Merge branch 'iap' of https://github.com/vIiRuS/habitrpg into vIiRuS-iap 2016-10-11 21:28:37 +02:00
Phillip Thelen
7568dd52e9 Fix wrong if statements 2016-10-11 20:49:46 +02:00
Phillip Thelen
c6e2b78982 Make requested syntax changes 2016-10-11 20:47:01 +02:00
Matteo Pagliazzi
b6104c3ef3 remove dup dependency 2016-10-11 18:52:50 +02:00
Sabe Jones
56b5c960f0 feat(content): Beetle Pet Quest 2016-10-11 16:40:27 +00:00
Matteo Pagliazzi
528abf77af amazon: directly cancel subscription when already closed by amazon 2016-10-11 15:54:48 +02:00
Blade Barringer
8db6b7c6cb fix(api): Allow x-client to be set in cors middleware (#8117)
* fix(api): Allow x-client to be set in cors middleware

* chore: update cors middlware tests
2016-10-10 17:35:00 -05:00
Sabe Jones
578dee59bd feat(content): pet quest strings 2016-10-10 19:43:24 +00:00
Sabe Jones
d40c923e6e refactor(test): less clunky timestamp conv 2016-10-10 16:02:08 +00:00
Sabe Jones
3c4c64b023 fix(subscriptions): don't reset Gems midmonth 2016-10-10 15:52:33 +00:00
Phillip Thelen
c84d6ba141 fix linter errors 2016-10-10 14:27:51 +02:00
Phillip Thelen
5f3b147d2a refactor IAP handling 2016-10-10 10:07:10 +02:00
Keith Holliday
ff08e8b586 [WIP] Group tasks claim (#8099)
* Added initial group tasks ui

* Changed group compnent directory

* Added group task checklist support

* Added checklist support to ui

* Fixed delete tags route

* Added checklist routes to support new group tasks

* Added assign user tag input

* Added new group members autocomplete directive

* Linked assign ui to api

* Added styles

* Limited tag use

* Fixed line endings

* Updated to new file structure

* Fixed failing task tests

* Updatd with new checklist logic and fixed columns

* Updated add task function

* Added userid check back to tag routes

* Added back routes accidently deleted

* Added locale strings

* Moved common task function to task service

* Removed files from manifest

* Added initial group tasks ui

* Changed group compnent directory

* Added checklist support to ui

* Added assign user tag input

* Added assign user tag input

* Added new group members autocomplete directive

* Added new group members autocomplete directive

* Removed group get tasks until live

* Linked assign ui to api

* Added styles

* Added server code for claiming a task

* ADded group task meta and claim button

* Adjusted styles, added local, and added confirm

* Updated claim with new file structures

* Fixed merge issue

* Removed extra file

* Removed duplicate functions

* Removed extra directive

* Removed dev items
2016-10-09 19:23:34 +02:00
Phillip Thelen
cb2acbfefd add additional IAP price tiers 2016-10-09 15:20:45 +02:00
Travis Husman
b16da35585 chore(cleanup): removing links to outdated tutorials
closes #7814
2016-10-07 17:17:29 -07:00
Sabe Jones
826d7b85d7 Subscriptions Fixes (#8105)
* fix(subscriptions): round up months

* fix(subscriptions): resub improvements
Don't allow negative extraMonths; flatten new Dates to YYYYMMDD

* fix(subscriptions): remove resub Gems exploit
Also standardizes some uses of new Date() to remove potential race condition oddities.

* fix(subscriptions): bump consecutive months...
...even if the user didn't log in then, if subscription has been continuous through that period

* test(subscriptions): cover fix cases
Also refactor: use constant for YYYY-MM format

* refactor(subscriptions): don't stringify moments
2016-10-07 15:08:30 -05:00
Travis
6bcc6a15e2 Hitting enter no longer sends a chat message, instead inserts a new line (#8096)
* changing behavior so hitting enter in a chat box only now inserts a newline instead of submitting the form. closes #8066

* Adding a tooltip message
2016-10-06 21:55:00 -05:00
MathWhiz
b600eceb49 /v3/content documentation
closes #8098
2016-10-06 21:45:37 -05:00
Blade Barringer
b83ef872c9 Merge branch 'JTorr-develop' into develop 2016-10-06 20:54:25 -05:00
Blade Barringer
4ebc2e2175 chore(docs): Adjust invite route docs 2016-10-06 20:54:04 -05:00
Julie Torres
e271e57f63 Improve API Docs for Invite to Group, Iss#8087 2016-10-06 14:23:07 -04:00
2268 changed files with 95444 additions and 35096 deletions

View File

@@ -14,7 +14,7 @@ files:
owner: root
group: users
content: |
$(ls -td /opt/elasticbeanstalk/node-install/node-* | head -1)/bin/npm install -g npm@3
$(ls -td /opt/elasticbeanstalk/node-install/node-* | head -1)/bin/npm install -g npm@4
container_commands:
01_makeBabel:
command: "touch /tmp/.babel.json"

View File

@@ -9,5 +9,6 @@ Fixes put_issue_url_here
[//]: # (Put User ID in here - found in Settings -> API)
----
UUID:

2
.nvmrc
View File

@@ -1 +1 @@
4.3.1
6

View File

@@ -1,17 +1,22 @@
language: node_js
node_js:
- '4.3.1'
- '6'
before_install:
- "npm install -g npm@3"
- "npm install -g gulp"
- "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10"
- "echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list"
- "sudo apt-get update"
- "sudo apt-get install mongodb-org-server"
- npm install -g npm@4
- if [ $REQUIRES_SERVER ]; then sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10; echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list; sudo apt-get update; sudo apt-get install mongodb-org-server; fi
before_script:
- 'npm install -g grunt-cli mocha'
- npm run test:build
- cp config.json.example config.json
- "until nc -z localhost 27017; do echo Waiting for MongoDB; sleep 1; done"
- "export DISPLAY=:99"
- if [ $REQUIRES_SERVER ]; then until nc -z localhost 27017; do echo Waiting for MongoDB; sleep 1; done; export DISPLAY=:99; fi
after_script:
- "./node_modules/.bin/lcov-result-merger 'coverage/**/*.info' | ./node_modules/coveralls/bin/coveralls.js"
- ./node_modules/.bin/lcov-result-merger 'coverage/**/*.info' | ./node_modules/coveralls/bin/coveralls.js
script: npm run $TEST
env:
matrix:
- TEST="lint"
- TEST="test:api-v3" REQUIRES_SERVER=true
- TEST="test:sanity"
- TEST="test:content"
- TEST="test:common"
- TEST="test:karma"
- TEST="client:unit"

View File

@@ -17,7 +17,7 @@ RUN apt-get install -y \
python
# Install NodeJS
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
RUN apt-get install -y nodejs
# Clean up package management
@@ -25,7 +25,7 @@ RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*
# Install global packages
RUN npm install -g npm@3
RUN npm install -g npm@4
RUN npm install -g gulp grunt-cli bower
# Clone Habitica repo and install dependencies

View File

@@ -57,7 +57,7 @@ module.exports = function(grunt) {
files: [
{expand: true, cwd: 'website/client-old/', src: 'favicon.ico', dest: 'website/build/'},
{expand: true, cwd: 'website/client-old/', src: 'favicon_192x192.png', dest: 'website/build/'},
{expand: true, cwd: 'website/assets/sprites/dist/', src: 'spritesmith*.png', dest: 'website/build/'},
{expand: true, cwd: 'website/assets/sprites/dist/', src: 'spritesmith*.png', dest: 'website/build/static/sprites'},
{expand: true, cwd: 'website/assets/sprites/', src: 'backer-only/*.gif', dest: 'website/build/'},
{expand: true, cwd: 'website/assets/sprites/', src: 'npc_ian.gif', dest: 'website/build/'},
{expand: true, cwd: 'website/assets/sprites/', src: 'quest_*.gif', dest: 'website/build/'},
@@ -78,6 +78,7 @@ module.exports = function(grunt) {
'website/build/favicon.ico',
'website/build/favicon_192x192.png',
'website/build/*.png',
'website/build/static/sprites/*.png',
'website/build/*.gif',
'website/build/bower_components/bootstrap/dist/fonts/*'
],
@@ -126,15 +127,7 @@ module.exports = function(grunt) {
// Register tasks.
grunt.registerTask('build:prod', ['loadManifestFiles', 'clean:build', 'uglify', 'stylus', 'cssmin', 'copy:build', 'hashres']);
grunt.registerTask('build:dev', ['cssmin', 'stylus']);
grunt.registerTask('build:test', ['test:prepare:translations', 'build:dev']);
grunt.registerTask('test:prepare:translations', function() {
var i18n = require('./website/server/libs/i18n'),
fs = require('fs');
fs.writeFileSync('test/client-old/spec/mocks/translations.js',
"if(!window.env) window.env = {};\n" +
"window.env.translations = " + JSON.stringify(i18n.translations['en']) + ';');
});
grunt.registerTask('build:test', ['build:dev']);
// Load tasks
grunt.loadNpmTasks('grunt-contrib-uglify');

View File

@@ -1,4 +1,4 @@
Habitica [![Build Status](https://travis-ci.org/HabitRPG/habitrpg.svg?branch=develop)](https://travis-ci.org/HabitRPG/habitrpg) [![Code Climate](https://codeclimate.com/github/HabitRPG/habitrpg.svg)](https://codeclimate.com/github/HabitRPG/habitrpg) [![Coverage Status](https://coveralls.io/repos/HabitRPG/habitrpg/badge.svg?branch=develop)](https://coveralls.io/r/HabitRPG/habitrpg?branch=develop) [![Bountysource](https://api.bountysource.com/badge/tracker?tracker_id=68393)](https://www.bountysource.com/trackers/68393-habitrpg?utm_source=68393&utm_medium=shield&utm_campaign=TRACKER_BADGE)
Habitica [![Build Status](https://travis-ci.org/HabitRPG/habitica.svg?branch=develop)](https://travis-ci.org/HabitRPG/habitica) [![Code Climate](https://codeclimate.com/github/HabitRPG/habitrpg.svg)](https://codeclimate.com/github/HabitRPG/habitrpg) [![Coverage Status](https://coveralls.io/repos/HabitRPG/habitrpg/badge.svg?branch=develop)](https://coveralls.io/r/HabitRPG/habitrpg?branch=develop) [![Bountysource](https://api.bountysource.com/badge/tracker?tracker_id=68393)](https://www.bountysource.com/trackers/68393-habitrpg?utm_source=68393&utm_medium=shield&utm_campaign=TRACKER_BADGE)
===============
[Habitica](https://habitica.com) is an open source habit building program which treats your life like a Role Playing Game. Level up as you succeed, lose HP as you fail, earn money to buy weapons and armor.

View File

@@ -36,7 +36,7 @@
"jquery-ui": "1.10.3",
"jquery.cookie": "1.4.0",
"js-emoji": "snicker/js-emoji#f25d8a303f",
"ngInfiniteScroll": "1.0.0",
"ngInfiniteScroll": "1.1.0",
"pnotify": "1.3.1",
"sticky": "1.0.3",
"swagger-ui": "wordnik/swagger-ui#v2.0.24",

View File

@@ -79,6 +79,7 @@
},
"SLACK": {
"FLAGGING_URL": "https://hooks.slack.com/services/id/id/id",
"FLAGGING_FOOTER_LINK": "https://habitrpg.github.io/flag-o-rama/"
"FLAGGING_FOOTER_LINK": "https://habitrpg.github.io/flag-o-rama/",
"SUBSCRIPTIONS_URL": "https://hooks.slack.com/services/id/id/id"
}
}

View File

@@ -12,6 +12,9 @@ import {each} from 'lodash';
const MAX_SPRITESHEET_SIZE = 1024 * 1024 * 3;
const DIST_PATH = 'website/assets/sprites/dist/';
const IMG_DIST_PATH_NEW_CLIENT = 'website/static/sprites/';
const CSS_DIST_PATH_NEW_CLIENT = 'website/client/assets/css/sprites/';
gulp.task('sprites:compile', ['sprites:clean', 'sprites:main', 'sprites:largeSprites', 'sprites:checkCompiledDimensions']);
gulp.task('sprites:main', () => {
@@ -25,7 +28,7 @@ gulp.task('sprites:largeSprites', () => {
});
gulp.task('sprites:clean', (done) => {
clean(`${DIST_PATH}spritesmith*`, done);
clean(`{${DIST_PATH}spritesmith*,${IMG_DIST_PATH_NEW_CLIENT}spritesmith*,${CSS_DIST_PATH_NEW_CLIENT}spritesmith*}`, done);
});
gulp.task('sprites:checkCompiledDimensions', ['sprites:main', 'sprites:largeSprites'], () => {
@@ -66,14 +69,16 @@ function createSpritesStream (name, src) {
algorithm: 'binary-tree',
padding: 1,
cssTemplate: 'website/assets/sprites/css/css.template.handlebars',
cssVarMap: cssVarMap
cssVarMap: cssVarMap,
}));
let imgStream = spriteData.img
.pipe(imagemin())
.pipe(gulp.dest(IMG_DIST_PATH_NEW_CLIENT))
.pipe(gulp.dest(DIST_PATH));
let cssStream = spriteData.css
.pipe(gulp.dest(CSS_DIST_PATH_NEW_CLIENT))
.pipe(gulp.dest(DIST_PATH));
stream.add(imgStream);
@@ -148,4 +153,9 @@ function cssVarMap (sprite) {
}
if (~sprite.name.indexOf('shirt'))
sprite.custom.px.offset_y = `-${ sprite.y + 30 }px`; // even more for shirts
if (~sprite.name.indexOf('hair_base')) {
let styleArray = sprite.name.split('_').slice(2,3);
if (Number(styleArray[0]) > 14)
sprite.custom.px.offset_y = `-${ sprite.y }px`; // don't crop updos
}
}

View File

@@ -13,6 +13,9 @@ import Bluebird from 'bluebird';
import runSequence from 'run-sequence';
import os from 'os';
import nconf from 'nconf';
import fs from 'fs';
const i18n = require('../website/server/libs/i18n');
// TODO rewrite
@@ -72,10 +75,17 @@ gulp.task('test:prepare:server', ['test:prepare:mongo'], () => {
}
});
gulp.task('test:prepare:build', ['build'], (cb) => {
exec(testBin('grunt build:test'), cb);
gulp.task('test:prepare:translations', (cb) => {
fs.writeFile(
'test/client-old/spec/mocks/translations.js',
`if(!window.env) window.env = {};
window.env.translations = ${JSON.stringify(i18n.translations['en'])};`, cb);
});
gulp.task('test:prepare:build', ['build', 'test:prepare:translations']);
// exec(testBin('grunt build:test'), cb);
gulp.task('test:prepare:webdriver', (cb) => {
exec('npm run test:prepare:webdriver', cb);
});
@@ -270,7 +280,7 @@ gulp.task('test:e2e:safe', ['test:prepare', 'test:prepare:server'], (cb) => {
gulp.task('test:api-v3:unit', (done) => {
let runner = exec(
testBin('mocha test/api/v3/unit --recursive'),
testBin('mocha test/api/v3/unit --recursive --require ./test/helpers/start-server'),
(err, stdout, stderr) => {
if (err) {
process.exit(1);
@@ -288,7 +298,7 @@ gulp.task('test:api-v3:unit:watch', () => {
gulp.task('test:api-v3:integration', (done) => {
let runner = exec(
testBin('mocha test/api/v3/integration --recursive'),
testBin('mocha test/api/v3/integration --recursive --require ./test/helpers/start-server'),
{maxBuffer: 500 * 1024},
(err, stdout, stderr) => {
if (err) {
@@ -308,7 +318,7 @@ gulp.task('test:api-v3:integration:watch', () => {
gulp.task('test:api-v3:integration:separate-server', (done) => {
let runner = exec(
testBin('mocha test/api/v3/integration --recursive', 'LOAD_SERVER=0'),
testBin('mocha test/api/v3/integration --recursive --require ./test/helpers/start-server', 'LOAD_SERVER=0'),
{maxBuffer: 500 * 1024},
(err, stdout, stderr) => done(err)
);

View File

@@ -0,0 +1,86 @@
var migrationName = '20161030-jackolanterns.js';
var authorName = 'Sabe'; // in case script author needs to know when their ...
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
/*
* set the newStuff flag in all user accounts so they see a Bailey message
*/
var mongo = require('mongoskin');
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
var dbUsers = mongo.db(connectionString).collection('users');
// specify a query to limit the affected users (empty for all users):
var query = {
'auth.timestamps.loggedin':{$gt:new Date('2016-10-01')} // remove when running migration a second time
};
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
var fields = {
'migration': 1,
'items.pets.JackOLantern-Base': 1,
'items.mounts.JackOLantern-Base': 1,
};
console.warn('Updating users...');
var progressCount = 1000;
var count = 0;
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
if (err) { return exiting(1, 'ERROR! ' + err); }
if (!user) {
console.warn('All appropriate users found and modified.');
setTimeout(displayData, 300000);
return;
}
count++;
// specify user data to change:
var set = {};
var inc = {};
if (user.migration !== migrationName) {
if (user.items.mounts['JackOLantern-Base']) {
set = {'migration':migrationName, 'items.pets.JackOLantern-Ghost':5};
} else if (user.items.pets['JackOLantern-Base']) {
set = {'migration':migrationName, 'items.mounts.JackOLantern-Base':true};
} else {
set = {'migration':migrationName, 'items.pets.JackOLantern-Base':5};
}
inc = {
'items.food.Candy_Base': 1,
'items.food.Candy_CottonCandyBlue': 1,
'items.food.Candy_CottonCandyPink': 1,
'items.food.Candy_Desert': 1,
'items.food.Candy_Golden': 1,
'items.food.Candy_Red': 1,
'items.food.Candy_Shade': 1,
'items.food.Candy_Skeleton': 1,
'items.food.Candy_White': 1,
'items.food.Candy_Zombie': 1,
}
}
dbUsers.update({_id:user._id}, {$set:set, $inc:inc});
if (count%progressCount == 0) console.warn(count + ' ' + user._id);
if (user._id == authorUuid) console.warn(authorName + ' processed');
});
function displayData() {
console.warn('\n' + count + ' users processed\n');
return exiting(0);
}
function exiting(code, msg) {
code = code || 0; // 0 = success
if (code && !msg) { msg = 'ERROR!'; }
if (msg) {
if (code) { console.error(msg); }
else { console.log( msg); }
}
process.exit(code);
}

View File

@@ -0,0 +1,75 @@
var migrationName = '20161102_takeThis.js';
var authorName = 'Sabe'; // in case script author needs to know when their ...
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
/*
* Award Take This ladder items to participants in this month's challenge
*/
var mongo = require('mongoskin');
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
var dbUsers = mongo.db(connectionString).collection('users');
// specify a query to limit the affected users (empty for all users):
var query = {
'migration':{$ne:migrationName},
'challenges':{$in:['d1be0965-e909-4d30-82fa-9a0011f885b2']}
};
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
var fields = {
'items.gear.owned': 1
};
console.warn('Updating users...');
var progressCount = 1000;
var count = 0;
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
if (err) { return exiting(1, 'ERROR! ' + err); }
if (!user) {
console.warn('All appropriate users found and modified.');
setTimeout(displayData, 300000);
return;
}
count++;
// specify user data to change:
var set = {};
if (typeof user.items.gear.owned.head_special_takeThis !== 'undefined') {
set = {'migration':migrationName, 'items.gear.owned.body_special_takeThis':false};
} else if (typeof user.items.gear.owned.armor_special_takeThis !== 'undefined') {
set = {'migration':migrationName, 'items.gear.owned.head_special_takeThis':false};
} else if (typeof user.items.gear.owned.weapon_special_takeThis !== 'undefined') {
set = {'migration':migrationName, 'items.gear.owned.armor_special_takeThis':false};
} else if (typeof user.items.gear.owned.shield_special_takeThis !== 'undefined') {
set = {'migration':migrationName, 'items.gear.owned.weapon_special_takeThis':false};
} else {
set = {'migration':migrationName, 'items.gear.owned.shield_special_takeThis':false};
}
dbUsers.update({_id:user._id}, {$set:set});
if (count%progressCount == 0) console.warn(count + ' ' + user._id);
if (user._id == authorUuid) console.warn(authorName + ' processed');
});
function displayData() {
console.warn('\n' + count + ' users processed\n');
return exiting(0);
}
function exiting(code, msg) {
code = code || 0; // 0 = success
if (code && !msg) { msg = 'ERROR!'; }
if (msg) {
if (code) { console.error(msg); }
else { console.log( msg); }
}
process.exit(code);
}

View File

@@ -0,0 +1,74 @@
var migrationName = '20161122_turkey_ladder.js';
var authorName = 'Sabe'; // in case script author needs to know when their ...
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
/*
* Yearly Turkey Day award. Turkey pet, Turkey mount, Gilded Turkey pet, Gilded Turkey mount
*/
var mongo = require('mongoskin');
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
var dbUsers = mongo.db(connectionString).collection('users');
// specify a query to limit the affected users (empty for all users):
var query = {
'migration':{$ne:migrationName},
'auth.timestamps.loggedin':{$gt:new Date('2016-10-31')} // Extend timeframe each run of migration
};
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
var fields = {
'migration': 1,
'items.mounts': 1,
'items.pets': 1,
};
console.warn('Updating users...');
var progressCount = 1000;
var count = 0;
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
if (err) { return exiting(1, 'ERROR! ' + err); }
if (!user) {
console.warn('All appropriate users found and modified.');
setTimeout(displayData, 300000);
return;
}
count++;
// specify user data to change:
var set = {};
if (user.items.pets['Turkey-Gilded']) {
set = {'migration':migrationName, 'items.mounts.Turkey-Gilded':true};
} else if (user.items.mounts['Turkey-Base']) {
set = {'migration':migrationName, 'items.pets.Turkey-Gilded':5};
} else if (user.items.pets['Turkey-Base']) {
set = {'migration':migrationName, 'items.mounts.Turkey-Base':true};
} else {
set = {'migration':migrationName, 'items.pets.Turkey-Base':5};
}
dbUsers.update({_id:user._id}, {$set:set});
if (count%progressCount == 0) console.warn(count + ' ' + user._id);
if (user._id == authorUuid) console.warn(authorName + ' processed');
});
function displayData() {
console.warn('\n' + count + ' users processed\n');
return exiting(0);
}
function exiting(code, msg) {
code = code || 0; // 0 = success
if (code && !msg) { msg = 'ERROR!'; }
if (msg) {
if (code) { console.error(msg); }
else { console.log( msg); }
}
process.exit(code);
}

View File

@@ -0,0 +1,78 @@
var migrationName = '20161201_takeThis.js';
var authorName = 'Sabe'; // in case script author needs to know when their ...
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
/*
* Award Take This ladder items to participants in this month's challenge
*/
var mongo = require('mongoskin');
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
var dbUsers = mongo.db(connectionString).collection('users');
// specify a query to limit the affected users (empty for all users):
var query = {
'migration':{$ne:migrationName},
'challenges':{$in:['ff674aba-a114-4a6f-8ebc-1de27ffb646e']}
};
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
var fields = {
'items.gear.owned': 1
};
console.warn('Updating users...');
var progressCount = 1000;
var count = 0;
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
if (err) { return exiting(1, 'ERROR! ' + err); }
if (!user) {
console.warn('All appropriate users found and modified.');
setTimeout(displayData, 300000);
return;
}
count++;
// specify user data to change:
var set = {};
if (typeof user.items.gear.owned.body_special_takeThis !== 'undefined') {
set = {'migration':migrationName, 'items.gear.owned.back_special_takeThis':false};
} else if (typeof user.items.gear.owned.head_special_takeThis !== 'undefined') {
set = {'migration':migrationName, 'items.gear.owned.body_special_takeThis':false};
} else if (typeof user.items.gear.owned.armor_special_takeThis !== 'undefined') {
set = {'migration':migrationName, 'items.gear.owned.head_special_takeThis':false};
} else if (typeof user.items.gear.owned.weapon_special_takeThis !== 'undefined') {
set = {'migration':migrationName, 'items.gear.owned.armor_special_takeThis':false};
} else if (typeof user.items.gear.owned.shield_special_takeThis !== 'undefined') {
set = {'migration':migrationName, 'items.gear.owned.weapon_special_takeThis':false};
} else {
set = {'migration':migrationName, 'items.gear.owned.shield_special_takeThis':false};
}
dbUsers.update({_id:user._id}, {$set:set});
if (count%progressCount == 0) console.warn(count + ' ' + user._id);
if (user._id == authorUuid) console.warn(authorName + ' processed');
});
function displayData() {
console.warn('\n' + count + ' users processed\n');
return exiting(0);
}
function exiting(code, msg) {
code = code || 0; // 0 = success
if (code && !msg) { msg = 'ERROR!'; }
if (msg) {
if (code) { console.error(msg); }
else { console.log( msg); }
}
process.exit(code);
}

View File

@@ -2,7 +2,7 @@ var _id = '';
var update = {
$addToSet: {
'purchased.plan.mysteryItems':{
$each:['head_mystery_201609','armor_mystery_201609']
$each:['head_mystery_201611','weapon_mystery_201611']
}
}
};

View File

@@ -6,14 +6,11 @@ var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
* Remove flag stating that the Enchanted Armoire is empty, for when new equipment is added
*/
var dbserver = 'localhost:27017'; // FOR TEST DATABASE
// var dbserver = 'username:password@ds031379-a0.mongolab.com:31379'; // FOR PRODUCTION DATABASE
var dbname = 'habitrpg';
var mongo = require('mongoskin');
var _ = require('lodash');
var dbUsers = mongo.db(dbserver + '/' + dbname + '?auto_reconnect').collection('users');
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
var dbUsers = mongo.db(connectionString).collection('users');
// specify a query to limit the affected users (empty for all users):
var query = {
@@ -22,7 +19,6 @@ var query = {
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
var fields = {
'flags.armoireEmpty':1
};
console.warn('Updating users...');
@@ -32,7 +28,8 @@ dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
if (err) { return exiting(1, 'ERROR! ' + err); }
if (!user) {
console.warn('All appropriate users found and modified.');
return displayData();
setTimeout(displayData, 300000);
return;
}
count++;

5806
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{
"name": "habitica",
"description": "A habit tracker app which treats your goals like a Role Playing Game.",
"version": "3.46.2",
"version": "3.62.0",
"main": "./website/server/index.js",
"dependencies": {
"@slack/client": "3.6.0",
@@ -15,8 +15,10 @@
"aws-sdk": "^2.0.25",
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-transform-async-to-module-method": "^6.8.0",
"babel-plugin-transform-object-rest-spread": "^6.16.0",
"babel-plugin-transform-regenerator": "^6.16.1",
"babel-polyfill": "^6.6.1",
"babel-preset-es2015": "^6.6.0",
"babel-register": "^6.6.0",
@@ -29,13 +31,13 @@
"compression": "^1.6.1",
"connect-ratelimit": "0.0.7",
"cookie-session": "^1.2.0",
"coupon-code": "^0.4.3",
"coupon-code": "^0.4.5",
"css-loader": "^0.23.1",
"csv-stringify": "^1.0.2",
"cwait": "^1.0.0",
"domain-middleware": "~0.1.0",
"estraverse": "^4.1.1",
"express": "~4.13.3",
"express": "~4.14.0",
"express-csv": "~0.6.0",
"express-validator": "^2.18.0",
"extract-text-webpack-plugin": "^1.0.1",
@@ -64,16 +66,18 @@
"image-size": "~0.3.2",
"in-app-purchase": "^1.1.6",
"jade": "~1.11.0",
"jquery": "https://registry.npmjs.org/jquery/-/jquery-3.1.1.tgz",
"js2xmlparser": "~1.0.0",
"json-loader": "^0.5.4",
"less": "^2.7.1",
"less-loader": "^2.2.3",
"lodash": "^3.10.1",
"lodash.pickby": "^4.2.0",
"lodash.setwith": "^4.2.0",
"merge-stream": "^1.0.0",
"method-override": "^2.3.5",
"moment": "^2.13.0",
"mongoose": "^4.4.16",
"mongoose": "^4.7.1",
"mongoose-id-autoinc": "~2013.7.14-4",
"morgan": "^1.7.0",
"nconf": "~0.8.2",
@@ -89,12 +93,13 @@
"passport-google-oauth20": "1.0.0",
"paypal-ipn": "3.0.0",
"paypal-rest-sdk": "^1.2.1",
"postcss-easy-import": "^1.0.1",
"pretty-data": "^0.40.0",
"ps-tree": "^1.0.0",
"pug": "^2.0.0-beta6",
"push-notify": "habitrpg/push-notify#v1.2.0",
"pusher": "^1.3.0",
"request": "~2.72.0",
"request": "~2.74.0",
"rimraf": "^2.4.3",
"run-sequence": "^1.1.4",
"s3-upload-stream": "^1.0.6",
@@ -110,11 +115,12 @@
"validator": "^4.9.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"vue": "^2.0.0-rc.6",
"vue": "^2.1.0",
"vue-hot-reload-api": "^1.2.0",
"vue-loader": "^9.4.0",
"vue-loader": "^10.0.0",
"vue-resource": "^1.0.2",
"vue-router": "^2.0.0-rc.5",
"vue-template-compiler": "^2.1.0",
"webpack": "^1.12.2",
"webpack-merge": "^0.8.3",
"winston": "^2.1.0",
@@ -122,12 +128,13 @@
},
"private": true,
"engines": {
"node": "^4.3.1",
"npm": "^3.8.9"
"node": "^6.9.1",
"npm": "^4.0.2"
},
"scripts": {
"lint": "eslint --ext .js,.vue .",
"test": "npm run lint && gulp test && npm run client:unit",
"test:build": "gulp test:prepare:build",
"test:api-v3": "gulp test:api-v3",
"test:api-v3:unit": "gulp test:api-v3:unit",
"test:api-v3:integration": "gulp test:api-v3:integration",
@@ -203,7 +210,6 @@
"sinon": "^1.17.2",
"sinon-chai": "^2.8.0",
"superagent-defaults": "^0.1.13",
"vinyl-source-stream": "^1.0.0",
"vinyl-transform": "^1.0.0",
"webpack-dev-middleware": "^1.4.0",
"webpack-hot-middleware": "^2.6.0"

View File

@@ -5,7 +5,7 @@ import {
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
describe('GET challenges/group/:groupId', () => {
describe('GET challenges/groups/:groupId', () => {
context('Public Guild', () => {
let publicGuild, user, nonMember, challenge, challenge2;

View File

@@ -29,14 +29,6 @@ describe('POST /coupons/generate/:event', () => {
});
});
it('returns an error if event is missing', async () => {
await expect(user.post('/coupons/generate')).to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: 'Not found.',
});
});
it('returns an error if event is invalid', async () => {
await expect(user.post('/coupons/generate/notValid?count=1')).to.eventually.be.rejected.and.eql({
code: 400,

View File

@@ -7,15 +7,21 @@ import {
import moment from 'moment';
describe('GET /export/history.csv', () => {
it('should return a valid CSV file with tasks history data', async () => {
// TODO disabled because it randomly causes the build to fail
xit('should return a valid CSV file with tasks history data', async () => {
let user = await generateUser();
let tasks = await user.post('/tasks/user', [
{type: 'habit', text: 'habit 1'},
{type: 'daily', text: 'daily 1'},
{type: 'habit', text: 'habit 1'},
{type: 'habit', text: 'habit 2'},
{type: 'todo', text: 'todo 1'},
]);
// to handle occasional inconsistency in task creation order
tasks.sort(function (a, b) {
return a.text.localeCompare(b.text);
});
// score all the tasks twice
await user.post(`/tasks/${tasks[0]._id}/score/up`);
await user.post(`/tasks/${tasks[1]._id}/score/up`);
@@ -28,7 +34,7 @@ describe('GET /export/history.csv', () => {
await user.post(`/tasks/${tasks[3]._id}/score/up`);
// adding an history entry to daily 1 manually because cron didn't run yet
await updateDocument('tasks', tasks[1], {
await updateDocument('tasks', tasks[0], {
history: [{value: 3.2, date: Number(new Date())}],
});
@@ -41,11 +47,11 @@ describe('GET /export/history.csv', () => {
let splitRes = res.split('\n');
expect(splitRes[0]).to.equal('Task Name,Task ID,Task Type,Date,Value');
expect(splitRes[1]).to.equal(`habit 1,${tasks[0]._id},habit,${moment(tasks[0].history[0].date).format('YYYY-MM-DD HH:mm:ss')},${tasks[0].history[0].value}`);
expect(splitRes[2]).to.equal(`habit 1,${tasks[0]._id},habit,${moment(tasks[0].history[1].date).format('YYYY-MM-DD HH:mm:ss')},${tasks[0].history[1].value}`);
expect(splitRes[3]).to.equal(`habit 2,${tasks[2]._id},habit,${moment(tasks[2].history[0].date).format('YYYY-MM-DD HH:mm:ss')},${tasks[2].history[0].value}`);
expect(splitRes[4]).to.equal(`habit 2,${tasks[2]._id},habit,${moment(tasks[2].history[1].date).format('YYYY-MM-DD HH:mm:ss')},${tasks[2].history[1].value}`);
expect(splitRes[5]).to.equal(`daily 1,${tasks[1]._id},daily,${moment(tasks[1].history[0].date).format('YYYY-MM-DD HH:mm:ss')},${tasks[1].history[0].value}`);
expect(splitRes[1]).to.equal(`daily 1,${tasks[0]._id},daily,${moment(tasks[0].history[0].date).format('YYYY-MM-DD HH:mm:ss')},${tasks[0].history[0].value}`);
expect(splitRes[2]).to.equal(`habit 1,${tasks[1]._id},habit,${moment(tasks[1].history[0].date).format('YYYY-MM-DD HH:mm:ss')},${tasks[1].history[0].value}`);
expect(splitRes[3]).to.equal(`habit 1,${tasks[1]._id},habit,${moment(tasks[1].history[1].date).format('YYYY-MM-DD HH:mm:ss')},${tasks[1].history[1].value}`);
expect(splitRes[4]).to.equal(`habit 2,${tasks[2]._id},habit,${moment(tasks[2].history[0].date).format('YYYY-MM-DD HH:mm:ss')},${tasks[2].history[0].value}`);
expect(splitRes[5]).to.equal(`habit 2,${tasks[2]._id},habit,${moment(tasks[2].history[1].date).format('YYYY-MM-DD HH:mm:ss')},${tasks[2].history[1].value}`);
expect(splitRes[6]).to.equal('');
});
});

View File

@@ -7,7 +7,8 @@ import Bluebird from 'bluebird';
let parseStringAsync = Bluebird.promisify(xml2js.parseString, {context: xml2js});
describe('GET /export/userdata.xml', () => {
it('should return a valid XML file with user data', async () => {
// TODO disabled because it randomly causes the build to fail
xit('should return a valid XML file with user data', async () => {
let user = await generateUser();
let tasks = await user.post('/tasks/user', [
{type: 'habit', text: 'habit 1'},

View File

@@ -134,6 +134,22 @@ describe('POST /group/:groupId/join', () => {
await expect(user.get('/user')).to.eventually.have.deep.property('items.quests.basilist', 1);
});
it('notifies inviting user that their invitation was accepted', async () => {
await invitedUser.post(`/groups/${guild._id}/join`);
let inviter = await user.get('/user');
let expectedData = {
headerText: t('invitationAcceptedHeader'),
bodyText: t('invitationAcceptedBody', {
username: invitedUser.auth.local.username,
groupName: guild.name,
}),
};
expect(inviter.notifications[0].type).to.eql('GROUP_INVITE_ACCEPTED');
expect(inviter.notifications[0].data).to.eql(expectedData);
});
});
});
@@ -172,6 +188,23 @@ describe('POST /group/:groupId/join', () => {
await expect(invitedUser.get('/user')).to.eventually.have.deep.property('party._id', party._id);
});
it('notifies inviting user that their invitation was accepted', async () => {
await invitedUser.post(`/groups/${party._id}/join`);
let inviter = await user.get('/user');
let expectedData = {
headerText: t('invitationAcceptedHeader'),
bodyText: t('invitationAcceptedBody', {
username: invitedUser.auth.local.username,
groupName: party.name,
}),
};
expect(inviter.notifications[0].type).to.eql('GROUP_INVITE_ACCEPTED');
expect(inviter.notifications[0].data).to.eql(expectedData);
});
it('clears invitation from user when joining party', async () => {
await invitedUser.post(`/groups/${party._id}/join`);

View File

@@ -65,6 +65,19 @@ describe('POST /groups/:groupId/leave', () => {
expect(groupToLeave.leader).to.equal(member._id);
});
it('removes new messages for that group from user', async () => {
await member.post(`/groups/${groupToLeave._id}/chat`, { message: 'Some message' });
await leader.sync();
expect(leader.newMessages[groupToLeave._id]).to.not.be.empty;
await leader.post(`/groups/${groupToLeave._id}/leave`);
await leader.sync();
expect(leader.newMessages[groupToLeave._id]).to.be.empty;
});
context('With challenges', () => {
let challenge;
@@ -122,6 +135,8 @@ describe('POST /groups/:groupId/leave', () => {
privateGuild = group;
leader = groupLeader;
invitedUser = invitees[0];
await leader.post(`/groups/${group._id}/chat`, { message: 'Some message' });
});
it('removes a group when the last member leaves', async () => {

View File

@@ -3,6 +3,7 @@ import {
createAndPopulateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
import * as email from '../../../../../website/server/libs/email';
describe('POST /groups/:groupId/removeMember/:memberId', () => {
let leader;
@@ -60,6 +61,14 @@ describe('POST /groups/:groupId/removeMember/:memberId', () => {
});
context('Guilds', () => {
beforeEach(() => {
sandbox.spy(email, 'sendTxn');
});
afterEach(() => {
sandbox.restore();
});
it('can remove other members', async () => {
await leader.post(`/groups/${guild._id}/removeMember/${member._id}`);
let memberRemoved = await member.get('/user');
@@ -80,6 +89,22 @@ describe('POST /groups/:groupId/removeMember/:memberId', () => {
expect(_.findIndex(invitedUserWithoutInvite.invitations.guilds, {id: guild._id})).eql(-1);
});
it('sends email to user with rescinded invite', async () => {
await leader.post(`/groups/${guild._id}/removeMember/${invitedUser._id}`);
expect(email.sendTxn).to.be.calledOnce;
expect(email.sendTxn.args[0][0]._id).to.be.eql(invitedUser._id);
expect(email.sendTxn.args[0][1]).to.be.eql('guild-invite-rescinded');
});
it('sends email to removed user', async () => {
await leader.post(`/groups/${guild._id}/removeMember/${member._id}`);
expect(email.sendTxn).to.be.calledOnce;
expect(email.sendTxn.args[0][0]._id).to.be.eql(member._id);
expect(email.sendTxn.args[0][1]).to.be.eql('kicked-from-guild');
});
});
context('Party', () => {
@@ -87,6 +112,7 @@ describe('POST /groups/:groupId/removeMember/:memberId', () => {
let partyLeader;
let partyInvitedUser;
let partyMember;
let removedMember;
beforeEach(async () => {
let { group, groupLeader, invitees, members } = await createAndPopulateGroup({
@@ -96,13 +122,19 @@ describe('POST /groups/:groupId/removeMember/:memberId', () => {
privacy: 'private',
},
invites: 1,
members: 1,
members: 2,
});
party = group;
partyLeader = groupLeader;
partyInvitedUser = invitees[0];
partyMember = members[0];
removedMember = members[1];
sandbox.spy(email, 'sendTxn');
});
afterEach(() => {
sandbox.restore();
});
it('can remove other members', async () => {
@@ -129,6 +161,18 @@ describe('POST /groups/:groupId/removeMember/:memberId', () => {
expect(invitedUserWithoutInvite.invitations.party).to.be.empty;
});
it('removes new messages from a member who is removed', async () => {
await partyLeader.post(`/groups/${party._id}/chat`, { message: 'Some message' });
await removedMember.sync();
expect(removedMember.newMessages[party._id]).to.not.be.empty;
await partyLeader.post(`/groups/${party._id}/removeMember/${removedMember._id}`);
await removedMember.sync();
expect(removedMember.newMessages[party._id]).to.be.empty;
});
it('removes user from quest when removing user from party after quest starts', async () => {
let petQuest = 'whale';
await partyLeader.update({
@@ -173,5 +217,21 @@ describe('POST /groups/:groupId/removeMember/:memberId', () => {
expect(party.quest.members[partyLeader._id]).to.be.true;
expect(party.quest.members[partyMember._id]).to.not.exist;
});
it('sends email to user with rescinded invite', async () => {
await partyLeader.post(`/groups/${party._id}/removeMember/${partyInvitedUser._id}`);
expect(email.sendTxn).to.be.calledOnce;
expect(email.sendTxn.args[0][0]._id).to.be.eql(partyInvitedUser._id);
expect(email.sendTxn.args[0][1]).to.be.eql('party-invite-rescinded');
});
it('sends email to removed user', async () => {
await partyLeader.post(`/groups/${party._id}/removeMember/${partyMember._id}`);
expect(email.sendTxn).to.be.calledOnce;
expect(email.sendTxn.args[0][0]._id).to.be.eql(partyMember._id);
expect(email.sendTxn.args[0][1]).to.be.eql('kicked-from-party');
});
});
});

View File

@@ -0,0 +1,44 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
import { v4 as generateUUID } from 'uuid';
describe('GET /members/:memberId/achievements', () => {
let user;
before(async () => {
user = await generateUser();
});
it('validates req.params.memberId', async () => {
await expect(user.get('/members/invalidUUID/achievements')).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('invalidReqParams'),
});
});
it('returns achievements based on given user', async () => {
let member = await generateUser({
contributor: {level: 1},
backer: {tier: 3},
});
let achievementsRes = await user.get(`/members/${member._id}/achievements`);
expect(achievementsRes.special.achievements.contributor.earned).to.equal(true);
expect(achievementsRes.special.achievements.contributor.value).to.equal(1);
expect(achievementsRes.special.achievements.kickstarter.earned).to.equal(true);
expect(achievementsRes.special.achievements.kickstarter.value).to.equal(3);
});
it('handles non-existing members', async () => {
let dummyId = generateUUID();
await expect(user.get(`/members/${dummyId}/achievements`)).to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('userWithIDNotFound', {userId: dummyId}),
});
});
});

View File

@@ -4,6 +4,14 @@ import {
} from '../../../../helpers/api-v3-integration.helper';
import { v4 as generateUUID } from 'uuid';
function findMessage (messages, receiverId) {
let message = _.find(messages, (inboxMessage) => {
return inboxMessage.uuid === receiverId;
});
return message;
}
describe('POST /members/transfer-gems', () => {
let userToSendMessage;
let receiver;
@@ -116,13 +124,8 @@ describe('POST /members/transfer-gems', () => {
let updatedReceiver = await receiver.get('/user');
let updatedSender = await userToSendMessage.get('/user');
let sendersMessageInReceiversInbox = _.find(updatedReceiver.inbox.messages, (inboxMessage) => {
return inboxMessage.uuid === userToSendMessage._id;
});
let sendersMessageInSendersInbox = _.find(updatedSender.inbox.messages, (inboxMessage) => {
return inboxMessage.uuid === receiver._id;
});
let sendersMessageInReceiversInbox = findMessage(updatedReceiver.inbox.messages, userToSendMessage._id);
let sendersMessageInSendersInbox = findMessage(updatedSender.inbox.messages, receiver._id);
let messageSentContent = t('privateMessageGiftIntro', {
receiverName: receiver.profile.name,
@@ -150,13 +153,8 @@ describe('POST /members/transfer-gems', () => {
let updatedReceiver = await receiver.get('/user');
let updatedSender = await userToSendMessage.get('/user');
let sendersMessageInReceiversInbox = _.find(updatedReceiver.inbox.messages, (inboxMessage) => {
return inboxMessage.uuid === userToSendMessage._id;
});
let sendersMessageInSendersInbox = _.find(updatedSender.inbox.messages, (inboxMessage) => {
return inboxMessage.uuid === receiver._id;
});
let sendersMessageInReceiversInbox = findMessage(updatedReceiver.inbox.messages, userToSendMessage._id);
let sendersMessageInSendersInbox = findMessage(updatedSender.inbox.messages, receiver._id);
let messageSentContent = t('privateMessageGiftIntro', {
receiverName: receiver.profile.name,
@@ -173,4 +171,40 @@ describe('POST /members/transfer-gems', () => {
expect(sendersMessageInSendersInbox.text).to.equal(messageSentContent);
expect(updatedSender.balance).to.equal(0);
});
it('sends transfer gems message in each participant\'s language', async () => {
await receiver.update({
'preferences.language': 'es',
});
await userToSendMessage.update({
'preferences.language': 'cs',
});
await userToSendMessage.post('/members/transfer-gems', {
gemAmount,
toUserId: receiver._id,
});
let updatedReceiver = await receiver.get('/user');
let updatedSender = await userToSendMessage.get('/user');
let sendersMessageInReceiversInbox = findMessage(updatedReceiver.inbox.messages, userToSendMessage._id);
let sendersMessageInSendersInbox = findMessage(updatedSender.inbox.messages, receiver._id);
let [receieversMessageContent, sendersMessageContent] = ['es', 'cs'].map((lang) => {
let messageContent = t('privateMessageGiftIntro', {
receiverName: receiver.profile.name,
senderName: userToSendMessage.profile.name,
}, lang);
messageContent += t('privateMessageGiftGemsMessage', {gemAmount}, lang);
return `\`${messageContent}\` `;
});
expect(sendersMessageInReceiversInbox).to.exist;
expect(sendersMessageInReceiversInbox.text).to.equal(receieversMessageContent);
expect(sendersMessageInSendersInbox).to.exist;
expect(sendersMessageInSendersInbox.text).to.equal(sendersMessageContent);
expect(updatedSender.balance).to.equal(0);
});
});

View File

@@ -0,0 +1,26 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
import { v4 as generateUUID } from 'uuid';
describe('POST /notifications/:notificationId/read', () => {
let user;
before(async () => {
user = await generateUser();
});
it('errors when notification is not found', async () => {
let dummyId = generateUUID();
await expect(user.post(`/notifications/${dummyId}/read`))
.to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('messageNotificationNotFound'),
});
});
xit('removes a notification', async () => {
});
});

View File

@@ -10,13 +10,11 @@ describe('payments - amazon - #createOrderReferenceId', () => {
user = await generateUser();
});
it('verifies billingAgreementId', async (done) => {
try {
await user.post(endpoint);
} catch (e) {
// Parameter AWSAccessKeyId cannot be empty.
expect(e.error).to.eql('BadRequest');
done();
}
it('verifies billingAgreementId', async () => {
await expect(user.post(endpoint)).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: 'Missing req.body.billingAgreementId',
});
});
});

View File

@@ -4,6 +4,7 @@ import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
import { v4 as generateUUID } from 'uuid';
import { model as Group } from '../../../../../website/server/models/group';
describe('POST /groups/:groupId/quests/abort', () => {
let questingGroup;
@@ -85,6 +86,7 @@ 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`);
@@ -123,5 +125,8 @@ describe('POST /groups/:groupId/quests/abort', () => {
},
members: {},
});
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();
});
});

View File

@@ -15,7 +15,7 @@ describe('GET /shops/seasonal', () => {
expect(shop.identifier).to.equal('seasonalShop');
expect(shop.text).to.eql(t('seasonalShop'));
expect(shop.notes).to.eql(t('seasonalShopFallText'));
expect(shop.notes).to.be.a('string');
expect(shop.imageName).to.be.a('string');
expect(shop.categories).to.be.an('array');
});

View File

@@ -74,6 +74,7 @@ describe('PUT /tasks/:id', () => {
checklist: [
{text: 123, completed: false},
],
collapseChecklist: false,
});
await sleep(2);
@@ -111,6 +112,7 @@ describe('PUT /tasks/:id', () => {
{text: 123, completed: false},
{text: 456, completed: true},
],
collapseChecklist: true,
notes: 'new notes',
attribute: 'per',
tags: [challengeUserTaskId],
@@ -143,6 +145,8 @@ describe('PUT /tasks/:id', () => {
expect(savedChallengeUserTask.streak).to.equal(25);
expect(savedChallengeUserTask.reminders.length).to.equal(2);
expect(savedChallengeUserTask.checklist.length).to.equal(2);
expect(savedChallengeUserTask.alias).to.equal('a-short-task-name');
expect(savedChallengeUserTask.collapseChecklist).to.equal(true);
});
});

View File

@@ -5,12 +5,17 @@ import {
translate as t,
} from '../../../../../helpers/api-v3-integration.helper';
import { v4 as generateUUID } from 'uuid';
import { find } from 'lodash';
describe('POST /tasks/challenge/:challengeId', () => {
let user;
let guild;
let challenge;
function findUserChallengeTask (memberTask) {
return memberTask.challenge.id === challenge._id;
}
beforeEach(async () => {
user = await generateUser({balance: 1});
guild = await generateGroup(user);
@@ -88,6 +93,9 @@ describe('POST /tasks/challenge/:challengeId', () => {
});
let challengeWithTask = await user.get(`/challenges/${challenge._id}`);
let memberTasks = await user.get('/tasks/user');
let userChallengeTask = find(memberTasks, findUserChallengeTask);
expect(challengeWithTask.tasksOrder.habits.indexOf(task._id)).to.be.above(-1);
expect(task.challenge.id).to.equal(challenge._id);
expect(task.text).to.eql('test habit');
@@ -95,6 +103,8 @@ describe('POST /tasks/challenge/:challengeId', () => {
expect(task.type).to.eql('habit');
expect(task.up).to.eql(false);
expect(task.down).to.eql(true);
expect(userChallengeTask.notes).to.eql(task.notes);
});
it('creates a todo', async () => {
@@ -105,11 +115,16 @@ describe('POST /tasks/challenge/:challengeId', () => {
});
let challengeWithTask = await user.get(`/challenges/${challenge._id}`);
let memberTasks = await user.get('/tasks/user');
let userChallengeTask = find(memberTasks, findUserChallengeTask);
expect(challengeWithTask.tasksOrder.todos.indexOf(task._id)).to.be.above(-1);
expect(task.challenge.id).to.equal(challenge._id);
expect(task.text).to.eql('test todo');
expect(task.notes).to.eql('1976');
expect(task.type).to.eql('todo');
expect(userChallengeTask.notes).to.eql(task.notes);
});
it('creates a daily', async () => {
@@ -124,6 +139,9 @@ describe('POST /tasks/challenge/:challengeId', () => {
});
let challengeWithTask = await user.get(`/challenges/${challenge._id}`);
let memberTasks = await user.get('/tasks/user');
let userChallengeTask = find(memberTasks, findUserChallengeTask);
expect(challengeWithTask.tasksOrder.dailys.indexOf(task._id)).to.be.above(-1);
expect(task.challenge.id).to.equal(challenge._id);
expect(task.text).to.eql('test daily');
@@ -132,5 +150,7 @@ describe('POST /tasks/challenge/:challengeId', () => {
expect(task.frequency).to.eql('daily');
expect(task.everyX).to.eql(5);
expect(new Date(task.startDate)).to.eql(now);
expect(userChallengeTask.notes).to.eql(task.notes);
});
});

View File

@@ -0,0 +1,58 @@
import {
createAndPopulateGroup,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import { find } from 'lodash';
describe('GET /approvals/group/:groupId', () => {
let user, guild, member, task, syncedTask;
function findAssignedTask (memberTask) {
return memberTask.group.id === guild._id;
}
beforeEach(async () => {
let {group, members, groupLeader} = await createAndPopulateGroup({
groupDetails: {
name: 'Test Guild',
type: 'guild',
},
members: 1,
});
guild = group;
user = groupLeader;
member = members[0];
task = await user.post(`/tasks/group/${guild._id}`, {
text: 'test todo',
type: 'todo',
requiresApproval: true,
});
await user.post(`/tasks/${task._id}/assign/${member._id}`);
let memberTasks = await member.get('/tasks/user');
syncedTask = find(memberTasks, findAssignedTask);
try {
await member.post(`/tasks/${syncedTask._id}/score/up`);
} catch (e) {
// eslint-disable-next-line no-empty
}
});
it('errors when user is not the group leader', async () => {
await expect(member.get(`/approvals/group/${guild._id}`))
.to.eventually.be.rejected.and.to.eql({
code: 401,
error: 'NotAuthorized',
message: t('onlyGroupLeaderCanEditTasks'),
});
});
it('gets a list of task that need approval', async () => {
let approvals = await user.get(`/approvals/group/${guild._id}`);
expect(approvals[0]._id).to.equal(syncedTask._id);
});
});

View File

@@ -0,0 +1,70 @@
import {
createAndPopulateGroup,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import { find } from 'lodash';
describe('POST /tasks/:id/approve/:userId', () => {
let user, guild, member, task;
function findAssignedTask (memberTask) {
return memberTask.group.id === guild._id;
}
beforeEach(async () => {
let {group, members, groupLeader} = await createAndPopulateGroup({
groupDetails: {
name: 'Test Guild',
type: 'guild',
},
members: 1,
});
guild = group;
user = groupLeader;
member = members[0];
task = await user.post(`/tasks/group/${guild._id}`, {
text: 'test todo',
type: 'todo',
requiresApproval: true,
});
});
it('errors when user is not assigned', async () => {
await expect(user.post(`/tasks/${task._id}/approve/${member._id}`))
.to.eventually.be.rejected.and.to.eql({
code: 404,
error: 'NotFound',
message: t('taskNotFound'),
});
});
it('errors when user is not the group leader', async () => {
await user.post(`/tasks/${task._id}/assign/${member._id}`);
await expect(member.post(`/tasks/${task._id}/approve/${member._id}`))
.to.eventually.be.rejected.and.to.eql({
code: 401,
error: 'NotAuthorized',
message: t('onlyGroupLeaderCanEditTasks'),
});
});
it('approves an assigned user', async () => {
await user.post(`/tasks/${task._id}/assign/${member._id}`);
await user.post(`/tasks/${task._id}/approve/${member._id}`);
let memberTasks = await member.get('/tasks/user');
let syncedTask = find(memberTasks, findAssignedTask);
await member.sync();
expect(member.notifications.length).to.equal(1);
expect(member.notifications[0].type).to.equal('GROUP_TASK_APPROVED');
expect(member.notifications[0].data.message).to.equal(t('yourTaskHasBeenApproved'));
expect(syncedTask.group.approval.approved).to.be.true;
expect(syncedTask.group.approval.approvingUser).to.equal(user._id);
expect(syncedTask.group.approval.dateApproved).to.be.a('string'); // date gets converted to a string as json doesn't have a Date type
});
});

View File

@@ -0,0 +1,93 @@
import {
createAndPopulateGroup,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import { find } from 'lodash';
describe('POST /tasks/:id/score/:direction', () => {
let user, guild, member, task;
function findAssignedTask (memberTask) {
return memberTask.group.id === guild._id;
}
beforeEach(async () => {
let {group, members, groupLeader} = await createAndPopulateGroup({
groupDetails: {
name: 'Test Guild',
type: 'guild',
},
members: 1,
});
guild = group;
user = groupLeader;
member = members[0];
task = await user.post(`/tasks/group/${guild._id}`, {
text: 'test todo',
type: 'todo',
requiresApproval: true,
});
await user.post(`/tasks/${task._id}/assign/${member._id}`);
});
it('prevents user from scoring a task that needs to be approved', async () => {
let memberTasks = await member.get('/tasks/user');
let syncedTask = find(memberTasks, findAssignedTask);
await expect(member.post(`/tasks/${syncedTask._id}/score/up`))
.to.eventually.be.rejected.and.to.eql({
code: 401,
error: 'NotAuthorized',
message: t('taskApprovalHasBeenRequested'),
});
let updatedTask = await member.get(`/tasks/${syncedTask._id}`);
await user.sync();
expect(user.notifications.length).to.equal(1);
expect(user.notifications[0].type).to.equal('GROUP_TASK_APPROVAL');
expect(user.notifications[0].data.message).to.equal(t('userHasRequestedTaskApproval', {
user: member.auth.local.username,
taskName: updatedTask.text,
}));
expect(user.notifications[0].data.groupId).to.equal(guild._id);
expect(updatedTask.group.approval.requested).to.equal(true);
expect(updatedTask.group.approval.requestedDate).to.be.a('string'); // date gets converted to a string as json doesn't have a Date type
});
it('errors when approval has already been requested', async () => {
let memberTasks = await member.get('/tasks/user');
let syncedTask = find(memberTasks, findAssignedTask);
await expect(member.post(`/tasks/${syncedTask._id}/score/up`))
.to.eventually.be.rejected.and.to.eql({
code: 401,
error: 'NotAuthorized',
message: t('taskApprovalHasBeenRequested'),
});
await expect(member.post(`/tasks/${syncedTask._id}/score/up`))
.to.eventually.be.rejected.and.eql({
code: 401,
error: 'NotAuthorized',
message: t('taskRequiresApproval'),
});
});
it('allows a user to score an apporoved task', async () => {
let memberTasks = await member.get('/tasks/user');
let syncedTask = find(memberTasks, findAssignedTask);
await user.post(`/tasks/${task._id}/approve/${member._id}`);
await member.post(`/tasks/${syncedTask._id}/score/up`);
let updatedTask = await member.get(`/tasks/${syncedTask._id}`);
expect(updatedTask.completed).to.equal(true);
expect(updatedTask.dateCompleted).to.be.a('string'); // date gets converted to a string as json doesn't have a Date type
});
});

View File

@@ -74,7 +74,7 @@ describe('POST /tasks/:taskId', () => {
});
it('returns error when non leader tries to create a task', async () => {
await expect(member.post(`/tasks/${task._id}/assign/${member._id}`))
await expect(member2.post(`/tasks/${task._id}/assign/${member._id}`))
.to.eventually.be.rejected.and.eql({
code: 401,
error: 'NotAuthorized',
@@ -82,6 +82,17 @@ describe('POST /tasks/:taskId', () => {
});
});
it('allows user to assign themselves', async () => {
await member.post(`/tasks/${task._id}/assign/${member._id}`);
let groupTask = await user.get(`/tasks/group/${guild._id}`);
let memberTasks = await member.get('/tasks/user');
let syncedTask = find(memberTasks, findAssignedTask);
expect(groupTask[0].group.assignedUsers).to.contain(member._id);
expect(syncedTask).to.exist;
});
it('assigns a task to a user', async () => {
await user.post(`/tasks/${task._id}/assign/${member._id}`);

View File

@@ -20,6 +20,6 @@ describe('POST /user/purchase-hourglass/:type/:key', () => {
expect(response.message).to.eql(t('hourglassPurchase'));
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
expect(user.items.pets).to.eql({'MantisShrimp-Base': 5});
expect(user.items.pets['MantisShrimp-Base']).to.eql(5);
});
});

View File

@@ -278,6 +278,7 @@ describe('analyticsService', () => {
todos: [{_id: 'todo'}],
rewards: [{_id: 'reward'}],
balance: 12,
loginIncentives: 1,
};
data.user = user;
@@ -302,6 +303,7 @@ describe('analyticsService', () => {
contributorLevel: 1,
subscription: 'foo-plan',
balance: 12,
loginIncentives: 1,
},
});
});

View File

@@ -8,6 +8,7 @@ import { model as User } from '../../../../../website/server/models/user';
import * as Tasks from '../../../../../website/server/models/task';
import { clone } from 'lodash';
import common from '../../../../../website/common';
import analytics from '../../../../../website/server/libs/analyticsService';
// const scoreTask = common.ops.scoreTask;
@@ -17,9 +18,6 @@ describe('cron', () => {
let user;
let tasksByType = {habits: [], dailys: [], todos: [], rewards: []};
let daysMissed = 0;
let analytics = {
track: sinon.spy(),
};
beforeEach(() => {
user = new User({
@@ -34,11 +32,17 @@ describe('cron', () => {
},
});
sinon.spy(analytics, 'track');
user._statsComputed = {
mp: 10,
};
});
afterEach(() => {
analytics.track.restore();
});
it('updates user.preferences.timezoneOffsetAtLastCron', () => {
let timezoneOffsetFromUserPrefs = 1;
@@ -59,10 +63,15 @@ describe('cron', () => {
expect(user.flags.cronCount).to.be.greaterThan(cronCountBefore);
});
it('calls analytics', () => {
cron({user, tasksByType, daysMissed, analytics});
expect(analytics.track.callCount).to.equal(1);
});
describe('end of the month perks', () => {
beforeEach(() => {
user.purchased.plan.customerId = 'subscribedId';
user.purchased.plan.dateUpdated = moment('012013', 'MMYYYY');
user.purchased.plan.dateUpdated = moment().subtract(1, 'months').toDate();
});
it('resets plan.gemsBought on a new month', () => {
@@ -71,10 +80,21 @@ describe('cron', () => {
expect(user.purchased.plan.gemsBought).to.equal(0);
});
it('resets plan.dateUpdated on a new month', () => {
let currentMonth = moment().format('MMYYYY');
it('does not reset plan.gemsBought within the month', () => {
let clock = sinon.useFakeTimers(moment().startOf('month').add(2, 'days').unix());
user.purchased.plan.dateUpdated = moment().startOf('month').toDate();
user.purchased.plan.gemsBought = 10;
cron({user, tasksByType, daysMissed, analytics});
expect(moment(user.purchased.plan.dateUpdated).format('MMYYYY')).to.equal(currentMonth);
expect(user.purchased.plan.gemsBought).to.equal(10);
clock.restore();
});
it('resets plan.dateUpdated on a new month', () => {
let currentMonth = moment().startOf('month');
cron({user, tasksByType, daysMissed, analytics});
expect(moment(user.purchased.plan.dateUpdated).startOf('month').isSame(currentMonth)).to.eql(true);
});
it('increments plan.consecutive.count', () => {
@@ -83,6 +103,13 @@ describe('cron', () => {
expect(user.purchased.plan.consecutive.count).to.equal(1);
});
it('increments plan.consecutive.count by more than 1 if user skipped months between logins', () => {
user.purchased.plan.dateUpdated = moment().subtract(2, 'months').toDate();
user.purchased.plan.consecutive.count = 0;
cron({user, tasksByType, daysMissed, analytics});
expect(user.purchased.plan.consecutive.count).to.equal(2);
});
it('decrements plan.consecutive.offset when offset is greater than 0', () => {
user.purchased.plan.consecutive.offset = 2;
cron({user, tasksByType, daysMissed, analytics});
@@ -97,6 +124,21 @@ describe('cron', () => {
expect(user.purchased.plan.consecutive.offset).to.equal(0);
});
it('increments plan.consecutive.trinkets multiple times if user has been absent with continuous subscription', () => {
user.purchased.plan.dateUpdated = moment().subtract(6, 'months').toDate();
user.purchased.plan.consecutive.count = 5;
cron({user, tasksByType, daysMissed, analytics});
expect(user.purchased.plan.consecutive.trinkets).to.equal(2);
});
it('does not award unearned plan.consecutive.trinkets if subscription ended during an absence', () => {
user.purchased.plan.dateUpdated = moment().subtract(6, 'months').toDate();
user.purchased.plan.dateTerminated = moment().subtract(3, 'months').toDate();
user.purchased.plan.consecutive.count = 5;
cron({user, tasksByType, daysMissed, analytics});
expect(user.purchased.plan.consecutive.trinkets).to.equal(1);
});
it('increments plan.consecutive.gemCapExtra when user has reached a month that is a multiple of 3', () => {
user.purchased.plan.consecutive.count = 5;
user.purchased.plan.consecutive.offset = 1;
@@ -105,6 +147,13 @@ describe('cron', () => {
expect(user.purchased.plan.consecutive.offset).to.equal(0);
});
it('increments plan.consecutive.gemCapExtra multiple times if user has been absent with continuous subscription', () => {
user.purchased.plan.dateUpdated = moment().subtract(6, 'months').toDate();
user.purchased.plan.consecutive.count = 5;
cron({user, tasksByType, daysMissed, analytics});
expect(user.purchased.plan.consecutive.gemCapExtra).to.equal(10);
});
it('does not increment plan.consecutive.gemCapExtra when user has reached the gemCap limit', () => {
user.purchased.plan.consecutive.gemCapExtra = 25;
user.purchased.plan.consecutive.count = 5;
@@ -118,7 +167,7 @@ describe('cron', () => {
expect(user.purchased.plan.customerId).to.exist;
});
it('does reset plan stats until we are after the last day of the cancelled month', () => {
it('does reset plan stats if we are after the last day of the cancelled month', () => {
user.purchased.plan.dateTerminated = moment(new Date()).subtract({days: 1});
user.purchased.plan.consecutive.gemCapExtra = 20;
user.purchased.plan.consecutive.count = 5;
@@ -134,10 +183,25 @@ describe('cron', () => {
});
describe('end of the month perks when user is not subscribed', () => {
it('does not reset plan.gemsBought on a new month', () => {
beforeEach(() => {
user.purchased.plan.dateUpdated = moment().subtract(1, 'months').toDate();
});
it('resets plan.gemsBought on a new month', () => {
user.purchased.plan.gemsBought = 10;
cron({user, tasksByType, daysMissed, analytics});
expect(user.purchased.plan.gemsBought).to.equal(0);
});
it('does not reset plan.gemsBought within the month', () => {
let clock = sinon.useFakeTimers(moment().startOf('month').add(2, 'days').unix());
user.purchased.plan.dateUpdated = moment().startOf('month').toDate();
user.purchased.plan.gemsBought = 10;
cron({user, tasksByType, daysMissed, analytics});
expect(user.purchased.plan.gemsBought).to.equal(10);
clock.restore();
});
it('does not reset plan.dateUpdated on a new month', () => {
@@ -202,6 +266,11 @@ describe('cron', () => {
user.preferences.sleep = true;
});
it('calls analytics', () => {
cron({user, tasksByType, daysMissed, analytics});
expect(analytics.track.callCount).to.equal(1);
});
it('clears user buffs', () => {
user.stats.buffs = {
str: 1,
@@ -601,9 +670,9 @@ describe('cron', () => {
cron({user, tasksByType, daysMissed, analytics});
expect(user.notifications.length).to.equal(1);
expect(user.notifications[0].type).to.equal('CRON');
expect(user.notifications[0].data).to.eql({
expect(user.notifications.length).to.be.greaterThan(0);
expect(user.notifications[1].type).to.equal('CRON');
expect(user.notifications[1].data).to.eql({
hp: user.stats.hp - hpBefore,
mp: user.stats.mp - mpBefore,
});
@@ -620,13 +689,14 @@ describe('cron', () => {
cron({user, tasksByType, daysMissed, analytics});
expect(user.notifications.length).to.equal(1);
expect(user.notifications[0].type).to.equal('CRON');
expect(user.notifications[0].data).to.eql({
expect(user.notifications.length).to.be.greaterThan(0);
expect(user.notifications[1].type).to.equal('CRON');
expect(user.notifications[1].data).to.eql({
hp: user.stats.hp - hpBefore1,
mp: user.stats.mp - mpBefore1,
});
let notifsBefore2 = user.notifications.length;
let hpBefore2 = user.stats.hp;
let mpBefore2 = user.stats.mp;
@@ -634,12 +704,14 @@ describe('cron', () => {
cron({user, tasksByType, daysMissed, analytics});
expect(user.notifications.length).to.equal(1);
expect(user.notifications[0].type).to.equal('CRON');
expect(user.notifications[0].data).to.eql({
expect(user.notifications.length - notifsBefore2).to.equal(0);
expect(user.notifications[0].type).to.not.equal('CRON');
expect(user.notifications[1].type).to.equal('CRON');
expect(user.notifications[1].data).to.eql({
hp: user.stats.hp - hpBefore2 - (hpBefore2 - hpBefore1),
mp: user.stats.mp - mpBefore2 - (mpBefore2 - mpBefore1),
});
expect(user.notifications[0].type).to.not.equal('CRON');
});
});
@@ -692,6 +764,188 @@ describe('cron', () => {
expect(user.inbox.messages[messageId]).to.not.exist;
});
});
describe('login incentives', () => {
it('increments incentive counter each cron', () => {
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(1);
user.lastCron = moment(new Date()).subtract({days: 1});
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(2);
});
it('pushes a notification of the day\'s incentive each cron', () => {
cron({user, tasksByType, daysMissed, analytics});
expect(user.notifications.length).to.be.greaterThan(1);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('replaces previous notifications', () => {
cron({user, tasksByType, daysMissed, analytics});
cron({user, tasksByType, daysMissed, analytics});
cron({user, tasksByType, daysMissed, analytics});
let filteredNotifications = user.notifications.filter(n => n.type === 'LOGIN_INCENTIVE');
expect(filteredNotifications.length).to.equal(1);
});
it('increments loginIncentives by 1 even if days are skipped in between', () => {
daysMissed = 3;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(1);
});
it('increments loginIncentives by 1 even if user has Dailies paused', () => {
user.preferences.sleep = true;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(1);
});
it('awards user bard robes if login incentive is 1', () => {
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(1);
expect(user.items.gear.owned.armor_special_bardRobes).to.eql(true);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user incentive backgrounds if login incentive is 2', () => {
user.loginIncentives = 1;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(2);
expect(user.purchased.background.blue).to.eql(true);
expect(user.purchased.background.green).to.eql(true);
expect(user.purchased.background.purple).to.eql(true);
expect(user.purchased.background.red).to.eql(true);
expect(user.purchased.background.yellow).to.eql(true);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user Bard Hat if login incentive is 3', () => {
user.loginIncentives = 2;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(3);
expect(user.items.gear.owned.head_special_bardHat).to.eql(true);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user RoyalPurple Hatching Potion if login incentive is 4', () => {
user.loginIncentives = 3;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(4);
expect(user.items.hatchingPotions.RoyalPurple).to.eql(1);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user a Chocolate, Meat and Pink Contton Candy if login incentive is 5', () => {
user.loginIncentives = 4;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(5);
expect(user.items.food.Chocolate).to.eql(1);
expect(user.items.food.Meat).to.eql(1);
expect(user.items.food.CottonCandyPink).to.eql(1);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user moon quest if login incentive is 7', () => {
user.loginIncentives = 6;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(7);
expect(user.items.quests.moon1).to.eql(1);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user RoyalPurple Hatching Potion if login incentive is 10', () => {
user.loginIncentives = 9;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(10);
expect(user.items.hatchingPotions.RoyalPurple).to.eql(1);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user a Strawberry, Patato and Blue Contton Candy if login incentive is 14', () => {
user.loginIncentives = 13;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(14);
expect(user.items.food.Strawberry).to.eql(1);
expect(user.items.food.Potatoe).to.eql(1);
expect(user.items.food.CottonCandyBlue).to.eql(1);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user a bard instrument if login incentive is 18', () => {
user.loginIncentives = 17;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(18);
expect(user.items.gear.owned.weapon_special_bardInstrument).to.eql(true);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user second moon quest if login incentive is 22', () => {
user.loginIncentives = 21;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(22);
expect(user.items.quests.moon2).to.eql(1);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user a RoyalPurple hatching potion if login incentive is 26', () => {
user.loginIncentives = 25;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(26);
expect(user.items.hatchingPotions.RoyalPurple).to.eql(1);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user Fish, Milk, Rotten Meat and Honey if login incentive is 30', () => {
user.loginIncentives = 29;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(30);
expect(user.items.food.Fish).to.eql(1);
expect(user.items.food.Milk).to.eql(1);
expect(user.items.food.RottenMeat).to.eql(1);
expect(user.items.food.Honey).to.eql(1);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user a RoyalPurple hatching potion if login incentive is 35', () => {
user.loginIncentives = 34;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(35);
expect(user.items.hatchingPotions.RoyalPurple).to.eql(1);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user the third moon quest if login incentive is 40', () => {
user.loginIncentives = 39;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(40);
expect(user.items.quests.moon3).to.eql(1);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user a RoyalPurple hatching potion if login incentive is 45', () => {
user.loginIncentives = 44;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(45);
expect(user.items.hatchingPotions.RoyalPurple).to.eql(1);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
it('awards user a saddle if login incentive is 50', () => {
user.loginIncentives = 49;
cron({user, tasksByType, daysMissed, analytics});
expect(user.loginIncentives).to.eql(50);
expect(user.items.food.Saddle).to.eql(1);
expect(user.notifications[0].type).to.eql('LOGIN_INCENTIVE');
});
});
});
describe('recoverCron', () => {

View File

@@ -3,15 +3,28 @@ import * as api from '../../../../../website/server/libs/payments';
import analytics from '../../../../../website/server/libs/analyticsService';
import notifications from '../../../../../website/server/libs/pushNotifications';
import { model as User } from '../../../../../website/server/models/user';
import { model as Group } from '../../../../../website/server/models/group';
import moment from 'moment';
import { translate as t } from '../../../../helpers/api-v3-integration.helper';
import {
generateGroup,
} from '../../../../helpers/api-unit.helper.js';
describe('payments/index', () => {
let user, data, plan;
let user, group, data, plan;
beforeEach(() => {
beforeEach(async () => {
user = new User();
user.profile.name = 'sender';
group = generateGroup({
name: 'test group',
type: 'guild',
privacy: 'public',
leader: user._id,
});
await group.save();
sandbox.stub(sender, 'sendTxn');
sandbox.stub(user, 'sendMessage');
sandbox.stub(analytics, 'trackPurchase');
@@ -80,6 +93,24 @@ describe('payments/index', () => {
expect(recipient.purchased.plan.extraMonths).to.eql(3);
});
it('does not set negative extraMonths if plan has past dateTerminated date', async () => {
let dateTerminated = moment().subtract(2, 'months').toDate();
recipient.purchased.plan.dateTerminated = dateTerminated;
await api.createSubscription(data);
expect(recipient.purchased.plan.extraMonths).to.eql(0);
});
it('does not reset Gold-to-Gems cap on an existing subscription', async () => {
recipient.purchased.plan = plan;
recipient.purchased.plan.gemsBought = 12;
await api.createSubscription(data);
expect(recipient.purchased.plan.gemsBought).to.eql(12);
});
it('adds to date terminated for an existing plan with a future terminated date', async () => {
let dateTerminated = moment().add(1, 'months').toDate();
recipient.purchased.plan = plan;
@@ -115,6 +146,14 @@ describe('payments/index', () => {
expect(recipient.purchased.plan.dateUpdated).to.exist;
});
it('sets plan.dateCreated if it did not previously exist', async () => {
expect(recipient.purchased.plan.dateCreated).to.not.exist;
await api.createSubscription(data);
expect(recipient.purchased.plan.dateCreated).to.exist;
});
it('does not change plan.customerId if it already exists', async () => {
recipient.purchased.plan = plan;
data.customerId = 'purchaserCustomerId';
@@ -143,9 +182,10 @@ describe('payments/index', () => {
it('sends a private message about the gift', async () => {
await api.createSubscription(data);
let msg = '\`Hello recipient, sender has sent you 3 months of subscription!\`';
expect(user.sendMessage).to.be.calledOnce;
expect(user.sendMessage).to.be.calledWith(recipient, '\`Hello recipient, sender has sent you 3 months of subscription!\`');
expect(user.sendMessage).to.be.calledWith(recipient, { receiverMsg: msg, senderMsg: msg });
});
it('sends an email about the gift', async () => {
@@ -168,6 +208,7 @@ describe('payments/index', () => {
expect(analytics.trackPurchase).to.be.calledOnce;
expect(analytics.trackPurchase).to.be.calledWith({
uuid: user._id,
groupId: undefined,
itemPurchased: 'Subscription',
sku: 'payment method-subscription',
purchaseType: 'subscribe',
@@ -210,6 +251,25 @@ describe('payments/index', () => {
expect(user.purchased.plan.extraMonths).to.within(1.9, 2);
});
it('does not set negative extraMonths if plan has past dateTerminated date', async () => {
user.purchased.plan = plan;
user.purchased.plan.dateTerminated = moment(new Date()).subtract(2, 'months');
expect(user.purchased.plan.extraMonths).to.eql(0);
await api.createSubscription(data);
expect(user.purchased.plan.extraMonths).to.eql(0);
});
it('does not reset Gold-to-Gems cap on additional subscription', async () => {
user.purchased.plan = plan;
user.purchased.plan.gemsBought = 10;
await api.createSubscription(data);
expect(user.purchased.plan.gemsBought).to.eql(10);
});
it('sets lastBillingDate if payment method is "Amazon Payments"', async () => {
data.paymentMethod = 'Amazon Payments';
@@ -218,7 +278,7 @@ describe('payments/index', () => {
expect(user.purchased.plan.lastBillingDate).to.exist;
});
it('increases the user\'s transcation count', async () => {
it('increases the user\'s transaction count', async () => {
expect(user.purchased.txnCount).to.eql(0);
await api.createSubscription(data);
@@ -239,6 +299,7 @@ describe('payments/index', () => {
expect(analytics.trackPurchase).to.be.calledOnce;
expect(analytics.trackPurchase).to.be.calledWith({
uuid: user._id,
groupId: undefined,
itemPurchased: 'Subscription',
sku: 'payment method-subscription',
purchaseType: 'subscribe',
@@ -254,6 +315,53 @@ describe('payments/index', () => {
});
});
context('Purchasing a subscription for group', () => {
it('creates a subscription', async () => {
expect(group.purchased.plan.planId).to.not.exist;
data.groupId = group._id;
await api.createSubscription(data);
let updatedGroup = await Group.findById(group._id).exec();
expect(updatedGroup.purchased.plan.planId).to.eql('basic_3mo');
expect(updatedGroup.purchased.plan.customerId).to.eql('customer-id');
expect(updatedGroup.purchased.plan.dateUpdated).to.exist;
expect(updatedGroup.purchased.plan.gemsBought).to.eql(0);
expect(updatedGroup.purchased.plan.paymentMethod).to.eql('Payment Method');
expect(updatedGroup.purchased.plan.extraMonths).to.eql(0);
expect(updatedGroup.purchased.plan.dateTerminated).to.eql(null);
expect(updatedGroup.purchased.plan.lastBillingDate).to.not.exist;
expect(updatedGroup.purchased.plan.dateCreated).to.exist;
});
it('sets extraMonths if plan has dateTerminated date', async () => {
group.purchased.plan = plan;
group.purchased.plan.dateTerminated = moment(new Date()).add(2, 'months');
await group.save();
expect(group.purchased.plan.extraMonths).to.eql(0);
data.groupId = group._id;
await api.createSubscription(data);
let updatedGroup = await Group.findById(group._id).exec();
expect(updatedGroup.purchased.plan.extraMonths).to.within(1.9, 2);
});
it('does not set negative extraMonths if plan has past dateTerminated date', async () => {
group.purchased.plan = plan;
group.purchased.plan.dateTerminated = moment(new Date()).subtract(2, 'months');
await group.save();
expect(group.purchased.plan.extraMonths).to.eql(0);
data.groupId = group._id;
await api.createSubscription(data);
let updatedGroup = await Group.findById(group._id).exec();
expect(updatedGroup.purchased.plan.extraMonths).to.eql(0);
});
});
context('Block subscription perks', () => {
it('adds block months to plan.consecutive.offset', async () => {
await api.createSubscription(data);
@@ -389,61 +497,136 @@ describe('payments/index', () => {
data = { user };
});
it('adds a month termination date by default', async () => {
await api.cancelSubscription(data);
context('Canceling a subscription for self', () => {
it('adds a month termination date by default', async () => {
await api.cancelSubscription(data);
let now = new Date();
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
let now = new Date();
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
expect(daysTillTermination).to.be.within(29, 30); // 1 month +/- 1 days
expect(daysTillTermination).to.be.within(29, 30); // 1 month +/- 1 days
});
it('adds extraMonths to dateTerminated value', async () => {
user.purchased.plan.extraMonths = 2;
await api.cancelSubscription(data);
let now = new Date();
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
expect(daysTillTermination).to.be.within(89, 90); // 3 months +/- 1 days
});
it('handles extra month fractions', async () => {
user.purchased.plan.extraMonths = 0.3;
await api.cancelSubscription(data);
let now = new Date();
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
expect(daysTillTermination).to.be.within(38, 39); // should be about 1 month + 1/3 month
});
it('terminates at next billing date if it exists', async () => {
data.nextBill = moment().add({ days: 15 });
await api.cancelSubscription(data);
let now = new Date();
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
expect(daysTillTermination).to.be.within(13, 15);
});
it('resets plan.extraMonths', async () => {
user.purchased.plan.extraMonths = 5;
await api.cancelSubscription(data);
expect(user.purchased.plan.extraMonths).to.eql(0);
});
it('sends an email', async () => {
await api.cancelSubscription(data);
expect(sender.sendTxn).to.be.calledOnce;
expect(sender.sendTxn).to.be.calledWith(user, 'cancel-subscription');
});
});
it('adds extraMonths to dateTerminated value', async () => {
user.purchased.plan.extraMonths = 2;
context('Canceling a subscription for group', () => {
it('adds a month termination date by default', async () => {
data.groupId = group._id;
await api.cancelSubscription(data);
await api.cancelSubscription(data);
let now = new Date();
let updatedGroup = await Group.findById(group._id).exec();
let daysTillTermination = moment(updatedGroup.purchased.plan.dateTerminated).diff(now, 'days');
let now = new Date();
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
expect(daysTillTermination).to.be.within(29, 30); // 1 month +/- 1 days
});
expect(daysTillTermination).to.be.within(89, 90); // 3 months +/- 1 days
});
it('adds extraMonths to dateTerminated value', async () => {
group.purchased.plan.extraMonths = 2;
await group.save();
data.groupId = group._id;
it('handles extra month fractions', async () => {
user.purchased.plan.extraMonths = 0.3;
await api.cancelSubscription(data);
await api.cancelSubscription(data);
let now = new Date();
let updatedGroup = await Group.findById(group._id).exec();
let daysTillTermination = moment(updatedGroup.purchased.plan.dateTerminated).diff(now, 'days');
let now = new Date();
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
expect(daysTillTermination).to.be.within(89, 90); // 3 months +/- 1 days
});
expect(daysTillTermination).to.be.within(38, 39); // should be about 1 month + 1/3 month
});
it('handles extra month fractions', async () => {
group.purchased.plan.extraMonths = 0.3;
await group.save();
data.groupId = group._id;
it('terminates at next billing date if it exists', async () => {
data.nextBill = moment().add({ days: 15 });
await api.cancelSubscription(data);
await api.cancelSubscription(data);
let now = new Date();
let updatedGroup = await Group.findById(group._id).exec();
let daysTillTermination = moment(updatedGroup.purchased.plan.dateTerminated).diff(now, 'days');
let now = new Date();
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
expect(daysTillTermination).to.be.within(38, 39); // should be about 1 month + 1/3 month
});
expect(daysTillTermination).to.be.within(13, 15);
});
it('terminates at next billing date if it exists', async () => {
data.nextBill = moment().add({ days: 15 });
data.groupId = group._id;
it('resets plan.extraMonths', async () => {
user.purchased.plan.extraMonths = 5;
await api.cancelSubscription(data);
await api.cancelSubscription(data);
let now = new Date();
let updatedGroup = await Group.findById(group._id).exec();
let daysTillTermination = moment(updatedGroup.purchased.plan.dateTerminated).diff(now, 'days');
expect(user.purchased.plan.extraMonths).to.eql(0);
});
expect(daysTillTermination).to.be.within(13, 15);
});
it('sends an email', async () => {
await api.cancelSubscription(data);
it('resets plan.extraMonths', async () => {
group.purchased.plan.extraMonths = 5;
await group.save();
data.groupId = group._id;
expect(sender.sendTxn).to.be.calledOnce;
expect(sender.sendTxn).to.be.calledWith(user, 'cancel-subscription');
await api.cancelSubscription(data);
let updatedGroup = await Group.findById(group._id).exec();
expect(updatedGroup.purchased.plan.extraMonths).to.eql(0);
});
it('sends an email', async () => {
data.groupId = group._id;
await api.cancelSubscription(data);
expect(sender.sendTxn).to.be.calledOnce;
expect(sender.sendTxn).to.be.calledWith(user, 'cancel-subscription');
});
});
});
@@ -516,14 +699,37 @@ describe('payments/index', () => {
it('sends a message from purchaser to recipient', async () => {
await api.buyGems(data);
let msg = '\`Hello recipient, sender has sent you 4 gems!\`';
expect(user.sendMessage).to.be.calledWith(recipient, '\`Hello recipient, sender has sent you 4 gems!\`');
expect(user.sendMessage).to.be.calledWith(recipient, { receiverMsg: msg, senderMsg: msg });
});
it('sends a push notification if user did not gift to self', async () => {
await api.buyGems(data);
expect(notifications.sendNotification).to.be.calledOnce;
});
it('sends gem donation message in each participant\'s language', async () => {
await recipient.update({
'preferences.language': 'es',
});
await user.update({
'preferences.language': 'cs',
});
await api.buyGems(data);
let [recipientsMessageContent, sendersMessageContent] = ['es', 'cs'].map((lang) => {
let messageContent = t('giftedGemsFull', {
username: recipient.profile.name,
sender: user.profile.name,
gemAmount: data.gift.gems.amount,
}, lang);
return `\`${messageContent}\``;
});
expect(user.sendMessage).to.be.calledWith(recipient, { receiverMsg: recipientsMessageContent, senderMsg: sendersMessageContent });
});
});
});
});

View File

@@ -19,6 +19,9 @@ describe('slack', () => {
profile: {
name: 'flagger',
},
preferences: {
language: 'flagger-lang',
},
},
group: {
id: 'group-id',
@@ -44,7 +47,7 @@ describe('slack', () => {
expect(IncomingWebhook.prototype.send).to.be.calledOnce;
expect(IncomingWebhook.prototype.send).to.be.calledWith({
text: 'flagger (flagger-id) flagged a message',
text: 'flagger (flagger-id) flagged a message (language: flagger-lang)',
attachments: [{
fallback: 'Flag Message',
color: 'danger',

View File

@@ -20,7 +20,7 @@ describe('cors middleware', () => {
expect(res.set).to.have.been.calledWith({
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'OPTIONS,GET,POST,PUT,HEAD,DELETE',
'Access-Control-Allow-Headers': 'Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key',
'Access-Control-Allow-Headers': 'Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key,x-client',
});
expect(res.sendStatus).to.not.have.been.called;
expect(next).to.have.been.called.once;
@@ -32,7 +32,7 @@ describe('cors middleware', () => {
expect(res.set).to.have.been.calledWith({
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'OPTIONS,GET,POST,PUT,HEAD,DELETE',
'Access-Control-Allow-Headers': 'Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key',
'Access-Control-Allow-Headers': 'Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key,x-client',
});
expect(res.sendStatus).to.have.been.calledWith(200);
expect(next).to.not.have.been.called;

View File

@@ -98,7 +98,6 @@ describe('response middleware', () => {
{
type: notification.type,
id: notification.id,
createdAt: notification.createdAt,
data: {},
},
],

View File

@@ -6,32 +6,36 @@ import common from '../../../../../website/common/';
import { each, find } from 'lodash';
describe('Challenge Model', () => {
let guild, leader, challenge, task, tasksToTest;
let guild, leader, challenge, task;
let tasksToTest = {
habit: {
text: 'test habit',
type: 'habit',
up: false,
down: true,
notes: 'test notes',
},
todo: {
text: 'test todo',
type: 'todo',
notes: 'test notes',
},
daily: {
text: 'test daily',
type: 'daily',
frequency: 'daily',
everyX: 5,
startDate: new Date(),
notes: 'test notes',
},
reward: {
text: 'test reward',
type: 'reward',
notes: 'test notes',
},
};
beforeEach(async () => {
tasksToTest = {
habit: {
text: 'test habit',
type: 'habit',
up: false,
down: true,
},
todo: {
text: 'test todo',
type: 'todo',
},
daily: {
text: 'test daily',
type: 'daily',
frequency: 'daily',
everyX: 5,
startDate: new Date(),
},
reward: {
text: 'test reward',
type: 'reward',
},
};
guild = new Group({
name: 'test party',
type: 'guild',
@@ -77,6 +81,7 @@ describe('Challenge Model', () => {
});
expect(syncedTask).to.exist;
expect(syncedTask.notes).to.eql(task.notes);
});
it('syncs a challenge to a user', async () => {
@@ -96,8 +101,8 @@ describe('Challenge Model', () => {
});
expect(updatedNewMember.challenges).to.contain(challenge._id);
expect(updatedNewMember.tags[3].id).to.equal(challenge._id);
expect(updatedNewMember.tags[3].name).to.equal(challenge.shortName);
expect(updatedNewMember.tags[7].id).to.equal(challenge._id);
expect(updatedNewMember.tags[7].name).to.equal(challenge.shortName);
expect(syncedTask).to.exist;
});

View File

@@ -628,24 +628,89 @@ describe('Group Model', () => {
});
});
it('deletes a private group when the last member leaves', async () => {
party.memberCount = 1;
it('deletes a private party when the last member leaves', async () => {
await party.leave(participatingMember);
await party.leave(questLeader);
await party.leave(nonParticipatingMember);
await party.leave(undecidedMember);
party = await Group.findOne({_id: party._id});
expect(party).to.not.exist;
});
it('does not delete a public group when the last member leaves', async () => {
party.memberCount = 1;
party.privacy = 'public';
await party.leave(participatingMember);
await party.leave(questLeader);
await party.leave(nonParticipatingMember);
await party.leave(undecidedMember);
party = await Group.findOne({_id: party._id});
expect(party).to.exist;
});
it('does not delete a private party when the member count reaches zero if there are still members', async () => {
party.memberCount = 1;
await party.leave(participatingMember);
party = await Group.findOne({_id: party._id});
expect(party).to.exist;
});
it('deletes a private guild when the last member leaves', async () => {
let guild = new Group({
name: 'test guild',
type: 'guild',
memberCount: 1,
});
let leader = new User({
guilds: [guild._id],
});
guild.leader = leader._id;
await Promise.all([
guild.save(),
leader.save(),
]);
await guild.leave(leader);
guild = await Group.findOne({_id: guild._id});
expect(guild).to.not.exist;
});
it('does not delete a private guild when the member count reaches zero if there are still members', async () => {
let guild = new Group({
name: 'test guild',
type: 'guild',
memberCount: 1,
});
let leader = new User({
guilds: [guild._id],
});
let member = new User({
guilds: [guild._id],
});
guild.leader = leader._id;
await Promise.all([
guild.save(),
leader.save(),
member.save(),
]);
await guild.leave(member);
guild = await Group.findOne({_id: guild._id});
expect(guild).to.exist;
});
});
describe('#sendChat', () => {
@@ -1061,8 +1126,45 @@ describe('Group Model', () => {
[nonParticipatingMember._id]: false,
[undecidedMember._id]: null,
};
});
sandbox.spy(User, 'update');
describe('user update retry failures', () => {
let successfulMock = {
exec: () => {
return Promise.resolve({raw: 'sucess'});
},
};
let failedMock = {
exec: () => {
return Promise.reject(new Error('error'));
},
};
it('doesn\'t retry successful operations', async () => {
sandbox.stub(User, 'update').returns(successfulMock);
await party.finishQuest(quest);
expect(User.update).to.be.calledTwice;
});
it('stops retrying when a successful update has occurred', async () => {
let updateStub = sandbox.stub(User, 'update');
updateStub.onCall(0).returns(failedMock);
updateStub.returns(successfulMock);
await party.finishQuest(quest);
expect(User.update).to.be.calledThrice;
});
it('retries failed updates at most five times per user', async () => {
sandbox.stub(User, 'update').returns(failedMock);
await expect(party.finishQuest(quest)).to.eventually.be.rejected;
expect(User.update.callCount).to.eql(10);
});
});
it('gives out achievements', async () => {
@@ -1171,13 +1273,15 @@ describe('Group Model', () => {
context('Party quests', () => {
it('updates participating members with rewards', async () => {
sandbox.spy(User, 'update');
await party.finishQuest(quest);
expect(User.update).to.be.calledOnce;
expect(User.update).to.be.calledTwice;
expect(User.update).to.be.calledWithMatch({
_id: {
$in: [questLeader._id, participatingMember._id],
},
_id: questLeader._id,
});
expect(User.update).to.be.calledWithMatch({
_id: participatingMember._id,
});
});
@@ -1204,6 +1308,7 @@ describe('Group Model', () => {
});
it('updates all users with rewards', async () => {
sandbox.spy(User, 'update');
await party.finishQuest(tavernQuest);
expect(User.update).to.be.calledOnce;

View File

@@ -107,6 +107,7 @@ describe('Group Task Methods', () => {
let updatedTaskName = 'Update Task name';
task.text = updatedTaskName;
task.group.approval.required = true;
await guild.updateTask(task);
@@ -121,10 +122,12 @@ describe('Group Task Methods', () => {
expect(task.group.assignedUsers).to.contain(leader._id);
expect(syncedTask).to.exist;
expect(syncedTask.text).to.equal(task.text);
expect(syncedTask.group.approval.required).to.equal(true);
expect(task.group.assignedUsers).to.contain(newMember._id);
expect(syncedMemberTask).to.exist;
expect(syncedMemberTask.text).to.equal(task.text);
expect(syncedMemberTask.group.approval.required).to.equal(true);
});
it('removes an assigned task and unlinks assignees', async () => {

View File

@@ -55,7 +55,7 @@ describe('User Model', () => {
let userToJSON = user.toJSON();
expect(user.notifications.length).to.equal(1);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type', 'createdAt']);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type']);
expect(userToJSON.notifications[0].type).to.equal('CRON');
expect(userToJSON.notifications[0].data).to.eql({});
});
@@ -67,7 +67,7 @@ describe('User Model', () => {
let userToJSON = user.toJSON();
expect(user.notifications.length).to.equal(1);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type', 'createdAt']);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type']);
expect(userToJSON.notifications[0].type).to.equal('CRON');
expect(userToJSON.notifications[0].data).to.eql({field: 1});
});

View File

@@ -28,7 +28,10 @@ describe('Inventory Controller', function() {
},
preferences: {
suppressModals: {}
}
},
purchased: {
plan: {}
},
});
Shared.wrap(user);
@@ -450,4 +453,84 @@ describe('Inventory Controller', function() {
expect(scope.hasAllTimeTravelerItemsOfType('mounts')).to.eql(true);
}));
});
describe('Gear search filter', function() {
var wrap = function(text) {
return {'text': function() {return text;}};
}
var toText = function(list) {
return _.map(list, function(ele) { return ele.text(); });
}
var gearByClass, gearByType;
beforeEach(function() {
scope.$digest();
gearByClass = {'raw': [wrap('kale'), wrap('sashimi')],
'cooked': [wrap('chicken'), wrap('potato')]};
gearByType = {'veg': [wrap('kale'), wrap('potato')],
'not': [wrap('chicken'), wrap('sashimi')]};
scope.gearByClass = gearByClass;
scope.gearByType = gearByType;
scope.equipmentQuery.query = 'a';
});
it('filters nothing if equipmentQuery is nothing', function() {
scope.equipmentQuery.query = '';
scope.$digest();
expect(toText(scope.filteredGearByClass['raw'])).to.eql(['kale', 'sashimi']);
expect(toText(scope.filteredGearByClass['cooked'])).to.eql(['chicken', 'potato']);
expect(toText(scope.filteredGearByType['veg'])).to.eql(['kale', 'potato']);
expect(toText(scope.filteredGearByType['not'])).to.eql(['chicken', 'sashimi']);
});
it('filters out gear if class gear changes', function() {
scope.$digest();
expect(toText(scope.filteredGearByClass['raw'])).to.eql(['kale', 'sashimi']);
expect(toText(scope.filteredGearByClass['cooked'])).to.eql(['potato']);
scope.gearByClass['raw'].push(wrap('zucchini'));
scope.gearByClass['cooked'].push(wrap('pizza'));
scope.$digest();
expect(toText(scope.filteredGearByClass['raw'])).to.eql(['kale', 'sashimi']);
expect(toText(scope.filteredGearByClass['cooked'])).to.eql(['potato', 'pizza']);
});
it('filters out gear if typed gear changes', function() {
scope.$digest();
expect(toText(scope.filteredGearByType['veg'])).to.eql(['kale', 'potato']);
expect(toText(scope.filteredGearByType['not'])).to.eql(['sashimi']);
scope.gearByType['veg'].push(wrap('zucchini'));
scope.gearByType['not'].push(wrap('pizza'));
scope.$digest();
expect(toText(scope.filteredGearByType['veg'])).to.eql(['kale', 'potato']);
expect(toText(scope.filteredGearByType['not'])).to.eql(['sashimi', 'pizza']);
});
it('filters out gear if filter query changes', function() {
scope.equipmentQuery.query = 'c';
scope.$digest();
expect(toText(scope.filteredGearByClass['raw'])).to.eql([]);
expect(toText(scope.filteredGearByClass['cooked'])).to.eql(['chicken']);
expect(toText(scope.filteredGearByType['veg'])).to.eql([]);
expect(toText(scope.filteredGearByType['not'])).to.eql(['chicken']);
});
it('returns the right filtered gear', function() {
var equipment = [wrap('spicy tuna'), wrap('dragon'), wrap('rainbow'), wrap('caterpillar')];
expect(toText(scope.equipmentSearch(equipment, 'ra'))).to.eql(['dragon', 'rainbow']);
});
it('returns the right filtered gear if the source gear has unicode', function() {
// blue hat, red hat, red shield
var equipment = [wrap('藍色軟帽'), wrap('紅色軟帽'), wrap('紅色盾牌')];
// searching for 'red' gives red hat, red shield
expect(toText(scope.equipmentSearch(equipment, '紅色'))).to.eql(['紅色軟帽', '紅色盾牌']);
});
});
});

View File

@@ -14,6 +14,7 @@ describe('Notification Controller', function() {
let User = {
user,
readNotification: function noop () {},
readNotifications: function noop () {},
sync: userSync
};

View File

@@ -1,5 +1,9 @@
{
"presets": ["es2015"],
"plugins": ["transform-object-rest-spread"],
"plugins": [
"transform-object-rest-spread",
"syntax-async-functions",
"transform-regenerator",
],
"comments": false
}

View File

@@ -36,7 +36,10 @@ webpackConfig.module.preLoaders = webpackConfig.module.preLoaders || [];
webpackConfig.module.preLoaders.unshift({
test: /\.js$/,
loader: 'isparta',
include: path.resolve(projectRoot, 'website/client'),
include: [
path.resolve(projectRoot, 'website/client'),
path.resolve(projectRoot, 'website/common'),
],
});
// only apply babel for test files when using isparta

View File

@@ -0,0 +1,8 @@
import floorFilter from 'client/filters/floor';
describe('floor filter', () => {
it('can floor a decimal number', () => {
expect(floorFilter(4.567)).to.equal(4.56);
expect(floorFilter(4.562)).to.equal(4.56);
});
});

View File

@@ -0,0 +1,8 @@
import roundFilter from 'client/filters/round';
describe('round filter', () => {
it('can round a decimal number', () => {
expect(roundFilter(4.567)).to.equal(4.57);
expect(roundFilter(4.562)).to.equal(4.56);
});
});

View File

@@ -0,0 +1,13 @@
import { gems as userGems } from 'client/store/getters/user';
describe('userGems getter', () => {
it('returns the user\'s gems', () => {
expect(userGems({
state: {
user: {
balance: 4.5,
},
},
})).to.equal(18);
});
});

View File

@@ -1,6 +1,7 @@
import Vue from 'vue';
import storeInjector from 'inject?-vue!client/store';
import { mapState, mapGetters, mapActions } from 'client/store';
import { flattenAndNamespace } from 'client/store/helpers/internals';
describe('Store', () => {
let injectedStore;
@@ -14,11 +15,25 @@ describe('Store', () => {
computedName ({ state }) {
return `${state.name} computed!`;
},
...flattenAndNamespace({
nested: {
computedName ({ state }) {
return `${state.name} computed!`;
},
},
}),
},
'./actions': {
getName ({ state }, ...args) {
return [state.name, ...args];
},
...flattenAndNamespace({
nested: {
getName ({ state }, ...args) {
return [state.name, ...args];
},
},
}),
},
}).default;
});
@@ -41,17 +56,29 @@ describe('Store', () => {
injectedStore.state.name = 'test updated';
});
it('supports getters', () => {
expect(injectedStore.getters.computedName).to.equal('test computed!');
injectedStore.state.name = 'test updated';
expect(injectedStore.getters.computedName).to.equal('test updated computed!');
describe('getters', () => {
it('supports getters', () => {
expect(injectedStore.getters.computedName).to.equal('test computed!');
injectedStore.state.name = 'test updated';
expect(injectedStore.getters.computedName).to.equal('test updated computed!');
});
it('supports nested getters', () => {
expect(injectedStore.getters['nested:computedName']).to.equal('test computed!');
injectedStore.state.name = 'test updated';
expect(injectedStore.getters['nested:computedName']).to.equal('test updated computed!');
});
});
describe('actions', () => {
it('can be dispatched', () => {
it('can dispatch an action', () => {
expect(injectedStore.dispatch('getName', 1, 2, 3)).to.deep.equal(['test', 1, 2, 3]);
});
it('can dispatch a nested action', () => {
expect(injectedStore.dispatch('nested:getName', 1, 2, 3)).to.deep.equal(['test', 1, 2, 3]);
});
it('throws an error is the action doesn\'t exists', () => {
expect(() => injectedStore.dispatched('wrong')).to.throw;
});
@@ -116,5 +143,26 @@ describe('Store', () => {
},
});
});
it('flattenAndNamespace', () => {
let result = flattenAndNamespace({
nested: {
computed ({ state }, ...args) {
return [state.name, ...args];
},
getName ({ state }, ...args) {
return [state.name, ...args];
},
},
nested2: {
getName ({ state }, ...args) {
return [state.name, ...args];
},
},
});
expect(Object.keys(result).length).to.equal(3);
expect(Object.keys(result).sort()).to.deep.equal(['nested2:getName', 'nested:computed', 'nested:getName']);
});
});
});

View File

@@ -38,7 +38,8 @@ describe('shared.fns.ultimateGear', () => {
expect(user.addNotification).to.be.calledWith('ULTIMATE_GEAR_ACHIEVEMENT');
});
it('does not set armoirEnabled when gear is not owned', () => {
it('does not set armoireEnabled when gear is not owned', () => {
user.flags.armoireEnabled = false;
let items = {
gear: {
owned: {

View File

@@ -0,0 +1,365 @@
import shared from '../../../website/common';
import {
generateUser,
} from '../../helpers/common.helper';
describe('achievements', () => {
describe('general well-formedness', () => {
let user = generateUser();
let achievements = shared.achievements.getAchievementsForProfile(user);
it('each category has \'label\' and \'achievements\' fields', () => {
_.each(achievements, (category) => {
expect(category).to.have.property('label')
.that.is.a('string');
expect(category).to.have.property('achievements')
.that.is.a('object');
});
});
it('each achievement has all required fields of correct types', () => {
_.each(achievements, (category) => {
_.each(category.achievements, (achiev) => {
// May have additional fields (such as 'value' and 'optionalCount').
expect(achiev).to.contain.all.keys(['title', 'text', 'icon', 'earned', 'index']);
expect(achiev.title).to.be.a('string');
expect(achiev.text).to.be.a('string');
expect(achiev.icon).to.be.a('string');
expect(achiev.earned).to.be.a('boolean');
expect(achiev.index).to.be.a('number');
});
});
});
it('categories have unique labels', () => {
let achievementsArray = _.values(achievements).map(cat => cat.label);
let labels = _.uniq(achievementsArray);
expect(labels.length).to.be.greaterThan(0);
expect(labels.length).to.eql(_.size(achievements));
});
it('achievements have unique keys', () => {
let keysSoFar = {};
_.each(achievements, (category) => {
_.keys(category.achievements).forEach((key) => {
expect(keysSoFar[key]).to.be.undefined;
keysSoFar[key] = key;
});
});
});
it('achievements have unique indices', () => {
let indicesSoFar = {};
_.each(achievements, (category) => {
_.each(category.achievements, (achiev) => {
let i = achiev.index;
expect(indicesSoFar[i]).to.be.undefined;
indicesSoFar[i] = i;
});
});
});
it('all categories have at least 1 achievement', () => {
_.each(achievements, (category) => {
expect(_.size(category.achievements)).to.be.greaterThan(0);
});
});
});
describe('unearned basic achievements', () => {
let user = generateUser();
let basicAchievs = shared.achievements.getAchievementsForProfile(user).basic.achievements;
it('streak and perfect day achievements exist with counts', () => {
let streak = basicAchievs.streak;
let perfect = basicAchievs.perfect;
expect(streak).to.exist;
expect(streak).to.have.property('optionalCount')
.that.is.a('number');
expect(perfect).to.exist;
expect(perfect).to.have.property('optionalCount')
.that.is.a('number');
});
it('party up/on achievements exist with no counts', () => {
let partyUp = basicAchievs.partyUp;
let partyOn = basicAchievs.partyOn;
expect(partyUp).to.exist;
expect(partyUp.optionalCount).to.be.undefined;
expect(partyOn).to.exist;
expect(partyOn.optionalCount).to.be.undefined;
});
it('pet/mount master and triad bingo achievements exist with counts', () => {
let beastMaster = basicAchievs.beastMaster;
let mountMaster = basicAchievs.mountMaster;
let triadBingo = basicAchievs.triadBingo;
expect(beastMaster).to.exist;
expect(beastMaster).to.have.property('optionalCount')
.that.is.a('number');
expect(mountMaster).to.exist;
expect(mountMaster).to.have.property('optionalCount')
.that.is.a('number');
expect(triadBingo).to.exist;
expect(triadBingo).to.have.property('optionalCount')
.that.is.a('number');
});
it('ultimate gear achievements exist with no counts', () => {
let gearTypes = ['healer', 'rogue', 'warrior', 'mage'];
gearTypes.forEach((gear) => {
let gearAchiev = basicAchievs[`${gear}UltimateGear`];
expect(gearAchiev).to.exist;
expect(gearAchiev.optionalCount).to.be.undefined;
});
});
it('rebirth achievement exists with no count', () => {
let rebirth = basicAchievs.rebirth;
expect(rebirth).to.exist;
expect(rebirth.optionalCount).to.be.undefined;
});
});
describe('unearned seasonal achievements', () => {
let user = generateUser();
let seasonalAchievs = shared.achievements.getAchievementsForProfile(user).seasonal.achievements;
it('habiticaDays and habitBirthdays achievements exist with counts', () => {
let habiticaDays = seasonalAchievs.habiticaDays;
let habitBirthdays = seasonalAchievs.habitBirthdays;
expect(habiticaDays).to.exist;
expect(habiticaDays).to.have.property('optionalCount')
.that.is.a('number');
expect(habitBirthdays).to.exist;
expect(habitBirthdays).to.have.property('optionalCount')
.that.is.a('number');
});
it('spell achievements exist with counts', () => {
let spellTypes = ['snowball', 'spookySparkles', 'shinySeed', 'seafoam'];
spellTypes.forEach((spell) => {
let spellAchiev = seasonalAchievs[spell];
expect(spellAchiev).to.exist;
expect(spellAchiev).to.have.property('optionalCount')
.that.is.a('number');
});
});
it('quest achievements do not exist', () => {
let quests = ['dilatory', 'stressbeast', 'burnout', 'bewilder'];
quests.forEach((quest) => {
let questAchiev = seasonalAchievs[`${quest}Quest`];
expect(questAchiev).to.not.exist;
});
});
it('costumeContests achievement exists with count', () => {
let costumeContests = seasonalAchievs.costumeContests;
expect(costumeContests).to.exist;
expect(costumeContests).to.have.property('optionalCount')
.that.is.a('number');
});
it('card achievements exist with counts', () => {
let cardTypes = ['greeting', 'thankyou', 'nye', 'valentine', 'birthday'];
cardTypes.forEach((card) => {
let cardAchiev = seasonalAchievs[`${card}Cards`];
expect(cardAchiev).to.exist;
expect(cardAchiev).to.have.property('optionalCount')
.that.is.a('number');
});
});
});
describe('unearned special achievements', () => {
let user = generateUser();
let specialAchievs = shared.achievements.getAchievementsForProfile(user).special.achievements;
it('habitSurveys achievement exists with count', () => {
let habitSurveys = specialAchievs.habitSurveys;
expect(habitSurveys).to.exist;
expect(habitSurveys).to.have.property('optionalCount')
.that.is.a('number');
});
it('contributor achievement exists with value and no count', () => {
let contributor = specialAchievs.contributor;
expect(contributor).to.exist;
expect(contributor).to.have.property('value')
.that.is.a('number');
expect(contributor.optionalCount).to.be.undefined;
});
it('npc achievement is hidden if unachieved', () => {
let npc = specialAchievs.npc;
expect(npc).to.not.exist;
});
it('kickstarter achievement is hidden if unachieved', () => {
let kickstarter = specialAchievs.kickstarter;
expect(kickstarter).to.not.exist;
});
it('veteran achievement is hidden if unachieved', () => {
let veteran = specialAchievs.veteran;
expect(veteran).to.not.exist;
});
it('originalUser achievement is hidden if unachieved', () => {
let originalUser = specialAchievs.originalUser;
expect(originalUser).to.not.exist;
});
});
describe('earned seasonal achievements', () => {
let user = generateUser();
let quests = ['dilatory', 'stressbeast', 'burnout', 'bewilder'];
quests.forEach((quest) => {
user.achievements.quests[quest] = 1;
});
let seasonalAchievs = shared.achievements.getAchievementsForProfile(user).seasonal.achievements;
it('quest achievements exist', () => {
quests.forEach((quest) => {
let questAchiev = seasonalAchievs[`${quest}Quest`];
expect(questAchiev).to.exist;
expect(questAchiev.optionalCount).to.be.undefined;
});
});
});
describe('earned special achievements', () => {
let user = generateUser({
achievements: {
habitSurveys: 2,
veteran: true,
originalUser: true,
},
backer: {tier: 3},
contributor: {level: 1},
});
let specialAchievs = shared.achievements.getAchievementsForProfile(user).special.achievements;
it('habitSurveys achievement is earned with correct value', () => {
let habitSurveys = specialAchievs.habitSurveys;
expect(habitSurveys).to.exist;
expect(habitSurveys.earned).to.eql(true);
expect(habitSurveys.value).to.eql(2);
});
it('contributor achievement is earned with correct value', () => {
let contributor = specialAchievs.contributor;
expect(contributor).to.exist;
expect(contributor.earned).to.eql(true);
expect(contributor.value).to.eql(1);
});
it('npc achievement is earned with correct value', () => {
let npcUser = generateUser({
backer: {npc: 'test'},
});
let npc = shared.achievements.getAchievementsForProfile(npcUser).special.achievements.npc;
expect(npc).to.exist;
expect(npc.earned).to.eql(true);
expect(npc.value).to.eql('test');
});
it('kickstarter achievement is earned with correct value', () => {
let kickstarter = specialAchievs.kickstarter;
expect(kickstarter).to.exist;
expect(kickstarter.earned).to.eql(true);
expect(kickstarter.value).to.eql(3);
});
it('veteran achievement is earned', () => {
let veteran = specialAchievs.veteran;
expect(veteran).to.exist;
expect(veteran.earned).to.eql(true);
});
it('originalUser achievement is earned', () => {
let originalUser = specialAchievs.originalUser;
expect(originalUser).to.exist;
expect(originalUser.earned).to.eql(true);
});
});
describe('mountMaster, beastMaster, and triadBingo achievements', () => {
it('master and triad bingo achievements do not include *Text2 strings if no keys have been used', () => {
let user = generateUser();
let basicAchievs = shared.achievements.getAchievementsForProfile(user).basic.achievements;
let beastMaster = basicAchievs.beastMaster;
let mountMaster = basicAchievs.mountMaster;
let triadBingo = basicAchievs.triadBingo;
expect(beastMaster.text).to.not.match(/released/);
expect(beastMaster.text).to.not.match(/0 time\(s\)/);
expect(mountMaster.text).to.not.match(/released/);
expect(mountMaster.text).to.not.match(/0 time\(s\)/);
expect(triadBingo.text).to.not.match(/released/);
expect(triadBingo.text).to.not.match(/0 time\(s\)/);
});
it('master and triad bingo achievements includes *Text2 strings if keys have been used', () => {
let user = generateUser({
achievements: {
beastMasterCount: 1,
mountMasterCount: 2,
triadBingoCount: 3,
},
});
let basicAchievs = shared.achievements.getAchievementsForProfile(user).basic.achievements;
let beastMaster = basicAchievs.beastMaster;
let mountMaster = basicAchievs.mountMaster;
let triadBingo = basicAchievs.triadBingo;
expect(beastMaster.text).to.match(/released/);
expect(beastMaster.text).to.match(/1 time\(s\)/);
expect(mountMaster.text).to.match(/released/);
expect(mountMaster.text).to.match(/2 time\(s\)/);
expect(triadBingo.text).to.match(/released/);
expect(triadBingo.text).to.match(/3 time\(s\)/);
});
});
describe('ultimateGear achievements', () => {
it('title and text contain localized class info', () => {
let user = generateUser();
let basicAchievs = shared.achievements.getAchievementsForProfile(user).basic.achievements;
let gearTypes = ['healer', 'rogue', 'warrior', 'mage'];
gearTypes.forEach((gear) => {
let gearAchiev = basicAchievs[`${gear}UltimateGear`];
let classNameRegex = new RegExp(gear.charAt(0).toUpperCase() + gear.slice(1));
expect(gearAchiev.title).to.match(classNameRegex);
expect(gearAchiev.text).to.match(classNameRegex);
});
});
});
});

View File

@@ -1,4 +1,5 @@
import randomVal from '../../../website/common/script/libs/randomVal';
import {times} from 'lodash';
describe('randomVal', () => {
let obj;
@@ -21,23 +22,12 @@ describe('randomVal', () => {
expect(result).to.be.oneOf([1, 2, 3, 4]);
});
it('uses Math.random to determine the property', () => {
sandbox.spy(Math, 'random');
randomVal(obj);
expect(Math.random).to.be.calledOnce;
});
it('can pass in a predictable random value', () => {
sandbox.spy(Math, 'random');
let result = randomVal(obj, {
predictableRandom: 0.3,
times(30, () => {
expect(randomVal(obj, {
predictableRandom: 0.3,
})).to.equal(2);
});
expect(Math.random).to.not.be.called;
expect(result).to.equal(2);
});
it('returns a random key when the key option is passed in', () => {

View File

@@ -22,7 +22,9 @@ describe('shops', () => {
it('items contain required fields', () => {
_.each(shopCategories, (category) => {
_.each(category.items, (item) => {
expect(item).to.have.all.keys(['key', 'text', 'notes', 'value', 'currency', 'locked', 'purchaseType', 'class']);
_.each(['key', 'text', 'notes', 'value', 'currency', 'locked', 'purchaseType', 'class'], (key) => {
expect(_.has(item, key)).to.eql(true);
});
});
});
});
@@ -46,7 +48,9 @@ describe('shops', () => {
it('items contain required fields', () => {
_.each(shopCategories, (category) => {
_.each(category.items, (item) => {
expect(item).to.have.all.keys('key', 'text', 'notes', 'value', 'currency', 'locked', 'purchaseType', 'boss', 'class', 'collect', 'drop', 'unlockCondition', 'lvl');
_.each(['key', 'text', 'notes', 'value', 'currency', 'locked', 'purchaseType', 'boss', 'class', 'collect', 'drop', 'unlockCondition', 'lvl'], (key) => {
expect(_.has(item, key)).to.eql(true);
});
});
});
});
@@ -70,7 +74,9 @@ describe('shops', () => {
it('items contain required fields', () => {
_.each(shopCategories, (category) => {
_.each(category.items, (item) => {
expect(item).to.have.all.keys('key', 'text', 'value', 'currency', 'locked', 'purchaseType', 'class', 'notes', 'class');
_.each(['key', 'text', 'value', 'currency', 'locked', 'purchaseType', 'class', 'notes', 'class'], (key) => {
expect(_.has(item, key)).to.eql(true);
});
});
});
});
@@ -94,7 +100,9 @@ describe('shops', () => {
it('items contain required fields', () => {
_.each(shopCategories, (category) => {
_.each(category.items, (item) => {
expect(item).to.have.all.keys('key', 'text', 'notes', 'value', 'currency', 'locked', 'purchaseType', 'specialClass', 'type');
_.each(['key', 'text', 'notes', 'value', 'currency', 'locked', 'purchaseType', 'type'], (key) => {
expect(_.has(item, key)).to.eql(true);
});
});
});
});

View File

@@ -18,7 +18,7 @@ describe('shared.ops.blockUser', () => {
it('validates uuid', (done) => {
try {
blockUser(user, { params: { uuid: 1 } });
blockUser(user, { params: { uuid: '1' } });
} catch (error) {
expect(error.message).to.eql(i18n.t('invalidUUID'));
done();

View File

@@ -5,6 +5,7 @@ import {
} from '../../helpers/common.helper';
import count from '../../../website/common/script/count';
import buyArmoire from '../../../website/common/script/ops/buyArmoire';
import randomVal from '../../../website/common/script/libs/randomVal';
import content from '../../../website/common/script/content/index';
import {
NotAuthorized,
@@ -43,11 +44,11 @@ describe('shared.ops.buyArmoire', () => {
user.stats.exp = 0;
user.items.food = {};
sandbox.stub(Math, 'random');
sandbox.stub(randomVal, 'trueRandom');
});
afterEach(() => {
Math.random.restore();
randomVal.trueRandom.restore();
});
context('failure conditions', () => {
@@ -89,7 +90,7 @@ describe('shared.ops.buyArmoire', () => {
context('non-gear awards', () => {
it('gives Experience', () => {
let previousExp = user.stats.exp;
Math.random.returns(YIELD_EXP);
randomVal.trueRandom.returns(YIELD_EXP);
buyArmoire(user);
@@ -102,7 +103,7 @@ describe('shared.ops.buyArmoire', () => {
it('gives food', () => {
let previousExp = user.stats.exp;
Math.random.returns(YIELD_FOOD);
randomVal.trueRandom.returns(YIELD_FOOD);
buyArmoire(user);
@@ -113,7 +114,7 @@ describe('shared.ops.buyArmoire', () => {
});
it('does not give equipment if all equipment has been found', () => {
Math.random.returns(YIELD_EQUIPMENT);
randomVal.trueRandom.returns(YIELD_EQUIPMENT);
user.items.gear.owned = getFullArmoire();
user.stats.gp = 150;
@@ -131,7 +132,7 @@ describe('shared.ops.buyArmoire', () => {
context('gear awards', () => {
it('always drops equipment the first time', () => {
delete user.flags.armoireOpened;
Math.random.returns(YIELD_EXP);
randomVal.trueRandom.returns(YIELD_EXP);
expect(_.size(user.items.gear.owned)).to.equal(1);
@@ -148,7 +149,7 @@ describe('shared.ops.buyArmoire', () => {
});
it('gives more equipment', () => {
Math.random.returns(YIELD_EQUIPMENT);
randomVal.trueRandom.returns(YIELD_EQUIPMENT);
user.items.gear.owned = {
weapon_warrior_0: true,
head_armoire_hornedIronHelm: true,

View File

@@ -11,7 +11,7 @@ import {
} from '../../helpers/common.helper';
describe('shared.ops.purchase', () => {
const SEASONAL_FOOD = 'Candy_Base';
const SEASONAL_FOOD = 'Meat';
let user;
let goldPoints = 40;
let gemsBought = 40;

View File

@@ -1,4 +1,5 @@
import releaseBoth from '../../../website/common/script/ops/releaseBoth';
import content from '../../../website/common/script/content/index';
import i18n from '../../../website/common/script/i18n';
import {
generateUser,
@@ -65,19 +66,41 @@ describe('shared.ops.releaseBoth', () => {
expect(user.items.mounts[animal]).to.equal(null);
});
it('removes currentPet', () => {
it('removes drop currentPet', () => {
let petInfo = content.petInfo[user.items.currentPet];
expect(petInfo.type).to.equal('drop');
releaseBoth(user);
expect(user.items.currentMount).to.be.empty;
expect(user.items.currentPet).to.be.empty;
});
it('removes currentMount', () => {
it('removes drop currentMount', () => {
let mountInfo = content.mountInfo[user.items.currentMount];
expect(mountInfo.type).to.equal('drop');
releaseBoth(user);
expect(user.items.currentMount).to.be.empty;
});
it('leaves non-drop pets and mounts equipped', () => {
let questAnimal = 'Gryphon-Base';
user.items.currentMount = questAnimal;
user.items.currentPet = questAnimal;
user.items.pets[questAnimal] = 5;
user.items.mounts[questAnimal] = true;
let petInfo = content.petInfo[user.items.currentPet];
expect(petInfo.type).to.not.equal('drop');
let mountInfo = content.mountInfo[user.items.currentMount];
expect(mountInfo.type).to.not.equal('drop');
releaseBoth(user);
expect(user.items.currentMount).to.equal(questAnimal);
expect(user.items.currentPet).to.equal(questAnimal);
});
it('decreases user\'s balance', () => {
releaseBoth(user);

View File

@@ -1,4 +1,5 @@
import releaseMounts from '../../../website/common/script/ops/releaseMounts';
import content from '../../../website/common/script/content/index';
import i18n from '../../../website/common/script/i18n';
import {
generateUser,
@@ -37,12 +38,26 @@ describe('shared.ops.releaseMounts', () => {
expect(user.items.mounts[animal]).to.equal(null);
});
it('removes currentMount', () => {
it('removes drop currentMount', () => {
let mountInfo = content.mountInfo[user.items.currentMount];
expect(mountInfo.type).to.equal('drop');
releaseMounts(user);
expect(user.items.currentMount).to.be.empty;
});
it('leaves non-drop mount equipped', () => {
let questAnimal = 'Gryphon-Base';
user.items.currentMount = questAnimal;
user.items.mounts[questAnimal] = true;
let mountInfo = content.mountInfo[user.items.currentMount];
expect(mountInfo.type).to.not.equal('drop');
releaseMounts(user);
expect(user.items.currentMount).to.equal(questAnimal);
});
it('increases mountMasterCount achievement', () => {
releaseMounts(user);

View File

@@ -1,4 +1,5 @@
import releasePets from '../../../website/common/script/ops/releasePets';
import content from '../../../website/common/script/content/index';
import i18n from '../../../website/common/script/i18n';
import {
generateUser,
@@ -37,12 +38,26 @@ describe('shared.ops.releasePets', () => {
expect(user.items.pets[animal]).to.equal(0);
});
it('removes currentPet', () => {
it('removes drop currentPet', () => {
let petInfo = content.petInfo[user.items.currentPet];
expect(petInfo.type).to.equal('drop');
releasePets(user);
expect(user.items.currentPet).to.be.empty;
});
it('leaves non-drop pets equipped', () => {
let questAnimal = 'Gryphon-Base';
user.items.currentPet = questAnimal;
user.items.pets[questAnimal] = 5;
let petInfo = content.petInfo[user.items.currentPet];
expect(petInfo.type).to.not.equal('drop');
releasePets(user);
expect(user.items.currentPet).to.equal(questAnimal);
});
it('decreases user\'s balance', () => {
releasePets(user);

View File

@@ -1,3 +1,5 @@
/* eslint-disable camelcase */
import revive from '../../../website/common/script/ops/revive';
import i18n from '../../../website/common/script/i18n';
import {
@@ -53,7 +55,21 @@ describe('shared.ops.revive', () => {
expect(user.stats.str).to.equal(1);
});
it('TODO: test actual ways stats are affected');
it('it decreases a random stat from str, con, per, int by one', () => {
let stats = ['str', 'con', 'per', 'int'];
_.each(stats, (s) => {
user.stats[s] = 1;
});
revive(user);
let statSum = _.reduce(stats, (m, k) => {
return m + user.stats[k];
}, 0);
expect(statSum).to.equal(3);
});
it('removes a random item from user gear owned', () => {
let weaponKey = 'weapon_warrior_0';
@@ -65,15 +81,58 @@ describe('shared.ops.revive', () => {
expect(user.items.gear.owned[weaponKey]).to.be.false;
});
it('does not remove 0 value items');
it('does not remove 0 value items', () => {
user.items.gear.owned = {
eyewear_special_yellowTopFrame: true,
};
it('allows removing warrior sword (0 value item)');
revive(user);
it('does not remove items of a different class');
expect(user.items.gear.owned.eyewear_special_yellowTopFrame).to.be.true;
});
it('removes "special" items');
it('allows removing warrior sword (0 value item)', () => {
user.items.gear.owned = {
weapon_warrior_0: true,
};
it('removes "armoire" items');
let weaponKey = 'weapon_warrior_0';
let [, message] = revive(user);
expect(message).to.equal(i18n.t('messageLostItem', { itemText: content.gear.flat[weaponKey].text()}));
expect(user.items.gear.owned[weaponKey]).to.be.false;
});
it('does not remove items of a different class', () => {
let weaponKey = 'weapon_wizard_1';
user.items.gear.owned[weaponKey] = true;
let [, message] = revive(user);
expect(message).to.equal('');
expect(user.items.gear.owned[weaponKey]).to.be.true;
});
it('removes "special" items', () => {
let weaponKey = 'weapon_special_1';
user.items.gear.owned[weaponKey] = true;
let [, message] = revive(user);
expect(message).to.equal(i18n.t('messageLostItem', { itemText: content.gear.flat[weaponKey].text()}));
expect(user.items.gear.owned[weaponKey]).to.be.false;
});
it('removes "armoire" items', () => {
let weaponKey = 'armor_armoire_goldenToga';
user.items.gear.owned[weaponKey] = true;
let [, message] = revive(user);
expect(message).to.equal(i18n.t('messageLostItem', { itemText: content.gear.flat[weaponKey].text()}));
expect(user.items.gear.owned[weaponKey]).to.be.false;
});
it('dequips lost item from user if user had it equipped', () => {
let weaponKey = 'weapon_warrior_0';

View File

@@ -0,0 +1,29 @@
import _ from 'lodash';
import {
generateUser,
} from '../helpers/common.helper';
import timeTravelers from '../../website/common/script/content/time-travelers'
describe('time-travelers store', () => {
let user;
beforeEach(() => {
user = generateUser();
});
it('removes owned sets from the time travelers store', () => {
user.items.gear.owned['head_mystery_201602'] = true;
expect(timeTravelers.timeTravelerStore(user)['201602']).to.not.exist;
expect(timeTravelers.timeTravelerStore(user)['201603']).to.exist;
});
it('removes unopened mystery item sets from the time travelers store', () => {
user.purchased = {
plan: {
mysteryItems: ['head_mystery_201602'],
},
};
expect(timeTravelers.timeTravelerStore(user)['201602']).to.not.exist;
expect(timeTravelers.timeTravelerStore(user)['201603']).to.exist;
});
});

View File

@@ -1,5 +1,4 @@
/* eslint-disable no-use-before-define */
// Import requester function, set it up for v3, export it
import { requester } from '../requester';
requester.setApiVersion('v3');

View File

@@ -15,25 +15,3 @@ global.expect = chai.expect;
global.sinon = require('sinon');
global.sandbox = sinon.sandbox.create();
global.Promise = Bluebird;
import nconf from 'nconf';
import mongoose from 'mongoose';
//------------------------------
// Load nconf for unit tests
//------------------------------
if (process.env.LOAD_SERVER === '0') { // when the server is in a different process we simply connect to mongoose
require('../../website/server/libs/setupNconf')('./config.json');
// Use Q promises instead of mpromise in mongoose
mongoose.Promise = Bluebird;
mongoose.connect(nconf.get('TEST_DB_URI'));
} else { // When running tests and the server in the same process
require('../../website/server/libs/setupNconf')('./config.json.example');
nconf.set('NODE_DB_URI', nconf.get('TEST_DB_URI'));
nconf.set('NODE_ENV', 'test');
nconf.set('IS_TEST', true);
// We require src/server and npt src/index because
// 1. nconf is already setup
// 2. we don't need clustering
require('../../website/server/server');
}

View File

@@ -0,0 +1,21 @@
/* eslint-disable no-process-env */
import nconf from 'nconf';
import mongoose from 'mongoose';
import Bluebird from 'bluebird';
import setupNconf from '../../website/server/libs/setupNconf';
if (process.env.LOAD_SERVER === '0') { // when the server is in a different process we simply connect to mongoose
setupNconf('./config.json');
// Use Q promises instead of mpromise in mongoose
mongoose.Promise = Bluebird;
mongoose.connect(nconf.get('TEST_DB_URI'));
} else { // When running tests and the server in the same process
setupNconf('./config.json.example');
nconf.set('NODE_DB_URI', nconf.get('TEST_DB_URI'));
nconf.set('NODE_ENV', 'test');
nconf.set('IS_TEST', true);
// We require src/server and npt src/index because
// 1. nconf is already setup
// 2. we don't need clustering
require('../../website/server/server'); // eslint-disable-line global-require
}

View File

@@ -7,8 +7,8 @@ const STRING_DOES_NOT_EXIST_MSG = /^String '.*' not found.$/;
// Use this to verify error messages returned by the server
// That way, if the translated string changes, the test
// will not break. NOTE: it checks against errors with string as well.
export function translate (key, variables) {
let translatedString = i18n.t(key, variables);
export function translate (key, variables, language) {
let translatedString = i18n.t(key, variables, language);
expect(translatedString).to.not.be.empty;
expect(translatedString).to.not.eql(STRING_ERROR_MSG);

View File

@@ -2,6 +2,7 @@ var path = require('path');
var config = require('./config');
var utils = require('./utils');
var projectRoot = path.resolve(__dirname, '../');
var webpack = require('webpack');
var IS_PROD = process.env.NODE_ENV === 'production';
var baseConfig = {
@@ -17,6 +18,7 @@ var baseConfig = {
extensions: ['', '.js', '.vue'],
fallback: [path.join(__dirname, '../node_modules')],
alias: {
jquery: 'jquery/src/jquery',
client: path.resolve(__dirname, '../website/client'),
assets: path.resolve(__dirname, '../website/client/assets'),
components: path.resolve(__dirname, '../website/client/components'),
@@ -25,6 +27,12 @@ var baseConfig = {
resolveLoader: {
fallback: [path.join(__dirname, '../node_modules')],
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),
],
module: {
preLoaders: !IS_PROD ? [
{
@@ -79,6 +87,9 @@ var baseConfig = {
require('autoprefixer')({
browsers: ['last 2 versions'],
}),
require('postcss-easy-import')({
glob: true,
}),
],
},
};

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Before

Width:  |  Height:  |  Size: 794 B

After

Width:  |  Height:  |  Size: 794 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Some files were not shown because too many files have changed in this diff Show More