From e4dbf09dda1b1758a4abf1c2db31e4037100d072 Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Fri, 24 Aug 2018 23:05:36 -0500 Subject: [PATCH 1/4] Prevented users with lvl less than 10 from seeing mana --- website/client/components/notifications.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/client/components/notifications.vue b/website/client/components/notifications.vue index d05667cfed..52490aea60 100644 --- a/website/client/components/notifications.vue +++ b/website/client/components/notifications.vue @@ -253,6 +253,8 @@ export default { if (!this.$store.getters['members:hasClass'](this.user)) return; let mana = after - before; + + if (this.user.stats.lvl < 10) return; this.mp(mana); }, userLvl (after, before) { @@ -506,7 +508,7 @@ export default { case 'CRON': if (notification.data) { if (notification.data.hp) this.hp(notification.data.hp, 'hp'); - if (notification.data.mp) this.mp(notification.data.mp); + if (notification.data.mp && this.user.stats.lvl >= 10) this.mp(notification.data.mp); } break; case 'SCORED_TASK': From 8153674dc0dbabe2b29efba2822cb751a32191ef Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Sun, 26 Aug 2018 17:41:55 -0500 Subject: [PATCH 2/4] Added in class checks and notification tests --- .../unit/specs/components/notifications.js | 47 +++++++++++++++++++ .../unit/specs/components/sidebarSection.js | 4 +- website/client/components/notifications.vue | 9 ++-- 3 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 test/client/unit/specs/components/notifications.js diff --git a/test/client/unit/specs/components/notifications.js b/test/client/unit/specs/components/notifications.js new file mode 100644 index 0000000000..fe0e0bc718 --- /dev/null +++ b/test/client/unit/specs/components/notifications.js @@ -0,0 +1,47 @@ +import { shallowMount, createLocalVue } from '@vue/test-utils'; +import NotificationsComponent from 'client/components/notifications.vue'; +import Store from 'client/libs/store'; + +const localVue = createLocalVue(); +localVue.use(Store); + +describe('Notifications', () => { + let store; + + beforeEach(() => { + store = new Store({ + state: { + user: { + data: { + stats: { + lvl: 0, + }, + flags: {}, + preferences: {}, + party: { + quest: { + }, + }, + }, + }, + }, + actions: { + 'user:fetch': () => {}, + 'tasks:fetchUserTasks': () => {}, + }, + getters: {}, + }); + }); + + it('set user has class computed prop', () => { + const wrapper = shallowMount(NotificationsComponent, { store, localVue }); + + expect(wrapper.vm.userHasClass).to.be.false; + + store.state.user.data.stats.lvl = 10; + store.state.user.data.flags.classSelected = true; + store.state.user.data.preferences.disableClasses = false; + + expect(wrapper.vm.userHasClass).to.be.true; + }); +}); diff --git a/test/client/unit/specs/components/sidebarSection.js b/test/client/unit/specs/components/sidebarSection.js index 23b651b7fc..f65bd87003 100644 --- a/test/client/unit/specs/components/sidebarSection.js +++ b/test/client/unit/specs/components/sidebarSection.js @@ -1,4 +1,4 @@ -import {shallow} from '@vue/test-utils'; +import { shallow } from '@vue/test-utils'; import SidebarSection from 'client/components/sidebarSection.vue'; @@ -51,4 +51,4 @@ describe('Sidebar Section', () => { expect(wrapper.find('.section-body').element.style.display).to.eq('none'); }); -}); \ No newline at end of file +}); diff --git a/website/client/components/notifications.vue b/website/client/components/notifications.vue index 52490aea60..15949ce89a 100644 --- a/website/client/components/notifications.vue +++ b/website/client/components/notifications.vue @@ -199,6 +199,9 @@ export default { userClassSelect () { return !this.user.flags.classSelected && this.user.stats.lvl >= 10; }, + userHasClass () { + return this.user.stats.lvl >= 10 && this.user.flags.classSelected && !this.user.preferences.disableClasses; + }, invitedToQuest () { return this.user.party.quest.RSVPNeeded && !this.user.party.quest.completed; }, @@ -252,9 +255,9 @@ export default { if (after === before) return; if (!this.$store.getters['members:hasClass'](this.user)) return; - let mana = after - before; + const mana = after - before; - if (this.user.stats.lvl < 10) return; + if (!this.userHasClass) return; this.mp(mana); }, userLvl (after, before) { @@ -508,7 +511,7 @@ export default { case 'CRON': if (notification.data) { if (notification.data.hp) this.hp(notification.data.hp, 'hp'); - if (notification.data.mp && this.user.stats.lvl >= 10) this.mp(notification.data.mp); + if (notification.data.mp && !this.userHasClass) this.mp(notification.data.mp); } break; case 'SCORED_TASK': From 9725da258e4d93454b74b743f9c28fa9e58f510c Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Sat, 1 Sep 2018 09:37:47 -0500 Subject: [PATCH 3/4] Added getter use --- test/client/unit/specs/components/notifications.js | 7 +++++-- website/client/components/notifications.vue | 6 ++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/test/client/unit/specs/components/notifications.js b/test/client/unit/specs/components/notifications.js index fe0e0bc718..9fede9de0b 100644 --- a/test/client/unit/specs/components/notifications.js +++ b/test/client/unit/specs/components/notifications.js @@ -1,11 +1,12 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'; import NotificationsComponent from 'client/components/notifications.vue'; import Store from 'client/libs/store'; +import { hasClass } from 'client/store/getters/members'; const localVue = createLocalVue(); localVue.use(Store); -describe('Notifications', () => { +describe.only('Notifications', () => { let store; beforeEach(() => { @@ -29,7 +30,9 @@ describe('Notifications', () => { 'user:fetch': () => {}, 'tasks:fetchUserTasks': () => {}, }, - getters: {}, + getters: { + 'members:hasClass': hasClass, + }, }); }); diff --git a/website/client/components/notifications.vue b/website/client/components/notifications.vue index 15949ce89a..34a79452b6 100644 --- a/website/client/components/notifications.vue +++ b/website/client/components/notifications.vue @@ -200,7 +200,7 @@ export default { return !this.user.flags.classSelected && this.user.stats.lvl >= 10; }, userHasClass () { - return this.user.stats.lvl >= 10 && this.user.flags.classSelected && !this.user.preferences.disableClasses; + return this.$store.getters['members:hasClass'](this.user); }, invitedToQuest () { return this.user.party.quest.RSVPNeeded && !this.user.party.quest.completed; @@ -253,11 +253,9 @@ export default { }, userMp (after, before) { if (after === before) return; - if (!this.$store.getters['members:hasClass'](this.user)) return; + if (!this.userHasClass) return; const mana = after - before; - - if (!this.userHasClass) return; this.mp(mana); }, userLvl (after, before) { From 2009bb97cb18c8d8404f144752afd33e48f6e12a Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Wed, 5 Sep 2018 14:10:59 -0500 Subject: [PATCH 4/4] Fixed class check --- website/client/components/notifications.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/client/components/notifications.vue b/website/client/components/notifications.vue index 34a79452b6..66493ccfa6 100644 --- a/website/client/components/notifications.vue +++ b/website/client/components/notifications.vue @@ -509,7 +509,7 @@ export default { case 'CRON': if (notification.data) { if (notification.data.hp) this.hp(notification.data.hp, 'hp'); - if (notification.data.mp && !this.userHasClass) this.mp(notification.data.mp); + if (notification.data.mp && this.userHasClass) this.mp(notification.data.mp); } break; case 'SCORED_TASK':