mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
chore(promo): end g1g1
This commit is contained in:
@@ -211,7 +211,7 @@ describe('payments/index', () => {
|
|||||||
await api.createSubscription(data);
|
await api.createSubscription(data);
|
||||||
const msg = '`Hello recipient, sender has sent you 3 months of subscription!`';
|
const 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(
|
expect(user.sendMessage).to.be.calledWith(
|
||||||
recipient,
|
recipient,
|
||||||
{ receiverMsg: msg, senderMsg: msg, save: false },
|
{ receiverMsg: msg, senderMsg: msg, save: false },
|
||||||
@@ -252,77 +252,6 @@ describe('payments/index', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context('Winter 2019-20 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);
|
|
||||||
const 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', () => {
|
context('Purchasing a subscription for self', () => {
|
||||||
|
|||||||
@@ -64,30 +64,6 @@
|
|||||||
></span>
|
></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
|
||||||
class="g1g1-banner d-flex justify-content-center align-items-center"
|
|
||||||
v-if="!giftingHidden">
|
|
||||||
<div
|
|
||||||
class="svg-icon svg-gifts left-gift"
|
|
||||||
v-html="icons.gifts">
|
|
||||||
</div>
|
|
||||||
<router-link class="g1g1-link" to="/user/settings/subscription">
|
|
||||||
{{ $t('g1g1Announcement') }}
|
|
||||||
</router-link>
|
|
||||||
<div
|
|
||||||
class="svg-icon svg-gifts right-gift"
|
|
||||||
v-html="icons.gifts">
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="closepadding"
|
|
||||||
@click="hideGiftingBanner()">
|
|
||||||
<span
|
|
||||||
class="svg-icon inline-icon icon-10"
|
|
||||||
aria-hidden="true"
|
|
||||||
v-html="icons.close">
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<notifications-display />
|
<notifications-display />
|
||||||
<app-menu />
|
<app-menu />
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
@@ -172,30 +148,6 @@
|
|||||||
flex: 1 0 auto;
|
flex: 1 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.g1g1-banner {
|
|
||||||
width: 100%;
|
|
||||||
min-height: 2.5rem;
|
|
||||||
background-color: $teal-50;
|
|
||||||
}
|
|
||||||
|
|
||||||
.g1g1-link {
|
|
||||||
color: $white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.left-gift {
|
|
||||||
margin: auto 1rem auto auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.right-gift {
|
|
||||||
margin: auto auto auto 1rem;
|
|
||||||
filter: flipH;
|
|
||||||
transform: scaleX(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.svg-gifts {
|
|
||||||
width: 4.6rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.notification {
|
.notification {
|
||||||
border-radius: 1000px;
|
border-radius: 1000px;
|
||||||
background-color: $green-10;
|
background-color: $green-10;
|
||||||
@@ -291,10 +243,8 @@ import {
|
|||||||
CONSTANTS,
|
CONSTANTS,
|
||||||
getLocalSetting,
|
getLocalSetting,
|
||||||
removeLocalSetting,
|
removeLocalSetting,
|
||||||
setLocalSetting,
|
|
||||||
} from '@/libs/userlocalManager';
|
} from '@/libs/userlocalManager';
|
||||||
|
|
||||||
import gifts from '@/assets/svg/gifts.svg';
|
|
||||||
import svgClose from '@/assets/svg/close.svg';
|
import svgClose from '@/assets/svg/close.svg';
|
||||||
import bannedAccountModal from '@/components/bannedAccountModal';
|
import bannedAccountModal from '@/components/bannedAccountModal';
|
||||||
|
|
||||||
@@ -321,7 +271,6 @@ export default {
|
|||||||
return {
|
return {
|
||||||
icons: Object.freeze({
|
icons: Object.freeze({
|
||||||
close: svgClose,
|
close: svgClose,
|
||||||
gifts,
|
|
||||||
}),
|
}),
|
||||||
selectedItemToBuy: null,
|
selectedItemToBuy: null,
|
||||||
selectedSpellToBuy: null,
|
selectedSpellToBuy: null,
|
||||||
@@ -332,7 +281,6 @@ export default {
|
|||||||
loading: true,
|
loading: true,
|
||||||
currentTipNumber: 0,
|
currentTipNumber: 0,
|
||||||
bannerHidden: false,
|
bannerHidden: false,
|
||||||
giftingHidden: getLocalSetting(CONSTANTS.keyConstants.GIFTING_BANNER_DISPLAY) === 'dismissed2019',
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -726,10 +674,6 @@ export default {
|
|||||||
hideBanner () {
|
hideBanner () {
|
||||||
this.bannerHidden = true;
|
this.bannerHidden = true;
|
||||||
},
|
},
|
||||||
hideGiftingBanner () {
|
|
||||||
setLocalSetting(CONSTANTS.keyConstants.GIFTING_BANNER_DISPLAY, 'dismissed2019');
|
|
||||||
this.giftingHidden = true;
|
|
||||||
},
|
|
||||||
resumeDamage () {
|
resumeDamage () {
|
||||||
this.$store.dispatch('user:sleep');
|
this.$store.dispatch('user:sleep');
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
</h3>
|
</h3>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-12">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<!-- eslint-disable vue/no-use-v-if-with-v-for -->
|
<!-- eslint-disable vue/no-use-v-if-with-v-for -->
|
||||||
<div
|
<div
|
||||||
@@ -98,11 +98,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-8">
|
|
||||||
<h4 v-once> {{ $t('winterPromoGiftHeader') }} </h4>
|
|
||||||
<p v-once> {{ $t('winterPromoGiftDetails1') }} </p>
|
|
||||||
<p v-once> {{ $t('winterPromoGiftDetails2') }} </p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -251,11 +251,6 @@
|
|||||||
{{ $t('giftSubscriptionText4') }}
|
{{ $t('giftSubscriptionText4') }}
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
|
||||||
<h2 v-once> {{ $t('winterPromoGiftHeader') }} </h2>
|
|
||||||
<p v-once> {{ $t('winterPromoGiftDetails1') }} </p>
|
|
||||||
<p v-once> {{ $t('winterPromoGiftDetails2') }} </p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -20,10 +20,6 @@
|
|||||||
z-index: 1400; // 1400 is above modal backgrounds
|
z-index: 1400; // 1400 is above modal backgrounds
|
||||||
|
|
||||||
&-top-pos {
|
&-top-pos {
|
||||||
&-double {
|
|
||||||
top: 145px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-normal {
|
&-normal {
|
||||||
top: 65px;
|
top: 65px;
|
||||||
}
|
}
|
||||||
@@ -38,7 +34,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapState } from '@/libs/store';
|
import { mapState } from '@/libs/store';
|
||||||
import notification from './notification';
|
import notification from './notification';
|
||||||
import { CONSTANTS, getLocalSetting } from '@/libs/userlocalManager';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -52,9 +47,7 @@ export default {
|
|||||||
notificationsTopPos () {
|
notificationsTopPos () {
|
||||||
const base = 'notifications-top-pos-';
|
const base = 'notifications-top-pos-';
|
||||||
let modifier = '';
|
let modifier = '';
|
||||||
if (this.userSleeping && this.giftingShown) {
|
if (this.userSleeping) {
|
||||||
modifier = 'double';
|
|
||||||
} else if (this.userSleeping || this.giftingShown) {
|
|
||||||
modifier = 'sleeping';
|
modifier = 'sleeping';
|
||||||
} else {
|
} else {
|
||||||
modifier = 'normal';
|
modifier = 'normal';
|
||||||
@@ -62,10 +55,5 @@ export default {
|
|||||||
return `${base}${modifier}`;
|
return `${base}${modifier}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
giftingShown: getLocalSetting(CONSTANTS.keyConstants.GIFTING_BANNER_DISPLAY) !== 'dismissed',
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ const CONSTANTS = {
|
|||||||
CURRENT_EQUIPMENT_DRAWER_TAB: 'current-equipment-drawer-tab',
|
CURRENT_EQUIPMENT_DRAWER_TAB: 'current-equipment-drawer-tab',
|
||||||
STABLE_SORT_STATE: 'stable-sort-state',
|
STABLE_SORT_STATE: 'stable-sort-state',
|
||||||
ONBOARDING_PANEL_STATE: 'onboarding-panel-state',
|
ONBOARDING_PANEL_STATE: 'onboarding-panel-state',
|
||||||
GIFTING_BANNER_DISPLAY: 'gifting-banner-display',
|
|
||||||
},
|
},
|
||||||
drawerStateValues: {
|
drawerStateValues: {
|
||||||
DRAWER_CLOSED: 'drawer-closed',
|
DRAWER_CLOSED: 'drawer-closed',
|
||||||
|
|||||||
@@ -234,20 +234,6 @@ async function createSubscription (data) {
|
|||||||
|
|
||||||
// Only send push notifications if sending to a user other than yourself
|
// Only send push notifications if sending to a user other than yourself
|
||||||
if (data.gift.member._id !== data.user._id) {
|
if (data.gift.member._id !== data.user._id) {
|
||||||
const promoData = {
|
|
||||||
user: data.user,
|
|
||||||
gift: {
|
|
||||||
member: data.user,
|
|
||||||
subscription: {
|
|
||||||
key: data.gift.subscription.key,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
paymentMethod: data.paymentMethod,
|
|
||||||
promo: 'Winter',
|
|
||||||
promoUsername: data.gift.member.auth.local.username,
|
|
||||||
};
|
|
||||||
await this.createSubscription(promoData);
|
|
||||||
|
|
||||||
if (data.gift.member.preferences.pushNotifications.giftedSubscription !== false) {
|
if (data.gift.member.preferences.pushNotifications.giftedSubscription !== false) {
|
||||||
sendPushNotification(data.gift.member,
|
sendPushNotification(data.gift.member,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ function sendSubscriptionNotification ({
|
|||||||
let text;
|
let text;
|
||||||
const timestamp = new Date();
|
const timestamp = new Date();
|
||||||
if (recipient.id) {
|
if (recipient.id) {
|
||||||
text = `${buyer.name} ${buyer.id} ${buyer.email} bought a ${months}-month gift subscription for ${recipient.name} ${recipient.id} ${recipient.email} and got a promo using ${paymentMethod} on ${timestamp}`;
|
text = `${buyer.name} ${buyer.id} ${buyer.email} bought a ${months}-month gift subscription for ${recipient.name} ${recipient.id} ${recipient.email} using ${paymentMethod} on ${timestamp}`;
|
||||||
} else if (groupId) {
|
} else if (groupId) {
|
||||||
text = `${buyer.name} ${buyer.id} ${buyer.email} bought a 1-month recurring group-plan for ${groupId} using ${paymentMethod} on ${timestamp}`;
|
text = `${buyer.name} ${buyer.id} ${buyer.email} bought a 1-month recurring group-plan for ${groupId} using ${paymentMethod} on ${timestamp}`;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user