mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
define custom error toast, use this custom toast for all error toasts
This commit is contained in:
parent
8122f218a9
commit
88002a5209
@ -16,6 +16,16 @@ import { apolloProvider } from './plugins/apolloProvider'
|
|||||||
Vue.use(DashboardPlugin)
|
Vue.use(DashboardPlugin)
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
|
Vue.toasted.register(
|
||||||
|
'error',
|
||||||
|
(payload) => {
|
||||||
|
return payload.replace(/^GraphQL error: /, '')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'error',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
loadAllRules(i18n)
|
loadAllRules(i18n)
|
||||||
|
|
||||||
addNavigationGuards(router, store, apolloProvider.defaultClient)
|
addNavigationGuards(router, store, apolloProvider.defaultClient)
|
||||||
|
|||||||
@ -13,7 +13,7 @@ export const getCommunityInfoMixin = {
|
|||||||
return result.data.getCommunityInfo
|
return result.data.getCommunityInfo
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.global.error(error.message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -4,8 +4,11 @@ import Vue from 'vue'
|
|||||||
import GlobalComponents from './globalComponents'
|
import GlobalComponents from './globalComponents'
|
||||||
import GlobalDirectives from './globalDirectives'
|
import GlobalDirectives from './globalDirectives'
|
||||||
|
|
||||||
|
import Toasted from 'vue-toasted'
|
||||||
|
|
||||||
jest.mock('./globalComponents')
|
jest.mock('./globalComponents')
|
||||||
jest.mock('./globalDirectives')
|
jest.mock('./globalDirectives')
|
||||||
|
jest.mock('vue-toasted')
|
||||||
|
|
||||||
jest.mock('vue')
|
jest.mock('vue')
|
||||||
|
|
||||||
@ -22,4 +25,21 @@ describe('dashboard plugin', () => {
|
|||||||
it('installs the global directives', () => {
|
it('installs the global directives', () => {
|
||||||
expect(vueUseMock).toBeCalledWith(GlobalDirectives)
|
expect(vueUseMock).toBeCalledWith(GlobalDirectives)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('vue toasted', () => {
|
||||||
|
const toastedAction = vueUseMock.mock.calls[11][1].action.onClick
|
||||||
|
const goAwayMock = jest.fn()
|
||||||
|
const toastObject = {
|
||||||
|
goAway: goAwayMock,
|
||||||
|
}
|
||||||
|
|
||||||
|
it('installs vue toasted', () => {
|
||||||
|
expect(vueUseMock).toBeCalledWith(Toasted, expect.anything())
|
||||||
|
})
|
||||||
|
|
||||||
|
it('onClick calls goAway(0)', () => {
|
||||||
|
toastedAction({}, toastObject)
|
||||||
|
expect(goAwayMock).toBeCalledWith(0)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -143,6 +143,13 @@ describe('router', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('password with param comingFrom', () => {
|
||||||
|
it('loads the "Password" component', async () => {
|
||||||
|
const component = await routes.find((r) => r.path === '/password/:comingFrom').component()
|
||||||
|
expect(component.default.name).toBe('password')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('register-community', () => {
|
describe('register-community', () => {
|
||||||
it('loads the "registerCommunity" component', async () => {
|
it('loads the "registerCommunity" component', async () => {
|
||||||
const component = await routes.find((r) => r.path === '/register-community').component()
|
const component = await routes.find((r) => r.path === '/register-community').component()
|
||||||
|
|||||||
@ -39,8 +39,10 @@ describe('DashboardLayoutGdd', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
$toasted: {
|
$toasted: {
|
||||||
|
global: {
|
||||||
error: toasterMock,
|
error: toasterMock,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
query: apolloMock,
|
query: apolloMock,
|
||||||
},
|
},
|
||||||
@ -266,7 +268,7 @@ describe('DashboardLayoutGdd', () => {
|
|||||||
expect(wrapper.vm.pending).toBeTruthy()
|
expect(wrapper.vm.pending).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls $toasted.error method', () => {
|
it('calls $toasted.global.error method', () => {
|
||||||
expect(toasterMock).toBeCalledWith('Ouch!')
|
expect(toasterMock).toBeCalledWith('Ouch!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -133,7 +133,7 @@ export default {
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.pending = true
|
this.pending = true
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.global.error(error.message)
|
||||||
// what to do when loading balance fails?
|
// what to do when loading balance fails?
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@ -37,8 +37,10 @@ describe('GdtTransactionList ', () => {
|
|||||||
$n: jest.fn((n) => n),
|
$n: jest.fn((n) => n),
|
||||||
$d: jest.fn((d) => d),
|
$d: jest.fn((d) => d),
|
||||||
$toasted: {
|
$toasted: {
|
||||||
|
global: {
|
||||||
error: toastErrorMock,
|
error: toastErrorMock,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
query: apolloMock,
|
query: apolloMock,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -71,7 +71,7 @@ export default {
|
|||||||
window.scrollTo(0, 0)
|
window.scrollTo(0, 0)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.global.error(error.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -52,8 +52,10 @@ describe('Login', () => {
|
|||||||
push: mockRouterPush,
|
push: mockRouterPush,
|
||||||
},
|
},
|
||||||
$toasted: {
|
$toasted: {
|
||||||
|
global: {
|
||||||
error: toastErrorMock,
|
error: toastErrorMock,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
query: apolloQueryMock,
|
query: apolloQueryMock,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -106,7 +106,7 @@ export default {
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (error.message.includes('No user with this credentials')) {
|
if (error.message.includes('No user with this credentials')) {
|
||||||
this.$toasted.error(this.$t('error.no-account'))
|
this.$toasted.global.error(this.$t('error.no-account'))
|
||||||
} else {
|
} else {
|
||||||
// : this.$t('error.no-email-verify')
|
// : this.$t('error.no-email-verify')
|
||||||
this.$router.push('/reset/login')
|
this.$router.push('/reset/login')
|
||||||
|
|||||||
@ -49,8 +49,10 @@ describe('Register', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
$toasted: {
|
$toasted: {
|
||||||
|
global: {
|
||||||
error: toastErrorMock,
|
error: toastErrorMock,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const stubs = {
|
const stubs = {
|
||||||
|
|||||||
@ -37,8 +37,10 @@ describe('RegisterCommunity', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
$toasted: {
|
$toasted: {
|
||||||
|
global: {
|
||||||
error: toastErrorMock,
|
error: toastErrorMock,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const stubs = {
|
const stubs = {
|
||||||
|
|||||||
@ -79,8 +79,10 @@ describe('RegisterSelectCommunity', () => {
|
|||||||
show: spinnerMock,
|
show: spinnerMock,
|
||||||
},
|
},
|
||||||
$toasted: {
|
$toasted: {
|
||||||
|
global: {
|
||||||
error: toasterMock,
|
error: toasterMock,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const stubs = {
|
const stubs = {
|
||||||
|
|||||||
@ -76,7 +76,7 @@ export default {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.global.error(error.message)
|
||||||
})
|
})
|
||||||
loader.hide()
|
loader.hide()
|
||||||
this.pending = false
|
this.pending = false
|
||||||
|
|||||||
@ -30,8 +30,10 @@ const createMockObject = (comingFrom) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
$toasted: {
|
$toasted: {
|
||||||
|
global: {
|
||||||
error: toasterMock,
|
error: toasterMock,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
$router: {
|
$router: {
|
||||||
push: routerPushMock,
|
push: routerPushMock,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -96,10 +96,10 @@ export default {
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (error.message.includes('Code is older than 10 minutes')) {
|
if (error.message.includes('Code is older than 10 minutes')) {
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.global.error(error.message)
|
||||||
this.$router.push('/password/reset')
|
this.$router.push('/password/reset')
|
||||||
} else {
|
} else {
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.global.error(error.message)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@ -24,8 +24,10 @@ describe('UserCard_CoinAnimation', () => {
|
|||||||
},
|
},
|
||||||
$toasted: {
|
$toasted: {
|
||||||
success: toastSuccessMock,
|
success: toastSuccessMock,
|
||||||
|
global: {
|
||||||
error: toastErrorMock,
|
error: toastErrorMock,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
mutate: mockAPIcall,
|
mutate: mockAPIcall,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -58,7 +58,7 @@ export default {
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.CoinAnimationStatus = this.$store.state.coinanimation
|
this.CoinAnimationStatus = this.$store.state.coinanimation
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.global.error(error.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -25,8 +25,10 @@ describe('UserCard_FormUserData', () => {
|
|||||||
},
|
},
|
||||||
$toasted: {
|
$toasted: {
|
||||||
success: toastSuccessMock,
|
success: toastSuccessMock,
|
||||||
|
global: {
|
||||||
error: toastErrorMock,
|
error: toastErrorMock,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
mutate: mockAPIcall,
|
mutate: mockAPIcall,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -124,7 +124,7 @@ export default {
|
|||||||
this.$toasted.success(this.$t('settings.name.change-success'))
|
this.$toasted.success(this.$t('settings.name.change-success'))
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.global.error(error.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -17,8 +17,10 @@ describe('UserCard_FormUserPasswort', () => {
|
|||||||
$t: jest.fn((t) => t),
|
$t: jest.fn((t) => t),
|
||||||
$toasted: {
|
$toasted: {
|
||||||
success: toastSuccessMock,
|
success: toastSuccessMock,
|
||||||
|
global: {
|
||||||
error: toastErrorMock,
|
error: toastErrorMock,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
mutate: changePasswordProfileMock,
|
mutate: changePasswordProfileMock,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -85,7 +85,7 @@ export default {
|
|||||||
this.cancelEdit()
|
this.cancelEdit()
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.global.error(error.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -31,8 +31,10 @@ describe('UserCard_FormUsername', () => {
|
|||||||
},
|
},
|
||||||
$toasted: {
|
$toasted: {
|
||||||
success: toastSuccessMock,
|
success: toastSuccessMock,
|
||||||
|
global: {
|
||||||
error: toastErrorMock,
|
error: toastErrorMock,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
mutate: mockAPIcall,
|
mutate: mockAPIcall,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -100,7 +100,7 @@ export default {
|
|||||||
this.$toasted.success(this.$t('settings.name.change-success'))
|
this.$toasted.success(this.$t('settings.name.change-success'))
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.global.error(error.message)
|
||||||
this.showUsername = true
|
this.showUsername = true
|
||||||
this.username = this.$store.state.username
|
this.username = this.$store.state.username
|
||||||
this.form.username = this.$store.state.username
|
this.form.username = this.$store.state.username
|
||||||
|
|||||||
@ -28,8 +28,10 @@ describe('UserCard_Language', () => {
|
|||||||
},
|
},
|
||||||
$toasted: {
|
$toasted: {
|
||||||
success: toastSuccessMock,
|
success: toastSuccessMock,
|
||||||
|
global: {
|
||||||
error: toastErrorMock,
|
error: toastErrorMock,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
mutate: mockAPIcall,
|
mutate: mockAPIcall,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -101,7 +101,7 @@ export default {
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.language = this.$store.state.language
|
this.language = this.$store.state.language
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.global.error(error.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
buildTagFromLanguageString() {
|
buildTagFromLanguageString() {
|
||||||
|
|||||||
@ -25,8 +25,10 @@ describe('UserCard_Newsletter', () => {
|
|||||||
},
|
},
|
||||||
$toasted: {
|
$toasted: {
|
||||||
success: toastSuccessMock,
|
success: toastSuccessMock,
|
||||||
|
global: {
|
||||||
error: toastErrorMock,
|
error: toastErrorMock,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
mutate: mockAPIcall,
|
mutate: mockAPIcall,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -56,7 +56,7 @@ export default {
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.newsletterState = this.$store.state.newsletterState
|
this.newsletterState = this.$store.state.newsletterState
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.global.error(error.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user