diff --git a/admin/src/main.js b/admin/src/main.js index c0004beca..5495ca996 100644 --- a/admin/src/main.js +++ b/admin/src/main.js @@ -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, diff --git a/admin/src/main.test.js b/admin/src/main.test.js index 06efa8b65..a5eda5c65 100644 --- a/admin/src/main.test.js +++ b/admin/src/main.test.js @@ -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') + }) }) diff --git a/backend/.env.template b/backend/.env.template index 9ff9beb01..4caebf107 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -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 \ No newline at end of file diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 871e1b9d6..88502a7d0 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -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) diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index 4e737a95e..f5fa4ce2c 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -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} diff --git a/frontend/src/components/LanguageSwitch.vue b/frontend/src/components/LanguageSwitch.vue index 5e4c71287..2678883c3 100644 --- a/frontend/src/components/LanguageSwitch.vue +++ b/frontend/src/components/LanguageSwitch.vue @@ -12,7 +12,6 @@ + diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 840cde454..c071e92af 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -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!", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 8cb2a609a..cb0b92ee9 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -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!", diff --git a/frontend/src/main.js b/frontend/src/main.js index 544dff66d..edc9e575e 100755 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -28,7 +28,7 @@ Vue.toasted.register( loadAllRules(i18n) -addNavigationGuards(router, store, apolloProvider.defaultClient, i18n) +addNavigationGuards(router, store, apolloProvider.defaultClient) if (!store) { setTimeout( diff --git a/frontend/src/routes/guards.js b/frontend/src/routes/guards.js index 15d1eb5a1..1838fa0fc 100644 --- a/frontend/src/routes/guards.js +++ b/frontend/src/routes/guards.js @@ -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' }) }) diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index d219ecacd..1a6521cd7 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -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) => { diff --git a/frontend/src/store/store.test.js b/frontend/src/store/store.test.js index da108b9ff..4c0c03178 100644 --- a/frontend/src/store/store.test.js +++ b/frontend/src/store/store.test.js @@ -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', () => { diff --git a/frontend/src/views/Pages/Register.vue b/frontend/src/views/Pages/Register.vue index 389efc68a..05cf61c46 100755 --- a/frontend/src/views/Pages/Register.vue +++ b/frontend/src/views/Pages/Register.vue @@ -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 diff --git a/frontend/src/views/Pages/ResetPassword.spec.js b/frontend/src/views/Pages/ResetPassword.spec.js index e3a7c81b1..18e85d207 100644 --- a/frontend/src/views/Pages/ResetPassword.spec.js +++ b/frontend/src/views/Pages/ResetPassword.spec.js @@ -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') }) diff --git a/frontend/src/views/Pages/ResetPassword.vue b/frontend/src/views/Pages/ResetPassword.vue index 2e171936a..2d9d1ad35 100644 --- a/frontend/src/views/Pages/ResetPassword.vue +++ b/frontend/src/views/Pages/ResetPassword.vue @@ -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) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js index e13d4a1d1..dab5a4945 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js @@ -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() }) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue index dfaf6cf55..a7b9d7f70 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue @@ -60,7 +60,6 @@