Compare commits

...

292 Commits

Author SHA1 Message Date
Sabe Jones
c3e41cc5e1 4.27.2 2018-02-16 03:07:52 +00:00
Sabe Jones
cae0120beb chore(i18n): update locales 2018-02-16 03:01:42 +00:00
SabreCat
10b978da4e fix(spoilers): don't reveal quest boss rewards 2018-02-16 02:56:08 +00:00
SabreCat
5987145b86 fix(phobia): show censored art as needed 2018-02-14 22:35:14 +00:00
Sabe Jones
ff65c4da78 4.27.1 2018-02-14 20:55:12 +00:00
Sabe Jones
163d56afe9 chore(i18n): update locales 2018-02-14 20:54:50 +00:00
SabreCat
2f46d1bc65 chore(sprites): compile 2018-02-14 20:48:48 +00:00
SabreCat
6ccb841b32 chore(news): Bailey text 2018-02-14 20:47:47 +00:00
Sabe Jones
cdcee8d169 World boss client (#9999)
* WIP(world-boss): client components partial

* WIP(world-boss): more client additions

* WIP(world-boss): some beautification

* WIP(world-boss): more Tavern beauty

* fix(world-boss): gradient adjustment

* fix(style): various WB tweaks

* fix(world-boss): better resolution Rage Strike

* fix(world-boss): alignment fixes

* Added world boss modal

* feat(world-boss): add info button

* fix(world-boss): move SVG and tweak padding
2018-02-14 13:43:10 -06:00
Sabe Jones
fd5ab32c43 4.27.0 2018-02-14 02:30:55 +00:00
Sabe Jones
e0933dc0a1 chore(i18n): update locales 2018-02-14 02:29:58 +00:00
Sabe Jones
d69e7e66ee World Boss 2018 (Server) (#9995)
* feat(world-boss): barebones API

* fix(world): use Express respond for better JSON

* fix(api): respond with code 200

* feat(content): canonical Dysheartener desc and Rage

* fix(world-boss): enable progress

* WIP(test): world state API

* WIP(test): refactor world boss setup

* WIP(test): better expectations

* fix(test): more expect polishing

* feat(event): server side World Boss

* fix(strings): accidental deletion

* fix(content): include encouragement after Rage

* refactor(world-boss): address comments
2018-02-13 19:21:39 -06:00
Matteo Pagliazzi
fa06628361 add new locales 2018-02-13 12:41:47 +01:00
Matteo Pagliazzi
7f1067e1ab chore(i18n): update locales 2018-02-13 12:40:05 +01:00
Matteo Pagliazzi
db6644a572 chore(i18n): update locales 2018-02-13 12:35:05 +01:00
Sabe Jones
b7b8faedd6 4.26.3 2018-02-12 22:07:52 +00:00
Sabe Jones
7da0b641dd chore(i18n): update locales 2018-02-12 22:07:00 +00:00
SabreCat
82ff241e39 chore(sprites): compile 2018-02-12 21:58:54 +00:00
SabreCat
cf4aaf1618 feat(event): enable Valentines 2018-02-12 21:56:29 +00:00
Sabe Jones
31eeb13598 4.26.2 2018-02-10 11:56:30 +00:00
Sabe Jones
818c201afe chore(i18n): update locales 2018-02-10 11:46:36 +00:00
Sabe Jones
f78bcc20c9 chore(i18n): update locales 2018-02-10 05:18:40 +00:00
Keith Holliday
9017eea0c4 4.26.1 2018-02-09 10:05:12 -06:00
Keith Holliday
92abb19f9c Docker update (#9976)
* Updated docker prod

* Added new gulp cli
2018-02-09 08:59:49 -07:00
Keith Holliday
3bee0446b8 Loaded profile when not cached (#9977) 2018-02-09 08:57:55 -07:00
Sabe Jones
e1e5a6cc34 4.26.0 2018-02-09 00:58:23 +00:00
Sabe Jones
9eb70ee9ba Merge branch 'develop' into release 2018-02-09 00:58:13 +00:00
Sabe Jones
7485300ee9 chore(i18n): update locales 2018-02-09 00:43:01 +00:00
SabreCat
762c202154 feat(content): enable Cupid Potions 2018-02-09 00:35:51 +00:00
Matteo Pagliazzi
7613e50917 remove mongoskin and mongodb packages 2018-02-08 19:10:01 +01:00
Matteo Pagliazzi
4c77434bf0 Upgrade karma and related deps (#9974)
* upgrade karma and karma babel

* upgrade karma-chai

* upgrade karma-coverage

* upgrade karma-mocha

* upgrade karma-mocha-reporter

* upgrade karma-sinon-chai

* upgrade karma-spec-reporter
2018-02-08 19:02:19 +01:00
Matteo Pagliazzi
1ab26a200e Upgrade tests packages (#9973)
* upgrade mochat to v5

* upgrade cross-spawn

* upgrade chalk

* try to fix mongoose

* upgrade shelljs

* upgrade expect.js

* upgrade coveralls

* upgrade cross-env

* upgrade lcov-result-merger

* upgrade image-size
2018-02-08 19:00:49 +01:00
Matteo Pagliazzi
b738824f76 fix indentation in app.vue 2018-02-07 18:47:14 +01:00
Sabe Jones
694c440b55 Merge branch 'release' into develop 2018-02-07 02:16:48 +00:00
Sabe Jones
667bb28fe3 4.25.0 2018-02-07 02:16:24 +00:00
Sabe Jones
8993337ad7 chore(i18n): update locales 2018-02-07 02:15:58 +00:00
SabreCat
a251a5d089 chore(sprites): compile 2018-02-07 02:04:37 +00:00
SabreCat
dcdeec6256 feat(content): Badger Pet Quest 2018-02-07 02:03:30 +00:00
SabreCat
9fd0df9f2f fix(food): add missing text functions to Bare Bones Cake 2018-02-06 20:34:33 +00:00
Matteo Pagliazzi
1061fb0c31 remove async (only used for old migrations) (#9961) 2018-02-06 18:13:13 +01:00
Keith Holliday
c14fdd3fed Fixed attribute binding. Removed member url (#9963) 2018-02-06 09:53:43 -07:00
Alys
e219ad6bdf adjust slurs / banned words. TRIGGER / CONTENT WARNING: assault, slurs, swearwords, etc 2018-02-06 08:40:31 +10:00
Alys
42d7fd0861 fix typo in equipment description (Armorie) 2018-02-06 08:37:39 +10:00
Nathan Sollenberger
7ade91a8b8 Updates notification text for armoire items in shops:genericPurchase. (#9240)
Adjusts column widths for 'drop' type notifications to prevent .text from overlapping .icon-item.
Adds new 'flavorMessage' property to Snackbar notifications, which overrides standard computed message.
Vertically center XP gain icon/amount.
Fixes unrelated typo in i18n key name.
2018-02-05 19:43:30 +01:00
Feywood
7c6dd6a6bd (in)definite articles for food items. Partial fix for https://github.com/HabitRPG/habitica/issues/3571 (#9658)
* testing additional event trigger for sendMessage

* moved keyup event to newmessage

* added keyup event to tavern vue too

* all food items now have version with definite and indefinite article. foodText also adapted in messages json

* modified api.food, and feed, armoire and drop mechanism

* drops now ok, removed dropArticle, corrected feed test

* test correction

* api doc modification for task completion
2018-02-05 19:43:12 +01:00
Jon Lim
9a00779698 Adding support for loading more members for Groups (#9740)
* Adding support for loading more members for Groups

Addresses issue #9720

Member modal component was only loading the maximum limit for queries
made to _getMembersForItem in /members, except with Challenges, which
was able to display a "Load More" button to retrieve another set of
users from the Challenge.

Made a few changes to how the GET request was being made when querying
for more members, added an easier way to know whether or not to display
the Load More button, and extracted some of the actions that were
too tightly coupled with the membersModal.vue.

* Fixes for failing lint tests

* Removing unnecessary async/await usage

* Fixing party view in header section

* Resolving missed conflict

* Adding necessary data for View Party in index header for web client to load party members
2018-02-05 19:42:54 +01:00
Lula Villalobos
a61d911c48 Feature - Store Exact Completion Date For Dailies (#9813)
* dailies history date added in scoreTask instead of cron

* fix lint issues

* changes based on feedback. Undo cron code deletion and deleted iteration on scoreTask

* fix lint issues

* add task history entry in cron for dailies that weren't completed

* add history entry after value is fully evaluated
2018-02-05 19:42:20 +01:00
Alexey Pyltsyn
fbacb56700 Fixed footer to bottom of page (#9860) 2018-02-05 19:42:01 +01:00
Alexey Pyltsyn
185717e6c3 Fixed a task tag tooltip position (#9910) 2018-02-05 19:41:46 +01:00
Mason Hahn
505dd4969d add contributor info for inbox tier styling (#9911) 2018-02-05 19:41:28 +01:00
Feywood
944e4fe399 collection items shown in quest progress (#9945) 2018-02-05 19:41:11 +01:00
Keith Holliday
804dd087f8 Updated notes on armoire when purchasing (#9891) 2018-02-05 10:27:10 -07:00
Keith Holliday
cb1136aadc Added markdown to tag edit fields/popup (#9867) 2018-02-05 09:54:42 -07:00
Keith Holliday
0f4b8f5f30 Added summary field tests (#9883)
* Added summary field tests

* Fixed typo
2018-02-05 09:52:44 -07:00
Keith Holliday
2d612b655d Added copy as todo (#9884) 2018-02-05 09:43:00 -07:00
negue
46877fb20c Purchase Card: fixes (#9803)
* prevent re-showing buy-modal after buying a card / fix class-badge in member-selection

* show notifications on card purchase

* move string to generic.json

* translation param "profileName"
2018-02-05 09:39:42 -07:00
Keith Holliday
38cded2083 4.24.6 2018-02-04 23:03:51 -06:00
Matteo Pagliazzi
65074df668 fix build task 2018-02-04 19:30:30 +01:00
Matteo Pagliazzi
b0ab09c352 Upgrade gulp (and gulp deps) (#9950)
* upgrade gulp to v4

* fix imagemin

* fixes
2018-02-04 18:18:10 +01:00
Matteo Pagliazzi
3a60e8de66 Merge branch 'develop' of github.com:HabitRPG/habitrpg into develop 2018-02-04 15:54:35 +01:00
Matteo Pagliazzi
886a96dac9 Merge branch 'release' into develop 2018-02-04 15:53:40 +01:00
Matteo Pagliazzi
20556e2af4 refactor casting spells on the client side (#9949) 2018-02-04 15:51:17 +01:00
Matteo Pagliazzi
3e849ec9a8 Revert "refactor casting spells on the client side (#9921)" (#9948)
This reverts commit 03946e6a87.
2018-02-04 15:50:36 +01:00
Matteo Pagliazzi
03946e6a87 refactor casting spells on the client side (#9921) 2018-02-04 14:47:34 +01:00
Matteo Pagliazzi
fdcc69fe4a Merge branch 'upgrade-universal-analytics' into develop 2018-02-04 14:45:31 +01:00
Matteo Pagliazzi
322b6a5e44 Merge branch 'develop' into upgrade-universal-analytics 2018-02-04 14:45:20 +01:00
Matteo Pagliazzi
2243a2f3dc upgrade winston-loggly-bulk (#9942) 2018-02-04 14:40:33 +01:00
Matteo Pagliazzi
59c848add5 upgrade request (#9941) 2018-02-04 14:39:54 +01:00
Matteo Pagliazzi
2d6a1fe709 remove jade, upgrade pug (#9940) 2018-02-04 14:39:46 +01:00
Matteo Pagliazzi
fac0338437 Merge branch 'release' into develop 2018-02-04 14:39:30 +01:00
Matteo Pagliazzi
e46f30894c fix test timeout 2018-02-04 14:39:16 +01:00
Matteo Pagliazzi
553dc116c5 Merge branch 'release' into develop 2018-02-04 14:21:35 +01:00
Matteo Pagliazzi
2029cd884c notifications: fix tests 2018-02-04 14:20:12 +01:00
Matteo Pagliazzi
ab89941ed5 notifications: fix tests 2018-02-04 14:04:41 +01:00
Matteo Pagliazzi
5dc0f5bb9b Merge branch 'release' into develop 2018-02-04 13:41:53 +01:00
Matteo Pagliazzi
d46a7ba985 notifications: fix typos and add extra check 2018-02-04 13:40:49 +01:00
Matteo Pagliazzi
86b3228a59 Merge branch 'release' into develop 2018-02-04 13:28:34 +01:00
Matteo Pagliazzi
4efbbd7bac notifications: fixes 2018-02-04 13:28:05 +01:00
Matteo Pagliazzi
d39e8a3587 upgrade universal-analytics 2018-02-03 22:40:40 +01:00
Matteo Pagliazzi
8bd3ef6f24 fix mongoose options 2018-02-03 22:17:10 +01:00
Matteo Pagliazzi
6d0917964b fix mongoose options 2018-02-03 22:15:40 +01:00
Sabe Jones
d463e2373e Merge branch 'release' into develop 2018-02-02 20:51:24 +00:00
Sabe Jones
2af99d7c65 4.24.5 2018-02-02 19:53:57 +00:00
Keith Holliday
4e01b14874 Removed required fields from user notifications (#9929) 2018-02-02 12:31:52 -07:00
Keith Holliday
944781c2f8 Added p parameter to group party query (#9857) 2018-02-02 11:24:41 -07:00
Keith Holliday
027eed1b25 Reset market on gear purchase (#9855) 2018-02-02 11:22:25 -07:00
Keith Holliday
803f63d991 Added two handed message to weapons (#9839)
* Added two handed message to weapons

* Added two handed message to content api

* Fixed static notes text. Added support for RTL
2018-02-02 11:21:53 -07:00
Keith Holliday
78ad1cd8b0 Added cache for user styles on chat (#9679)
* Added cache for user styles on chat

* Added loading on new message and other minor checks

* Added null checks

* Updated chat tests

* Added costume preference to chat

* Removed single profile cacheing for new chat messages

* Remove owned gear from cache

* Updated stats to only use buffs
2018-02-02 11:18:25 -07:00
Sabe Jones
a3ddd0746c 4.24.4 2018-02-02 16:55:55 +00:00
SabreCat
94845ec629 fix(event): remove seasonal pinned items 2018-02-02 16:54:25 +00:00
Sabe Jones
7e63856e64 4.24.3 2018-02-02 16:44:09 +00:00
Matteo Pagliazzi
3727d69d51 Merge branch 'release' into develop 2018-02-02 16:38:27 +01:00
Matteo Pagliazzi
1fbdb7dbd0 Mongoose 4.x (#9928)
* update mongoose to ^4.x

* another fix
2018-02-02 16:37:36 +01:00
Matteo Pagliazzi
b430b6ccb6 Revert "Mongoose 4.13 (#9926)" (#9927)
This reverts commit 7859f20a40.
2018-02-02 16:36:54 +01:00
Matteo Pagliazzi
7859f20a40 Mongoose 4.13 (#9926)
* update mongoose to ^4.x

* another fix
2018-02-02 16:35:05 +01:00
Matteo Pagliazzi
389d6f18b4 travis split unit and integration tests (#9925) 2018-02-02 15:07:39 +01:00
Sabe Jones
fd1d1da509 Revert "fix(test): update for event"
This reverts commit ede28ac33a.
2018-02-02 12:09:45 +00:00
Matteo Pagliazzi
014b367f56 do not use lodash to find notification 2018-02-02 12:24:43 +01:00
Matteo Pagliazzi
4580b33e43 fix progress bar hidden behind the menu 2018-02-02 09:57:39 +01:00
Sabe Jones
48bcc1e968 4.24.2 2018-02-02 03:35:00 +00:00
Sabe Jones
35368eb6ad chore(i18n): update locales 2018-02-02 03:33:27 +00:00
Sabe Jones
9b337983ed fix(strings): Capital Party, comrade 2018-02-02 03:27:19 +00:00
Sabe Jones
cd4951d204 fix(notifs): brevity 2018-02-02 03:19:13 +00:00
Sabe Jones
bd83d6f5aa 4.24.1 2018-02-02 01:51:08 +00:00
Sabe Jones
9c241a6159 fix(classes): remove winter preview
Also adds a new index to the Mongo doc and fixes a typo in that file.
2018-02-02 01:49:33 +00:00
Sabe Jones
7a6baeadbd 4.24.0 2018-02-02 00:48:36 +00:00
Sabe Jones
5495acea96 chore(i18n): update locales 2018-02-02 00:46:45 +00:00
SabreCat
a3aa2cc175 chore(sprites): compile 2018-02-02 00:33:04 +00:00
SabreCat
8b0d02a16b feat(content): backgrounds and Armoire Feb 2018
Also ends Winter Wonderland event
2018-02-02 00:31:38 +00:00
SabreCat
c3c0eb974a Merge branch 'develop' into release 2018-02-02 00:29:58 +00:00
Keith Holliday
56539100e3 Fixed zindex for progress bar (#9922) 2018-02-01 18:12:34 -06:00
SabreCat
b706db43e4 Merge branch 'release' into develop 2018-02-01 21:09:57 +00:00
Keith Holliday
3e0a7c70ed Event off fixes (#9918)
* Added removes for all events

* Moved to beforeDestroy
2018-02-01 10:14:21 -07:00
Sabe Jones
6a5bd1b0a5 Merge branch 'release' into develop 2018-01-31 22:23:15 +00:00
Sabe Jones
7f8a9be766 4.23.2 2018-01-31 22:20:51 +00:00
Sabe Jones
dbdf679e4a chore(i18n): update locales 2018-01-31 22:20:39 +00:00
SabreCat
eb28dfadf9 chore(news): Last Chance Bailey
Also fixes a linting issue with birthday fun.
2018-01-31 22:10:50 +00:00
SabreCat
ede28ac33a fix(test): update for event 2018-01-31 22:00:54 +00:00
Matteo Pagliazzi
33b249d078 Notifications v2 and Bailey API (#9716)
* Added initial bailey api

* wip

* implement new panel header

* Fixed lint

* add ability to mark notification as seen

* add notification count, remove top badge from user and add ability to mark multiple notifications as seen

* add support dismissall and mark all as read

* do not dismiss actionable notif

* mark as seen when menu is opened instead of closed

* implement ordering, list of actionable notifications

* add groups messages and fix badges count

* add notifications for received cards

* send card received notification to target not sender

* rename notificaion field

* fix integration tests

* mark cards notifications as read and update tests

* add mystery items notifications

* add unallocated stats points notifications

* fix linting

* simplify code

* refactoring and fixes

* fix dropdown opening

* start splitting notifications into their own component

* add notifications for inbox messages

* fix unit tests

* fix default buttons styles

* add initial bailey support

* add title and tests to new stuff notification

* add notification if a group task needs more work

* add tests and fixes for marking a task as needing more work

* make sure user._v is updated

* remove console.log

* notification: hover status and margins

* start styling notifications, add separate files and basic functionalities

* fix tests

* start adding mystery items notification

* wip card notification

* fix cards text

* initial implementation inbox messages

* initial implementation group messages

* disable inbox notifications until mobile is ready

* wip group chat messages

* finish mystery and card notifications

* add bailey notification and fix a lot of stuff

* start adding guilds and parties invitations

* misc invitation fixes

* fix lint issues

* remove old code and add key to notifications

* fix tests

* remove unused code

* add link for public guilds invite

* starts to implement needs work notification design and feature

* fixes to needs work, add group task approved notification

* finish needs work feature

* lots of fixes

* implement quest notification

* bailey fixes and static page

* routing fixes

* fixes #      this.$store.dispatch(guilds:join, {groupId: group.id, type: party});

* read notifications on click

* chat notifications

* fix tests for chat notifications

* fix chat notification test

* fix tests

* fix tests (again)

* try awaiting

* remove only

* more sleep

* add bailey tests

* fix icons alignment

* fix issue with multiple points notifications

* remove merge code

* fix rejecting guild invitation

* make remove area bigger

* fix error with notifications and add migration

* fix migration

* fix typos

* add cleanup migration too

* notifications empty state, new counter color, fix marking messages as seen in guilds

* fixes

* add image and install correct packages

* fix mongoose version

* update bailey

* typo

* make sure chat is marked as read after other requests
2018-01-31 11:55:39 +01:00
Matteo Pagliazzi
a85282763f Upgrade sinonjs (and related libs) (#9914)
* update sinon

* remove errors

* fix unit tests
2018-01-31 10:56:32 +01:00
Sabe Jones
ba9d7b3b5e 4.23.1 2018-01-31 00:53:27 +00:00
Sabe Jones
3b794c017a fix(event): update birthday vars and hooks 2018-01-31 00:41:06 +00:00
SabreCat
47dbe4561f fix(test): update for event 2018-01-30 22:22:02 +00:00
Sabe Jones
97135a1ac3 Merge branch 'release' into develop 2018-01-30 21:38:56 +00:00
Sabe Jones
a636e15d11 4.23.0 2018-01-30 21:38:34 +00:00
Sabe Jones
3cc15e869e chore(i18n): update locales 2018-01-30 21:38:00 +00:00
SabreCat
88c8b92a68 chore(sprites): compile 2018-01-30 21:26:15 +00:00
SabreCat
cee4d7e87b feat(event): Habit Birthday 2018 2018-01-30 21:25:19 +00:00
Matteo Pagliazzi
9488ec2eb0 Merge branch 'release' into develop 2018-01-30 18:56:25 +01:00
Keith Holliday
4fe6c8db64 Clone challenges api (#9684)
* Added clone api

* Added new clone UI

* Fixed challenge clone

* Fixed lint and added mongo toObject

* Removed clone field, fixed type, fixed challenge task query

* Auto selected group

* Accounted for group balance when creating challenge

* Added check for if user is leader of guild

* Added leader existence check

* Added fix for leader and prizecost equal to
2018-01-30 08:23:20 -07:00
Keith Holliday
ccf8e0b320 Removed gitattributes 2018-01-29 21:34:18 -06:00
Matteo Pagliazzi
1dc558ddba prevent ex-participants appearing in challenge export file - Fix #9844 (#9846)
* possible fix for 9844

* fix typo in challengeModal file

* remove lines for empty users
2018-01-29 16:23:40 -06:00
Alexey Pyltsyn
ae27ae0090 Improved Party page UI (#9892) 2018-01-29 15:44:22 -06:00
Alys
47c2a3a21a prevent "Zero-day streak" giving a 21-day streak achievement + tests - fixes #2578 (#9688)
* prevent "Zero-day streak" giving a 21-day streak achievement - fixes #2578

* add tests for streak achievements

* remove .only from set of tests

* refactor(test): fix linting
2018-01-29 15:43:59 -06:00
Cassidy Pignatello
5d4e1362bb updates Orb of Rebirth description to more accurately list its effects (#9894) 2018-01-29 15:32:21 -06:00
James Hwang
25cecf298f Fixed formatting of modal strings to correctly display message #9818 (#9862) 2018-01-29 15:30:05 -06:00
Alexey Pyltsyn
2de3b63e87 Fixed a community guidelines layout (#9893)
* Fixed a community guidelines layout

* Refactoring: add community guidelines component
2018-01-29 15:18:20 -06:00
John Zhou
7abb8a81a7 Do not show visual buffs on choose class avatars (#9812) 2018-01-29 15:16:49 -06:00
Daniel Reeves
3eb3891899 Update copyright year 2017->2018 (#9889) 2018-01-29 15:14:00 -06:00
Alexey Pyltsyn
4b0ad422f1 Use translatable strings in footer (#9866) 2018-01-29 15:11:30 -06:00
Alexey Pyltsyn
3c603e3bb1 Fixed horizontal scrollbar (#9853) 2018-01-29 15:07:59 -06:00
Nicole Massaro
4ee788f541 Hide stats points allocation on locked or disabled class system (#9826) (#9851) 2018-01-29 15:05:06 -06:00
Sabe Jones
99ab9726b4 Allow user to buy numbered special gear (#9823)
* fix(buy): allow user to buy numbered special gear

* fix(buy): correct content constant
2018-01-29 15:02:55 -06:00
Maru de Vera
23dd402e79 Unpin Regained Items from Enchanted Armoire (#9766) 2018-01-29 15:00:19 -06:00
Irina Brennen
6bd90807f3 Fixing issue with hair bangs, styles and colors not getting the option.active class (#9759) 2018-01-29 14:57:35 -06:00
Alys
563a5845f0 refund gems when deleting a "Public Challenge" (Tavern challenge) (#9752) 2018-01-29 14:56:46 -06:00
Brad Lugo
2e580baf27 Update the docker compose process (#9724)
Since the client side code and server side code run independently, the
docker compose process needed to be updated to reflect this change.
This fix included updating the docker-compose files' versions.
2018-01-29 14:56:08 -06:00
Clement134
44ded25f6d Add .gitattributes file fixes #9717 (#9722)
* chore(gitattributes): add .gitattributes file

*  chore(gitattributes): specify file type for each extension

* fix(presskit): use LF line endings
2018-01-29 14:53:14 -06:00
Alys
70da5940a7 clarify that "Leave" refers to guild/party; fix pluralisation in keep/remove challenge tasks (#9706)
* change "Keep/Remove It" to "Keep/Remove Them" when asking about all challenge tasks while leaving a challenge

* change "Leave" button on groups to "Leave Guild" or "Leave Party"

This is because the button is underneath the challenges so this
clarifies that it is referring to the group, not a challenge.

* change "Keep/Remove Them" to "Keep/Remove Tasks"
2018-01-29 14:52:28 -06:00
Cai Lu
12aa8a78c1 Track sleeping in the inn with analytics (fixes #9561) (#9685)
* Sleep status is tracked by analytics when toggled.

* Modify test: test that analytics is called with 'sleep' event and data passed includes the user's new sleep status
2018-01-29 14:48:24 -06:00
Keith Holliday
94619737e8 Adjusted zindex of navbar to be above snackbars and modals (#9873) 2018-01-29 08:25:07 -07:00
Alys
ccc9e6611c adjust terminology in delete To-Dos message; move similar messages together 2018-01-28 12:29:24 +10:00
Keith Holliday
1f1459b0d8 4.22.1 2018-01-27 11:31:59 -06:00
Keith Holliday
6489e74b6b Added tests for new username restrictions (#9900) 2018-01-27 10:30:17 -07:00
Alys
c1e264955f describe Login Name limitations on Registration form and Add Local Auth form (#9896)
* describe Login Name limitations on registration form and Add Local Auth form

* adjust text in response to this change: c69687f935

* update max length
2018-01-27 09:38:23 -07:00
Alys
f302d15bc4 add length and character limitations for login name (username) (#9895)
* update API comments to for `username` restrictions and to use Login Name terminology

We use "login name" rather than "username" in user-visible text
on the website and (usually) when communicating with users because
"username" could be confused with "profile name".
Using it in the docs allows you to search for that term.

* add alphanumeric and length validation for creating new login name (username)

The 'en-US' locale is specified explicitly to ensure we never use
another locale. The point of this change is to limit the character
set to prevent login names being used to send spam in the Welcome
emails, such as Chinese language spam we've had trouble with.

* add error messages for bad login names

* allow login name to also contain hyphens

This is because our automated tests generate user accounts using:
  let username = generateUUID();

* allow login names to be up to 36 characters long because we use UUIDs as login names in our tests

* revert back to using max 20 characters and only a-z, 0-9 for login name.

It's been decided to change the username generation in the tests instead.

* disable test that is failing because it's redundant

Spaces are now prohibited by other code.

We can probably delete this test later. I don't want to delete it
now, but instead give us time to think about that.

* fix typos

* revert to login name restrictions that allow us to keep using our existing test code

I'm really not comfortable changing our test suite in ways that
aren't essential, especially since we're working in a hurry with
a larger chance than normal of breaking things.
The 36 character length is larger than we initially decided but
not so much larger that it's a huge problem.
We can reduce it to 20 when we have more time.

* limit username length to 20 chars

* fix tests
2018-01-27 09:33:56 -07:00
Keith Holliday
8c70c8839b 4.22.0 2018-01-25 17:35:45 -06:00
Keith Holliday
3fcd04fd8a Updated encryption 2018-01-25 17:33:50 -06:00
Sabe Jones
d85f18751c chore(i18n): update locales 2018-01-25 23:26:24 +00:00
SabreCat
1390c4eae5 Merge branch 'develop' into release 2018-01-25 23:20:01 +00:00
Sabe Jones
18ade8ca65 Analytics: track challenge and task events (#9885)
* feat(analytics): track challenge and task events

* feat(analytics): add more challenge events
Also tweaks data for better troubleshooting utility

* refactor(analytics): include IDs for challenges/groups

* refactor(analytics): term for award challenge is "close"
2018-01-25 17:14:41 -06:00
Keith Holliday
7b026fa32c Added existence check for lastMessageText (#9886) 2018-01-25 13:46:49 -07:00
Keith Holliday
33698c219f Added existence check for lastMessageText (#9881) 2018-01-25 11:33:37 -07:00
Matteo Pagliazzi
b76d731cee fix gold icon alignment 2018-01-25 16:53:53 +01:00
Matteo Pagliazzi
4d1ac51543 upgrade datepicker 2018-01-25 15:13:21 +01:00
Matteo Pagliazzi
3818fbdd3e update boostrap and bootstrap-vue (no breaking changes) 2018-01-24 19:08:07 +01:00
Sabe Jones
af245b63d9 Merge branch 'release' into develop 2018-01-24 01:31:27 +00:00
Sabe Jones
028da1d6a9 4.21.0 2018-01-23 23:07:20 +00:00
Sabe Jones
49397244c4 chore(i18n): update locales 2018-01-23 23:07:05 +00:00
SabreCat
2b04ed3246 feat(content): Mystery Items 2018/01 2018-01-23 22:38:23 +00:00
Keith Holliday
51aebb540c Removed display of users personal checklist on challenge tasks (#9837) 2018-01-23 10:55:55 -07:00
Keith Holliday
f5d7777b2c Reloaded user data after cancelling subscription (#9836) 2018-01-23 10:28:44 -07:00
Keith Holliday
be1ffbd671 Removed promot to leader from challenge member modal (#9831) 2018-01-23 09:58:12 -07:00
Keith Holliday
5640139ef1 Awaited unlink so the UI refreshes removed tasks (#9815) 2018-01-23 09:36:46 -07:00
Keith Holliday
0959499450 Changed width to maxwidth (#9830) 2018-01-22 09:15:55 -07:00
Keith Holliday
90ffe587dd Added analytics to drop (#9792)
* Added analytics to drop

* Updated tracking category
2018-01-22 09:15:23 -07:00
Keith Holliday
38aafb6c7b Added clear completed todos (#9782) 2018-01-22 08:28:42 -07:00
Keith Holliday
ecfcf09184 Added more responsive styles to filters (#9820) 2018-01-22 08:20:34 -07:00
Keith Holliday
7083dc7e05 Added resync for completed todos (#9821) 2018-01-22 08:19:47 -07:00
Keith Holliday
d4e0417c48 Added challenge tag when challenge task is added to existing challenge (#9833) 2018-01-22 08:19:27 -07:00
Matteo Pagliazzi
ec7c25de9f add new notifications types 2018-01-22 11:46:51 +01:00
Matteo Pagliazzi
6f9db87843 Upgrade travis (#9850)
* upgrade travis

* upgrade travis
2018-01-21 22:47:58 +01:00
Matteo Pagliazzi
46c9038f54 Remove unused packages (#9849)
* remove unused packages

* update lock package

* try with paypal-rest-sdk 1.7.1

* setup nconf
2018-01-21 21:23:25 +01:00
Keith Holliday
1ce09aeb34 Added chatscroll check (#9814) 2018-01-20 17:00:54 -07:00
Keith Holliday
2ba327ef14 Fixed gem purchasing and error catching 2018-01-20 15:09:08 -06:00
Matteo Pagliazzi
de93b47493 add new notifications types 2018-01-20 17:28:50 +01:00
Sabe Jones
b0a21e116a 4.20.3 2018-01-19 03:59:29 +00:00
Sabe Jones
53d1a5f9dc chore(i18n): update locales 2018-01-19 03:58:59 +00:00
SabreCat
274f942b1e chore(news): Add note re audio themes 2018-01-18 21:45:15 +00:00
SabreCat
4aad52242c chore(news): iOS + Blog Bailey 2018-01-18 21:25:59 +00:00
Keith Holliday
166a48e139 Temporarily removed task allocation settings (#9822) 2018-01-18 14:16:30 -06:00
SabreCat
13de97dde6 fix(market): hide nav buttons when too few items
Fixes https://github.com/HabitRPG/habitica/issues/9802#issuecomment-358687806
2018-01-18 20:05:16 +00:00
Matteo Pagliazzi
6d8407ff94 fix tags selection in groups 2018-01-18 17:39:50 +01:00
Alys
663b794435 adjust Ram Barbarian equipment set to say "(Item .. of 3)"
"Item" had been missing.
2018-01-18 21:25:26 +10:00
Keith Holliday
c0276e3663 More staging fixes (#9816)
* Added ability to adjust challenge task copy's streak

* Disabled stat allocation if method is incorrect
2018-01-18 11:51:56 +01:00
Matteo Pagliazzi
6d57ce3050 fix typo 2018-01-18 11:41:19 +01:00
Matteo Pagliazzi
2159df785f Staging fixes (#9819)
* categories can be selected

* quick inventory fixes
2018-01-18 11:30:39 +01:00
Matteo Pagliazzi
9762258975 Merge branch 'develop' of github.com:HabitRPG/habitrpg into develop 2018-01-17 19:33:30 +01:00
Matteo Pagliazzi
deea64e839 more fixes for the task modal 2018-01-17 19:33:21 +01:00
Matteo Pagliazzi
9e615ba862 move delete task btn outside of advanced settings 2018-01-17 19:27:53 +01:00
SabreCat
d34beca3cc Merge branch 'release' into develop 2018-01-17 18:24:48 +00:00
Sabe Jones
07ed989862 4.20.2 2018-01-16 22:46:08 +00:00
Sabe Jones
049844ea7d chore(i18n): update locales 2018-01-16 22:35:00 +00:00
SabreCat
ff4c76165a fix(event): end New Year's cards 2018-01-16 22:09:24 +00:00
Keith Holliday
c3220e7c03 Pushed zindex of progress bar above modals (#9781)
* Pushed zindex of progress bar above modals

* Moved notifications above modals
2018-01-15 13:30:03 -07:00
Keith Holliday
cb4c6b3ca6 Added redirects for old url styles (#9780) 2018-01-15 12:43:02 -07:00
Keith Holliday
ba36ba0157 Added max width to profile image (#9783) 2018-01-15 12:34:00 -07:00
Keith Holliday
dd95acf436 Added coupon purchasing back to stripe (#9794) 2018-01-15 12:12:19 -07:00
Keith Holliday
a73b03452a Fixed overflow for member lists larger than 10 (#9777) 2018-01-15 10:32:32 -07:00
Keith Holliday
935fa1baae Fixed update query to revert challenge tags when broken (#9791) 2018-01-15 10:31:33 -07:00
Keith Holliday
745f930749 Added docs for mongo indexes (#9790) 2018-01-15 10:30:49 -07:00
Keith Holliday
d87db40c52 Staging fixes (#9804)
* Fixed party member loading

* Fixed quest details

* Fixed party creating

* Fixed challenge habit restore streak permissions

* Fixed fetch recent messages for party

* Adjusted category box placement for challenges

* Fixed zindex for input on group

* Changed reset streak restriction and allowed for adjust streak
2018-01-15 10:21:08 -07:00
Keith Holliday
0ea91016f8 Trimmed username spaces (#9793) 2018-01-15 10:20:36 -07:00
Keith Holliday
d4f634c3d8 Fixed disabling button and dismissing modals (#9805) 2018-01-15 09:16:15 -07:00
Matteo Pagliazzi
286566fc0c misc fixes for task modal 2018-01-13 11:27:02 +01:00
Cassidy Pignatello
2ed4df0b7c unhides scroll bar and adjusts overflow to remove whitespace at bottom (#9767) 2018-01-12 16:38:54 -06:00
Alys
9bb7c6ece0 allow user to restore streak on their copy of a challenge Daily (#9757) 2018-01-12 16:37:36 -06:00
Lula Villalobos
db0a6f6bb8 Fix Server Errors Appear As Blank Red Bar (#9747)
* fix path to error message

* changed error message path to check user auth error
2018-01-12 16:33:00 -06:00
Brad Lugo
b6305826be Update Vagrantfile.example to forward port 8080 (#9732)
There was a change in how the code is run locally and part
of this change included using port 8080. This change includes
the port forwarding for said port in the example file for Vagrant
2018-01-12 16:32:09 -06:00
Mel
f00ab86eff Update tier icons to correct size and color (#9727)
* update tier icons to correct size and color

* make tier text bold
2018-01-12 16:29:37 -06:00
Cassidy Pignatello
a44f29dad8 replaces btn-default with btn-secondary (#9704) 2018-01-12 16:25:02 -06:00
Pizilden
67b396bf16 Added Lunasol Theme (#9635) 2018-01-12 16:22:57 -06:00
Grayson Gilmore
ce14a9dadb Challenge modal optimization - remove unnecessary API call - partial fix for #9371 (#9546)
* Attempt to use party data from the store rather than always fetching it from the API

* Move init code to shown() to prevent unnecessary network requests

* Use store party data in getGroup action if possible to save an API call

* Use store data rather than API call for party in challengeModal; remove unnecessary code in guilds:getGroup action

* Create party:getParty action and employ it in Group and ChallengeModal

* Use store instead of action return for party data

* Change how party data is stored
2018-01-12 16:18:56 -06:00
MathWhiz
183c90ac3a Fix presskit (#9418)
* Move presskit to static folder

* Fix image location

* Add press kit FAQ strings

* Add faq section, fix images

* Update Images

* Add images to presskit page

* Remove unecessary parts
2018-01-12 16:18:20 -06:00
borisabramovich86
9e1a262f96 Fixes Purchase contributor equipment (fixes #9179) (#9306)
* Able to see all non class related items in market

* Fix lint errors

* Able to see all non class related items in market

* Fix lint errors

* add test for showing contributor gear

* Added previously owned items to test with eslint exception
2018-01-12 16:16:28 -06:00
MathWhiz
06dd9fe859 Add SpacePenguin's Theme (#9237)
* Add SpacePenguin's Theme

* Fix files
2018-01-12 16:15:55 -06:00
zags
2a2c525c2d Add support for multiDaysCountAsOneDay == false to evasion (#9077)
* Add support for `multiDaysCountAsOneDay == false` to evasion

`if (dailiesDaysMissed > 1) dailiesDaysMissed = 1;` causes the evasion for-loop to only evaluate once even if `multiDaysCountAsOneDay == false`.  This statement isn't necessary because `if (multiDaysCountAsOneDay) break;` will cause the for-loop to evaluate only once if `multiDaysCountAsOneDay == true`.  Removing this statement makes the `dailiesDaysMissed` variable unnecessary.

* Moves break statement out of conditional
2018-01-12 16:12:19 -06:00
Sabe Jones
b2c1c9d9dc Merge branch 'release' into develop 2018-01-12 21:54:20 +00:00
Sabe Jones
c33eba6736 4.20.1 2018-01-12 21:47:21 +00:00
Sabe Jones
56434cce71 chore(i18n): update locales 2018-01-12 21:46:32 +00:00
SabreCat
c41123c36c chore(news): Blog Bailey 2018-01-12 21:38:16 +00:00
SabreCat
043a6cd4ba chore(shops): update Featured Items 2018-01-12 21:25:09 +00:00
SabreCat
0ca2f9034f Revert "WIP: Buy-1-Get-1 Gift Subs (#9719)"
This reverts commit dc3d694d0e, with the exception of locale strings that need not be purged.
2018-01-12 21:15:42 +00:00
Keith Holliday
4c7157807b Synced isdue/next due when user joins challenge (#9779) 2018-01-12 10:16:51 -06:00
Keith Holliday
0afe797bae Fixed display when quest has no completion function (#9778) 2018-01-12 10:16:21 -06:00
Alys
1c8797e473 change Attribute to Stat and upper-case Stat Points and a couple of other terms 2018-01-12 08:09:31 +10:00
Keith Holliday
e0bf6d2e55 Reverted group flag code (#9784)
* Reverted group flag code

* Reverted all flagging code

* Added hyphens back
2018-01-11 12:04:07 -06:00
Matteo Pagliazzi
e96d0659cb fix typos in migration to convert field for Apple subscribers 2018-01-10 18:19:32 +01:00
Matteo Pagliazzi
72d70236ea fix typos in migration to convert field for Apple subscribers 2018-01-10 18:10:01 +01:00
Matteo Pagliazzi
ee2fc8c763 add migration to convert field for Apple subscribers 2018-01-10 18:08:32 +01:00
Sabe Jones
b53c03bca8 Merge branch 'release' into develop 2018-01-10 16:42:13 +00:00
Sabe Jones
9545f692ef 4.20.0 2018-01-10 16:41:44 +00:00
Sabe Jones
0112bd9b5a chore(i18n): update locales 2018-01-10 16:40:59 +00:00
SabreCat
d235576e18 chore(sprites): compile 2018-01-10 16:32:34 +00:00
SabreCat
3d5d5da933 feat(content): Pept quest 2018-01-10 16:31:56 +00:00
Alys
9b19477e2f adjust wording for Keys to Kennels
Also moves the new Keys text strings to the same place as the old ones in the locales file.
Also fixes minor typos in code that was preventing the new text from being displayed.
2018-01-10 21:21:58 +10:00
Sabe Jones
5a9c95f07e fix(guilds): include exact breakpoints 2018-01-09 18:29:59 -06:00
Keith Holliday
3000e2b72c Removed keys and inbox flagging (#9776) 2018-01-09 12:58:01 -06:00
Matteo Pagliazzi
c1f6f0398e fix positioning of checkmarks for checklist items 2018-01-09 11:31:02 +01:00
Matteo Pagliazzi
cb6488fa05 fix path for KeysToKennel module 2018-01-09 11:29:12 +01:00
Keith Holliday
126d90f471 Added keys to the kennel (#9772)
* Added keys to the kennel

* Added titles and descriptions
2018-01-08 13:15:19 -06:00
Keith Holliday
98d4fb0f34 Chat flag inbox (#9761)
* Refactored chat reporting

* Added inbox flag chat

* Added flag chat to inbox

* Added you have flagged message
2018-01-08 13:13:25 -06:00
Keith Holliday
d3ee3ca53d Updated plan updated date if user has cancelled (#9773)
* Updated plan updated date if user has cancelled

* Added test for plan with only date updated
2018-01-08 12:50:15 -06:00
Matteo Pagliazzi
7eac5cebf5 fix typo 2018-01-08 18:47:59 +01:00
Matteo Pagliazzi
6a109adbc5 Task Modal Improvements (#9560)
* start adding advanced options

* new imput

* partial colors

* update deps

* misc adds

* fix text color

* add advanced options

* initial reordering of task modal labels

* start to fix colors in the modal

* wip colors

* update package-lock.json

* fix merge

* finish modal

* refactor colors

* fix quick add

* fix colors

* new icon colors

* add markdown formatting help

* fix habits colors

* fix rewards colors

* fixed remaining colors

* start to inline inputs

* fix typ

* fixes

* habits hover state

* wip new task modal inputs

* bootstrap: upgrade to v4-beta3

* finish reward edit modal

* fix attributes allocation, checklists and add help tooltips for attributes and difficulty

* lots of fixes

* update datepicker

* misc fixes
2018-01-08 18:43:57 +01:00
Sabe Jones
587847f5e9 4.19.1 2018-01-08 17:23:28 +00:00
Sabe Jones
7842cd8a41 chore(i18n): update locales 2018-01-08 17:18:12 +00:00
SabreCat
2f9cf02932 fix(sprites): rename 2018/01 background icons 2018-01-08 17:11:20 +00:00
Pizilden
daa796454c Added Farvoid Theme (new, clean branch) (#9634)
* Added Farvoid Theme

* Updated generic.json and index.js

* fix(merge): address conflicts
2018-01-05 14:34:19 -06:00
Cassidy Pignatello
c531239618 Fixes equipment sorting by name in inventory (#9692)
* returns items sorted in ascending order when sorted by name

* returns items sorted in ascending order when sorted by name
2018-01-05 13:51:47 -06:00
Matti Petrelius
f6ac7b890a Both eggs and potions should hatch pets from Items (#9645)
* Show click on hatching potion when egg is clicked

* Fix translation parameter name

* Show egg as active when clicked

* Remove itemDragStart event handler from egg items

* Change isHatchable to take in potion and egg objects

* Add margin to item popover content
2018-01-05 13:31:34 -06:00
kartik adur
229e39facf Other user checkins: user profile modal checkin count (#9646)
* add loginIncentives to public fields to show non-loggedin user checkins

* update integration tests for update in api response
2018-01-05 13:29:38 -06:00
Allison Virgil
75b00ce2df Fixed Challenge Winner Text (partial fix for #9629) (#9664)
* Fixed Challenge Winner Text (#9629)

* Fixing typo
2018-01-05 13:29:00 -06:00
Julius Jung
4576353f26 inital commit to add confirmation to animalEars (#9666) 2018-01-05 13:26:45 -06:00
Allister
acf4b4da63 Change focused state of introjs button (#9677) 2018-01-05 13:24:32 -06:00
josteins1
8b5933177a Given back header the priority over snackbar with z-index value and a padding to avoid collision. (#9687)
* increased top padding to match main header

referring to issue 9678
https://github.com/HabitRPG/habitica/issues/9678

* adjusted the z value to appropriate levels

z-index adjusted from 99999 to 999
2018-01-05 13:23:03 -06:00
Julius Jung
a6ddd6d233 fix drawer-slider carousel function && convert to pointer logic (fixes #9366 AND #9638) (#9711)
* fix drawer-slider carousel function && convert to pointer logic

* refactor conditional logic

* get rid of absolute value
2018-01-05 13:20:21 -06:00
Sabe Jones
5ca5adc774 4.19.0 2018-01-04 21:49:53 +00:00
Sabe Jones
005ffe850a chore(i18n): update locales 2018-01-04 21:44:47 +00:00
SabreCat
71cb4e8510 feat(content): enable Wintery Skins and Hair 2018-01-04 21:35:26 +00:00
SabreCat
40244ab81b Merge branch 'develop' into release 2018-01-04 21:11:44 +00:00
Keith Holliday
15b65b342a Removed extra achievement sound (#9763) 2018-01-04 10:17:33 -06:00
Matteo Pagliazzi
7df3aba71b make search case insensitive in equipment and inventory pages (#9762) 2018-01-04 13:06:15 +01:00
Keith Holliday
6bb535c129 Reset chat options when change guild routes (#9743) 2018-01-02 22:56:31 -07:00
Sabe Jones
e3bf3d29f7 4.18.1 2018-01-03 00:54:23 +00:00
SabreCat
df9c42c1b5 fix(backgrounds): add 2018 group 2018-01-03 00:52:54 +00:00
Sabe Jones
7e241bb76f Merge branch 'release' into develop 2018-01-03 00:07:42 +00:00
Sabe Jones
6e7f4a231d chore(sprites): compile 2018-01-02 21:41:37 +00:00
Sabe Jones
822a0e56af feat(notifications): recanvas sprites for notifs 2018-01-02 21:38:34 +00:00
Sabe Jones
da73c5c418 Merge branch 'release' into develop 2017-12-31 02:45:04 +00:00
Alys
9a3a104ba4 fix typo in apidocs comment block 2017-12-30 08:43:11 +10:00
Keith Holliday
63bba13b5f Changed paypal redirect to subscription page (#9742) 2017-12-26 17:31:23 -06:00
Keith Holliday
d90d781740 Added mobile style fixes (#9741) 2017-12-26 17:31:00 -06:00
Alys
a3bf329c44 make reset password apidocs comment more accurate 2017-12-24 09:23:32 +00:00
SabreCat
446e0422c7 Merge branch 'release' into develop 2017-12-22 21:57:43 +00:00
Sabe Jones
e8976b40f4 Merge branch 'release' into develop 2017-12-22 21:42:02 +00:00
Alys
d725b5be19 fix typo in loading screen tip 8 2017-12-22 20:45:35 +00:00
SabreCat
028b9d569d Merge branch 'release' into develop 2017-12-21 23:20:51 +00:00
Keith Holliday
95c99295c1 Removed gold locally when user buys a card (#9736) 2017-12-21 10:27:09 -06:00
Keith Holliday
a7617fa947 Added broken megaphone icon (#9737) 2017-12-21 10:25:54 -06:00
Keith Holliday
afc1ffd90b Refactored duplicate card section (#9730)
* Refactored duplicate card section

* Updated to new computed methods
2017-12-20 12:27:21 -06:00
Keith Holliday
6e0b6171c6 Many ie style fixes (#9728) 2017-12-20 10:33:21 -06:00
1299 changed files with 51322 additions and 38277 deletions

View File

@@ -1,36 +1,27 @@
language: node_js
node_js:
- '6'
sudo: required
dist: precise
services:
- mongodb
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
cache:
directories:
- 'node_modules'
before_install:
- $CXX --version
- npm install -g npm@5
- 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
install:
- npm install &> npm.install.log || (cat npm.install.log; false)
before_script:
- npm run test:build
- cp config.json.example config.json
- sleep 15
- sleep 5
script:
- npm run $TEST
- if [ $COVERAGE ]; then ./node_modules/.bin/lcov-result-merger 'coverage/**/*.info' | ./node_modules/coveralls/bin/coveralls.js; fi
env:
global:
- CXX=g++-4.8
- DISABLE_REQUEST_LOGGING=true
matrix:
- TEST="lint"
- TEST="test:api-v3" REQUIRES_SERVER=true COVERAGE=true
- TEST="test:api-v3:unit" REQUIRES_SERVER=true COVERAGE=true
- TEST="test:api-v3:integration" REQUIRES_SERVER=true COVERAGE=true
- TEST="test:sanity"
- TEST="test:content" COVERAGE=true
- TEST="test:common" COVERAGE=true

View File

@@ -15,12 +15,12 @@ ENV STRIPE_PUB_KEY pk_85fQ0yMECHNfHTSsZoxZXlPSwSNfA
# The used solution is suggested here https://github.com/npm/npm/issues/16807#issuecomment-313591975
RUN yarn global add npm@5
# Install global packages
RUN npm install -g gulp mocha
RUN npm install -g gulp-cli mocha
# Clone Habitica repo and install dependencies
RUN mkdir -p /usr/src/habitrpg
WORKDIR /usr/src/habitrpg
RUN git clone --branch v4.16.2 https://github.com/HabitRPG/habitica.git /usr/src/habitrpg
RUN git clone --branch v4.27.0 https://github.com/HabitRPG/habitica.git /usr/src/habitrpg
RUN npm install
RUN gulp build:prod --force

View File

@@ -16,5 +16,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.hostname = "habitrpg"
config.vm.network "forwarded_port", guest: 3000, host: 3000, auto_correct: true
config.vm.usable_port_range = (3000..3050)
config.vm.network "forwarded_port", guest: 8080, host: 8080, auto_correct: true
config.vm.usable_port_range = (8080..8130)
config.vm.provision :shell, :path => "vagrant_scripts/vagrant.sh"
end

View File

@@ -22,6 +22,8 @@
"CRON_SEMI_SAFE_MODE":"false",
"MAINTENANCE_MODE": "false",
"SESSION_SECRET":"YOUR SECRET HERE",
"SESSION_SECRET_KEY": "1234567891234567891234567891234567891234567891234567891234567891",
"SESSION_SECRET_IV": "12345678912345678912345678912345",
"ADMIN_EMAIL": "you@example.com",
"SMTP_USER":"user@example.com",
"SMTP_PASS":"password",

View File

@@ -1,3 +1,10 @@
web:
volumes:
- '.:/usr/src/habitrpg'
version: "3"
services:
client:
volumes:
- '.:/usr/src/habitrpg'
server:
volumes:
- '.:/usr/src/habitrpg'

View File

@@ -1,13 +1,36 @@
web:
build: .
ports:
- "3000:3000"
links:
- mongo
environment:
- NODE_DB_URI=mongodb://mongo/habitrpg
version: "3"
services:
mongo:
image: mongo
ports:
- "27017:27017"
client:
build: .
networks:
- habitica
environment:
- BASE_URL=http://server:3000
ports:
- "8080:8080"
command: ["npm", "run", "client:dev"]
depends_on:
- server
server:
build: .
ports:
- "3000:3000"
networks:
- habitica
environment:
- NODE_DB_URI=mongodb://mongo/habitrpg
depends_on:
- mongo
mongo:
image: mongo
ports:
- "27017:27017"
networks:
- habitica
networks:
habitica:
driver: bridge

View File

@@ -8,7 +8,7 @@ gulp.task('apidoc:clean', (done) => {
clean(APIDOC_DEST_PATH, done);
});
gulp.task('apidoc', ['apidoc:clean'], (done) => {
gulp.task('apidoc', gulp.series('apidoc:clean', (done) => {
let result = apidoc.createDoc({
src: APIDOC_SRC_PATH,
dest: APIDOC_DEST_PATH,
@@ -19,8 +19,8 @@ gulp.task('apidoc', ['apidoc:clean'], (done) => {
} else {
done();
}
});
}));
gulp.task('apidoc:watch', ['apidoc'], () => {
return gulp.watch(`${APIDOC_SRC_PATH}/**/*.js`, ['apidoc']);
});
gulp.task('apidoc:watch', gulp.series('apidoc', (done) => {
return gulp.watch(`${APIDOC_SRC_PATH}/**/*.js`, gulp.series('apidoc', done));
}));

View File

@@ -2,12 +2,6 @@ import gulp from 'gulp';
import babel from 'gulp-babel';
import webpackProductionBuild from '../webpack/build';
gulp.task('build', () => {
if (process.env.NODE_ENV === 'production') { // eslint-disable-line no-process-env
gulp.start('build:prod');
}
});
gulp.task('build:src', () => {
return gulp.src('website/server/**/*.js')
.pipe(babel())
@@ -20,18 +14,30 @@ gulp.task('build:common', () => {
.pipe(gulp.dest('website/common/transpiled-babel/'));
});
gulp.task('build:server', ['build:src', 'build:common']);
gulp.task('build:server', gulp.series('build:src', 'build:common', done => done()));
// Client Production Build
gulp.task('build:client', (done) => {
webpackProductionBuild((err, output) => {
if (err) return done(err);
console.log(output); // eslint-disable-line no-console
done();
});
});
gulp.task('build:prod', [
gulp.task('build:prod', gulp.series(
'build:server',
'build:client',
'apidoc',
]);
done => done()
));
let buildArgs = [];
if (process.env.NODE_ENV === 'production') { // eslint-disable-line no-process-env
buildArgs.push('build:prod');
}
gulp.task('build', gulp.series(buildArgs, (done) => {
done();
}));

View File

@@ -1,5 +1,4 @@
import mongoose from 'mongoose';
import autoinc from 'mongoose-id-autoinc';
import logger from '../website/server/libs/logger';
import nconf from 'nconf';
import repl from 'repl';
@@ -25,23 +24,23 @@ let improveRepl = (context) => {
const isProd = nconf.get('NODE_ENV') === 'production';
const mongooseOptions = !isProd ? {} : {
replset: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } },
server: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } },
keepAlive: 1,
connectTimeoutMS: 30000,
useMongoClient: true,
};
autoinc.init(
mongoose.connect(
nconf.get('NODE_DB_URI'),
mongooseOptions,
(err) => {
if (err) throw err;
logger.info('Connected with Mongoose');
}
)
mongoose.connect(
nconf.get('NODE_DB_URI'),
mongooseOptions,
(err) => {
if (err) throw err;
logger.info('Connected with Mongoose');
}
);
};
gulp.task('console', () => {
gulp.task('console', (done) => {
improveRepl(repl.start({
prompt: 'Habitica > ',
}).context);
done();
});

View File

@@ -7,6 +7,7 @@ import mergeStream from 'merge-stream';
import {basename} from 'path';
import {sync} from 'glob';
import {each} from 'lodash';
import vinylBuffer from 'vinyl-buffer';
// https://github.com/Ensighten/grunt-spritesmith/issues/67#issuecomment-34786248
const MAX_SPRITESHEET_SIZE = 1024 * 1024 * 3;
@@ -104,6 +105,7 @@ function createSpritesStream (name, src) {
}));
let imgStream = spriteData.img
.pipe(vinylBuffer())
.pipe(imagemin())
.pipe(gulp.dest(IMG_DIST_PATH));
@@ -117,8 +119,6 @@ function createSpritesStream (name, src) {
return stream;
}
gulp.task('sprites:compile', ['sprites:clean', 'sprites:main', 'sprites:largeSprites', 'sprites:checkCompiledDimensions']);
gulp.task('sprites:main', () => {
let mainSrc = sync('website/raw_sprites/spritesmith/**/*.png');
return createSpritesStream('main', mainSrc);
@@ -133,7 +133,7 @@ gulp.task('sprites:clean', (done) => {
clean(`${IMG_DIST_PATH}spritesmith*,${CSS_DIST_PATH}spritesmith*}`, done);
});
gulp.task('sprites:checkCompiledDimensions', ['sprites:main', 'sprites:largeSprites'], () => {
gulp.task('sprites:checkCompiledDimensions', gulp.series('sprites:main', 'sprites:largeSprites', (done) => {
console.log('Verifiying that images do not exceed max dimensions'); // eslint-disable-line no-console
let numberOfSheetsThatAreTooBig = 0;
@@ -159,4 +159,7 @@ gulp.task('sprites:checkCompiledDimensions', ['sprites:main', 'sprites:largeSpri
} else {
console.log('All images are within the correct dimensions'); // eslint-disable-line no-console
}
});
done();
}));
gulp.task('sprites:compile', gulp.series('sprites:clean', 'sprites:main', 'sprites:largeSprites', 'sprites:checkCompiledDimensions', done => done()));

View File

@@ -3,7 +3,7 @@ import nodemon from 'gulp-nodemon';
let pkg = require('../package.json');
gulp.task('nodemon', () => {
gulp.task('nodemon', (done) => {
nodemon({
script: pkg.main,
ignore: [
@@ -12,4 +12,5 @@ gulp.task('nodemon', () => {
'common/dist/script/content/*',
],
});
done();
});

View File

@@ -4,7 +4,6 @@ import {
import mongoose from 'mongoose';
import { exec } from 'child_process';
import gulp from 'gulp';
import runSequence from 'run-sequence';
import os from 'os';
import nconf from 'nconf';
@@ -39,23 +38,23 @@ let testBin = (string, additionalEnvVariables = '') => {
}
};
gulp.task('test:nodemon', () => {
gulp.task('test:nodemon', gulp.series(function setupNodemon (done) {
process.env.PORT = TEST_SERVER_PORT; // eslint-disable-line no-process-env
process.env.NODE_DB_URI = TEST_DB_URI; // eslint-disable-line no-process-env
runSequence('nodemon');
});
done();
}, 'nodemon'));
gulp.task('test:prepare:mongo', (cb) => {
mongoose.connect(TEST_DB_URI, (err) => {
if (err) return cb(`Unable to connect to mongo database. Are you sure it's running? \n\n${err}`);
mongoose.connection.db.dropDatabase();
mongoose.connection.close();
cb();
mongoose.connection.dropDatabase((err2) => {
if (err2) return cb(err2);
mongoose.connection.close(cb);
});
});
});
gulp.task('test:prepare:server', ['test:prepare:mongo'], () => {
gulp.task('test:prepare:server', gulp.series('test:prepare:mongo', (done) => {
if (!server) {
server = exec(testBin('node ./website/server/index.js', `NODE_DB_URI=${TEST_DB_URI} PORT=${TEST_SERVER_PORT}`), (error, stdout, stderr) => {
if (error) {
@@ -64,16 +63,18 @@ gulp.task('test:prepare:server', ['test:prepare:mongo'], () => {
if (stderr) {
console.error(stderr); // eslint-disable-line no-console
}
done();
});
}
});
}));
gulp.task('test:prepare:build', ['build']);
gulp.task('test:prepare:build', gulp.series('build', done => done()));
gulp.task('test:prepare', [
gulp.task('test:prepare', gulp.series(
'test:prepare:build',
'test:prepare:mongo',
]);
done => done()
));
gulp.task('test:sanity', (cb) => {
let runner = exec(
@@ -88,7 +89,7 @@ gulp.task('test:sanity', (cb) => {
pipe(runner);
});
gulp.task('test:common', ['test:prepare:build'], (cb) => {
gulp.task('test:common', gulp.series('test:prepare:build', (cb) => {
let runner = exec(
testBin(COMMON_TEST_COMMAND),
(err) => {
@@ -99,17 +100,17 @@ gulp.task('test:common', ['test:prepare:build'], (cb) => {
}
);
pipe(runner);
});
}));
gulp.task('test:common:clean', (cb) => {
pipe(exec(testBin(COMMON_TEST_COMMAND), () => cb()));
});
gulp.task('test:common:watch', ['test:common:clean'], () => {
gulp.watch(['common/script/**/*', 'test/common/**/*'], ['test:common:clean']);
});
gulp.task('test:common:watch', gulp.series('test:common:clean', () => {
return gulp.watch(['common/script/**/*', 'test/common/**/*'], gulp.series('test:common:clean', done => done()));
}));
gulp.task('test:common:safe', ['test:prepare:build'], (cb) => {
gulp.task('test:common:safe', gulp.series('test:prepare:build', (cb) => {
let runner = exec(
testBin(COMMON_TEST_COMMAND),
(err, stdout) => { // eslint-disable-line handle-callback-err
@@ -123,9 +124,9 @@ gulp.task('test:common:safe', ['test:prepare:build'], (cb) => {
}
);
pipe(runner);
});
}));
gulp.task('test:content', ['test:prepare:build'], (cb) => {
gulp.task('test:content', gulp.series('test:prepare:build', (cb) => {
let runner = exec(
testBin(CONTENT_TEST_COMMAND),
CONTENT_OPTIONS,
@@ -137,17 +138,17 @@ gulp.task('test:content', ['test:prepare:build'], (cb) => {
}
);
pipe(runner);
});
}));
gulp.task('test:content:clean', (cb) => {
pipe(exec(testBin(CONTENT_TEST_COMMAND), CONTENT_OPTIONS, () => cb()));
});
gulp.task('test:content:watch', ['test:content:clean'], () => {
gulp.watch(['common/script/content/**', 'test/**'], ['test:content:clean']);
});
gulp.task('test:content:watch', gulp.series('test:content:clean', () => {
return gulp.watch(['common/script/content/**', 'test/**'], gulp.series('test:content:clean', done => done()));
}));
gulp.task('test:content:safe', ['test:prepare:build'], (cb) => {
gulp.task('test:content:safe', gulp.series('test:prepare:build', (cb) => {
let runner = exec(
testBin(CONTENT_TEST_COMMAND),
CONTENT_OPTIONS,
@@ -162,7 +163,7 @@ gulp.task('test:content:safe', ['test:prepare:build'], (cb) => {
}
);
pipe(runner);
});
}));
gulp.task('test:api-v3:unit', (done) => {
let runner = exec(
@@ -179,7 +180,7 @@ gulp.task('test:api-v3:unit', (done) => {
});
gulp.task('test:api-v3:unit:watch', () => {
gulp.watch(['website/server/libs/*', 'test/api/v3/unit/**/*', 'website/server/controllers/**/*'], ['test:api-v3:unit']);
return gulp.watch(['website/server/libs/*', 'test/api/v3/unit/**/*', 'website/server/controllers/**/*'], gulp.series('test:api-v3:unit', done => done()));
});
gulp.task('test:api-v3:integration', (done) => {
@@ -198,8 +199,10 @@ gulp.task('test:api-v3:integration', (done) => {
});
gulp.task('test:api-v3:integration:watch', () => {
gulp.watch(['website/server/controllers/api-v3/**/*', 'common/script/ops/*', 'website/server/libs/*.js',
'test/api/v3/integration/**/*'], ['test:api-v3:integration']);
return gulp.watch([
'website/server/controllers/api-v3/**/*', 'common/script/ops/*', 'website/server/libs/*.js',
'test/api/v3/integration/**/*',
], gulp.series('test:api-v3:integration', done => done()));
});
gulp.task('test:api-v3:integration:separate-server', (done) => {
@@ -212,21 +215,17 @@ gulp.task('test:api-v3:integration:separate-server', (done) => {
pipe(runner);
});
gulp.task('test', (done) => {
runSequence(
'test:sanity',
'test:content',
'test:common',
'test:api-v3:unit',
'test:api-v3:integration',
done
);
});
gulp.task('test', gulp.series(
'test:sanity',
'test:content',
'test:common',
'test:api-v3:unit',
'test:api-v3:integration',
done => done()
));
gulp.task('test:api-v3', (done) => {
runSequence(
'test:api-v3:unit',
'test:api-v3:integration',
done
);
});
gulp.task('test:api-v3', gulp.series(
'test:api-v3:unit',
'test:api-v3:integration',
done => done()
));

View File

@@ -93,9 +93,7 @@ const malformedStringExceptions = {
feedPet: true,
};
gulp.task('transifex', ['transifex:missingFiles', 'transifex:missingStrings', 'transifex:malformedStrings']);
gulp.task('transifex:missingFiles', () => {
gulp.task('transifex:missingFiles', (done) => {
let missingStrings = [];
eachTranslationFile(ALL_LANGUAGES, (error) => {
@@ -109,9 +107,10 @@ gulp.task('transifex:missingFiles', () => {
let formattedMessage = formatMessageForPosting(message, missingStrings);
postToSlack(formattedMessage, SLACK_CONFIG);
}
done();
});
gulp.task('transifex:missingStrings', () => {
gulp.task('transifex:missingStrings', (done) => {
let missingStrings = [];
eachTranslationString(ALL_LANGUAGES, (language, filename, key, englishString, translationString) => {
@@ -126,9 +125,10 @@ gulp.task('transifex:missingStrings', () => {
let formattedMessage = formatMessageForPosting(message, missingStrings);
postToSlack(formattedMessage, SLACK_CONFIG);
}
done();
});
gulp.task('transifex:malformedStrings', () => {
gulp.task('transifex:malformedStrings', (done) => {
let jsonFiles = stripOutNonJsonFiles(fs.readdirSync(ENGLISH_LOCALE));
let interpolationRegex = /<%= [a-zA-Z]* %>/g;
let stringsToLookFor = getStringsWith(jsonFiles, interpolationRegex);
@@ -170,4 +170,11 @@ gulp.task('transifex:malformedStrings', () => {
let formattedMessage = formatMessageForPosting(message, stringsWithIncorrectNumberOfInterpolations);
postToSlack(formattedMessage, SLACK_CONFIG);
}
done();
});
gulp.task(
'transifex',
gulp.series('transifex:missingFiles', 'transifex:missingStrings', 'transifex:malformedStrings'),
(done) => done()
);

View File

@@ -8,10 +8,12 @@
require('babel-register');
const gulp = require('gulp');
if (process.env.NODE_ENV === 'production') { // eslint-disable-line no-process-env
require('./gulp/gulp-apidoc'); // eslint-disable-line global-require
require('./gulp/gulp-build'); // eslint-disable-line global-require
} else {
require('glob').sync('./gulp/gulp-*').forEach(require); // eslint-disable-line global-require
require('gulp').task('default', ['test']); // eslint-disable-line global-require
require('gulp').task('default', gulp.series('test')); // eslint-disable-line global-require
}

View File

@@ -0,0 +1,79 @@
/*
* Convert purchased.plan.nextPaymentProcessing from a double to a date field for Apple subscribers
*/
var monk = require('monk');
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
var dbUsers = monk(connectionString).get('users', { castIds: false });
function processUsers(lastId) {
// specify a query to limit the affected users (empty for all users):
var query = {
'purchased.plan.paymentMethod': "Apple",
'purchased.plan.nextPaymentProcessing': {$type: 'double'},
};
if (lastId) {
query._id = {
$gt: lastId
}
}
dbUsers.find(query, {
sort: {_id: 1},
limit: 250,
})
.then(updateUsers)
.catch(function (err) {
console.log(err);
return exiting(1, 'ERROR! ' + err);
});
}
var progressCount = 100;
var count = 0;
function updateUsers (users) {
if (!users || users.length === 0) {
console.warn('All appropriate users found and modified.');
displayData();
return;
}
var userPromises = users.map(updateUser);
var lastUser = users[users.length - 1];
return Promise.all(userPromises)
.then(function () {
processUsers(lastUser._id);
});
}
function updateUser (user) {
count++;
var set = {
'purchased.plan.nextPaymentProcessing': new Date(user.purchased.plan.nextPaymentProcessing),
};
dbUsers.update({_id: user._id}, {$set: set});
if (count % progressCount == 0) console.warn(count + ' ' + user._id);
}
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);
}
module.exports = processUsers;

View File

@@ -0,0 +1,93 @@
const UserNotification = require('../website/server/models/userNotification').model;
const content = require('../website/common/script/content/index');
const migrationName = '20180125_clean_new_migrations';
const authorName = 'paglias'; // in case script author needs to know when their ...
const authorUuid = 'ed4c688c-6652-4a92-9d03-a5a79844174a'; // ... own data is done
/*
* Clean new migration types for processed users
*/
const monk = require('monk');
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
const dbUsers = monk(connectionString).get('users', { castIds: false });
const progressCount = 1000;
let count = 0;
function updateUser (user) {
count++;
const types = ['NEW_MYSTERY_ITEMS', 'CARD_RECEIVED', 'NEW_CHAT_MESSAGE'];
dbUsers.update({_id: user._id}, {
$pull: {notifications: { type: {$in: types } } },
$set: {migration: migrationName},
});
if (count % progressCount === 0) console.warn(`${count } ${ user._id}`);
if (user._id === authorUuid) console.warn(`${authorName } processed`);
}
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);
}
function displayData () {
console.warn(`\n${ count } users processed\n`);
return exiting(0);
}
function updateUsers (users) {
if (!users || users.length === 0) {
console.warn('All appropriate users found and modified.');
displayData();
return;
}
const userPromises = users.map(updateUser);
const lastUser = users[users.length - 1];
return Promise.all(userPromises)
.then(() => {
processUsers(lastUser._id);
});
}
function processUsers (lastId) {
// specify a query to limit the affected users (empty for all users):
const query = {
migration: {$ne: migrationName},
'auth.timestamps.loggedin': {$gt: new Date('2010-01-24')},
};
if (lastId) {
query._id = {
$gt: lastId,
};
}
dbUsers.find(query, {
sort: {_id: 1},
limit: 250,
})
.then(updateUsers)
.catch((err) => {
console.log(err);
return exiting(1, `ERROR! ${ err}`);
});
}
module.exports = processUsers;

View File

@@ -0,0 +1,149 @@
const UserNotification = require('../website/server/models/userNotification').model;
const content = require('../website/common/script/content/index');
const migrationName = '20180125_migrations-v2';
const authorName = 'paglias'; // in case script author needs to know when their ...
const authorUuid = 'ed4c688c-6652-4a92-9d03-a5a79844174a'; // ... own data is done
/*
* Migrate to new notifications system
*/
const monk = require('monk');
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
const dbUsers = monk(connectionString).get('users', { castIds: false });
const progressCount = 1000;
let count = 0;
function updateUser (user) {
count++;
const notifications = [];
// UNALLOCATED_STATS_POINTS skipped because added on each save
// NEW_STUFF skipped because it's a new type
// GROUP_TASK_NEEDS_WORK because it's a new type
// NEW_INBOX_MESSAGE not implemented yet
// NEW_MYSTERY_ITEMS
const mysteryItems = user.purchased && user.purchased.plan && user.purchased.plan.mysteryItems;
if (Array.isArray(mysteryItems) && mysteryItems.length > 0) {
const newMysteryNotif = new UserNotification({
type: 'NEW_MYSTERY_ITEMS',
data: {
items: mysteryItems,
},
}).toJSON();
notifications.push(newMysteryNotif);
}
// CARD_RECEIVED
Object.keys(content.cardTypes).forEach(cardType => {
const existingCards = user.items.special[`${cardType}Received`] || [];
existingCards.forEach(sender => {
const newNotif = new UserNotification({
type: 'CARD_RECEIVED',
data: {
card: cardType,
from: {
// id is missing in old notifications
name: sender,
},
},
}).toJSON();
notifications.push(newNotif);
});
});
// NEW_CHAT_MESSAGE
Object.keys(user.newMessages).forEach(groupId => {
const existingNotif = user.newMessages[groupId];
if (existingNotif) {
const newNotif = new UserNotification({
type: 'NEW_CHAT_MESSAGE',
data: {
group: {
id: groupId,
name: existingNotif.name,
},
},
}).toJSON();
notifications.push(newNotif);
}
});
dbUsers.update({_id: user._id}, {
$push: {notifications: { $each: notifications } },
$set: {migration: migrationName},
});
if (count % progressCount === 0) console.warn(`${count } ${ user._id}`);
if (user._id === authorUuid) console.warn(`${authorName } processed`);
}
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);
}
function displayData () {
console.warn(`\n${ count } users processed\n`);
return exiting(0);
}
function updateUsers (users) {
if (!users || users.length === 0) {
console.warn('All appropriate users found and modified.');
displayData();
return;
}
const userPromises = users.map(updateUser);
const lastUser = users[users.length - 1];
return Promise.all(userPromises)
.then(() => {
processUsers(lastUser._id);
});
}
function processUsers (lastId) {
// specify a query to limit the affected users (empty for all users):
const query = {
migration: {$ne: migrationName},
'auth.timestamps.loggedin': {$gt: new Date('2010-01-24')},
};
if (lastId) {
query._id = {
$gt: lastId,
};
}
dbUsers.find(query, {
sort: {_id: 1},
limit: 250,
})
.then(updateUsers)
.catch((err) => {
console.log(err);
return exiting(1, `ERROR! ${ err}`);
});
}
module.exports = processUsers;

View File

@@ -0,0 +1,118 @@
var migrationName = '20180130_habit_birthday.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 party robes: most recent user doesn't have of 2014-2018. Also cake!
*/
var monk = require('monk');
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
var dbUsers = monk(connectionString).get('users', { castIds: false });
function processUsers(lastId) {
// specify a query to limit the affected users (empty for all users):
var query = {
'migration':{$ne:migrationName},
'auth.timestamps.loggedin':{$gt:new Date('2018-01-01')}, // remove after first run to cover remaining users
};
if (lastId) {
query._id = {
$gt: lastId
}
}
dbUsers.find(query, {
sort: {_id: 1},
limit: 250,
fields: [ // specify fields we are interested in to limit retrieved data (empty if we're not reading data)
'items.gear.owned'
],
})
.then(updateUsers)
.catch(function (err) {
console.log(err);
return exiting(1, 'ERROR! ' + err);
});
}
var progressCount = 1000;
var count = 0;
function updateUsers (users) {
if (!users || users.length === 0) {
console.warn('All appropriate users found and modified.');
displayData();
return;
}
var userPromises = users.map(updateUser);
var lastUser = users[users.length - 1];
return Promise.all(userPromises)
.then(function () {
processUsers(lastUser._id);
});
}
function updateUser (user) {
count++;
var push;
var set = {'migration':migrationName};
if (user.items && user.items.gear && user.items.gear.owned && user.items.gear.owned.hasOwnProperty('armor_special_birthday2017')) {
set['items.gear.owned.armor_special_birthday2018'] = false;
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2018', '_id': monk.id()}};
} else if (user.items && user.items.gear && user.items.gear.owned && user.items.gear.owned.hasOwnProperty('armor_special_birthday2016')) {
set['items.gear.owned.armor_special_birthday2017'] = false;
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2017', '_id': monk.id()}};
} else if (user.items && user.items.gear && user.items.gear.owned && user.items.gear.owned.hasOwnProperty('armor_special_birthday2015')) {
set['items.gear.owned.armor_special_birthday2016'] = false;
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2016', '_id': monk.id()}};
} else if (user.items && user.items.gear && user.items.gear.owned && user.items.gear.owned.hasOwnProperty('armor_special_birthday')) {
set['items.gear.owned.armor_special_birthday2015'] = false;
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2015', '_id': monk.id()}};
} else {
set['items.gear.owned.armor_special_birthday'] = false;
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday', '_id': monk.id()}};
}
var inc = {
'items.food.Cake_Skeleton':1,
'items.food.Cake_Base':1,
'items.food.Cake_CottonCandyBlue':1,
'items.food.Cake_CottonCandyPink':1,
'items.food.Cake_Shade':1,
'items.food.Cake_White':1,
'items.food.Cake_Golden':1,
'items.food.Cake_Zombie':1,
'items.food.Cake_Desert':1,
'items.food.Cake_Red':1,
'achievements.habitBirthdays':1
};
dbUsers.update({_id: user._id}, {$set: set, $inc: inc, $push: push});
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);
}
module.exports = processUsers;

View File

@@ -0,0 +1,59 @@
# Indexes
This file contains a list of indexes that are on Habitica's production Mongo server.
If we ever have an issue, use this list to reindex.
## Challenges
- `{ "group": 1, "official": -1, "timestamp": -1 }`
- `{ "leader": 1, "official": -1, "timestamp": -1 }`
- `{ "official": -1, "timestamp": -1 }`
## Groups
- `{ "privacy": 1, "type": 1, "memberCount": -1 }`
- `{ "privacy": 1 }`
- `{ "purchased.plan.customerId": 1 }`
- `{ "purchased.plan.paymentMethod": 1 }`
- `{ "purchased.plan.planId": 1, "purchased.plan.dateTerminated": 1 }`
- `{ "type": 1, "memberCount": -1, "_id": 1 }`
- `{ "type": 1 }`
## Tasks
- `{ "challenge.id": 1 }`
- `{ "challenge.taskId": 1 }`
- `{ "group.id": 1 }`
- `{ "group.taskId": 1 }`
- `{ "type": 1, "everyX": 1, "frequency": 1 }`
- `{ "userId": 1 }`
- `{ "yesterDaily": 1, "type": 1 }`
## Users
- `{ "_id": 1, "apiToken": 1 }`
- `{ "auth.facebook.emails.value": 1 }`
- `{ "auth.facebook.id": 1 }`
- `{ "auth.google.emails.value": 1 }`
- `{ "auth.google.id": 1 }`
- `{ "auth.local.email": 1 }`
- `{ "auth.local.lowerCaseUsername": 1 }`
- `{ "auth.local.username": 1 }`
- `{ "auth.timestamps.created": 1 }`
- `{ "auth.timestamps.loggedin": 1, "_lastPushNotification": 1, "preferences.timezoneOffset": 1 }`
- `{ "auth.timestamps.loggedin": 1 }`
- `{ "backer.tier": -1 }`
- `{ "challenges": 1, "_id": 1 }`
- `{ "contributor.admin": 1, "contributor.level": -1, "backer.npc": -1, "profile.name": 1 }`
- `{ "contributor.level": 1 }`
- `{ "flags.newStuff": 1 }`
- `{ "flags.armoireEmpty": 1 }`
- `{ "guilds": 1, "_id": 1 }`
- `{ "invitations.guilds.id": 1, "_id": 1 }`
- `{ "invitations.party.id": 1 }`
- `{ "loginIncentives": 1 }`
- `{ "migration": 1 }`
- `{ "party._id": 1, "_id": 1 }`
- `{ "preferences.sleep": 1, "_id": 1, "flags.lastWeeklyRecap": 1, "preferences.emailNotifications.unsubscribeFromAll": 1, "preferences.emailNotifications.weeklyRecaps": 1 }`
- `{ "preferences.sleep": 1, "_id": 1, "lastCron": 1, "preferences.emailNotifications.importantAnnouncements": 1, "preferences.emailNotifications.unsubscribeFromAll": 1, "flags.recaptureEmailsPhase": 1 }`
- `{ "profile.name": 1 }`
- `{ "purchased.plan.customerId": 1 }`
- `{ "purchased.plan.paymentMethod": 1 }`
- `{ "stats.score.overall": 1 }`
- `{ "webhooks.type": 1 }`

View File

@@ -17,5 +17,5 @@ function setUpServer () {
setUpServer();
// Replace this with your migration
const processUsers = require('./takeThis');
const processUsers = require('./20180125_clean_new_notifications.js');
processUsers();

View File

@@ -1,10 +1,23 @@
var UserNotification = require('../website/server/models/userNotification').model
var _id = '';
var items = ['back_mystery_201801','headAccessory_mystery_201801']
var update = {
$addToSet: {
'purchased.plan.mysteryItems':{
$each:['armor_mystery_201712','head_mystery_201712']
$each: items,
}
}
},
$push: {
notifications: (new UserNotification({
type: 'NEW_MYSTERY_ITEMS',
data: {
items: items,
},
})).toJSON(),
},
};
/*var update = {

View File

@@ -18,71 +18,94 @@ var authorUuid = '3e595299-3d8a-4a10-bfe0-88f555e4aa0c'; //... own data is done
*
*/
var dbserver = 'localhost:27017'; // FOR TEST DATABASE
var dbserver = 'username:password@ds031379-a0.mongolab.com:31379'; // FOR PRODUCTION DATABASE
var dbname = 'habitrpg';
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
var mongo = require('mongoskin');
var _ = require('lodash');
var monk = require('monk');
var dbUsers = monk(connectionString).get('users', { castIds: false });
var dbUsers = mongo.db(dbserver + '/' + dbname + '?auto_reconnect').collection('users');
// specify a query to limit the affected users (empty for all users):
var query = {
'auth.timestamps.loggedin':{$gt:new Date('2016-01-04')}
// '_id': authorUuid // FOR TESTING
};
function processUsers(lastId) {
// specify a query to limit the affected users (empty for all users):
var query = {
'auth.timestamps.loggedin':{$gt:new Date('2016-01-04')}
// '_id': authorUuid // FOR TESTING
};
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
var fields = {
'flags.armoireEmpty':1,
'items.gear.owned':1
};
// specify a query to limit the affected users (empty for all users):
var fields = {
'flags.armoireEmpty':1,
'items.gear.owned':1
};
// specify user data to change:
var set = {'migration':migrationName, 'flags.armoireEmpty':false};
console.warn('Updating users...');
var progressCount = 1000;
var countSearched = 0;
var countModified = 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.');
return displayData();
if (lastId) {
query._id = {
$gt: lastId
}
}
countSearched++;
dbUsers.find(query, {
sort: {_id: 1},
limit: 250,
fields: {
'flags.armoireEmpty':1,
'items.gear.owned':1
} // specify fields we are interested in to limit retrieved data (empty if we're not reading data):
})
.then(updateUsers)
.catch(function (err) {
console.log(err);
return exiting(1, 'ERROR! ' + err);
});
}
var progressCount = 1000;
var count = 0;
function updateUsers (users) {
if (!users || users.length === 0) {
console.warn('All appropriate users found and modified.');
displayData();
return;
}
var userPromises = users.map(updateUser);
var lastUser = users[users.length - 1];
return Promise.all(userPromises)
.then(function () {
processUsers(lastUser._id);
});
}
function updateUser (user) {
count++;
var set = {'migration':migrationName, 'flags.armoireEmpty':false};
if (user.flags.armoireEmpty) {
// this user believes their armoire has no more items in it
if (user.items.gear.owned.weapon_armoire_barristerGavel && user.items.gear.owned.armor_armoire_barristerRobes && user.items.gear.owned.head_armoire_jesterCap && user.items.gear.owned.armor_armoire_jesterCostume && user.items.gear.owned.head_armoire_barristerWig && user.items.gear.owned.weapon_armoire_jesterBaton && user.items.gear.owned.weapon_armoire_lunarSceptre && user.items.gear.owned.armor_armoire_gladiatorArmor && user.items.gear.owned.weapon_armoire_basicCrossbow && user.items.gear.owned.head_armoire_gladiatorHelm && user.items.gear.owned.armor_armoire_lunarArmor && user.items.gear.owned.head_armoire_redHairbow && user.items.gear.owned.head_armoire_violetFloppyHat && user.items.gear.owned.head_armoire_rancherHat && user.items.gear.owned.shield_armoire_gladiatorShield && user.items.gear.owned.head_armoire_blueHairbow && user.items.gear.owned.weapon_armoire_mythmakerSword && user.items.gear.owned.head_armoire_royalCrown && user.items.gear.owned.head_armoire_hornedIronHelm && user.items.gear.owned.weapon_armoire_rancherLasso && user.items.gear.owned.armor_armoire_rancherRobes && user.items.gear.owned.armor_armoire_hornedIronArmor && user.items.gear.owned.armor_armoire_goldenToga && user.items.gear.owned.weapon_armoire_ironCrook && user.items.gear.owned.head_armoire_goldenLaurels && user.items.gear.owned.head_armoire_redFloppyHat && user.items.gear.owned.armor_armoire_plagueDoctorOvercoat && user.items.gear.owned.head_armoire_plagueDoctorHat && user.items.gear.owned.weapon_armoire_goldWingStaff && user.items.gear.owned.head_armoire_yellowHairbow && user.items.gear.owned.eyewear_armoire_plagueDoctorMask && user.items.gear.owned.head_armoire_blackCat && user.items.gear.owned.weapon_armoire_batWand && user.items.gear.owned.head_armoire_orangeCat && user.items.gear.owned.shield_armoire_midnightShield && user.items.gear.owned.armor_armoire_royalRobes && user.items.gear.owned.head_armoire_blueFloppyHat && user.items.gear.owned.shield_armoire_royalCane && user.items.gear.owned.weapon_armoire_shepherdsCrook && user.items.gear.owned.armor_armoire_shepherdRobes && user.items.gear.owned.head_armoire_shepherdHeaddress && user.items.gear.owned.weapon_armoire_blueLongbow && user.items.gear.owned.weapon_armoire_crystalCrescentStaff && user.items.gear.owned.head_armoire_crystalCrescentHat && user.items.gear.owned.armor_armoire_dragonTamerArmor && user.items.gear.owned.head_armoire_dragonTamerHelm && user.items.gear.owned.armor_armoire_crystalCrescentRobes && user.items.gear.owned.shield_armoire_dragonTamerShield && user.items.gear.owned.weapon_armoire_glowingSpear) {
// this user does have all the armoire items so we don't change the flag
// console.log("don't change: " + user._id); // FOR TESTING
// console.log("don't change: " + user._id); // FOR TESTING
} else {
// console.log("change: " + user._id); // FOR TESTING
dbUsers.update({_id: user._id}, {$set: set});
}
else {
countModified++;
// console.log("change: " + user._id); // FOR TESTING
dbUsers.update({_id:user._id}, {$set:set});
}
}
else {
} else {
// this user already has armoire marked as containing items to be bought
// so don't change the flag
// console.log("DON'T CHANGE: " + user._id); // FOR TESTING
// console.log("DON'T CHANGE: " + user._id); // FOR TESTING
}
if (countSearched%progressCount == 0) console.warn(countSearched + ' ' + user._id);
if (count % progressCount == 0) console.warn(count + ' ' + user._id);
if (user._id == authorUuid) console.warn(authorName + ' processed');
});
function displayData() {
console.warn('\n' + countSearched + ' users searched\n');
console.warn('\n' + countModified + ' users modified\n');
return exiting(0);
}
function displayData() {
console.warn('\n' + count + ' users processed\n');
return exiting(0);
}
function exiting(code, msg) {
code = code || 0; // 0 = success
@@ -93,3 +116,5 @@ function exiting(code, msg) {
}
process.exit(code);
}
module.exports = processUsers;

View File

@@ -1,13 +1,13 @@
var migrationName = 'tasks-set-everyX';
var authorName = ''; // in case script author needs to know when their ...
var authorUuid = ''; //... own data is done
var authorName = 'Sabe'; // in case script author needs to know when their ...
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
/*
* Iterates over all tasks and sets invalid everyX values (less than 0 or more than 9999 or not an int) field to 0
*/
var monk = require('monk');
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
var connectionString = 'mongodb://sabrecat:z8e8jyRA8CTofMQ@ds013393-a0.mlab.com:13393/habitica?auto_reconnect=true';
var dbTasks = monk(connectionString).get('tasks', { castIds: false });
function processTasks(lastId) {

11594
package-lock.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": "4.18.0",
"version": "4.27.2",
"main": "./website/server/index.js",
"dependencies": {
"@slack/client": "^3.8.1",
@@ -10,7 +10,6 @@
"amplitude": "^2.0.3",
"apidoc": "^0.17.5",
"apn": "^1.7.6",
"async": "^1.5.0",
"autoprefixer": "^6.4.0",
"aws-sdk": "^2.0.25",
"axios": "^0.16.0",
@@ -27,95 +26,77 @@
"babel-preset-es2015": "^6.6.0",
"babel-register": "^6.6.0",
"babel-runtime": "^6.11.6",
"babelify": "^7.2.0",
"bcrypt": "^1.0.2",
"bluebird": "^3.3.5",
"body-parser": "^1.15.0",
"bootstrap": "4.0.0-beta.2",
"bootstrap-vue": "^1.0.2",
"browserify": "~12.0.1",
"bootstrap": "^4.0.0",
"bootstrap-vue": "^1.5.0",
"compression": "^1.6.1",
"connect-ratelimit": "0.0.7",
"cookie-session": "^1.2.0",
"coupon-code": "^0.4.5",
"cross-env": "^4.0.0",
"cross-env": "^5.1.3",
"css-loader": "^0.28.0",
"csv-stringify": "^1.0.2",
"cwait": "~1.0.1",
"domain-middleware": "~0.1.0",
"estraverse": "^4.1.1",
"express": "~4.14.0",
"express-basic-auth": "^1.0.1",
"express-csv": "~0.6.0",
"express-validator": "^2.18.0",
"extract-text-webpack-plugin": "^2.0.0-rc.3",
"file-loader": "^0.10.0",
"glob": "^4.3.5",
"glob": "^7.1.2",
"got": "^6.1.1",
"gulp": "^3.9.0",
"gulp": "^4.0.0",
"gulp-babel": "^6.1.2",
"gulp-imagemin": "^2.4.0",
"gulp-nodemon": "^2.0.4",
"gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^1.4.2",
"gulp.spritesmith": "^4.1.0",
"gulp-imagemin": "^4.1.0",
"gulp-nodemon": "^2.2.1",
"gulp.spritesmith": "^6.9.0",
"habitica-markdown": "^1.3.0",
"hellojs": "^1.15.1",
"html-webpack-plugin": "^2.8.1",
"image-size": "~0.3.2",
"image-size": "^0.6.2",
"in-app-purchase": "^1.1.6",
"intro.js": "^2.6.0",
"jade": "~1.11.0",
"jquery": ">=3.0.0",
"js2xmlparser": "~1.0.0",
"lodash": "^4.17.4",
"merge-stream": "^1.0.0",
"method-override": "^2.3.5",
"moment": "^2.13.0",
"moment-recur": "git://github.com/habitrpg/moment-recur#f147ef27bbc26ca67638385f3db4a44084c76626",
"mongoose": "~4.8.6",
"mongoose-id-autoinc": "~2013.7.14-4",
"moment-recur": "git://github.com/habitrpg/moment-recur.git#f147ef27bbc26ca67638385f3db4a44084c76626",
"mongoose": "^4.13.10",
"morgan": "^1.7.0",
"nconf": "~0.8.2",
"nib": "^1.1.0",
"node-gcm": "^0.14.4",
"node-sass": "^4.5.0",
"nodemailer": "^2.3.2",
"object-path": "^0.9.2",
"ora": "^1.1.0",
"pageres": "^4.1.1",
"passport": "^0.3.2",
"passport-facebook": "^2.0.0",
"passport-google-oauth20": "1.0.0",
"paypal-ipn": "3.0.0",
"paypal-rest-sdk": "^1.2.1",
"popper.js": "^1.11.0",
"paypal-rest-sdk": "^1.8.1",
"popper.js": "^1.13.0",
"postcss-easy-import": "^2.0.0",
"pretty-data": "^0.40.0",
"ps-tree": "^1.0.0",
"pug": "^2.0.0-beta.12",
"push-notify": "git://github.com/habitrpg/push-notify#6bc2b5fdb1bdc9649b9ec1964d79ca50187fc8a9",
"pug": "^2.0.0-rc.4",
"push-notify": "git://github.com/habitrpg/push-notify.git#6bc2b5fdb1bdc9649b9ec1964d79ca50187fc8a9",
"pusher": "^1.3.0",
"request": "~2.74.0",
"request": "^2.83.0",
"rimraf": "^2.4.3",
"run-sequence": "^1.1.4",
"s3-upload-stream": "^1.0.6",
"sass-loader": "^6.0.2",
"serve-favicon": "^2.3.0",
"shelljs": "^0.7.6",
"sortablejs": "^1.6.1",
"shelljs": "^0.8.1",
"stripe": "^4.2.0",
"superagent": "^3.4.3",
"svg-inline-loader": "^0.7.1",
"svg-url-loader": "^2.0.2",
"svgo-loader": "^1.2.1",
"universal-analytics": "~0.3.2",
"universal-analytics": "^0.4.16",
"url-loader": "^0.5.7",
"useragent": "^2.1.9",
"uuid": "^3.0.1",
"validator": "^4.9.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"vinyl-buffer": "^1.0.1",
"vue": "^2.5.2",
"vue-loader": "^13.3.0",
"vue-mugen-scroll": "^0.2.1",
@@ -123,11 +104,11 @@
"vue-style-loader": "^3.0.0",
"vue-template-compiler": "^2.5.2",
"vuedraggable": "^2.15.0",
"vuejs-datepicker": "git://github.com/habitrpg/vuejs-datepicker#825a866b6a9c52dd8c588a3e8b900880875ce914",
"vuejs-datepicker": "git://github.com/habitrpg/vuejs-datepicker.git#5d237615463a84a23dd6f3f77c6ab577d68593ec",
"webpack": "^2.2.1",
"webpack-merge": "^4.0.0",
"winston": "^2.1.0",
"winston-loggly-bulk": "^1.4.2",
"winston-loggly-bulk": "^2.0.2",
"xml2js": "^0.4.4"
},
"private": true,
@@ -163,55 +144,44 @@
"babel-plugin-istanbul": "^4.0.0",
"chai": "^3.4.0",
"chai-as-promised": "^5.1.0",
"chalk": "^1.1.3",
"chalk": "^2.3.0",
"chromedriver": "^2.27.2",
"connect-history-api-fallback": "^1.1.0",
"coveralls": "^2.11.2",
"cross-spawn": "^5.0.1",
"coveralls": "^3.0.0",
"cross-spawn": "^6.0.4",
"csv": "~0.3.6",
"deep-diff": "~0.1.4",
"eslint": "^3.0.0",
"eslint-config-habitrpg": "^3.0.0",
"eslint-friendly-formatter": "^2.0.5",
"eslint-loader": "^1.3.0",
"eslint-plugin-html": "^2.0.0",
"eslint-plugin-mocha": "^4.7.0",
"event-stream": "^3.2.2",
"eventsource-polyfill": "^0.9.6",
"expect.js": "~0.2.0",
"expect.js": "^0.3.1",
"http-proxy-middleware": "^0.17.0",
"inject-loader": "^3.0.0-beta4",
"istanbul": "^1.1.0-alpha.1",
"karma": "^1.3.0",
"karma-babel-preprocessor": "^6.0.1",
"karma-chai-plugins": "~0.6.0",
"karma-coverage": "^0.5.3",
"karma-mocha": "^0.2.0",
"karma-mocha-reporter": "^1.1.1",
"karma": "^2.0.0",
"karma-babel-preprocessor": "^7.0.0",
"karma-chai-plugins": "^0.9.0",
"karma-coverage": "^1.1.1",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-phantomjs-launcher": "^1.0.0",
"karma-sinon-chai": "~1.2.0",
"karma-sinon-chai": "^1.3.3",
"karma-sinon-stub-promise": "^1.0.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.24",
"karma-spec-reporter": "0.0.32",
"karma-webpack": "^2.0.2",
"lcov-result-merger": "^1.0.2",
"lolex": "^1.4.0",
"mocha": "^3.2.0",
"mongodb": "^2.0.46",
"mongoskin": "~2.1.0",
"lcov-result-merger": "^2.0.0",
"mocha": "^5.0.0",
"monk": "^4.0.0",
"nightwatch": "^0.9.12",
"phantomjs-prebuilt": "^2.1.12",
"protractor": "^3.1.1",
"raw-loader": "^0.5.1",
"require-again": "^2.0.0",
"rewire": "^2.3.3",
"selenium-server": "^3.0.1",
"sinon": "^1.17.2",
"sinon": "^4.2.2",
"sinon-chai": "^2.8.0",
"sinon-stub-promise": "^4.0.0",
"superagent-defaults": "^0.1.13",
"vinyl-transform": "^1.0.0",
"webpack-bundle-analyzer": "^2.2.1",
"webpack-dev-middleware": "^1.10.0",
"webpack-hot-middleware": "^2.6.1"

View File

@@ -149,7 +149,10 @@ describe('GET /challenges/:challengeId/members', () => {
let usersToGenerate = [];
for (let i = 0; i < 3; i++) {
usersToGenerate.push(generateUser({challenges: [challenge._id]}));
usersToGenerate.push(generateUser({
challenges: [challenge._id],
'profile.name': `${i}profilename`,
}));
}
let generatedUsers = await Promise.all(usersToGenerate);
let profileNames = generatedUsers.map(generatedUser => generatedUser.profile.name);

View File

@@ -95,13 +95,23 @@ describe('GET /challenges/:challengeId/members/:memberId', () => {
expect(memberProgress.tasks[0].challenge.taskId).to.equal(chalTasks[0]._id);
});
it('returns the tasks without the tags', async () => {
it('returns the tasks without the tags and checklist', async () => {
let group = await generateGroup(user, {type: 'party', name: generateUUID()});
let challenge = await generateChallenge(user, group);
let taskText = 'Test Text';
await user.post(`/tasks/challenge/${challenge._id}`, [{type: 'habit', text: taskText}]);
await user.post(`/tasks/challenge/${challenge._id}`, [{
type: 'todo',
text: taskText,
checklist: [
{
_id: 123,
text: 'test',
},
],
}]);
let memberProgress = await user.get(`/challenges/${challenge._id}/members/${user._id}`);
expect(memberProgress.tasks[0]).not.to.have.key('tags');
expect(memberProgress.tasks[0].checklist).to.eql([]);
});
});

View File

@@ -314,5 +314,33 @@ describe('POST /challenges', () => {
groupLeader = await groupLeader.sync();
expect(groupLeader.achievements.joinedChallenge).to.be.true;
});
it('sets summary to challenges name when not supplied', async () => {
const name = 'Test Challenge';
const challenge = await groupLeader.post('/challenges', {
group: group._id,
name,
shortName: 'TC Label',
});
const updatedChallenge = await groupLeader.get(`/challenges/${challenge._id}`);
expect(updatedChallenge.summary).to.eql(name);
});
it('sets summary to challenges', async () => {
const name = 'Test Challenge';
const summary = 'Test Summary Challenge';
const challenge = await groupLeader.post('/challenges', {
group: group._id,
name,
shortName: 'TC Label',
summary,
});
const updatedChallenge = await groupLeader.get(`/challenges/${challenge._id}`);
expect(updatedChallenge.summary).to.eql(summary);
});
});
});

View File

@@ -101,19 +101,21 @@ describe('POST /challenges/:challengeId/join', () => {
});
it('syncs challenge tasks to joining user', async () => {
let taskText = 'A challenge task text';
const taskText = 'A challenge task text';
await groupLeader.post(`/tasks/challenge/${challenge._id}`, [
{type: 'habit', text: taskText},
{type: 'daily', text: taskText},
]);
await authorizedUser.post(`/challenges/${challenge._id}/join`);
let tasks = await authorizedUser.get('/tasks/user');
let tasksTexts = tasks.map((task) => {
return task.text;
const tasks = await authorizedUser.get('/tasks/user');
const syncedTask = tasks.find((task) => {
return task.text === taskText;
});
expect(tasksTexts).to.include(taskText);
expect(syncedTask.text).to.eql(taskText);
expect(syncedTask.isDue).to.exist;
expect(syncedTask.nextDue).to.exist;
});
it('adds challenge tag to user tags', async () => {

View File

@@ -149,13 +149,19 @@ describe('POST /challenges/:challengeId/winner/:winnerId', () => {
await sleep(0.5);
let tasks = await winningUser.get('/tasks/user');
let testTask = _.find(tasks, (task) => {
const tasks = await winningUser.get('/tasks/user');
const testTask = _.find(tasks, (task) => {
return task.text === taskText;
});
const updatedUser = await winningUser.sync();
const challengeTag = updatedUser.tags.find(tags => {
return tags.id === challenge._id;
});
expect(testTask.challenge.broken).to.eql('CHALLENGE_CLOSED');
expect(testTask.challenge.winner).to.eql(winningUser.profile.name);
expect(challengeTag.challenge).to.eql('false');
});
});
});

View File

@@ -0,0 +1,43 @@
import {
generateUser,
generateGroup,
} from '../../../../helpers/api-v3-integration.helper';
describe('POST /challenges/:challengeId/clone', () => {
it('clones a challenge', async () => {
const user = await generateUser({balance: 10});
const group = await generateGroup(user);
const name = 'Test Challenge';
const shortName = 'TC Label';
const description = 'Test Description';
const prize = 1;
const challenge = await user.post('/challenges', {
group: group._id,
name,
shortName,
description,
prize,
});
const challengeTask = await user.post(`/tasks/challenge/${challenge._id}`, {
text: 'test habit',
type: 'habit',
up: false,
down: true,
notes: 1976,
});
const cloneChallengeResponse = await user.post(`/challenges/${challenge._id}/clone`, {
group: group._id,
name: `${name} cloned`,
shortName,
description,
prize,
});
expect(cloneChallengeResponse.clonedTasks[0].text).to.eql(challengeTask.text);
expect(cloneChallengeResponse.clonedTasks[0]._id).to.not.eql(challengeTask._id);
expect(cloneChallengeResponse.clonedTasks[0].challenge.id).to.eql(cloneChallengeResponse.clonedChallenge._id);
});
});

View File

@@ -71,11 +71,9 @@ describe('DELETE /groups/:groupId/chat/:chatId', () => {
});
it('returns the update chat when previous message parameter is passed and the chat is updated', async () => {
await expect(user.del(`/groups/${groupWithChat._id}/chat/${nextMessage.id}?previousMsg=${message.id}`))
.eventually
.is.an('array')
.to.include(message)
.to.be.lengthOf(1);
let deleteResult = await user.del(`/groups/${groupWithChat._id}/chat/${nextMessage.id}?previousMsg=${message.id}`);
expect(deleteResult[0].id).to.eql(message.id);
});
});
});

View File

@@ -234,7 +234,7 @@ describe('POST /chat', () => {
// Email sent to mods
await sleep(0.5);
expect(email.sendTxn).to.be.calledOnce;
expect(email.sendTxn.args[0][1]).to.be.eql('slur-report-to-mods');
expect(email.sendTxn.args[0][1]).to.eql('slur-report-to-mods');
// Slack message to mods
expect(IncomingWebhook.prototype.send).to.be.calledOnce;
@@ -287,7 +287,7 @@ describe('POST /chat', () => {
// Email sent to mods
await sleep(0.5);
expect(email.sendTxn).to.be.calledThrice;
expect(email.sendTxn.args[2][1]).to.be.eql('slur-report-to-mods');
expect(email.sendTxn.args[2][1]).to.eql('slur-report-to-mods');
// Slack message to mods
expect(IncomingWebhook.prototype.send).to.be.calledOnce;
@@ -364,6 +364,30 @@ describe('POST /chat', () => {
expect(message.message.id).to.exist;
});
it('creates a chat with user styles', async () => {
const mount = 'test-mount';
const pet = 'test-pet';
const style = 'test-style';
const userWithStyle = await generateUser({
'items.currentMount': mount,
'items.currentPet': pet,
'preferences.style': style,
});
await userWithStyle.sync();
const message = await userWithStyle.post(`/groups/${groupWithChat._id}/chat`, { message: testMessage});
expect(message.message.id).to.exist;
expect(message.message.userStyles.items.currentMount).to.eql(userWithStyle.items.currentMount);
expect(message.message.userStyles.items.currentPet).to.eql(userWithStyle.items.currentPet);
expect(message.message.userStyles.preferences.style).to.eql(userWithStyle.preferences.style);
expect(message.message.userStyles.preferences.hair).to.eql(userWithStyle.preferences.hair);
expect(message.message.userStyles.preferences.skin).to.eql(userWithStyle.preferences.skin);
expect(message.message.userStyles.preferences.shirt).to.eql(userWithStyle.preferences.shirt);
expect(message.message.userStyles.preferences.chair).to.eql(userWithStyle.preferences.chair);
expect(message.message.userStyles.preferences.background).to.eql(userWithStyle.preferences.background);
});
it('adds backer info to chat', async () => {
const backerInfo = {
npc: 'Town Crier',
@@ -426,6 +450,9 @@ describe('POST /chat', () => {
expect(message.message.id).to.exist;
expect(memberWithNotification.newMessages[`${groupWithChat._id}`]).to.exist;
expect(memberWithNotification.notifications.find(n => {
return n.type === 'NEW_CHAT_MESSAGE' && n.data.group.id === groupWithChat._id;
})).to.exist;
});
it('notifies other users of new messages for a party', async () => {
@@ -443,6 +470,9 @@ describe('POST /chat', () => {
expect(message.message.id).to.exist;
expect(memberWithNotification.newMessages[`${group._id}`]).to.exist;
expect(memberWithNotification.notifications.find(n => {
return n.type === 'NEW_CHAT_MESSAGE' && n.data.group.id === group._id;
})).to.exist;
});
context('Spam prevention', () => {

View File

@@ -1,5 +1,6 @@
import {
createAndPopulateGroup,
sleep,
} from '../../../../helpers/api-v3-integration.helper';
describe('POST /groups/:id/chat/seen', () => {
@@ -24,10 +25,15 @@ describe('POST /groups/:id/chat/seen', () => {
});
it('clears new messages for a guild', async () => {
await guildMember.sync();
const initialNotifications = guildMember.notifications.length;
await guildMember.post(`/groups/${guild._id}/chat/seen`);
await sleep(0.5);
let guildThatHasSeenChat = await guildMember.get('/user');
expect(guildThatHasSeenChat.notifications.length).to.equal(initialNotifications - 1);
expect(guildThatHasSeenChat.newMessages).to.be.empty;
});
});
@@ -53,10 +59,13 @@ describe('POST /groups/:id/chat/seen', () => {
});
it('clears new messages for a party', async () => {
await partyMember.sync();
const initialNotifications = partyMember.notifications.length;
await partyMember.post(`/groups/${party._id}/chat/seen`);
let partyMemberThatHasSeenChat = await partyMember.get('/user');
expect(partyMemberThatHasSeenChat.notifications.length).to.equal(initialNotifications - 1);
expect(partyMemberThatHasSeenChat.newMessages).to.be.empty;
});
});

View File

@@ -72,7 +72,7 @@ describe('GET /groups/:groupId/members', () => {
expect(memberRes).to.have.all.keys([ // works as: object has all and only these keys
'_id', 'id', 'preferences', 'profile', 'stats', 'achievements', 'party',
'backer', 'contributor', 'auth', 'items', 'inbox',
'backer', 'contributor', 'auth', 'items', 'inbox', 'loginIncentives',
]);
expect(Object.keys(memberRes.auth)).to.eql(['timestamps']);
expect(Object.keys(memberRes.preferences).sort()).to.eql([
@@ -93,7 +93,7 @@ describe('GET /groups/:groupId/members', () => {
expect(memberRes).to.have.all.keys([ // works as: object has all and only these keys
'_id', 'id', 'preferences', 'profile', 'stats', 'achievements', 'party',
'backer', 'contributor', 'auth', 'items', 'inbox',
'backer', 'contributor', 'auth', 'items', 'inbox', 'loginIncentives',
]);
expect(Object.keys(memberRes.auth)).to.eql(['timestamps']);
expect(Object.keys(memberRes.preferences).sort()).to.eql([

View File

@@ -44,6 +44,32 @@ describe('POST /group', () => {
},
});
});
it('sets summary to groups name when not supplied', async () => {
const name = 'Test Group';
const group = await user.post('/groups', {
name,
type: 'guild',
});
const updatedGroup = await user.get(`/groups/${group._id}`);
expect(updatedGroup.summary).to.eql(name);
});
it('sets summary to groups', async () => {
const name = 'Test Group';
const summary = 'Test Summary';
const group = await user.post('/groups', {
name,
type: 'guild',
summary,
});
const updatedGroup = await user.get(`/groups/${group._id}`);
expect(updatedGroup.summary).to.eql(summary);
});
});
context('Guilds', () => {

View File

@@ -70,13 +70,21 @@ describe('POST /groups/:groupId/leave', () => {
it('removes new messages for that group from user', async () => {
await member.post(`/groups/${groupToLeave._id}/chat`, { message: 'Some message' });
await sleep(0.5);
await leader.sync();
expect(leader.notifications.find(n => {
return n.type === 'NEW_CHAT_MESSAGE' && n.data.group.id === groupToLeave._id;
})).to.exist;
expect(leader.newMessages[groupToLeave._id]).to.not.be.empty;
await leader.post(`/groups/${groupToLeave._id}/leave`);
await leader.sync();
expect(leader.notifications.find(n => {
return n.type === 'NEW_CHAT_MESSAGE' && n.data.group.id === groupToLeave._id;
})).to.not.exist;
expect(leader.newMessages[groupToLeave._id]).to.be.empty;
});
@@ -256,7 +264,7 @@ describe('POST /groups/:groupId/leave', () => {
it('deletes non existant party from user when user tries to leave', async () => {
let nonExistentPartyId = generateUUID();
let userWithNonExistentParty = await generateUser({'party._id': nonExistentPartyId});
expect(userWithNonExistentParty.party._id).to.be.eql(nonExistentPartyId);
expect(userWithNonExistentParty.party._id).to.eql(nonExistentPartyId);
await expect(userWithNonExistentParty.post(`/groups/${nonExistentPartyId}/leave`))
.to.eventually.be.rejected;

View File

@@ -2,6 +2,7 @@ import {
generateUser,
createAndPopulateGroup,
translate as t,
sleep,
} from '../../../../helpers/api-v3-integration.helper';
import * as email from '../../../../../website/server/libs/email';
@@ -119,16 +120,16 @@ describe('POST /groups/:groupId/removeMember/:memberId', () => {
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');
expect(email.sendTxn.args[0][0]._id).to.eql(invitedUser._id);
expect(email.sendTxn.args[0][1]).to.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');
expect(email.sendTxn.args[0][0]._id).to.eql(member._id);
expect(email.sendTxn.args[0][1]).to.eql('kicked-from-guild');
});
});
@@ -188,13 +189,20 @@ describe('POST /groups/:groupId/removeMember/:memberId', () => {
it('removes new messages from a member who is removed', async () => {
await partyLeader.post(`/groups/${party._id}/chat`, { message: 'Some message' });
await sleep(0.5);
await removedMember.sync();
expect(removedMember.notifications.find(n => {
return n.type === 'NEW_CHAT_MESSAGE' && n.data.group.id === party._id;
})).to.exist;
expect(removedMember.newMessages[party._id]).to.not.be.empty;
await partyLeader.post(`/groups/${party._id}/removeMember/${removedMember._id}`);
await removedMember.sync();
expect(removedMember.notifications.find(n => {
return n.type === 'NEW_CHAT_MESSAGE' && n.data.group.id === party._id;
})).to.not.exist;
expect(removedMember.newMessages[party._id]).to.be.empty;
});
@@ -247,16 +255,16 @@ describe('POST /groups/:groupId/removeMember/:memberId', () => {
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');
expect(email.sendTxn.args[0][0]._id).to.eql(partyInvitedUser._id);
expect(email.sendTxn.args[0][1]).to.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');
expect(email.sendTxn.args[0][0]._id).to.eql(partyMember._id);
expect(email.sendTxn.args[0][1]).to.eql('kicked-from-party');
});
});
});

View File

@@ -110,6 +110,7 @@ describe('Post /groups/:groupId/invite', () => {
id: group._id,
name: groupName,
inviter: inviter._id,
publicGuild: false,
}]);
await expect(userToInvite.get('/user'))
@@ -127,11 +128,13 @@ describe('Post /groups/:groupId/invite', () => {
id: group._id,
name: groupName,
inviter: inviter._id,
publicGuild: false,
},
{
id: group._id,
name: groupName,
inviter: inviter._id,
publicGuild: false,
},
]);

View File

@@ -32,7 +32,7 @@ describe('GET /members/:memberId', () => {
let memberRes = await user.get(`/members/${member._id}`);
expect(memberRes).to.have.all.keys([ // works as: object has all and only these keys
'_id', 'id', 'preferences', 'profile', 'stats', 'achievements', 'party',
'backer', 'contributor', 'auth', 'items', 'inbox',
'backer', 'contributor', 'auth', 'items', 'inbox', 'loginIncentives',
]);
expect(Object.keys(memberRes.auth)).to.eql(['timestamps']);
expect(Object.keys(memberRes.preferences).sort()).to.eql([

View File

@@ -98,6 +98,7 @@ describe('POST /members/send-private-message', () => {
it('sends a private message to a user', async () => {
let receiver = await generateUser();
// const initialNotifications = receiver.notifications.length;
await userToSendMessage.post('/members/send-private-message', {
message: messageToSend,
@@ -115,10 +116,44 @@ describe('POST /members/send-private-message', () => {
return message.uuid === receiver._id && message.text === messageToSend;
});
// @TODO waiting for mobile support
// expect(updatedReceiver.notifications.length).to.equal(initialNotifications + 1);
// const notification = updatedReceiver.notifications[updatedReceiver.notifications.length - 1];
// expect(notification.type).to.equal('NEW_INBOX_MESSAGE');
// expect(notification.data.messageId).to.equal(sendersMessageInReceiversInbox.id);
// expect(notification.data.excerpt).to.equal(messageToSend);
// expect(notification.data.sender.id).to.equal(updatedSender._id);
// expect(notification.data.sender.name).to.equal(updatedSender.profile.name);
expect(sendersMessageInReceiversInbox).to.exist;
expect(sendersMessageInSendersInbox).to.exist;
});
// @TODO waiting for mobile support
xit('creates a notification with an excerpt if the message is too long', async () => {
let receiver = await generateUser();
let longerMessageToSend = 'A very long message, that for sure exceeds the limit of 100 chars for the excerpt that we set to 100 chars';
let messageExcerpt = `${longerMessageToSend.substring(0, 100)}...`;
await userToSendMessage.post('/members/send-private-message', {
message: longerMessageToSend,
toUserId: receiver._id,
});
let updatedReceiver = await receiver.get('/user');
let sendersMessageInReceiversInbox = _.find(updatedReceiver.inbox.messages, (message) => {
return message.uuid === userToSendMessage._id && message.text === longerMessageToSend;
});
const notification = updatedReceiver.notifications[updatedReceiver.notifications.length - 1];
expect(notification.type).to.equal('NEW_INBOX_MESSAGE');
expect(notification.data.messageId).to.equal(sendersMessageInReceiversInbox.id);
expect(notification.data.excerpt).to.equal(messageExcerpt);
});
it('allows admin to send when sender has blocked the admin', async () => {
userToSendMessage = await generateUser({
'contributor.admin': 1,

View File

@@ -0,0 +1,16 @@
import {
requester,
} from '../../../../helpers/api-v3-integration.helper';
describe('GET /news', () => {
let api;
beforeEach(async () => {
api = requester();
});
it('returns the latest news in html format, does not require authentication', async () => {
const res = await api.get('/news');
expect(res).to.be.a.string;
});
});

View File

@@ -0,0 +1,42 @@
import {
generateUser,
} from '../../../../helpers/api-v3-integration.helper';
describe('POST /news/tell-me-later', () => {
let user;
beforeEach(async () => {
user = await generateUser({
'flags.newStuff': true,
});
});
it('marks new stuff as read and adds notification', async () => {
expect(user.flags.newStuff).to.equal(true);
const initialNotifications = user.notifications.length;
await user.post('/news/tell-me-later');
await user.sync();
expect(user.flags.newStuff).to.equal(false);
expect(user.notifications.length).to.equal(initialNotifications + 1);
const notification = user.notifications[user.notifications.length - 1];
expect(notification.type).to.equal('NEW_STUFF');
// should be marked as seen by default so it's not counted in the number of notifications
expect(notification.seen).to.equal(true);
expect(notification.data.title).to.be.a.string;
});
it('never adds two notifications', async () => {
const initialNotifications = user.notifications.length;
await user.post('/news/tell-me-later');
await user.post('/news/tell-me-later');
await user.sync();
expect(user.notifications.length).to.equal(initialNotifications + 1);
});
});

View File

@@ -47,6 +47,7 @@ describe('POST /notifications/:notificationId/read', () => {
id: id2,
type: 'LOGIN_INCENTIVE',
data: {},
seen: false,
}]);
await user.sync();

View File

@@ -0,0 +1,59 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
import { v4 as generateUUID } from 'uuid';
describe('POST /notifications/:notificationId/see', () => {
let user;
before(async () => {
user = await generateUser();
});
it('errors when notification is not found', async () => {
let dummyId = generateUUID();
await expect(user.post(`/notifications/${dummyId}/see`)).to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('messageNotificationNotFound'),
});
});
it('mark a notification as seen', async () => {
expect(user.notifications.length).to.equal(0);
const id = generateUUID();
const id2 = generateUUID();
await user.update({
notifications: [{
id,
type: 'DROPS_ENABLED',
data: {},
}, {
id: id2,
type: 'LOGIN_INCENTIVE',
data: {},
}],
});
const userObj = await user.get('/user'); // so we can check that defaults have been applied
expect(userObj.notifications.length).to.equal(2);
expect(userObj.notifications[0].seen).to.equal(false);
const res = await user.post(`/notifications/${id}/see`);
expect(res).to.deep.equal({
id,
type: 'DROPS_ENABLED',
data: {},
seen: true,
});
await user.sync();
expect(user.notifications.length).to.equal(2);
expect(user.notifications[0].id).to.equal(id);
expect(user.notifications[0].seen).to.equal(true);
});
});

View File

@@ -4,7 +4,7 @@ import {
} from '../../../../helpers/api-v3-integration.helper';
import { v4 as generateUUID } from 'uuid';
describe('POST /notifications/:notificationId/read', () => {
describe('POST /notifications/read', () => {
let user;
before(async () => {
@@ -57,6 +57,7 @@ describe('POST /notifications/:notificationId/read', () => {
id: id2,
type: 'LOGIN_INCENTIVE',
data: {},
seen: false,
}]);
await user.sync();

View File

@@ -0,0 +1,88 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
import { v4 as generateUUID } from 'uuid';
describe('POST /notifications/see', () => {
let user;
before(async () => {
user = await generateUser();
});
it('errors when notification is not found', async () => {
let dummyId = generateUUID();
await expect(user.post('/notifications/see', {
notificationIds: [dummyId],
})).to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('messageNotificationNotFound'),
});
});
it('mark multiple notifications as seen', async () => {
expect(user.notifications.length).to.equal(0);
const id = generateUUID();
const id2 = generateUUID();
const id3 = generateUUID();
await user.update({
notifications: [{
id,
type: 'DROPS_ENABLED',
data: {},
seen: false,
}, {
id: id2,
type: 'LOGIN_INCENTIVE',
data: {},
seen: false,
}, {
id: id3,
type: 'CRON',
data: {},
seen: false,
}],
});
await user.sync();
expect(user.notifications.length).to.equal(3);
const res = await user.post('/notifications/see', {
notificationIds: [id, id3],
});
expect(res).to.deep.equal([
{
id,
type: 'DROPS_ENABLED',
data: {},
seen: true,
}, {
id: id2,
type: 'LOGIN_INCENTIVE',
data: {},
seen: false,
}, {
id: id3,
type: 'CRON',
data: {},
seen: true,
}]);
await user.sync();
expect(user.notifications.length).to.equal(3);
expect(user.notifications[0].id).to.equal(id);
expect(user.notifications[0].seen).to.equal(true);
expect(user.notifications[1].id).to.equal(id2);
expect(user.notifications[1].seen).to.equal(false);
expect(user.notifications[2].id).to.equal(id3);
expect(user.notifications[2].seen).to.equal(true);
});
});

View File

@@ -139,6 +139,23 @@ describe('PUT /tasks/:id', () => {
expect(savedHabit.up).to.eql(false);
expect(savedHabit.down).to.eql(false);
});
it('allows user to update their copy', async () => {
const userTasks = await user.get('/tasks/user');
const userChallengeTasks = userTasks.filter(task => task.challenge.id === challenge._id);
const userCopyOfChallengeTask = userChallengeTasks[0];
await user.put(`/tasks/${userCopyOfChallengeTask._id}`, {
notes: 'some new notes',
counterDown: 1,
counterUp: 2,
});
const savedHabit = await user.get(`/tasks/${userCopyOfChallengeTask._id}`);
expect(savedHabit.notes).to.eql('some new notes');
expect(savedHabit.counterDown).to.eql(1);
expect(savedHabit.counterUp).to.eql(2);
});
});
context('todos', () => {

View File

@@ -0,0 +1,189 @@
import {
createAndPopulateGroup,
translate as t,
} from '../../../../../helpers/api-integration/v3';
import { find } from 'lodash';
describe('POST /tasks/:id/needs-work/:userId', () => {
let user, guild, member, member2, 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: 2,
});
guild = group;
user = groupLeader;
member = members[0];
member2 = members[1];
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}/needs-work/${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}/needs-work/${member._id}`))
.to.eventually.be.rejected.and.to.eql({
code: 401,
error: 'NotAuthorized',
message: t('onlyGroupLeaderCanEditTasks'),
});
});
it('marks as task as needing more work', async () => {
const initialNotifications = member.notifications.length;
await user.post(`/tasks/${task._id}/assign/${member._id}`);
let memberTasks = await member.get('/tasks/user');
let syncedTask = find(memberTasks, findAssignedTask);
// score task to require approval
await expect(member.post(`/tasks/${syncedTask._id}/score/up`))
.to.eventually.be.rejected.and.to.eql({
code: 401,
error: 'NotAuthorized',
message: t('taskApprovalHasBeenRequested'),
});
await user.post(`/tasks/${task._id}/needs-work/${member._id}`);
[memberTasks] = await Promise.all([member.get('/tasks/user'), member.sync()]);
syncedTask = find(memberTasks, findAssignedTask);
// Check that the notification approval request has been removed
expect(syncedTask.group.approval.requested).to.equal(false);
expect(syncedTask.group.approval.requestedDate).to.equal(undefined);
// Check that the notification is correct
expect(member.notifications.length).to.equal(initialNotifications + 1);
const notification = member.notifications[member.notifications.length - 1];
expect(notification.type).to.equal('GROUP_TASK_NEEDS_WORK');
const taskText = syncedTask.text;
const managerName = user.profile.name;
expect(notification.data.message).to.equal(t('taskNeedsWork', {taskText, managerName}));
expect(notification.data.task.id).to.equal(syncedTask._id);
expect(notification.data.task.text).to.equal(taskText);
expect(notification.data.group.id).to.equal(syncedTask.group.id);
expect(notification.data.group.name).to.equal(guild.name);
expect(notification.data.manager.id).to.equal(user._id);
expect(notification.data.manager.name).to.equal(managerName);
// Check that the managers' GROUP_TASK_APPROVAL notifications have been removed
await user.sync();
expect(user.notifications.find(n => {
n.data.taskId === syncedTask._id && n.type === 'GROUP_TASK_APPROVAL';
})).to.equal(undefined);
});
it('allows a manager to mark a task as needing work', async () => {
await user.post(`/groups/${guild._id}/add-manager`, {
managerId: member2._id,
});
await member2.post(`/tasks/${task._id}/assign/${member._id}`);
let memberTasks = await member.get('/tasks/user');
let syncedTask = find(memberTasks, findAssignedTask);
// score task to require approval
await expect(member.post(`/tasks/${syncedTask._id}/score/up`))
.to.eventually.be.rejected.and.to.eql({
code: 401,
error: 'NotAuthorized',
message: t('taskApprovalHasBeenRequested'),
});
const initialNotifications = member.notifications.length;
await member2.post(`/tasks/${task._id}/needs-work/${member._id}`);
[memberTasks] = await Promise.all([member.get('/tasks/user'), member.sync()]);
syncedTask = find(memberTasks, findAssignedTask);
// Check that the notification approval request has been removed
expect(syncedTask.group.approval.requested).to.equal(false);
expect(syncedTask.group.approval.requestedDate).to.equal(undefined);
expect(member.notifications.length).to.equal(initialNotifications + 1);
const notification = member.notifications[member.notifications.length - 1];
expect(notification.type).to.equal('GROUP_TASK_NEEDS_WORK');
const taskText = syncedTask.text;
const managerName = member2.profile.name;
expect(notification.data.message).to.equal(t('taskNeedsWork', {taskText, managerName}));
expect(notification.data.task.id).to.equal(syncedTask._id);
expect(notification.data.task.text).to.equal(taskText);
expect(notification.data.group.id).to.equal(syncedTask.group.id);
expect(notification.data.group.name).to.equal(guild.name);
expect(notification.data.manager.id).to.equal(member2._id);
expect(notification.data.manager.name).to.equal(managerName);
// Check that the managers' GROUP_TASK_APPROVAL notifications have been removed
await Promise.all([user.sync(), member2.sync()]);
expect(user.notifications.find(n => {
n.data.taskId === syncedTask._id && n.type === 'GROUP_TASK_APPROVAL';
})).to.equal(undefined);
expect(member2.notifications.find(n => {
n.data.taskId === syncedTask._id && n.type === 'GROUP_TASK_APPROVAL';
})).to.equal(undefined);
});
it('prevents marking a task as needing work if it was already approved', async () => {
await user.post(`/groups/${guild._id}/add-manager`, {
managerId: member2._id,
});
await member2.post(`/tasks/${task._id}/assign/${member._id}`);
await member2.post(`/tasks/${task._id}/approve/${member._id}`);
await expect(user.post(`/tasks/${task._id}/needs-work/${member._id}`))
.to.eventually.be.rejected.and.to.eql({
code: 401,
error: 'NotAuthorized',
message: t('canOnlyApproveTaskOnce'),
});
});
it('prevents marking a task as needing work if it is not waiting for approval', async () => {
await user.post(`/tasks/${task._id}/assign/${member._id}`);
await expect(user.post(`/tasks/${task._id}/needs-work/${member._id}`))
.to.eventually.be.rejected.and.to.eql({
code: 401,
error: 'NotAuthorized',
message: t('taskApprovalWasNotRequested'),
});
});
});

View File

@@ -25,6 +25,7 @@ describe('GET /user/anonymized', () => {
'achievements.challenges': 'some',
'inbox.messages': [{ text: 'some text' }],
tags: [{ name: 'some name', challenge: 'some challenge' }],
notifications: [],
});
await generateHabit({ userId: user._id });
@@ -65,6 +66,7 @@ describe('GET /user/anonymized', () => {
expect(returnedUser.stats.toNextLevel).to.eql(common.tnl(user.stats.lvl));
expect(returnedUser.stats.maxMP).to.eql(30); // TODO why 30?
expect(returnedUser.newMessages).to.not.exist;
expect(returnedUser.notifications).to.not.exist;
expect(returnedUser.profile).to.not.exist;
expect(returnedUser.purchased.plan).to.not.exist;
expect(returnedUser.contributor).to.not.exist;

View File

@@ -30,7 +30,7 @@ describe('POST /user/feed/:pet/:food', () => {
data: user.items.pets['Wolf-Base'],
message: t('messageDontEnjoyFood', {
egg: pet.text(),
foodText: food.text(),
foodText: food.textThe(),
}),
});

View File

@@ -13,15 +13,20 @@ describe('POST /user/open-mystery-item', () => {
beforeEach(async () => {
user = await generateUser({
'purchased.plan.mysteryItems': [mysteryItemKey],
notifications: [
{type: 'NEW_MYSTERY_ITEMS', data: { items: [mysteryItemKey] }},
],
});
});
// More tests in common code unit tests
it('opens a mystery item', async () => {
expect(user.notifications.length).to.equal(1);
let response = await user.post('/user/open-mystery-item');
await user.sync();
expect(user.notifications.length).to.equal(0);
expect(user.items.gear.owned[mysteryItemKey]).to.be.true;
expect(response.message).to.equal(t('mysteryItemOpened'));
expect(response.data.key).to.eql(mysteryItemKey);

View File

@@ -26,13 +26,21 @@ describe('POST /user/read-card/:cardType', () => {
await user.update({
'items.special.greetingReceived': [true],
'flags.cardReceived': true,
notifications: [{
type: 'CARD_RECEIVED',
data: {card: cardType},
}],
});
await user.sync();
expect(user.notifications.length).to.equal(1);
let response = await user.post(`/user/read-card/${cardType}`);
await user.sync();
expect(response.message).to.equal(t('readCard', {cardType}));
expect(user.items.special[`${cardType}Received`]).to.be.empty;
expect(user.flags.cardReceived).to.be.false;
expect(user.notifications.length).to.equal(0);
});
});

View File

@@ -1,6 +1,7 @@
import {
generateUser,
} from '../../../../helpers/api-integration/v3';
import { mockAnalyticsService as analytics } from '../../../../../website/server/libs/analyticsService';
describe('POST /user/sleep', () => {
let user;
@@ -22,4 +23,15 @@ describe('POST /user/sleep', () => {
await user.sync();
expect(user.preferences.sleep).to.be.false;
});
it('sends sleep status to analytics service', async () => {
sandbox.spy(analytics, 'track');
await user.post('/user/sleep');
await user.sync();
expect(analytics.track).to.be.calledOnce;
expect(analytics.track).to.be.calledWith('sleep', sandbox.match.has('status', user.preferences.sleep));
sandbox.restore();
});
});

View File

@@ -6,10 +6,14 @@ import {
getProperty,
} from '../../../../../helpers/api-integration/v3';
import { ApiUser } from '../../../../../helpers/api-integration/api-classes';
import { v4 as generateRandomUserName } from 'uuid';
import { v4 as uuid } from 'uuid';
import { each } from 'lodash';
import { encrypt } from '../../../../../../website/server/libs/encryption';
function generateRandomUserName () {
return (Date.now() + uuid()).substring(0, 20);
}
describe('POST /user/auth/local/register', () => {
context('username and email are free', () => {
let api;
@@ -37,6 +41,71 @@ describe('POST /user/auth/local/register', () => {
expect(user.newUser).to.eql(true);
});
xit('remove spaces from username', async () => {
// TODO can probably delete this test now
let username = ' usernamewithspaces ';
let email = 'test@example.com';
let password = 'password';
let user = await api.post('/user/auth/local/register', {
username,
email,
password,
confirmPassword: password,
});
expect(user.auth.local.username).to.eql(username.trim());
expect(user.profile.name).to.eql(username.trim());
});
context('validates username', () => {
const email = 'test@example.com';
const password = 'password';
it('requires to username to be less than 20', async () => {
const username = (Date.now() + uuid()).substring(0, 21);
await expect(api.post('/user/auth/local/register', {
username,
email,
password,
confirmPassword: password,
})).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: 'Invalid request parameters.',
});
});
it('rejects chracters not in [-_a-zA-Z0-9]', async () => {
const username = 'a-zA_Z09*';
await expect(api.post('/user/auth/local/register', {
username,
email,
password,
confirmPassword: password,
})).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: 'Invalid request parameters.',
});
});
it('allows only [-_a-zA-Z0-9] characters', async () => {
const username = 'a-zA_Z09';
const user = await api.post('/user/auth/local/register', {
username,
email,
password,
confirmPassword: password,
});
expect(user.auth.local.username).to.eql(username);
});
});
context('provides default tags and tasks', async () => {
it('for a generic API consumer', async () => {
let username = generateRandomUserName();

View File

@@ -0,0 +1,35 @@
import { TAVERN_ID } from '../../../../../website/server/models/group';
import { updateDocument } from '../../../../helpers/mongo';
import {
requester,
resetHabiticaDB,
} from '../../../../helpers/api-v3-integration.helper';
describe('GET /world-state', () => {
before(async () => {
await resetHabiticaDB();
});
it('returns empty worldBoss object when world boss is not active (and does not require authentication)', async () => {
const res = await requester().get('/world-state');
expect(res.worldBoss).to.eql({});
});
it('returns Tavern quest data when world boss is active', async () => {
await updateDocument('groups', {_id: TAVERN_ID}, {quest: {active: true, key: 'dysheartener', progress: {hp: 50000, rage: 9999}}});
const res = await requester().get('/world-state');
expect(res).to.have.deep.property('worldBoss');
expect(res.worldBoss).to.eql({
active: true,
extra: {},
key: 'dysheartener',
progress: {
collect: {},
hp: 50000,
rage: 9999,
},
});
});
});

View File

@@ -153,6 +153,24 @@ describe('payments/index', () => {
expect(recipient.purchased.plan.dateUpdated).to.exist;
});
it('sets plan.dateUpdated if it did exist but the user has cancelled', async () => {
recipient.purchased.plan.dateUpdated = moment().subtract(1, 'days').toDate();
recipient.purchased.plan.dateTerminated = moment().subtract(1, 'days').toDate();
recipient.purchased.plan.customerId = 'testing';
await api.createSubscription(data);
expect(moment(recipient.purchased.plan.dateUpdated).date()).to.eql(moment().date());
});
it('sets plan.dateUpdated if it did exist but the user has a corrupt plan', async () => {
recipient.purchased.plan.dateUpdated = moment().subtract(1, 'days').toDate();
await api.createSubscription(data);
expect(moment(recipient.purchased.plan.dateUpdated).date()).to.eql(moment().date());
});
it('sets plan.dateCreated if it did not previously exist', async () => {
expect(recipient.purchased.plan.dateCreated).to.not.exist;
@@ -191,7 +209,7 @@ describe('payments/index', () => {
await api.createSubscription(data);
let msg = '\`Hello recipient, sender has sent you 3 months of subscription!\`';
expect(user.sendMessage).to.be.calledTwice;
expect(user.sendMessage).to.be.calledOnce;
expect(user.sendMessage).to.be.calledWith(recipient, { receiverMsg: msg, senderMsg: msg });
});
@@ -229,77 +247,6 @@ describe('payments/index', () => {
},
});
});
context('Winter 2017-18 Gift-1-Get-1 Promotion', async () => {
it('creates a gift subscription for purchaser and recipient if none exist', async () => {
await api.createSubscription(data);
expect(user.items.pets['Jackalope-RoyalPurple']).to.eql(5);
expect(user.purchased.plan.customerId).to.eql('Gift');
expect(user.purchased.plan.dateTerminated).to.exist;
expect(user.purchased.plan.dateUpdated).to.exist;
expect(user.purchased.plan.dateCreated).to.exist;
expect(recipient.items.pets['Jackalope-RoyalPurple']).to.eql(5);
expect(recipient.purchased.plan.customerId).to.eql('Gift');
expect(recipient.purchased.plan.dateTerminated).to.exist;
expect(recipient.purchased.plan.dateUpdated).to.exist;
expect(recipient.purchased.plan.dateCreated).to.exist;
});
it('adds extraMonths to existing subscription for purchaser and creates a gift subscription for recipient without sub', async () => {
user.purchased.plan = plan;
expect(user.purchased.plan.extraMonths).to.eql(0);
await api.createSubscription(data);
expect(user.purchased.plan.extraMonths).to.eql(3);
expect(recipient.items.pets['Jackalope-RoyalPurple']).to.eql(5);
expect(recipient.purchased.plan.customerId).to.eql('Gift');
expect(recipient.purchased.plan.dateTerminated).to.exist;
expect(recipient.purchased.plan.dateUpdated).to.exist;
expect(recipient.purchased.plan.dateCreated).to.exist;
});
it('adds extraMonths to existing subscription for recipient and creates a gift subscription for purchaser without sub', async () => {
recipient.purchased.plan = plan;
expect(recipient.purchased.plan.extraMonths).to.eql(0);
await api.createSubscription(data);
expect(recipient.purchased.plan.extraMonths).to.eql(3);
expect(user.items.pets['Jackalope-RoyalPurple']).to.eql(5);
expect(user.purchased.plan.customerId).to.eql('Gift');
expect(user.purchased.plan.dateTerminated).to.exist;
expect(user.purchased.plan.dateUpdated).to.exist;
expect(user.purchased.plan.dateCreated).to.exist;
});
it('adds extraMonths to existing subscriptions for purchaser and recipient', async () => {
user.purchased.plan = plan;
recipient.purchased.plan = plan;
expect(user.purchased.plan.extraMonths).to.eql(0);
expect(recipient.purchased.plan.extraMonths).to.eql(0);
await api.createSubscription(data);
expect(user.purchased.plan.extraMonths).to.eql(3);
expect(recipient.purchased.plan.extraMonths).to.eql(3);
});
it('sends a private message about the promotion', async () => {
await api.createSubscription(data);
let msg = '\`Hello sender, you received 3 months of subscription as part of our holiday gift-giving promotion!\`';
expect(user.sendMessage).to.be.calledTwice;
expect(user.sendMessage).to.be.calledWith(user, { senderMsg: msg });
});
});
});
context('Purchasing a subscription for self', () => {
@@ -470,13 +417,19 @@ describe('payments/index', () => {
it('awards mystery items when within the timeframe for a mystery item', async () => {
let mayMysteryItemTimeframe = 1464725113000; // May 31st 2016
let fakeClock = sinon.useFakeTimers(mayMysteryItemTimeframe);
data = { paymentMethod: 'PaymentMethod', user, sub: { key: 'basic_3mo' } };
const oldNotificationsCount = user.notifications.length;
await api.createSubscription(data);
expect(user.notifications.find(n => n.type === 'NEW_MYSTERY_ITEMS')).to.not.be.undefined;
expect(user.purchased.plan.mysteryItems).to.have.a.lengthOf(2);
expect(user.purchased.plan.mysteryItems).to.include('armor_mystery_201605');
expect(user.purchased.plan.mysteryItems).to.include('head_mystery_201605');
expect(user.notifications.length).to.equal(oldNotificationsCount + 1);
expect(user.notifications[0].type).to.equal('NEW_MYSTERY_ITEMS');
fakeClock.restore();
});

View File

@@ -47,7 +47,7 @@ describe('#upgradeGroupPlan', () => {
});
afterEach(function () {
sinon.restore(amzLib.authorizeOnBillingAgreement);
amzLib.authorizeOnBillingAgreement.restore();
uuid.v4.restore();
});

View File

@@ -58,7 +58,7 @@ describe('subscribe', () => {
cc.validate.restore();
});
it('subscribes with amazon with a coupon', async () => {
it('subscribes with paypal with a coupon', async () => {
sub.discount = 40;
sub.key = 'google_6mo';
coupon = 'example-coupon';

View File

@@ -73,7 +73,7 @@ describe('checkout with subscription', () => {
});
afterEach(function () {
sinon.restore(stripe.subscriptions.update);
stripe.subscriptions.update.restore();
stripe.customers.create.restore();
payments.createSubscription.restore();
});
@@ -144,7 +144,7 @@ describe('checkout with subscription', () => {
cc.validate.restore();
});
it('subscribes with amazon with a coupon', async () => {
it('subscribes with stripe with a coupon', async () => {
sub.discount = 40;
sub.key = 'google_6mo';
coupon = 'example-coupon';

View File

@@ -35,7 +35,10 @@ describe('Stripe - Webhooks', () => {
const error = new Error(`Missing handler for Stripe webhook ${eventType}`);
await stripePayments.handleWebhooks({requestBody: event}, stripe);
expect(logger.error).to.have.been.called.once;
expect(logger.error).to.have.been.calledWith(error, {event: eventRetrieved});
const calledWith = logger.error.getCall(0).args;
expect(calledWith[0].message).to.equal(error.message);
expect(calledWith[1].event).to.equal(eventRetrieved);
});
it('retrieves and validates the event from Stripe', async () => {

View File

@@ -45,7 +45,7 @@ describe('Stripe - Upgrade Group Plan', () => {
});
afterEach(function () {
sinon.restore(stripe.subscriptions.update);
stripe.subscriptions.update.restore();
});
it('updates a group plan quantity', async () => {

View File

@@ -8,7 +8,10 @@ describe('preenHistory', () => {
beforeEach(() => {
// Replace system clocks so we can get predictable results
clock = sinon.useFakeTimers(Number(moment('2013-10-20').zone(0).startOf('day').toDate()), 'Date');
clock = sinon.useFakeTimers({
now: Number(moment('2013-10-20').zone(0).startOf('day').toDate()),
toFake: ['Date'],
});
});
afterEach(() => {
return clock.restore();

View File

@@ -22,7 +22,7 @@ describe('pushNotifications', () => {
sandbox.stub(nconf, 'get').returns('true-key');
sandbox.stub(gcmLib.Sender.prototype, 'send', fcmSendSpy);
sandbox.stub(gcmLib.Sender.prototype, 'send').callsFake(fcmSendSpy);
sandbox.stub(pushNotify, 'apn').returns({
on: () => null,

View File

@@ -24,7 +24,9 @@ describe('ensure access middlewares', () => {
ensureAdmin(req, res, next);
expect(next).to.be.calledWith(new NotAuthorized(i18n.t('noAdminAccess')));
const calledWith = next.getCall(0).args;
expect(calledWith[0].message).to.equal(i18n.t('noAdminAccess'));
expect(calledWith[0] instanceof NotAuthorized).to.equal(true);
});
it('passes when user is an admin', () => {
@@ -43,7 +45,9 @@ describe('ensure access middlewares', () => {
ensureSudo(req, res, next);
expect(next).to.be.calledWith(new NotAuthorized(apiMessages('noSudoAccess')));
const calledWith = next.getCall(0).args;
expect(calledWith[0].message).to.equal(apiMessages('noSudoAccess'));
expect(calledWith[0] instanceof NotAuthorized).to.equal(true);
});
it('passes when user is a sudo user', () => {

View File

@@ -22,7 +22,8 @@ describe('developmentMode middleware', () => {
ensureDevelpmentMode(req, res, next);
expect(next).to.be.calledWith(new NotFound());
const calledWith = next.getCall(0).args;
expect(calledWith[0] instanceof NotFound).to.equal(true);
});
it('passes when not in production', () => {

View File

@@ -131,7 +131,7 @@ describe('errorHandler', () => {
});
it('handle Mongoose Validation errors', () => {
let error = new Error('User validation failed.');
let error = new Error('User validation failed');
error.name = 'ValidationError';
error.errors = {
@@ -151,7 +151,7 @@ describe('errorHandler', () => {
expect(res.json).to.be.calledWith({
success: false,
error: 'BadRequest',
message: 'User validation failed.',
message: 'User validation failed',
errors: [
{ path: 'auth.local.email', message: 'Invalid email.', value: 'not an email' },
],

View File

@@ -90,8 +90,15 @@ describe('response middleware', () => {
});
it('returns notifications if a user is authenticated', () => {
res.locals.user.notifications.push({type: 'NEW_CONTRIBUTOR_LEVEL'});
let notification = res.locals.user.notifications[0].toJSON();
const user = res.locals.user;
user.notifications = [
null, // invalid, not an object
{seen: true}, // invalid, no type or id
{id: 123}, // invalid, no type
// {type: 'ABC'}, // invalid, no id, not included here because the id would be added automatically
{type: 'ABC', id: '123'}, // valid
];
responseMiddleware(req, res, next);
res.respond(200, {field: 1});
@@ -103,9 +110,10 @@ describe('response middleware', () => {
data: {field: 1},
notifications: [
{
type: notification.type,
id: notification.id,
type: 'ABC',
id: '123',
data: {},
seen: false,
},
],
userV: res.locals.user._v,

View File

@@ -74,14 +74,15 @@ describe('Challenge Model', () => {
it('adds tasks to challenge and challenge members', async () => {
await challenge.addTasks([task]);
let updatedLeader = await User.findOne({_id: leader._id});
let updatedLeadersTasks = await Tasks.Task.find({_id: { $in: updatedLeader.tasksOrder[`${taskType}s`]}});
let syncedTask = find(updatedLeadersTasks, function findNewTask (updatedLeadersTask) {
const updatedLeader = await User.findOne({_id: leader._id});
const updatedLeadersTasks = await Tasks.Task.find({_id: { $in: updatedLeader.tasksOrder[`${taskType}s`]}});
const syncedTask = find(updatedLeadersTasks, function findNewTask (updatedLeadersTask) {
return updatedLeadersTask.type === taskValue.type && updatedLeadersTask.text === taskValue.text;
});
expect(syncedTask).to.exist;
expect(syncedTask.notes).to.eql(task.notes);
expect(syncedTask.tags[0]).to.eql(challenge._id);
});
it('syncs a challenge to a user', async () => {

View File

@@ -1011,13 +1011,6 @@ describe('Group Model', () => {
expect(User.update).to.be.calledWithMatch({
'party._id': party._id,
_id: { $ne: '' },
}, {
$set: {
[`newMessages.${party._id}`]: {
name: party.name,
value: true,
},
},
});
});
@@ -1032,13 +1025,6 @@ describe('Group Model', () => {
expect(User.update).to.be.calledWithMatch({
guilds: group._id,
_id: { $ne: '' },
}, {
$set: {
[`newMessages.${group._id}`]: {
name: group.name,
value: true,
},
},
});
});
@@ -1049,13 +1035,6 @@ describe('Group Model', () => {
expect(User.update).to.be.calledWithMatch({
'party._id': party._id,
_id: { $ne: 'user-id' },
}, {
$set: {
[`newMessages.${party._id}`]: {
name: party.name,
value: true,
},
},
});
});

View File

@@ -58,25 +58,46 @@ 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']);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type', 'seen']);
expect(userToJSON.notifications[0].type).to.equal('CRON');
expect(userToJSON.notifications[0].data).to.eql({});
expect(userToJSON.notifications[0].seen).to.eql(false);
});
it('can add notifications with data', () => {
it('removes invalid notifications when calling toJSON', () => {
let user = new User();
user.addNotification('CRON', {field: 1});
user.notifications = [
null, // invalid, not an object
{seen: true}, // invalid, no type or id
{id: 123}, // invalid, no type
// {type: 'ABC'}, // invalid, no id, not included here because the id would be added automatically
{type: 'ABC', id: '123'}, // valid
];
const userToJSON = user.toJSON();
expect(userToJSON.notifications.length).to.equal(1);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type', 'seen']);
expect(userToJSON.notifications[0].type).to.equal('ABC');
expect(userToJSON.notifications[0].id).to.equal('123');
});
it('can add notifications with data and already marked as seen', () => {
let user = new User();
user.addNotification('CRON', {field: 1}, true);
let userToJSON = user.toJSON();
expect(user.notifications.length).to.equal(1);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type']);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type', 'seen']);
expect(userToJSON.notifications[0].type).to.equal('CRON');
expect(userToJSON.notifications[0].data).to.eql({field: 1});
expect(userToJSON.notifications[0].seen).to.eql(true);
});
context('static push method', () => {
it('adds notifications for a single member via static method', async() => {
it('adds notifications for a single member via static method', async () => {
let user = new User();
await user.save();
@@ -86,16 +107,17 @@ 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']);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type', 'seen']);
expect(userToJSON.notifications[0].type).to.equal('CRON');
expect(userToJSON.notifications[0].data).to.eql({});
});
it('validates notifications via static method', async() => {
it('validates notifications via static method', async () => {
let user = new User();
await user.save();
expect(User.pushNotification({_id: user._id}, 'BAD_TYPE')).to.eventually.be.rejected;
expect(User.pushNotification({_id: user._id}, 'CRON', null, 'INVALID_SEEN')).to.eventually.be.rejected;
});
it('adds notifications without data for all given users via static method', async() => {
@@ -109,41 +131,45 @@ 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']);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type', 'seen']);
expect(userToJSON.notifications[0].type).to.equal('CRON');
expect(userToJSON.notifications[0].data).to.eql({});
expect(userToJSON.notifications[0].seen).to.eql(false);
user = await User.findOne({_id: otherUser._id}).exec();
userToJSON = user.toJSON();
expect(user.notifications.length).to.equal(1);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type']);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type', 'seen']);
expect(userToJSON.notifications[0].type).to.equal('CRON');
expect(userToJSON.notifications[0].data).to.eql({});
expect(userToJSON.notifications[0].seen).to.eql(false);
});
it('adds notifications with data for all given users via static method', async() => {
it('adds notifications with data and seen status for all given users via static method', async () => {
let user = new User();
let otherUser = new User();
await Bluebird.all([user.save(), otherUser.save()]);
await User.pushNotification({_id: {$in: [user._id, otherUser._id]}}, 'CRON', {field: 1});
await User.pushNotification({_id: {$in: [user._id, otherUser._id]}}, 'CRON', {field: 1}, true);
user = await User.findOne({_id: user._id}).exec();
let userToJSON = user.toJSON();
expect(user.notifications.length).to.equal(1);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type']);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type', 'seen']);
expect(userToJSON.notifications[0].type).to.equal('CRON');
expect(userToJSON.notifications[0].data).to.eql({field: 1});
expect(userToJSON.notifications[0].seen).to.eql(true);
user = await User.findOne({_id: otherUser._id}).exec();
userToJSON = user.toJSON();
expect(user.notifications.length).to.equal(1);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type']);
expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type', 'seen']);
expect(userToJSON.notifications[0].type).to.equal('CRON');
expect(userToJSON.notifications[0].data).to.eql({field: 1});
expect(userToJSON.notifications[0].seen).to.eql(true);
});
});
});
@@ -322,6 +348,65 @@ describe('User Model', () => {
user = await user.save();
expect(user.achievements.beastMaster).to.not.equal(true);
});
context('manage unallocated stats points notifications', () => {
it('doesn\'t add a notification if there are no points to allocate', async () => {
let user = new User();
user = await user.save(); // necessary for user.isSelected to work correctly
const oldNotificationsCount = user.notifications.length;
user.stats.points = 0;
user = await user.save();
expect(user.notifications.length).to.equal(oldNotificationsCount);
});
it('removes a notification if there are no more points to allocate', async () => {
let user = new User();
user.stats.points = 9;
user = await user.save(); // necessary for user.isSelected to work correctly
expect(user.notifications[0].type).to.equal('UNALLOCATED_STATS_POINTS');
const oldNotificationsCount = user.notifications.length;
user.stats.points = 0;
user = await user.save();
expect(user.notifications.length).to.equal(oldNotificationsCount - 1);
});
it('adds a notification if there are points to allocate', async () => {
let user = new User();
user = await user.save(); // necessary for user.isSelected to work correctly
const oldNotificationsCount = user.notifications.length;
user.stats.points = 9;
user = await user.save();
expect(user.notifications.length).to.equal(oldNotificationsCount + 1);
expect(user.notifications[0].type).to.equal('UNALLOCATED_STATS_POINTS');
expect(user.notifications[0].data.points).to.equal(9);
});
it('adds a notification if the points to allocate have changed', async () => {
let user = new User();
user.stats.points = 9;
user = await user.save(); // necessary for user.isSelected to work correctly
const oldNotificationsCount = user.notifications.length;
const oldNotificationsUUID = user.notifications[0].id;
expect(user.notifications[0].type).to.equal('UNALLOCATED_STATS_POINTS');
expect(user.notifications[0].data.points).to.equal(9);
user.stats.points = 11;
user = await user.save();
expect(user.notifications.length).to.equal(oldNotificationsCount);
expect(user.notifications[0].type).to.equal('UNALLOCATED_STATS_POINTS');
expect(user.notifications[0].data.points).to.equal(11);
expect(user.notifications[0].id).to.not.equal(oldNotificationsUUID);
});
});
});
context('days missed', () => {

View File

@@ -0,0 +1,21 @@
import { model as UserNotification } from '../../../../../website/server/models/userNotification';
describe('UserNotification Model', () => {
context('convertNotificationsToSafeJson', () => {
it('converts an array of notifications to a safe version', () => {
const notifications = [
null, // invalid, not an object
{seen: true}, // invalid, no type or id
{id: 123}, // invalid, no type
{type: 'ABC'}, // invalid, no id
new UserNotification({type: 'ABC', id: 123}), // valid
];
const notificationsToJSON = UserNotification.convertNotificationsToSafeJson(notifications);
expect(notificationsToJSON.length).to.equal(1);
expect(notificationsToJSON[0]).to.have.all.keys(['data', 'id', 'type', 'seen']);
expect(notificationsToJSON[0].type).to.equal('ABC');
expect(notificationsToJSON[0].id).to.equal('123');
});
});
});

View File

@@ -34,6 +34,31 @@ describe('shops', () => {
});
});
});
it('shows relevant non class gear in special category', () => {
let contributor = generateUser({
contributor: {
level: 7,
critical: true,
},
items: {
gear: {
owned: {
weapon_armoire_basicCrossbow: true, // eslint-disable-line camelcase
},
},
},
});
let gearCategories = shared.shops.getMarketGearCategories(contributor);
let specialCategory = gearCategories.find(o => o.identifier === 'none');
expect(specialCategory.items.find((item) => item.key === 'weapon_special_1'));
expect(specialCategory.items.find((item) => item.key === 'armor_special_1'));
expect(specialCategory.items.find((item) => item.key === 'head_special_1'));
expect(specialCategory.items.find((item) => item.key === 'shield_special_1'));
expect(specialCategory.items.find((item) => item.key === 'weapon_special_critical'));
expect(specialCategory.items.find((item) => item.key === 'weapon_armoire_basicCrossbow'));// eslint-disable-line camelcase
});
});
describe('questShop', () => {

View File

@@ -138,5 +138,27 @@ describe('shared.ops.buyGear', () => {
done();
}
});
it('does not buyGear equipment if user does not own prior item in sequence', (done) => {
user.stats.gp = 200;
try {
buyGear(user, {params: {key: 'armor_warrior_2'}});
} catch (err) {
expect(err).to.be.an.instanceof(NotAuthorized);
expect(err.message).to.equal(i18n.t('previousGearNotOwned'));
expect(user.items.gear.owned).to.not.have.property('armor_warrior_2');
done();
}
});
it('does buyGear equipment if item is a numbered special item user qualifies for', () => {
user.stats.gp = 200;
user.items.gear.owned.head_special_2 = false;
buyGear(user, {params: {key: 'head_special_2'}});
expect(user.items.gear.owned).to.have.property('head_special_2', true);
});
});
});

View File

@@ -125,7 +125,7 @@ describe('shared.ops.feed', () => {
expect(data).to.eql(user.items.pets['Wolf-Base']);
expect(message).to.eql(i18n.t('messageLikesFood', {
egg: pet.text(),
foodText: food.text(),
foodText: food.textThe(),
}));
expect(user.items.food.Meat).to.equal(1);
@@ -143,7 +143,7 @@ describe('shared.ops.feed', () => {
expect(data).to.eql(user.items.pets['Wolf-Spooky']);
expect(message).to.eql(i18n.t('messageLikesFood', {
egg: pet.text(),
foodText: food.text(),
foodText: food.textThe(),
}));
expect(user.items.food.Milk).to.equal(1);
@@ -161,7 +161,7 @@ describe('shared.ops.feed', () => {
expect(data).to.eql(user.items.pets['Wolf-Base']);
expect(message).to.eql(i18n.t('messageDontEnjoyFood', {
egg: pet.text(),
foodText: food.text(),
foodText: food.textThe(),
}));
expect(user.items.food.Milk).to.equal(1);

View File

@@ -29,11 +29,14 @@ describe('shared.ops.openMysteryItem', () => {
let mysteryItemKey = 'eyewear_special_summerRogue';
user.purchased.plan.mysteryItems = [mysteryItemKey];
user.notifications.push({type: 'NEW_MYSTERY_ITEMS', data: {items: [mysteryItemKey]}});
expect(user.notifications.length).to.equal(1);
let [data, message] = openMysteryItem(user);
expect(user.items.gear.owned[mysteryItemKey]).to.be.true;
expect(message).to.equal(i18n.t('mysteryItemOpened'));
expect(data).to.eql(content.gear.flat[mysteryItemKey]);
expect(user.notifications.length).to.equal(0);
});
});

View File

@@ -39,10 +39,17 @@ describe('shared.ops.readCard', () => {
});
it('reads a card', () => {
user.notifications.push({
type: 'CARD_RECEIVED',
data: {card: cardType},
});
const initialNotificationNuber = user.notifications.length;
let [, message] = readCard(user, {params: {cardType: 'greeting'}});
expect(message).to.equal(i18n.t('readCard', {cardType}));
expect(user.items.special[`${cardType}Received`]).to.be.empty;
expect(user.flags.cardReceived).to.be.false;
expect(user.notifications.length).to.equal(initialNotificationNuber - 1);
});
});

View File

@@ -74,13 +74,6 @@ describe('shared.ops.scoreTask', () => {
}
});
it('checks that the streak parameters affects the score', () => {
let task = generateDaily({ userId: ref.afterUser._id, text: 'task to check streak' });
scoreTask({ user: ref.afterUser, task, direction: 'up', cron: false });
scoreTask({ user: ref.afterUser, task, direction: 'up', cron: false });
expect(task.streak).to.eql(2);
});
it('completes when the task direction is up', () => {
let task = generateTodo({ userId: ref.afterUser._id, text: 'todo to complete', cron: false });
scoreTask({ user: ref.afterUser, task, direction: 'up' });
@@ -123,6 +116,64 @@ describe('shared.ops.scoreTask', () => {
});
});
it('checks that the streak parameters affects the score', () => {
let task = generateDaily({ userId: ref.afterUser._id, text: 'task to check streak' });
scoreTask({ user: ref.afterUser, task, direction: 'up', cron: false });
scoreTask({ user: ref.afterUser, task, direction: 'up', cron: false });
expect(task.streak).to.eql(2);
});
describe('verifies that 21-day streak achievements are given/removed correctly', () => {
let initialStreakCount = 20; // 1 before the streak achievement is awarded
beforeEach(() => {
ref = beforeAfter();
});
it('awards the first streak achievement', () => {
let task = generateDaily({ userId: ref.afterUser._id, text: 'some daily', streak: initialStreakCount });
scoreTask({ user: ref.afterUser, task, direction: 'up' });
expect(ref.afterUser.achievements.streak).to.equal(1);
});
it('increments the streak achievement for a second streak', () => {
let task1 = generateDaily({ userId: ref.afterUser._id, text: 'first daily', streak: initialStreakCount });
scoreTask({ user: ref.afterUser, task: task1, direction: 'up' });
let task2 = generateDaily({ userId: ref.afterUser._id, text: 'second daily', streak: initialStreakCount });
scoreTask({ user: ref.afterUser, task: task2, direction: 'up' });
expect(ref.afterUser.achievements.streak).to.equal(2);
});
it('removes the first streak achievement when unticking a Daily', () => {
let task = generateDaily({ userId: ref.afterUser._id, text: 'some daily', streak: initialStreakCount });
scoreTask({ user: ref.afterUser, task, direction: 'up' });
scoreTask({ user: ref.afterUser, task, direction: 'down' });
expect(ref.afterUser.achievements.streak).to.equal(0);
});
it('decrements a multiple streak achievement when unticking a Daily', () => {
let task1 = generateDaily({ userId: ref.afterUser._id, text: 'first daily', streak: initialStreakCount });
scoreTask({ user: ref.afterUser, task: task1, direction: 'up' });
let task2 = generateDaily({ userId: ref.afterUser._id, text: 'second daily', streak: initialStreakCount });
scoreTask({ user: ref.afterUser, task: task2, direction: 'up' });
scoreTask({ user: ref.afterUser, task: task2, direction: 'down' });
expect(ref.afterUser.achievements.streak).to.equal(1);
});
it('does not give a streak achievement for a streak of zero', () => {
let task = generateDaily({ userId: ref.afterUser._id, text: 'some daily', streak: -1 });
scoreTask({ user: ref.afterUser, task, direction: 'up' });
expect(ref.afterUser.achievements.streak).to.be.undefined;
});
it('does not remove a streak achievement when unticking a Daily gives a streak of zero', () => {
let task1 = generateDaily({ userId: ref.afterUser._id, text: 'first daily', streak: initialStreakCount });
scoreTask({ user: ref.afterUser, task: task1, direction: 'up' });
let task2 = generateDaily({ userId: ref.afterUser._id, text: 'second daily', streak: 1 });
scoreTask({ user: ref.afterUser, task: task2, direction: 'down' });
expect(ref.afterUser.achievements.streak).to.equal(1);
});
});
describe('scores', () => {
let options = {};
let habit;
@@ -240,11 +291,14 @@ describe('shared.ops.scoreTask', () => {
scoreTask({user: ref.afterUser, task: daily, direction: 'up'});
expectGainedPoints(ref.beforeUser, ref.afterUser, freshDaily, daily);
expect(daily.completed).to.eql(true);
expect(daily.history.length).to.eql(1);
});
it('up, down', () => {
scoreTask({user: ref.afterUser, task: daily, direction: 'up'});
expect(daily.history.length).to.eql(1);
scoreTask({user: ref.afterUser, task: daily, direction: 'down'});
expect(daily.history.length).to.eql(0);
expectClosePoints(ref.beforeUser, ref.afterUser, freshDaily, daily);
});

View File

@@ -15,7 +15,7 @@ import * as Tasks from '../../../../website/server/models/task';
// , you can do so by passing in the full path as a string:
// { 'items.eggs.Wolf': 10 }
export async function generateUser (update = {}) {
let username = generateUUID();
let username = (Date.now() + generateUUID()).substring(0, 20);
let password = 'password';
let email = `${username}@example.com`;

View File

@@ -11,7 +11,7 @@ import * as Tasks from '../../website/server/models/task';
afterEach((done) => {
sandbox.restore();
mongoose.connection.db.dropDatabase(done);
mongoose.connection.dropDatabase(done);
});
export { sleep } from './sleep';

View File

@@ -17,3 +17,6 @@ let sinonStubPromise = require('sinon-stub-promise');
sinonStubPromise(global.sinon);
global.sandbox = sinon.sandbox.create();
global.Promise = Bluebird;
import setupNconf from '../../website/server/libs/setupNconf';
setupNconf('./config.json.example');

View File

@@ -37,7 +37,7 @@ export async function getProperty (collectionName, id, path) {
// resets the db to an empty state and creates a tavern document
export async function resetHabiticaDB () {
return new Promise((resolve, reject) => {
mongoose.connection.db.dropDatabase((dbErr) => {
mongoose.connection.dropDatabase((dbErr) => {
if (dbErr) return reject(dbErr);
let groups = mongoose.connection.db.collection('groups');
let users = mongoose.connection.db.collection('users');
@@ -119,7 +119,7 @@ before((done) => {
});
after((done) => {
mongoose.connection.db.dropDatabase((err) => {
mongoose.connection.dropDatabase((err) => {
if (err) return done(err);
mongoose.connection.close(done);
});

View File

@@ -5,5 +5,6 @@
--growl
--globals io
-r babel-polyfill
--compilers js:babel-register
--require babel-register
--require ./test/helpers/globals.helper
--exit

View File

@@ -7,7 +7,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
// add hot-reload related code to entry chunks
Object.keys(baseWebpackConfig.entry).forEach((name) => {
baseWebpackConfig.entry[name] = ['./webpack/dev-client'].concat(baseWebpackConfig.entry[name]);
baseWebpackConfig.entry[name] = baseWebpackConfig.entry[name].concat('./webpack/dev-client');
});
module.exports = merge(baseWebpackConfig, {

View File

@@ -13,32 +13,31 @@ div
snackbars
router-view(v-if="!isUserLoggedIn || isStaticPage")
template(v-else)
template(v-if="isUserLoaded")
notifications-display
app-menu
.container-fluid
app-header
buyModal(
:item="selectedItemToBuy || {}",
:withPin="true",
@change="resetItemToBuy($event)",
@buyPressed="customPurchase($event)",
:genericPurchase="genericPurchase(selectedItemToBuy)",
template(v-if="isUserLoaded")
notifications-display
app-menu
.container-fluid
app-header
buyModal(
:item="selectedItemToBuy || {}",
:withPin="true",
@change="resetItemToBuy($event)",
@buyPressed="customPurchase($event)",
:genericPurchase="genericPurchase(selectedItemToBuy)",
)
selectMembersModal(
:item="selectedSpellToBuy || {}",
:group="user.party",
@memberSelected="memberSelected($event)",
)
)
selectMembersModal(
:item="selectedSpellToBuy || {}",
:group="user.party",
@memberSelected="memberSelected($event)",
)
div(:class='{sticky: user.preferences.stickyHeader}')
router-view
app-footer
audio#sound(autoplay, ref="sound")
source#oggSource(type="audio/ogg", :src="sound.oggSource")
source#mp3Source(type="audio/mp3", :src="sound.mp3Source")
div(:class='{sticky: user.preferences.stickyHeader}')
router-view
app-footer
audio#sound(autoplay, ref="sound")
source#oggSource(type="audio/ogg", :src="sound.oggSource")
source#mp3Source(type="audio/mp3", :src="sound.mp3Source")
</template>
<style lang='scss' scoped>
@@ -49,6 +48,10 @@ div
margin-bottom: 1em;
}
.row {
width: 100%;
}
h2 {
color: #fff;
font-size: 32px;
@@ -79,10 +82,14 @@ div
.container-fluid {
overflow-x: hidden;
flex: 1 0 auto;
}
#app {
height: calc(100% - 56px); /* 56px is the menu */
display: flex;
flex-direction: column;
min-height: 100vh;
}
</style>
@@ -96,6 +103,11 @@ div
opacity: 1 !important;
background-color: rgba(67, 40, 116, 0.9) !important;
}
/* Push progress bar above modals */
#nprogress .bar {
z-index: 1043 !important; /* Must stay above nav bar */
}
</style>
<script>
@@ -203,7 +215,7 @@ export default {
if (error.response.status >= 400) {
// Check for conditions to reset the user auth
const invalidUserMessage = [this.$t('invalidCredentials'), 'Missing authentication headers.'];
if (invalidUserMessage.indexOf(error.response.data.message) !== -1) {
if (invalidUserMessage.indexOf(error.response.data) !== -1) {
this.$store.dispatch('auth:logout');
}
@@ -218,7 +230,7 @@ export default {
this.$store.dispatch('snackbars:add', {
title: 'Habitica',
text: error.response.data.message,
text: error.response.data,
type: 'error',
timeout: true,
});
@@ -355,6 +367,13 @@ export default {
if (modalOnTop) this.$root.$emit('bv::show::modal', modalOnTop, {fromRoot: true});
});
},
beforeDestroy () {
this.$root.$off('playSound');
this.$root.$off('bv::modal::hidden');
this.$root.$off('bv::show::modal');
this.$root.$off('buyModal::showItem');
this.$root.$off('selectMembersModal::showItem');
},
mounted () {
// Remove the index.html loading screen and now show the inapp loading
const loadingScreen = document.getElementById('loading-screen');
@@ -384,12 +403,29 @@ export default {
if (item.purchaseType === 'card') {
this.selectedSpellToBuy = item;
// hide the dialog
this.$root.$emit('bv::hide::modal', 'buy-modal');
// remove the dialog from our modal-stack,
// the default hidden event is delayed
this.$root.$emit('bv::modal::hidden', {
target: {
id: 'buy-modal',
},
});
this.$root.$emit('bv::show::modal', 'select-member-modal');
}
},
async memberSelected (member) {
this.$store.dispatch('user:castSpell', {key: this.selectedSpellToBuy.key, targetId: member.id});
let castResult = await this.$store.dispatch('user:castSpell', {key: this.selectedSpellToBuy.key, targetId: member.id});
// Subtract gold for cards
if (this.selectedSpellToBuy.pinType === 'card') {
const newUserGp = castResult.data.data.user.stats.gp;
this.$store.state.user.data.stats.gp = newUserGp;
this.text(this.$t('sentCardToUser', { profileName: member.profile.name }));
}
this.selectedSpellToBuy = null;
if (this.user.party._id) {
@@ -429,4 +465,5 @@ export default {
<style src="assets/css/sprites/spritesmith-main-18.css"></style>
<style src="assets/css/sprites/spritesmith-main-19.css"></style>
<style src="assets/css/sprites/spritesmith-main-20.css"></style>
<style src="assets/css/sprites/spritesmith-main-21.css"></style>
<style src="assets/css/sprites.css"></style>

View File

@@ -1,18 +1,5 @@
/* Comment out for holiday events */
/* .npc_ian {
background: url("/npc_ian.gif") no-repeat;
width: 78px;
height: 135px;
} */
.quest_burnout {
background: url("~assets/images/quest_burnout.gif") no-repeat;
width: 219px;
height: 249px;
}
.quest_bewilder {
background: url("~assets/images/quest_bewilder.gif") no-repeat;
.quest_dysheartener {
background: url("~assets/images/quest_dysheartener.gif") no-repeat;
width: 219px;
height: 219px;
}

View File

@@ -1,24 +1,90 @@
.promo_armoire_bgs_201801 {
.promo_armoire_backgrounds_201802 {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: 0px -369px;
background-position: -142px -664px;
width: 141px;
height: 441px;
}
.promo_cupid_potions {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -425px -664px;
width: 138px;
height: 441px;
}
.promo_dysheartener {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -441px 0px;
width: 730px;
height: 170px;
}
.promo_habit_birthday_2018 {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -441px -171px;
width: 432px;
height: 144px;
}
.promo_ios {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: 0px -327px;
width: 325px;
height: 336px;
}
.promo_mystery_201801 {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -654px -327px;
width: 376px;
height: 196px;
}
.promo_starry_potions {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: 0px -664px;
width: 141px;
height: 441px;
}
.promo_take_this {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -142px -595px;
background-position: -874px -171px;
width: 114px;
height: 87px;
}
.scene_calendar {
.promo_valentines {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -564px -860px;
width: 309px;
height: 147px;
}
.promo_winter_customizations {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -284px -664px;
width: 140px;
height: 441px;
}
.scene_lady_glaciate {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -874px -860px;
width: 282px;
height: 147px;
}
.scene_setting_up_todos {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -564px -664px;
width: 240px;
height: 195px;
}
.scene_task_list {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -805px -664px;
width: 240px;
height: 195px;
}
.scene_tavern {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: 0px 0px;
width: 436px;
height: 368px;
width: 440px;
height: 326px;
}
.scene_winter_cleaning {
.scene_yesterdailies_repeatables {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -142px -369px;
width: 276px;
height: 225px;
background-position: -326px -327px;
width: 327px;
height: 276px;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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