diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c3687cc5a..dae41fc1c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -344,7 +344,7 @@ jobs: report_name: Coverage Frontend type: lcov result_path: ./coverage/lcov.info - min_coverage: 73 + min_coverage: 75 token: ${{ github.token }} ############################################################################## diff --git a/frontend/src/components/LanguageSwitch.spec.js b/frontend/src/components/LanguageSwitch.spec.js index dc76d854b..cf7c4a35e 100644 --- a/frontend/src/components/LanguageSwitch.spec.js +++ b/frontend/src/components/LanguageSwitch.spec.js @@ -122,7 +122,6 @@ describe('LanguageSwitch', () => { expect(updateUserInfosMutationMock).toBeCalledWith( expect.objectContaining({ variables: { - email: 'he@ho.he', locale: 'en', }, }), @@ -134,7 +133,6 @@ describe('LanguageSwitch', () => { expect(updateUserInfosMutationMock).toBeCalledWith( expect.objectContaining({ variables: { - email: 'he@ho.he', locale: 'de', }, }), diff --git a/frontend/src/components/LanguageSwitch.vue b/frontend/src/components/LanguageSwitch.vue index 14894e46e..5e4c71287 100644 --- a/frontend/src/components/LanguageSwitch.vue +++ b/frontend/src/components/LanguageSwitch.vue @@ -39,7 +39,6 @@ export default { .mutate({ mutation: updateUserInfos, variables: { - email: this.$store.state.email, locale: locale, }, }) diff --git a/frontend/src/directives/click-ouside.js b/frontend/src/directives/click-ouside.js.unused similarity index 100% rename from frontend/src/directives/click-ouside.js rename to frontend/src/directives/click-ouside.js.unused diff --git a/frontend/src/plugins/globalDirectives.js b/frontend/src/plugins/globalDirectives.js index 56d8c9e13..1ef005f5b 100755 --- a/frontend/src/plugins/globalDirectives.js +++ b/frontend/src/plugins/globalDirectives.js @@ -1,4 +1,4 @@ -import clickOutside from '@/directives/click-ouside.js' +// import clickOutside from '@/directives/click-ouside.js' import { focus } from 'vue-focus' /** @@ -7,7 +7,7 @@ import { focus } from 'vue-focus' const GlobalDirectives = { install(Vue) { - Vue.directive('click-outside', clickOutside) + // Vue.directive('click-outside', clickOutside) Vue.directive('focus', focus) }, } diff --git a/frontend/src/routes/router.test.js b/frontend/src/routes/router.test.js index 57fca142b..8b6fbf3b9 100644 --- a/frontend/src/routes/router.test.js +++ b/frontend/src/routes/router.test.js @@ -55,8 +55,8 @@ describe('router', () => { expect(routes.find((r) => r.path === '/').redirect()).toEqual({ path: '/login' }) }) - it('has ten routes defined', () => { - expect(routes).toHaveLength(10) + it('has twelve routes defined', () => { + expect(routes).toHaveLength(12) }) describe('overview', () => { diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index f9b40fd15..080b63a5f 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -32,6 +32,9 @@ export const mutations = { community: (state, community) => { state.community = community }, + coinanimation: (state, coinanimation) => { + state.coinanimation = coinanimation + }, } export const actions = { @@ -42,6 +45,7 @@ export const actions = { commit('firstName', data.firstName) commit('lastName', data.lastName) commit('description', data.description) + commit('coinanimation', data.coinanimation) commit('newsletterState', data.klickTipp.newsletterState) }, logout: ({ commit, state }) => { @@ -51,6 +55,7 @@ export const actions = { commit('firstName', '') commit('lastName', '') commit('description', '') + commit('coinanimation', true) commit('newsletterState', null) localStorage.clear() }, diff --git a/frontend/src/store/store.test.js b/frontend/src/store/store.test.js index 7ae3344d9..bdc0b5b93 100644 --- a/frontend/src/store/store.test.js +++ b/frontend/src/store/store.test.js @@ -8,6 +8,7 @@ const { firstName, lastName, description, + coinanimation, newsletterState, } = mutations const { login, logout } = actions @@ -70,6 +71,14 @@ describe('Vuex store', () => { }) }) + describe('coinanimation', () => { + it('sets the state of coinanimation', () => { + const state = { coinanimation: true } + coinanimation(state, false) + expect(state.coinanimation).toEqual(false) + }) + }) + describe('newsletterState', () => { it('sets the state of newsletterState', () => { const state = { newsletterState: null } @@ -90,14 +99,15 @@ describe('Vuex store', () => { firstName: 'Peter', lastName: 'Lustig', description: 'Nickelbrille', + coinanimation: false, klickTipp: { newsletterState: true, }, } - it('calls seven commits', () => { + it('calls eight commits', () => { login({ commit, state }, commitedData) - expect(commit).toHaveBeenCalledTimes(7) + expect(commit).toHaveBeenCalledTimes(8) }) it('commits email', () => { @@ -130,9 +140,14 @@ describe('Vuex store', () => { expect(commit).toHaveBeenNthCalledWith(6, 'description', 'Nickelbrille') }) + it('commits coinanimation', () => { + login({ commit, state }, commitedData) + expect(commit).toHaveBeenNthCalledWith(7, 'coinanimation', false) + }) + it('commits newsletterState', () => { login({ commit, state }, commitedData) - expect(commit).toHaveBeenNthCalledWith(7, 'newsletterState', true) + expect(commit).toHaveBeenNthCalledWith(8, 'newsletterState', true) }) }) @@ -140,9 +155,9 @@ describe('Vuex store', () => { const commit = jest.fn() const state = {} - it('calls six commits', () => { + it('calls eight commits', () => { logout({ commit, state }) - expect(commit).toHaveBeenCalledTimes(7) + expect(commit).toHaveBeenCalledTimes(8) }) it('commits token', () => { @@ -175,9 +190,14 @@ describe('Vuex store', () => { expect(commit).toHaveBeenNthCalledWith(6, 'description', '') }) + it('commits coinanimation', () => { + logout({ commit, state }) + expect(commit).toHaveBeenNthCalledWith(7, 'coinanimation', true) + }) + it('commits newsletterState', () => { logout({ commit, state }) - expect(commit).toHaveBeenNthCalledWith(7, 'newsletterState', null) + expect(commit).toHaveBeenNthCalledWith(8, 'newsletterState', null) }) // how to get this working? diff --git a/frontend/src/views/Pages/AccountOverview/GddSend/TransactionForm.spec.js b/frontend/src/views/Pages/AccountOverview/GddSend/TransactionForm.spec.js index 6178805c8..463613449 100644 --- a/frontend/src/views/Pages/AccountOverview/GddSend/TransactionForm.spec.js +++ b/frontend/src/views/Pages/AccountOverview/GddSend/TransactionForm.spec.js @@ -67,12 +67,13 @@ describe('GddSend', () => { it('trims the email after blur', async () => { await wrapper.find('#input-group-1').find('input').setValue(' valid@email.com ') + await wrapper.find('#input-group-1').find('input').trigger('blur') await flushPromises() expect(wrapper.vm.form.email).toBe('valid@email.com') }) }) - describe('ammount field', () => { + describe('amount field', () => { it('has an input field of type text', () => { expect(wrapper.find('#input-group-2').find('input').attributes('type')).toBe('text') }) @@ -91,6 +92,13 @@ describe('GddSend', () => { ) }) + it('does not update form amount when invalid', async () => { + await wrapper.find('#input-group-2').find('input').setValue('invalid') + await wrapper.find('#input-group-2').find('input').trigger('blur') + await flushPromises() + expect(wrapper.vm.form.amountValue).toBe(0) + }) + it('flushes an error message when no valid amount is given', async () => { await wrapper.find('#input-group-2').find('input').setValue('a') await flushPromises() @@ -150,11 +158,11 @@ describe('GddSend', () => { it('clears all fields on click', async () => { await wrapper.find('#input-group-1').find('input').setValue('someone@watches.tv') await wrapper.find('#input-group-2').find('input').setValue('87.23') - await wrapper.find('#input-group-3').find('textarea').setValue('Long enugh') + await wrapper.find('#input-group-3').find('textarea').setValue('Long enough') await flushPromises() expect(wrapper.vm.form.email).toBe('someone@watches.tv') expect(wrapper.vm.form.amount).toBe('87.23') - expect(wrapper.vm.form.memo).toBe('Long enugh') + expect(wrapper.vm.form.memo).toBe('Long enough') await wrapper.find('button[type="reset"]').trigger('click') await flushPromises() expect(wrapper.vm.form.email).toBe('') @@ -167,7 +175,7 @@ describe('GddSend', () => { beforeEach(async () => { await wrapper.find('#input-group-1').find('input').setValue('someone@watches.tv') await wrapper.find('#input-group-2').find('input').setValue('87.23') - await wrapper.find('#input-group-3').find('textarea').setValue('Long enugh') + await wrapper.find('#input-group-3').find('textarea').setValue('Long enough') await wrapper.find('form').trigger('submit') await flushPromises() }) @@ -179,7 +187,7 @@ describe('GddSend', () => { { email: 'someone@watches.tv', amount: 87.23, - memo: 'Long enugh', + memo: 'Long enough', }, ], ]) diff --git a/frontend/src/views/Pages/Register.vue b/frontend/src/views/Pages/Register.vue index 85fe51325..43885e1c6 100755 --- a/frontend/src/views/Pages/Register.vue +++ b/frontend/src/views/Pages/Register.vue @@ -129,7 +129,7 @@ @@ -239,9 +239,6 @@ export default { emailFilled() { return this.form.email !== '' }, - languageFilled() { - return !!this.language - }, }, } diff --git a/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js index 54132f423..8e95605a5 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js @@ -1,5 +1,6 @@ import { mount } from '@vue/test-utils' import UserCardCoinAnimation from './UserCard_CoinAnimation' +import { updateUserInfos } from '../../../graphql/mutations' const localVue = global.localVue @@ -17,6 +18,7 @@ describe('UserCard_CoinAnimation', () => { $store: { state: { language: 'de', + coinanimation: true, }, commit: storeCommitMock, }, @@ -25,7 +27,7 @@ describe('UserCard_CoinAnimation', () => { error: toastErrorMock, }, $apollo: { - query: mockAPIcall, + mutate: mockAPIcall, }, } @@ -45,5 +47,84 @@ describe('UserCard_CoinAnimation', () => { it('has an edit BFormCheckbox switch', () => { expect(wrapper.find('.Test-BFormCheckbox').exists()).toBeTruthy() }) + + describe('enable with success', () => { + beforeEach(async () => { + mocks.$store.state.coinanimation = false + mockAPIcall.mockResolvedValue({ + data: { + updateUserInfos: { + validValues: 1, + }, + }, + }) + await wrapper.find('input').trigger('change') + }) + + it('calls the updateUserInfos mutation', () => { + expect(mockAPIcall).toBeCalledWith({ + mutation: updateUserInfos, + variables: { + coinanimation: true, + }, + }) + }) + + it('updates the store', () => { + expect(storeCommitMock).toBeCalledWith('coinanimation', true) + }) + + it('toasts a success message', () => { + expect(toastSuccessMock).toBeCalledWith('settings.coinanimation.True') + }) + }) + + describe('disable with success', () => { + beforeEach(async () => { + mocks.$store.state.coinanimation = true + mockAPIcall.mockResolvedValue({ + data: { + updateUserInfos: { + validValues: 1, + }, + }, + }) + wrapper.find('input').trigger('change') + }) + + it('calls the subscribe mutation', () => { + expect(mockAPIcall).toBeCalledWith({ + mutation: updateUserInfos, + variables: { + coinanimation: false, + }, + }) + }) + + it('updates the store', () => { + expect(storeCommitMock).toBeCalledWith('coinanimation', false) + }) + + it('toasts a success message', () => { + expect(toastSuccessMock).toBeCalledWith('settings.coinanimation.False') + }) + }) + + describe('disable with server error', () => { + beforeEach(() => { + mockAPIcall.mockRejectedValue({ + message: 'Ouch', + }) + wrapper.find('input').trigger('change') + }) + + it('resets the CoinAnimationStatus', () => { + expect(wrapper.vm.CoinAnimationStatus).toBeTruthy() + }) + + it('toasts an error message', () => { + expect(toastErrorMock).toBeCalledWith('Ouch') + }) + }) }) }) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.vue b/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.vue index 11c0fc823..21192af93 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.vue @@ -36,12 +36,9 @@ export default { name: 'FormUserCoinAnimation', data() { return { - CoinAnimationStatus: true, + CoinAnimationStatus: this.$store.state.coinanimation, } }, - created() { - this.CoinAnimationStatus = this.$store.state.coinanimation /* existiert noch nicht im store */ - }, methods: { async onSubmit() { this.$apollo @@ -52,7 +49,7 @@ export default { }, }) .then(() => { - this.$store.state.coinanimation = this.CoinAnimationStatus + this.$store.commit('coinanimation', this.CoinAnimationStatus) this.$toasted.success( this.CoinAnimationStatus ? this.$t('settings.coinanimation.True') @@ -60,6 +57,7 @@ export default { ) }) .catch((error) => { + this.CoinAnimationStatus = this.$store.state.coinanimation this.$toasted.error(error.message) }) }, diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.spec.js index 927f1d29d..b4cdc0fb7 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.spec.js @@ -17,7 +17,6 @@ describe('UserCard_FormUserData', () => { $t: jest.fn((t) => t), $store: { state: { - email: 'user@example.org', firstName: 'Peter', lastName: 'Lustig', description: '', @@ -117,7 +116,6 @@ describe('UserCard_FormUserData', () => { expect(mockAPIcall).toBeCalledWith( expect.objectContaining({ variables: { - email: 'user@example.org', firstName: 'Petra', lastName: 'Lustiger', description: 'Keine Nickelbrille', @@ -165,7 +163,6 @@ describe('UserCard_FormUserData', () => { expect(mockAPIcall).toBeCalledWith( expect.objectContaining({ variables: { - email: 'user@example.org', firstName: 'Petra', lastName: 'Lustiger', description: 'Keine Nickelbrille', diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue index b3cee1ef5..f22a48ccd 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue @@ -111,7 +111,6 @@ export default { .mutate({ mutation: updateUserInfos, variables: { - email: this.$store.state.email, firstName: this.form.firstName, lastName: this.form.lastName, description: this.form.description, diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.spec.js index 84836dc91..cc4911683 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.spec.js @@ -75,7 +75,6 @@ describe('UserCard_FormUserMail', () => { expect(mockAPIcall).toHaveBeenCalledWith( expect.objectContaining({ variables: { - email: 'user@example.org', newEmail: 'test@example.org', }, }), @@ -104,7 +103,6 @@ describe('UserCard_FormUserMail', () => { expect(mockAPIcall).toHaveBeenCalledWith( expect.objectContaining({ variables: { - email: 'user@example.org', newEmail: 'test@example.org', }, }), diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.vue index 50e0317d1..de276afdf 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.vue @@ -48,7 +48,6 @@ export default { .mutate({ mutation: updateUserInfos, variables: { - email: this.$store.state.email, newEmail: this.newEmail, }, }) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.spec.js index 296d61b7c..3997bb71e 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.spec.js @@ -15,11 +15,6 @@ describe('UserCard_FormUserPasswort', () => { const mocks = { $t: jest.fn((t) => t), - $store: { - state: { - email: 'user@example.org', - }, - }, $toasted: { success: toastSuccessMock, error: toastErrorMock, @@ -191,7 +186,6 @@ describe('UserCard_FormUserPasswort', () => { expect(changePasswordProfileMock).toHaveBeenCalledWith( expect.objectContaining({ variables: { - email: 'user@example.org', password: '1234', passwordNew: 'Aa123456_', }, diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue index 1f6c34c26..5235c4554 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue @@ -76,7 +76,6 @@ export default { .mutate({ mutation: updateUserInfos, variables: { - email: this.$store.state.email, password: this.form.password, passwordNew: this.form.newPassword.password, }, diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.spec.js index a55c223d7..be3abbbee 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.spec.js @@ -25,7 +25,6 @@ describe('UserCard_FormUsername', () => { $t: jest.fn((t) => t), $store: { state: { - email: 'user@example.org', username: '', }, commit: storeCommitMock, @@ -109,7 +108,6 @@ describe('UserCard_FormUsername', () => { expect(mockAPIcall).toHaveBeenCalledWith( expect.objectContaining({ variables: { - email: 'user@example.org', username: 'username', }, }), @@ -148,7 +146,6 @@ describe('UserCard_FormUsername', () => { expect(mockAPIcall).toHaveBeenCalledWith( expect.objectContaining({ variables: { - email: 'user@example.org', username: 'username', }, }), diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue index f9d46bbba..90ac23884 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue @@ -90,7 +90,6 @@ export default { .mutate({ mutation: updateUserInfos, variables: { - email: this.$store.state.email, username: this.form.username, }, }) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js index 774bc9e32..f2acacd5b 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js @@ -23,7 +23,6 @@ describe('UserCard_Language', () => { $store: { state: { language: 'de', - email: 'peter@lustig.de', }, commit: storeCommitMock, }, @@ -127,7 +126,6 @@ describe('UserCard_Language', () => { expect(mockAPIcall).toBeCalledWith( expect.objectContaining({ variables: { - email: 'peter@lustig.de', locale: 'en', }, }), diff --git a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue index 2962731e9..9315c747e 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue @@ -89,7 +89,6 @@ export default { .mutate({ mutation: updateUserInfos, variables: { - email: this.$store.state.email, locale: this.language, }, }) diff --git a/frontend/test/testSetup.js b/frontend/test/testSetup.js index daf862548..9ae5777ec 100644 --- a/frontend/test/testSetup.js +++ b/frontend/test/testSetup.js @@ -13,7 +13,7 @@ import VueQrcode from 'vue-qrcode' import VueMoment from 'vue-moment' -import clickOutside from '@/directives/click-ouside.js' +// import clickOutside from '@/directives/click-ouside.js' import { focus } from 'vue-focus' import { loadAllRules } from '../src/validation-rules' @@ -46,7 +46,7 @@ global.localVue.use(VueQrcode) global.localVue.use(VueMoment) global.localVue.component('validation-provider', ValidationProvider) global.localVue.component('validation-observer', ValidationObserver) -global.localVue.directive('click-outside', clickOutside) +// global.localVue.directive('click-outside', clickOutside) global.localVue.directive('focus', focus) // throw errors for vue warnings to force the programmers to take care about warnings