Merge branch 'master' into 1319-email-optin

This commit is contained in:
Hannes Heine 2022-01-25 14:29:16 +01:00 committed by GitHub
commit ffcf8106a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 145 additions and 73 deletions

View File

@ -44,6 +44,9 @@ Vue.use(Toasted, {
addNavigationGuards(router, store, apolloProvider.defaultClient, i18n)
i18n.locale =
store.state.moderator && store.state.moderator.language ? store.state.moderator.language : 'en'
new Vue({
moment,
router,

View File

@ -15,7 +15,15 @@ jest.mock('vue-apollo')
jest.mock('vuex')
jest.mock('vue-i18n')
jest.mock('vue-moment')
jest.mock('./store/store')
jest.mock('./store/store', () => {
return {
state: {
moderator: {
language: 'es',
},
},
}
})
jest.mock('./i18n')
jest.mock('./router/router')
@ -101,4 +109,8 @@ describe('main', () => {
}),
)
})
it('sets the locale from store', () => {
expect(i18n.locale).toBe('es')
})
})

View File

@ -27,9 +27,9 @@ EMAIL_LINK_SETPASSWORD=$EMAIL_LINK_SETPASSWORD
#KLICKTIPP_APIKEY_DE=
#KLICKTIPP_APIKEY_EN=
#KLICKTIPP=true
COMMUNITY_NAME=
COMMUNITY_URL=
COMMUNITY_REGISTER_URL=
COMMUNITY_DESCRIPTION=
COMMUNITY_NAME=$COMMUNITY_NAME
COMMUNITY_URL=$COMMUNITY_URL
COMMUNITY_REGISTER_URL=$COMMUNITY_REGISTER_URL
COMMUNITY_DESCRIPTION=$COMMUNITY_DESCRIPTION
WEBHOOK_ELOPAGE_SECRET=$WEBHOOK_ELOPAGE_SECRET

View File

@ -503,7 +503,7 @@ export class TransactionResolver {
email: userEntity.email,
})
if (!resultGDTSum.success) throw new Error(resultGDTSum.data)
transactions.gdtSum = Number(resultGDTSum.data.sum / 100) || 0
transactions.gdtSum = Number(resultGDTSum.data.sum) || 0
// get balance
const balanceRepository = getCustomRepository(BalanceRepository)

View File

@ -30,6 +30,11 @@ TYPEORM_LOGGING_RELATIVE_PATH=../deployment/bare_metal/log/typeorm.backend.log
WEBHOOK_ELOPAGE_SECRET=secret
COMMUNITY_NAME=Gradido Development Stage1
COMMUNITY_URL=https://stage1.gradido.net/
COMMUNITY_REGISTER_URL=https://stage1.gradido.net/register
COMMUNITY_DESCRIPTION=Gradido Development Stage1 Test Community
# frontend
GRAPHQL_URI=https://stage1.gradido.net/graphql
ADMIN_AUTH_URL=https://stage1.gradido.net/admin/authenticate?token={token}

View File

@ -12,7 +12,6 @@
</div>
</template>
<script>
import { localeChanged } from 'vee-validate'
import locales from '../locales/'
import { updateUserInfos } from '../graphql/mutations'
@ -26,10 +25,8 @@ export default {
},
methods: {
setLocale(locale) {
this.$i18n.locale = locale
this.$store.commit('language', this.$i18n.locale)
this.$store.commit('language', locale)
this.currentLanguage = this.getLocaleObject(locale)
localeChanged(locale)
},
async saveLocale(locale) {
// if (this.$i18n.locale === locale) return

View File

@ -4,7 +4,7 @@
<p></p>
<div class="mb-6">
<b-nav vertical class="w-200">
<b-nav-item to="/overview" class="mb-3" active>
<b-nav-item to="/overview" class="mb-3">
<b-icon icon="house" aria-hidden="true"></b-icon>
{{ $t('overview') }}
</b-nav-item>
@ -52,3 +52,9 @@ export default {
},
}
</script>
<style>
#component-sidebar .active,
.component-navbar .active {
font-weight: bold;
}
</style>

View File

@ -198,7 +198,7 @@
},
"thx": {
"activateEmail": "Dein Konto wurde noch nicht aktiviert. Bitte überprüfe deine E-Mail und klicke den Aktivierungslink! Oder fordere einen neuen Aktivierungslink über die password reset seite.",
"checkEmail": "Deine E-Mail wurde erfolgreich verifiziert.",
"checkEmail": "Deine E-Mail wurde erfolgreich verifiziert. Du kannst dich jetzt anmelden.
"email": "Wir haben dir eine E-Mail gesendet.",
"emailActivated": "Danke dass Du deine E-Mail bestätigt hast.",
"errorTitle": "Achtung!",

View File

@ -198,7 +198,7 @@
},
"thx": {
"activateEmail": "Your account has not been activated yet, please check your emails and click the activation link! Or order a new activation link over the password reset page.",
"checkEmail": "Your email has been successfully verified.",
"checkEmail": "Your email has been successfully verified. You can sign in now.",
"email": "We have sent you an email.",
"emailActivated": "Thank you your email has been activated.",
"errorTitle": "Attention!",

View File

@ -28,7 +28,7 @@ Vue.toasted.register(
loadAllRules(i18n)
addNavigationGuards(router, store, apolloProvider.defaultClient, i18n)
addNavigationGuards(router, store, apolloProvider.defaultClient)
if (!store) {
setTimeout(

View File

@ -1,6 +1,6 @@
import { verifyLogin } from '../graphql/queries'
const addNavigationGuards = (router, store, apollo, i18n) => {
const addNavigationGuards = (router, store, apollo) => {
// handle publisherId
router.beforeEach((to, from, next) => {
const publisherId = to.query.pid
@ -21,7 +21,6 @@ const addNavigationGuards = (router, store, apollo, i18n) => {
fetchPolicy: 'network-only',
})
.then((result) => {
i18n.locale = result.data.verifyLogin.language
store.dispatch('login', result.data.verifyLogin)
next({ path: '/overview' })
})

View File

@ -1,11 +1,15 @@
import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
import { localeChanged } from 'vee-validate'
import i18n from '../i18n.js'
Vue.use(Vuex)
export const mutations = {
language: (state, language) => {
i18n.locale = language
localeChanged(language)
state.language = language
},
email: (state, email) => {

View File

@ -1,8 +1,18 @@
import { mutations, actions } from './store'
import Vuex from 'vuex'
import Vue from 'vue'
import i18n from '../i18n.js'
import { localeChanged } from 'vee-validate'
jest.mock('vuex')
jest.mock('../i18n.js')
jest.mock('vee-validate', () => {
return {
localeChanged: jest.fn(),
}
})
i18n.locale = 'blubb'
const {
language,
@ -29,6 +39,14 @@ describe('Vuex store', () => {
language(state, 'de')
expect(state.language).toEqual('de')
})
it('sets the i18n locale', () => {
expect(i18n.locale).toBe('de')
})
it('calls localChanged of vee-validate', () => {
expect(localeChanged).toBeCalledWith('de')
})
})
describe('email', () => {

View File

@ -191,7 +191,6 @@
import InputEmail from '../../components/Inputs/InputEmail.vue'
import LanguageSwitchSelect from '../../components/LanguageSwitchSelect.vue'
import { createUser } from '../../graphql/mutations'
import { localeChanged } from 'vee-validate'
import { getCommunityInfoMixin } from '../../mixins/getCommunityInfo'
export default {
@ -218,8 +217,6 @@ export default {
updateLanguage(e) {
this.language = e
this.$store.commit('language', this.language)
this.$i18n.locale = this.language
localeChanged(this.language)
},
getValidationState({ dirty, validated, valid = null }) {
return dirty || validated ? valid : null

View File

@ -15,54 +15,48 @@ const stubs = {
RouterLink: RouterLinkStub,
}
const createMockObject = (comingFrom) => {
return {
localVue,
mocks: {
$i18n: {
locale: 'en',
},
$t: jest.fn((t) => t),
$route: {
params: {
optin: '123',
comingFrom,
},
path: {
includes: (t) => t,
},
},
$toasted: {
global: {
error: toasterMock,
},
},
$router: {
push: routerPushMock,
},
$loading: {
show: jest.fn(() => {
return { hide: jest.fn() }
}),
},
$apollo: {
mutate: apolloMutationMock,
},
const mocks = {
$i18n: {
locale: 'en',
},
$t: jest.fn((t) => t),
$route: {
params: {
optin: '123',
},
stubs,
}
path: {
mock: 'checkEmail',
includes: jest.fn((t) => t === mocks.$route.path.mock),
},
},
$toasted: {
global: {
error: toasterMock,
},
},
$router: {
push: routerPushMock,
},
$loading: {
show: jest.fn(() => {
return { hide: jest.fn() }
}),
},
$apollo: {
mutate: apolloMutationMock,
},
}
describe('ResetPassword', () => {
let wrapper
const Wrapper = (functionName) => {
return mount(ResetPassword, functionName)
const Wrapper = () => {
return mount(ResetPassword, { localVue, mocks, stubs })
}
describe('mount', () => {
beforeEach(() => {
wrapper = Wrapper(createMockObject())
wrapper = Wrapper()
})
describe('No valid optin', () => {
@ -86,11 +80,32 @@ describe('ResetPassword', () => {
})
describe('Register header', () => {
it('has a welcome message', async () => {
expect(wrapper.find('div.header').text()).toContain('settings.password.reset')
expect(wrapper.find('div.header').text()).toContain(
'settings.password.reset-password.text',
)
describe('from reset', () => {
beforeEach(() => {
mocks.$route.path.mock = 'reset'
wrapper = Wrapper()
})
it('has a welcome message', async () => {
expect(wrapper.find('div.header').text()).toContain('settings.password.reset')
expect(wrapper.find('div.header').text()).toContain(
'settings.password.reset-password.text',
)
})
})
describe('from checkEmail', () => {
beforeEach(() => {
mocks.$route.path.mock = 'checkEmail'
wrapper = Wrapper()
})
it('has a welcome message', async () => {
expect(wrapper.find('div.header').text()).toContain('settings.password.set')
expect(wrapper.find('div.header').text()).toContain(
'settings.password.set-password.text',
)
})
})
})
@ -128,7 +143,6 @@ describe('ResetPassword', () => {
describe('submit form', () => {
beforeEach(async () => {
// wrapper = Wrapper(createMockObject())
await wrapper.findAll('input').at(0).setValue('Aa123456_')
await wrapper.findAll('input').at(1).setValue('Aa123456_')
await flushPromises()
@ -164,14 +178,14 @@ describe('ResetPassword', () => {
})
})
describe('server response with success', () => {
describe('server response with success on /checkEmail', () => {
beforeEach(async () => {
mocks.$route.path.mock = 'checkEmail'
apolloMutationMock.mockResolvedValue({
data: {
resetPassword: 'success',
},
})
wrapper = Wrapper(createMockObject('checkEmail'))
await wrapper.findAll('input').at(0).setValue('Aa123456_')
await wrapper.findAll('input').at(1).setValue('Aa123456_')
await wrapper.find('form').trigger('submit')
@ -189,6 +203,26 @@ describe('ResetPassword', () => {
)
})
it('redirects to "/thx/checkEmail"', () => {
expect(routerPushMock).toHaveBeenCalledWith('/thx/checkEmail')
})
})
describe('server response with success on /reset', () => {
beforeEach(async () => {
mocks.$route.path.mock = 'reset'
wrapper = Wrapper()
apolloMutationMock.mockResolvedValue({
data: {
resetPassword: 'success',
},
})
await wrapper.findAll('input').at(0).setValue('Aa123456_')
await wrapper.findAll('input').at(1).setValue('Aa123456_')
await wrapper.find('form').trigger('submit')
await flushPromises()
})
it('redirects to "/thx/reset"', () => {
expect(routerPushMock).toHaveBeenCalledWith('/thx/reset')
})

View File

@ -92,7 +92,11 @@ export default {
})
.then(() => {
this.form.password = ''
this.$router.push('/thx/reset')
if (this.$route.path.includes('checkEmail')) {
this.$router.push('/thx/checkEmail')
} else {
this.$router.push('/thx/reset')
}
})
.catch((error) => {
this.$toasted.global.error(error.message)

View File

@ -138,10 +138,6 @@ describe('UserCard_Language', () => {
expect(storeCommitMock).toBeCalledWith('language', 'en')
})
it('changes the i18n locale', () => {
expect(mocks.$i18n.locale).toBe('en')
})
it('has no select field anymore', () => {
expect(wrapper.find('select').exists()).toBeFalsy()
})

View File

@ -60,7 +60,6 @@
</b-card>
</template>
<script>
import { localeChanged } from 'vee-validate'
import LanguageSwitchSelect from '../../../components/LanguageSwitchSelect.vue'
import { updateUserInfos } from '../../../graphql/mutations'
@ -97,8 +96,6 @@ export default {
})
.then(() => {
this.$store.commit('language', this.language)
this.$i18n.locale = this.language
localeChanged(this.language)
this.cancelEdit()
this.$toasted.success(this.$t('settings.language.success'))
})