mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Fix error logs in client unit tests from setTitle (#12967)
This commit is contained in:
@@ -42,6 +42,7 @@ describe('Challenge Detail', () => {
|
||||
{ _id: '3', type: 'reward' },
|
||||
{ _id: '4', type: 'todo' },
|
||||
],
|
||||
'common:setTitle': () => {},
|
||||
},
|
||||
getters: {
|
||||
},
|
||||
|
||||
@@ -49,6 +49,7 @@ describe('myGuilds component', () => {
|
||||
getters: {},
|
||||
actions: {
|
||||
'guilds:getMyGuilds': () => guilds,
|
||||
'common:setTitle': () => {},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ describe('Home', () => {
|
||||
actions: {
|
||||
'auth:register': registerStub,
|
||||
'auth:socialAuth': socialAuthStub,
|
||||
'auth:verifyUsername': () => Promise.resolve({}),
|
||||
'auth:verifyUsername': () => async () => ({}),
|
||||
'common:setTitle': () => {},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
||||
|
||||
import Home from '@/components/static/home.vue';
|
||||
import Store from '@/libs/store';
|
||||
import * as Analytics from '@/libs/analytics';
|
||||
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(Store);
|
||||
|
||||
describe('Home', () => {
|
||||
let registerStub;
|
||||
let socialAuthStub;
|
||||
let store;
|
||||
let wrapper;
|
||||
|
||||
function mountWrapper (query) {
|
||||
return shallowMount(Home, {
|
||||
store,
|
||||
localVue,
|
||||
mocks: {
|
||||
$t: string => string,
|
||||
$route: { query: query || {} },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function fillOutUserForm (username, email, password) {
|
||||
await wrapper.find('#usernameInput').setValue(username);
|
||||
await wrapper.find('input[type=email]').setValue(email);
|
||||
await wrapper.findAll('input[type=password]').setValue(password);
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
registerStub = sinon.stub();
|
||||
socialAuthStub = sinon.stub();
|
||||
store = new Store({
|
||||
state: {},
|
||||
getters: {},
|
||||
actions: {
|
||||
'auth:register': registerStub,
|
||||
'auth:socialAuth': socialAuthStub,
|
||||
},
|
||||
});
|
||||
|
||||
sinon.stub(Analytics, 'track');
|
||||
|
||||
wrapper = mountWrapper();
|
||||
});
|
||||
|
||||
afterEach(sinon.restore);
|
||||
|
||||
it('has a visible title', () => {
|
||||
expect(wrapper.find('h1').text()).to.equal('motivateYourself');
|
||||
});
|
||||
|
||||
describe('signup form', () => {
|
||||
it('registers a user from the form', async () => {
|
||||
const username = 'newUser';
|
||||
const email = 'rookie@habitica.com';
|
||||
const password = 'ImmaG3tProductive!';
|
||||
await fillOutUserForm(username, email, password);
|
||||
|
||||
await wrapper.find('form').trigger('submit');
|
||||
|
||||
expect(registerStub.calledOnce).to.be.true;
|
||||
expect(registerStub.getCall(0).args[1]).to.deep.equal({
|
||||
username,
|
||||
email,
|
||||
password,
|
||||
passwordConfirm: password,
|
||||
groupInvite: '',
|
||||
});
|
||||
});
|
||||
|
||||
it('registers a user with group invite if groupInvite in the query', async () => {
|
||||
const groupInvite = 'TheBestGroup';
|
||||
wrapper = mountWrapper({ groupInvite });
|
||||
await fillOutUserForm('invitedUser', 'invited@habitica.com', '1veGotFri3ndsHooray!');
|
||||
|
||||
await wrapper.find('form').trigger('submit');
|
||||
|
||||
expect(registerStub.calledOnce).to.be.true;
|
||||
expect(registerStub.getCall(0).args[1].groupInvite).to.equal(groupInvite);
|
||||
});
|
||||
|
||||
it('registers a user with group invite if p in the query', async () => {
|
||||
const p = 'ThePiGroup';
|
||||
wrapper = mountWrapper({ p });
|
||||
await fillOutUserForm('alsoInvitedUser', 'invited2@habitica.com', '1veGotFri3nds2!');
|
||||
|
||||
await wrapper.find('form').trigger('submit');
|
||||
|
||||
expect(registerStub.calledOnce).to.be.true;
|
||||
expect(registerStub.getCall(0).args[1].groupInvite).to.equal(p);
|
||||
});
|
||||
|
||||
it('registers a user with group invite invite if both p and groupInvite are in the query', async () => {
|
||||
const groupInvite = 'StillTheBestGroup';
|
||||
wrapper = mountWrapper({ p: 'LesserGroup', groupInvite });
|
||||
await fillOutUserForm('doublyInvitedUser', 'invited3@habitica.com', '1veGotSm4rtFri3nds!');
|
||||
|
||||
await wrapper.find('form').trigger('submit');
|
||||
|
||||
expect(registerStub.calledOnce).to.be.true;
|
||||
expect(registerStub.getCall(0).args[1].groupInvite).to.equal(groupInvite);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -10,6 +10,7 @@ describe('Tasks User', () => {
|
||||
const store = new Store({
|
||||
state: { user: { data: { tags: [challengeTag] } } },
|
||||
getters: {},
|
||||
actions: { 'common:setTitle': () => {} },
|
||||
});
|
||||
return shallowMount(User, {
|
||||
store,
|
||||
|
||||
@@ -32,7 +32,6 @@ export async function handleWebhooks (options, stripeInc) {
|
||||
try {
|
||||
// Verify the event by fetching it from Stripe
|
||||
event = stripeApi.webhooks.constructEvent(body, headers['stripe-signature'], endpointSecret);
|
||||
console.log(event);
|
||||
} catch (err) {
|
||||
logger.error(new Error('Error verifying Stripe webhook'), { err });
|
||||
throw new BadRequest(`Webhook Error: ${err.message}`);
|
||||
|
||||
Reference in New Issue
Block a user