Merge branch 'master' into set-locale-on-page-reload

This commit is contained in:
Moriz Wahl 2022-01-24 17:50:31 +01:00 committed by GitHub
commit b890c3fc3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 111 additions and 57 deletions

View File

@ -12,6 +12,9 @@
"select_value": "Betrag auswählen", "select_value": "Betrag auswählen",
"submit_creation": "Schöpfung einreichen", "submit_creation": "Schöpfung einreichen",
"toasted": "Offene Schöpfung ({value} GDD) für {email} wurde gespeichert und liegt zur Bestätigung bereit", "toasted": "Offene Schöpfung ({value} GDD) für {email} wurde gespeichert und liegt zur Bestätigung bereit",
"toasted_created": "Schöpfung wurde erfolgreich gespeichert",
"toasted_default": "`Fall {event} wird nicht unterstützt`",
"toasted_delete": "Offene Schöpfung wurde gelöscht",
"toasted_update": "`Offene Schöpfung {value} GDD) für {email} wurde geändert und liegt zur Bestätigung bereit", "toasted_update": "`Offene Schöpfung {value} GDD) für {email} wurde geändert und liegt zur Bestätigung bereit",
"update_creation": "Schöpfung aktualisieren" "update_creation": "Schöpfung aktualisieren"
}, },

View File

@ -12,6 +12,9 @@
"select_value": "Select amount", "select_value": "Select amount",
"submit_creation": "Submit creation", "submit_creation": "Submit creation",
"toasted": "Open creation ({value} GDD) for {email} has been saved and is ready for confirmation.", "toasted": "Open creation ({value} GDD) for {email} has been saved and is ready for confirmation.",
"toasted_created": "Creation has been successfully saved",
"toasted_default": "`Case {event} is not supported`",
"toasted_delete": "Open creation has been deleted",
"toasted_update": "Open creation {value} GDD) for {email} has been changed and is ready for confirmation.", "toasted_update": "Open creation {value} GDD) for {email} has been changed and is ready for confirmation.",
"update_creation": "Creation update" "update_creation": "Creation update"
}, },

View File

@ -127,7 +127,7 @@ describe('CreationConfirm', () => {
}) })
it('toasts a success message', () => { it('toasts a success message', () => {
expect(toastedSuccessMock).toBeCalledWith('Pending Creation has been deleted') expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_delete')
}) })
}) })
@ -189,7 +189,7 @@ describe('CreationConfirm', () => {
}) })
it('toasts a success message', () => { it('toasts a success message', () => {
expect(toastedSuccessMock).toBeCalledWith('Pending Creation has been deleted') expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_created')
}) })
}) })
@ -201,7 +201,7 @@ describe('CreationConfirm', () => {
}) })
it('toasts an error message', () => { it('toasts an error message', () => {
expect(toastedErrorMock).toBeCalledWith('Case confirm is not supported') expect(toastedErrorMock).toBeCalledWith('creation_form.toasted_default')
}) })
}) })

View File

@ -66,7 +66,7 @@ export default {
index = this.confirmResult.indexOf(findArr) index = this.confirmResult.indexOf(findArr)
this.confirmResult.splice(index, 1) this.confirmResult.splice(index, 1)
this.$store.commit('openCreationsMinus', 1) this.$store.commit('openCreationsMinus', 1)
this.$toasted.success('Pending Creation has been deleted') this.$toasted.success(this.$t('creation_form.toasted_delete'))
}) })
.catch((error) => { .catch((error) => {
this.$toasted.error(error.message) this.$toasted.error(error.message)
@ -75,10 +75,10 @@ export default {
case 'confirmed': case 'confirmed':
this.confirmResult.splice(index, 1) this.confirmResult.splice(index, 1)
this.$store.commit('openCreationsMinus', 1) this.$store.commit('openCreationsMinus', 1)
this.$toasted.success('Pending Creation has been deleted') this.$toasted.success(this.$t('creation_form.toasted_created'))
break break
default: default:
this.$toasted.error('Case ' + event + ' is not supported') this.$toasted.error(this.$t('creation_form.toasted_default', { event }))
} }
}, },
getPendingCreations() { getPendingCreations() {

View File

@ -24,8 +24,12 @@
<b-row class="mb-2"> <b-row class="mb-2">
<b-col> <b-col>
<input-password <input-password
:rules="{ samePassword: value.password }" :rules="{
required: true,
samePassword: value.password,
}"
:label="register ? $t('form.passwordRepeat') : $t('form.password_new_repeat')" :label="register ? $t('form.passwordRepeat') : $t('form.password_new_repeat')"
:immediate="true"
:name="createId(register ? $t('form.passwordRepeat') : $t('form.password_new_repeat'))" :name="createId(register ? $t('form.passwordRepeat') : $t('form.password_new_repeat'))"
:placeholder="register ? $t('form.passwordRepeat') : $t('form.password_new_repeat')" :placeholder="register ? $t('form.passwordRepeat') : $t('form.password_new_repeat')"
v-model="passwordRepeat" v-model="passwordRepeat"

View File

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

View File

@ -198,7 +198,7 @@
}, },
"thx": { "thx": {
"activateEmail": "Dein Konto wurde noch nicht aktiviert. Bitte überprüfe deine E-Mail und klicke den Aktivierungslink!", "activateEmail": "Dein Konto wurde noch nicht aktiviert. Bitte überprüfe deine E-Mail und klicke den Aktivierungslink!",
"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.", "email": "Wir haben dir eine E-Mail gesendet.",
"emailActivated": "Danke dass Du deine E-Mail bestätigt hast.", "emailActivated": "Danke dass Du deine E-Mail bestätigt hast.",
"errorTitle": "Achtung!", "errorTitle": "Achtung!",

View File

@ -198,7 +198,7 @@
}, },
"thx": { "thx": {
"activateEmail": "Your account has not been activated yet, please check your emails and click the activation link!", "activateEmail": "Your account has not been activated yet, please check your emails and click the activation link!",
"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.", "email": "We have sent you an email.",
"emailActivated": "Thank you your email has been activated.", "emailActivated": "Thank you your email has been activated.",
"errorTitle": "Attention!", "errorTitle": "Attention!",

View File

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

View File

@ -92,7 +92,11 @@ export default {
}) })
.then(() => { .then(() => {
this.form.password = '' 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) => { .catch((error) => {
this.$toasted.global.error(error.message) this.$toasted.global.error(error.message)