mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
* Update getClass() for users who have not yet selected a class * Added tests for members.getClass() * fix linter errors * Update test * Update import in test to point to correct module * use hasClass() getter where appropriate * Fix linter error
This commit is contained in:
63
test/client/unit/specs/store/getters/members/hasClass.js
Normal file
63
test/client/unit/specs/store/getters/members/hasClass.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import { hasClass } from 'client/store/getters/members';
|
||||||
|
|
||||||
|
describe('hasClass getter', () => {
|
||||||
|
it('returns false if level < 10', () => {
|
||||||
|
const member = {
|
||||||
|
stats: {
|
||||||
|
lvl: 5,
|
||||||
|
},
|
||||||
|
preferences: {
|
||||||
|
disableClasses: false,
|
||||||
|
},
|
||||||
|
flags: {
|
||||||
|
classSelected: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
expect(hasClass()(member)).to.equal(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false if member has disabled classes', () => {
|
||||||
|
const member = {
|
||||||
|
stats: {
|
||||||
|
lvl: 10,
|
||||||
|
},
|
||||||
|
preferences: {
|
||||||
|
disableClasses: true,
|
||||||
|
},
|
||||||
|
flags: {
|
||||||
|
classSelected: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
expect(hasClass()(member)).to.equal(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false if member has not yet selected a class', () => {
|
||||||
|
const member = {
|
||||||
|
stats: {
|
||||||
|
lvl: 10,
|
||||||
|
},
|
||||||
|
preferences: {
|
||||||
|
disableClasses: false,
|
||||||
|
},
|
||||||
|
flags: {
|
||||||
|
classSelected: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
expect(hasClass()(member)).to.equal(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns true when all conditions are met', () => {
|
||||||
|
const member = {
|
||||||
|
stats: {
|
||||||
|
lvl: 10,
|
||||||
|
},
|
||||||
|
preferences: {
|
||||||
|
disableClasses: false,
|
||||||
|
},
|
||||||
|
flags: {
|
||||||
|
classSelected: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
expect(hasClass()(member)).to.equal(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -149,7 +149,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState({user: 'user.data'}),
|
...mapState({user: 'user.data'}),
|
||||||
showAllocation () {
|
showAllocation () {
|
||||||
return this.user.flags.classSelected && !this.user.preferences.disableClasses && !this.user.preferences.automaticAllocation;
|
return this.$store.getters['members:hasClass'](this.user) && !this.user.preferences.automaticAllocation;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ export default {
|
|||||||
// skipping those not defined in the handledNotifications object
|
// skipping those not defined in the handledNotifications object
|
||||||
notifications.push(...this.user.notifications.filter(notification => {
|
notifications.push(...this.user.notifications.filter(notification => {
|
||||||
if (notification.type === 'UNALLOCATED_STATS_POINTS') {
|
if (notification.type === 'UNALLOCATED_STATS_POINTS') {
|
||||||
if (!this.user.flags.classSelected || this.user.preferences.disableClasses) return false;
|
if (!this.hasClass) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return orderMap[notification.type] !== undefined;
|
return orderMap[notification.type] !== undefined;
|
||||||
@@ -212,6 +212,9 @@ export default {
|
|||||||
return notification.seen === false ? true : false;
|
return notification.seen === false ? true : false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
hasClass () {
|
||||||
|
return this.$store.getters['members:hasClass'](this.user);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions({
|
...mapActions({
|
||||||
|
|||||||
@@ -244,7 +244,8 @@ export default {
|
|||||||
},
|
},
|
||||||
userMp (after, before) {
|
userMp (after, before) {
|
||||||
if (after === before) return;
|
if (after === before) return;
|
||||||
if (!this.user.flags.classSelected || this.user.preferences.disableClasses) return;
|
if (!this.$store.getters['members:hasClass'](this.user)) return;
|
||||||
|
|
||||||
let mana = after - before;
|
let mana = after - before;
|
||||||
this.mp(mana);
|
this.mp(mana);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
option(v-for='sound in availableAudioThemes', :value='sound') {{ $t(`audioTheme_${sound}`) }}
|
option(v-for='sound in availableAudioThemes', :value='sound') {{ $t(`audioTheme_${sound}`) }}
|
||||||
hr
|
hr
|
||||||
|
|
||||||
.form-horizontal(v-if='user.flags.classSelected && !user.preferences.disableClasses')
|
.form-horizontal(v-if='hasClass')
|
||||||
h5 {{ $t('characterBuild') }}
|
h5 {{ $t('characterBuild') }}
|
||||||
h6(v-once) {{ $t('class') + ': ' }}
|
h6(v-once) {{ $t('class') + ': ' }}
|
||||||
// @TODO: what is classText
|
// @TODO: what is classText
|
||||||
@@ -270,6 +270,9 @@ export default {
|
|||||||
dayStart () {
|
dayStart () {
|
||||||
return this.user.preferences.dayStart;
|
return this.user.preferences.dayStart;
|
||||||
},
|
},
|
||||||
|
hasClass () {
|
||||||
|
return this.$store.getters['members:hasClass'](this.user);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
set (preferenceType, subtype) {
|
set (preferenceType, subtype) {
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ div
|
|||||||
li
|
li
|
||||||
strong {{$t('buffs')}}:
|
strong {{$t('buffs')}}:
|
||||||
| {{user.stats.buffs[stat]}}
|
| {{user.stats.buffs[stat]}}
|
||||||
#allocation(v-if='user._id === userLoggedIn._id && user.flags.classSelected && !user.preferences.disableClasses')
|
#allocation(v-if='user._id === userLoggedIn._id && hasClass')
|
||||||
.row.title-row
|
.row.title-row
|
||||||
.col-12.col-md-6
|
.col-12.col-md-6
|
||||||
h3(v-if='userLevel100Plus', v-once, v-html="$t('noMoreAllocate')")
|
h3(v-if='userLevel100Plus', v-once, v-html="$t('noMoreAllocate')")
|
||||||
@@ -733,6 +733,9 @@ export default {
|
|||||||
startingPageOption () {
|
startingPageOption () {
|
||||||
return this.$store.state.profileOptions.startingPage;
|
return this.$store.state.profileOptions.startingPage;
|
||||||
},
|
},
|
||||||
|
hasClass () {
|
||||||
|
return this.$store.getters['members:hasClass'](this.userLoggedIn);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
startingPageOption () {
|
startingPageOption () {
|
||||||
|
|||||||
@@ -116,7 +116,7 @@
|
|||||||
popover-placement='right', :popover="$t('streaksFrozenText')")
|
popover-placement='right', :popover="$t('streaksFrozenText')")
|
||||||
| {{ $t('streaksFrozen') }}
|
| {{ $t('streaksFrozen') }}
|
||||||
|
|
||||||
.col-4(v-if='user.flags.classSelected && !user.preferences.disableClasses')
|
.col-4(v-if='hasClass')
|
||||||
h3(v-once) {{ $t('characterBuild') }}
|
h3(v-once) {{ $t('characterBuild') }}
|
||||||
h4(v-once) {{ $t('class') + ': ' }}
|
h4(v-once) {{ $t('class') + ': ' }}
|
||||||
span {{ classText }}
|
span {{ classText }}
|
||||||
@@ -239,6 +239,9 @@ export default {
|
|||||||
|
|
||||||
return classTexts[this.user.stats.class];
|
return classTexts[this.user.stats.class];
|
||||||
},
|
},
|
||||||
|
hasClass () {
|
||||||
|
return this.$store.getters['members:hasClass'](this.user);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
formatAnimal (animalName, type) {
|
formatAnimal (animalName, type) {
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ export function isBuffed () {
|
|||||||
|
|
||||||
export function hasClass () {
|
export function hasClass () {
|
||||||
return (member) => {
|
return (member) => {
|
||||||
return member.stats.lvl >= 10 && !member.preferences.disableClasses;
|
return member.stats.lvl >= 10 && !member.preferences.disableClasses && member.flags.classSelected;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user