diff --git a/frontend/src/components/Menu/Navbar.vue b/frontend/src/components/Menu/Navbar.vue
index 73470a91b..648c273d0 100644
--- a/frontend/src/components/Menu/Navbar.vue
+++ b/frontend/src/components/Menu/Navbar.vue
@@ -29,10 +29,7 @@
{{ username.username }}
-
-
- {{ $store.state.email }}
-
+
{{ $store.state.email }}
diff --git a/frontend/src/pages/Login.spec.js b/frontend/src/pages/Login.spec.js
index 14bf77aa6..511685efa 100644
--- a/frontend/src/pages/Login.spec.js
+++ b/frontend/src/pages/Login.spec.js
@@ -146,6 +146,10 @@ describe('Login', () => {
expect(mockStoreDispach).toBeCalledWith('login', 'token')
})
+ it('commits email to store', () => {
+ expect(mockStoreCommit).toBeCalledWith('email', 'user@example.org')
+ })
+
it('hides the spinner', () => {
expect(spinnerHideMock).toBeCalled()
})
diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue
index c02ee0e45..6fd435c2d 100644
--- a/frontend/src/pages/Login.vue
+++ b/frontend/src/pages/Login.vue
@@ -100,6 +100,7 @@ export default {
data: { login },
} = result
this.$store.dispatch('login', login)
+ this.$store.commit('email', this.form.email)
await loader.hide()
if (this.$route.params.code) {
this.$router.push(`/redeem/${this.$route.params.code}`)
diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js
index 7716d00de..4036626d8 100644
--- a/frontend/src/store/store.js
+++ b/frontend/src/store/store.js
@@ -53,6 +53,9 @@ export const mutations = {
hideAmountGDT: (state, hideAmountGDT) => {
state.hideAmountGDT = !!hideAmountGDT
},
+ email: (state, email) => {
+ state.email = email || ''
+ },
}
export const actions = {
@@ -81,6 +84,7 @@ export const actions = {
commit('isAdmin', false)
commit('hideAmountGDD', false)
commit('hideAmountGDT', true)
+ commit('email', '')
localStorage.clear()
},
}
@@ -109,6 +113,7 @@ try {
publisherId: null,
hideAmountGDD: null,
hideAmountGDT: null,
+ email: '',
},
getters: {},
// Syncronous mutation of the state
diff --git a/frontend/src/store/store.test.js b/frontend/src/store/store.test.js
index 116594e77..a6a596209 100644
--- a/frontend/src/store/store.test.js
+++ b/frontend/src/store/store.test.js
@@ -33,6 +33,7 @@ const {
hasElopage,
hideAmountGDD,
hideAmountGDT,
+ email,
} = mutations
const { login, logout } = actions
@@ -166,6 +167,14 @@ describe('Vuex store', () => {
expect(state.hideAmountGDT).toEqual(true)
})
})
+
+ describe('email', () => {
+ it('sets the state of email', () => {
+ const state = { email: '' }
+ email(state, 'peter@luatig.de')
+ expect(state.email).toEqual('peter@luatig.de')
+ })
+ })
})
describe('actions', () => {
@@ -253,9 +262,9 @@ describe('Vuex store', () => {
const commit = jest.fn()
const state = {}
- it('calls eleven commits', () => {
+ it('calls twelve commits', () => {
logout({ commit, state })
- expect(commit).toHaveBeenCalledTimes(11)
+ expect(commit).toHaveBeenCalledTimes(12)
})
it('commits token', () => {
@@ -312,6 +321,12 @@ describe('Vuex store', () => {
logout({ commit, state })
expect(commit).toHaveBeenNthCalledWith(11, 'hideAmountGDT', true)
})
+
+ it('commits email', () => {
+ logout({ commit, state })
+ expect(commit).toHaveBeenNthCalledWith(12, 'email', '')
+ })
+
// how to get this working?
it.skip('calls localStorage.clear()', () => {
const clearStorageMock = jest.fn()