From daedba08214d9514b2f501f593edba73c37e8a33 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 3 Oct 2021 13:34:59 +0200 Subject: [PATCH 01/16] we do not use this i believe --- .../directives/{click-ouside.js => click-ouside.js.unused} | 0 frontend/src/plugins/globalDirectives.js | 4 ++-- frontend/test/testSetup.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename frontend/src/directives/{click-ouside.js => click-ouside.js.unused} (100%) 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/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 From f8706d485221fca74187c20475f97c7f3dac0e13 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 3 Oct 2021 13:35:24 +0200 Subject: [PATCH 02/16] simplified Register.vue to increase line coverage --- frontend/src/views/Pages/Register.vue | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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 - }, }, } From 5a417cd2a8142bb74027647b7a3648fcfee094cf Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 3 Oct 2021 13:36:01 +0200 Subject: [PATCH 03/16] fixed broken tests and increase line coverage of TransactionForm --- .../GddSend/TransactionForm.spec.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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', }, ], ]) From ce826deb1d6d92caba514713539dca2da3f74de7 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 3 Oct 2021 13:36:42 +0200 Subject: [PATCH 04/16] fix UserCard_CoinAnimation to properly use the store, have 100% coverage and other minor fixes & simplifications --- frontend/src/store/store.js | 5 ++ frontend/src/store/store.test.js | 30 +++++-- .../UserCard_CoinAnimation.spec.js | 83 ++++++++++++++++++- .../UserProfile/UserCard_CoinAnimation.vue | 8 +- 4 files changed, 115 insertions(+), 11 deletions(-) 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..e2c06095e 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) }) }) @@ -142,7 +157,7 @@ describe('Vuex store', () => { it('calls six 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/UserProfile/UserCard_CoinAnimation.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js index 54132f423..d51800268 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 () => { + await wrapper.setData({ CoinAnimationStatus: 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: false, + }, + }) + }) + + it('updates the store', () => { + expect(storeCommitMock).toBeCalledWith('coinanimation', false) + }) + + it('toasts a success message', () => { + expect(toastSuccessMock).toBeCalledWith('settings.coinanimation.False') + }) + }) + + describe('disable with success', () => { + beforeEach(async () => { + await wrapper.setData({ CoinAnimationStatus: true }) + mockAPIcall.mockResolvedValue({ + data: { + updateUserInfos: { + validValues: 1, + }, + }, + }) + wrapper.find('input').trigger('change') + }) + + it('calls the subscribe 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 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) }) }, From c755c77af7919dc40b69c939a02a214022d2522f Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 3 Oct 2021 13:36:50 +0200 Subject: [PATCH 05/16] require 71% coverage --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c3687cc5a..79710c98a 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: 100 token: ${{ github.token }} ############################################################################## From f6a37f6f04b3efb80f4b9a9d4e20591d0ca62ab2 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 4 Oct 2021 10:12:50 +0200 Subject: [PATCH 06/16] correct test description --- frontend/src/store/store.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/store/store.test.js b/frontend/src/store/store.test.js index e2c06095e..bdc0b5b93 100644 --- a/frontend/src/store/store.test.js +++ b/frontend/src/store/store.test.js @@ -155,7 +155,7 @@ describe('Vuex store', () => { const commit = jest.fn() const state = {} - it('calls six commits', () => { + it('calls eight commits', () => { logout({ commit, state }) expect(commit).toHaveBeenCalledTimes(8) }) From ad3064af53f8310e69e8067e7a8f79e088e30e0a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 4 Oct 2021 10:24:32 +0200 Subject: [PATCH 07/16] corrected test (will this fail now) --- .../src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js index d51800268..5a7a8be60 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js @@ -65,7 +65,7 @@ describe('UserCard_CoinAnimation', () => { expect(mockAPIcall).toBeCalledWith({ mutation: updateUserInfos, variables: { - coinanimation: false, + coinanimation: true, }, }) }) From 3135a437599cc4214255ada30884e35c8b1a1c26 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 4 Oct 2021 10:41:27 +0200 Subject: [PATCH 08/16] removed email from all user profile queries --- frontend/src/components/LanguageSwitch.spec.js | 2 -- frontend/src/components/LanguageSwitch.vue | 1 - frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue | 1 - frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.vue | 1 - .../src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue | 1 - frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue | 1 - frontend/src/views/Pages/UserProfile/UserCard_Language.vue | 1 - 7 files changed, 8 deletions(-) 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/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.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.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.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.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, }, }) From c4a61fb8be1279f071eb5ee9927e36573785d0c9 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 4 Oct 2021 10:49:50 +0200 Subject: [PATCH 09/16] removed more emails --- .../Pages/UserProfile/UserCard_FormUserPasswort.spec.js | 6 ------ 1 file changed, 6 deletions(-) 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_', }, From f4017311b5db6e1ae38a9c3a768479a8b7198be2 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 4 Oct 2021 10:52:56 +0200 Subject: [PATCH 10/16] remove more emails --- .../src/views/Pages/UserProfile/UserCard_FormUserData.spec.js | 3 --- 1 file changed, 3 deletions(-) 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', From d3a095fb1c13d8c832603eefa0ff7cb618f09014 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 4 Oct 2021 11:04:27 +0200 Subject: [PATCH 11/16] remove more email --- .../Pages/UserProfile/UserCard_FormUserMail.spec.js | 10 ---------- .../Pages/UserProfile/UserCard_FormUsername.spec.js | 6 ------ .../views/Pages/UserProfile/UserCard_Language.spec.js | 5 ----- 3 files changed, 21 deletions(-) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.spec.js index 84836dc91..3eb24de3f 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.spec.js @@ -12,14 +12,6 @@ describe('UserCard_FormUserMail', () => { const mocks = { $t: jest.fn((t) => t), - $store: { - state: { - email: 'user@example.org', - firstName: 'Peter', - lastName: 'Lustig', - description: '', - }, - }, $apollo: { mutate: mockAPIcall, }, @@ -75,7 +67,6 @@ describe('UserCard_FormUserMail', () => { expect(mockAPIcall).toHaveBeenCalledWith( expect.objectContaining({ variables: { - email: 'user@example.org', newEmail: 'test@example.org', }, }), @@ -104,7 +95,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_FormUsername.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.spec.js index a55c223d7..cf39abc2b 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.spec.js @@ -24,10 +24,6 @@ describe('UserCard_FormUsername', () => { const mocks = { $t: jest.fn((t) => t), $store: { - state: { - email: 'user@example.org', - username: '', - }, commit: storeCommitMock, }, $toasted: { @@ -109,7 +105,6 @@ describe('UserCard_FormUsername', () => { expect(mockAPIcall).toHaveBeenCalledWith( expect.objectContaining({ variables: { - email: 'user@example.org', username: 'username', }, }), @@ -148,7 +143,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_Language.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js index 774bc9e32..195bba631 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js @@ -21,10 +21,6 @@ describe('UserCard_Language', () => { const mocks = { $t: jest.fn((t) => t), $store: { - state: { - language: 'de', - email: 'peter@lustig.de', - }, commit: storeCommitMock, }, $toasted: { @@ -127,7 +123,6 @@ describe('UserCard_Language', () => { expect(mockAPIcall).toBeCalledWith( expect.objectContaining({ variables: { - email: 'peter@lustig.de', locale: 'en', }, }), From 9da8483b1493b8523e80e4a14e30f0376e17e820 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 4 Oct 2021 11:20:28 +0200 Subject: [PATCH 12/16] not all emails and not all stores can be removed ;) --- .../views/Pages/UserProfile/UserCard_FormUserMail.spec.js | 8 ++++++++ .../views/Pages/UserProfile/UserCard_FormUsername.spec.js | 3 +++ .../src/views/Pages/UserProfile/UserCard_Language.spec.js | 3 +++ 3 files changed, 14 insertions(+) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.spec.js index 3eb24de3f..cc4911683 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.spec.js @@ -12,6 +12,14 @@ describe('UserCard_FormUserMail', () => { const mocks = { $t: jest.fn((t) => t), + $store: { + state: { + email: 'user@example.org', + firstName: 'Peter', + lastName: 'Lustig', + description: '', + }, + }, $apollo: { mutate: mockAPIcall, }, diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.spec.js index cf39abc2b..be3abbbee 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.spec.js @@ -24,6 +24,9 @@ describe('UserCard_FormUsername', () => { const mocks = { $t: jest.fn((t) => t), $store: { + state: { + username: '', + }, commit: storeCommitMock, }, $toasted: { diff --git a/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js index 195bba631..f2acacd5b 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_Language.spec.js @@ -21,6 +21,9 @@ describe('UserCard_Language', () => { const mocks = { $t: jest.fn((t) => t), $store: { + state: { + language: 'de', + }, commit: storeCommitMock, }, $toasted: { From 37d4ef092755710556c752770d635cdc631e929c Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 4 Oct 2021 11:37:55 +0200 Subject: [PATCH 13/16] fixes - finally --- .../views/Pages/UserProfile/UserCard_CoinAnimation.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js index 5a7a8be60..3a6e7d5d2 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js @@ -50,7 +50,7 @@ describe('UserCard_CoinAnimation', () => { describe('enable with success', () => { beforeEach(async () => { - await wrapper.setData({ CoinAnimationStatus: false }) + mocks.$store.state.coinanimation = false mockAPIcall.mockResolvedValue({ data: { updateUserInfos: { @@ -81,7 +81,7 @@ describe('UserCard_CoinAnimation', () => { describe('disable with success', () => { beforeEach(async () => { - await wrapper.setData({ CoinAnimationStatus: true }) + mocks.$store.state.coinanimation = true mockAPIcall.mockResolvedValue({ data: { updateUserInfos: { @@ -96,7 +96,7 @@ describe('UserCard_CoinAnimation', () => { expect(mockAPIcall).toBeCalledWith({ mutation: updateUserInfos, variables: { - coinanimation: true, + coinanimation: false, }, }) }) From bb293c4b194e0cec523790264ff7829a6c21dac0 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 7 Oct 2021 09:46:47 +0200 Subject: [PATCH 14/16] fixed router test --- frontend/src/routes/router.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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', () => { From 275992b5606a26be2830eaca66337db4ae894c27 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 7 Oct 2021 09:49:37 +0200 Subject: [PATCH 15/16] fixed coinanimation tests --- .../Pages/UserProfile/UserCard_CoinAnimation.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js b/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js index 3a6e7d5d2..8e95605a5 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js +++ b/frontend/src/views/Pages/UserProfile/UserCard_CoinAnimation.spec.js @@ -71,11 +71,11 @@ describe('UserCard_CoinAnimation', () => { }) it('updates the store', () => { - expect(storeCommitMock).toBeCalledWith('coinanimation', false) + expect(storeCommitMock).toBeCalledWith('coinanimation', true) }) it('toasts a success message', () => { - expect(toastSuccessMock).toBeCalledWith('settings.coinanimation.False') + expect(toastSuccessMock).toBeCalledWith('settings.coinanimation.True') }) }) @@ -102,11 +102,11 @@ describe('UserCard_CoinAnimation', () => { }) it('updates the store', () => { - expect(storeCommitMock).toBeCalledWith('coinanimation', true) + expect(storeCommitMock).toBeCalledWith('coinanimation', false) }) it('toasts a success message', () => { - expect(toastSuccessMock).toBeCalledWith('settings.coinanimation.True') + expect(toastSuccessMock).toBeCalledWith('settings.coinanimation.False') }) }) From c8a4eb73a17a3a2b2f045b039d3ae159022fe726 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 7 Oct 2021 09:59:30 +0200 Subject: [PATCH 16/16] set minimum coverage to 75 on the frontend --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 79710c98a..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: 100 + min_coverage: 75 token: ${{ github.token }} ##############################################################################