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.config.productionTip = false
|
||||
|
||||
Vue.toasted.register(
|
||||
'error',
|
||||
(payload) => {
|
||||
return payload.replace(/^GraphQL error: /, '')
|
||||
},
|
||||
{
|
||||
type: 'error',
|
||||
},
|
||||
)
|
||||
|
||||
loadAllRules(i18n)
|
||||
|
||||
addNavigationGuards(router, store, apolloProvider.defaultClient)
|
||||
|
||||
@ -13,7 +13,7 @@ export const getCommunityInfoMixin = {
|
||||
return result.data.getCommunityInfo
|
||||
})
|
||||
.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 GlobalDirectives from './globalDirectives'
|
||||
|
||||
import Toasted from 'vue-toasted'
|
||||
|
||||
jest.mock('./globalComponents')
|
||||
jest.mock('./globalDirectives')
|
||||
jest.mock('vue-toasted')
|
||||
|
||||
jest.mock('vue')
|
||||
|
||||
@ -22,4 +25,21 @@ describe('dashboard plugin', () => {
|
||||
it('installs the global directives', () => {
|
||||
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', () => {
|
||||
it('loads the "registerCommunity" component', async () => {
|
||||
const component = await routes.find((r) => r.path === '/register-community').component()
|
||||
|
||||
@ -39,7 +39,9 @@ describe('DashboardLayoutGdd', () => {
|
||||
},
|
||||
},
|
||||
$toasted: {
|
||||
error: toasterMock,
|
||||
global: {
|
||||
error: toasterMock,
|
||||
},
|
||||
},
|
||||
$apollo: {
|
||||
query: apolloMock,
|
||||
@ -266,7 +268,7 @@ describe('DashboardLayoutGdd', () => {
|
||||
expect(wrapper.vm.pending).toBeTruthy()
|
||||
})
|
||||
|
||||
it('calls $toasted.error method', () => {
|
||||
it('calls $toasted.global.error method', () => {
|
||||
expect(toasterMock).toBeCalledWith('Ouch!')
|
||||
})
|
||||
})
|
||||
|
||||
@ -133,7 +133,7 @@ export default {
|
||||
})
|
||||
.catch((error) => {
|
||||
this.pending = true
|
||||
this.$toasted.error(error.message)
|
||||
this.$toasted.global.error(error.message)
|
||||
// what to do when loading balance fails?
|
||||
})
|
||||
},
|
||||
|
||||
@ -37,7 +37,9 @@ describe('GdtTransactionList ', () => {
|
||||
$n: jest.fn((n) => n),
|
||||
$d: jest.fn((d) => d),
|
||||
$toasted: {
|
||||
error: toastErrorMock,
|
||||
global: {
|
||||
error: toastErrorMock,
|
||||
},
|
||||
},
|
||||
$apollo: {
|
||||
query: apolloMock,
|
||||
|
||||
@ -71,7 +71,7 @@ export default {
|
||||
window.scrollTo(0, 0)
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.error(error.message)
|
||||
this.$toasted.global.error(error.message)
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
@ -52,7 +52,9 @@ describe('Login', () => {
|
||||
push: mockRouterPush,
|
||||
},
|
||||
$toasted: {
|
||||
error: toastErrorMock,
|
||||
global: {
|
||||
error: toastErrorMock,
|
||||
},
|
||||
},
|
||||
$apollo: {
|
||||
query: apolloQueryMock,
|
||||
|
||||
@ -106,7 +106,7 @@ export default {
|
||||
})
|
||||
.catch((error) => {
|
||||
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 {
|
||||
// : this.$t('error.no-email-verify')
|
||||
this.$router.push('/reset/login')
|
||||
|
||||
@ -49,7 +49,9 @@ describe('Register', () => {
|
||||
},
|
||||
},
|
||||
$toasted: {
|
||||
error: toastErrorMock,
|
||||
global: {
|
||||
error: toastErrorMock,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,9 @@ describe('RegisterCommunity', () => {
|
||||
},
|
||||
},
|
||||
$toasted: {
|
||||
error: toastErrorMock,
|
||||
global: {
|
||||
error: toastErrorMock,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -79,7 +79,9 @@ describe('RegisterSelectCommunity', () => {
|
||||
show: spinnerMock,
|
||||
},
|
||||
$toasted: {
|
||||
error: toasterMock,
|
||||
global: {
|
||||
error: toasterMock,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ export default {
|
||||
)
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.error(error.message)
|
||||
this.$toasted.global.error(error.message)
|
||||
})
|
||||
loader.hide()
|
||||
this.pending = false
|
||||
|
||||
@ -30,7 +30,9 @@ const createMockObject = (comingFrom) => {
|
||||
},
|
||||
},
|
||||
$toasted: {
|
||||
error: toasterMock,
|
||||
global: {
|
||||
error: toasterMock,
|
||||
},
|
||||
},
|
||||
$router: {
|
||||
push: routerPushMock,
|
||||
|
||||
@ -96,10 +96,10 @@ export default {
|
||||
})
|
||||
.catch((error) => {
|
||||
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')
|
||||
} else {
|
||||
this.$toasted.error(error.message)
|
||||
this.$toasted.global.error(error.message)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@ -24,7 +24,9 @@ describe('UserCard_CoinAnimation', () => {
|
||||
},
|
||||
$toasted: {
|
||||
success: toastSuccessMock,
|
||||
error: toastErrorMock,
|
||||
global: {
|
||||
error: toastErrorMock,
|
||||
},
|
||||
},
|
||||
$apollo: {
|
||||
mutate: mockAPIcall,
|
||||
|
||||
@ -58,7 +58,7 @@ export default {
|
||||
})
|
||||
.catch((error) => {
|
||||
this.CoinAnimationStatus = this.$store.state.coinanimation
|
||||
this.$toasted.error(error.message)
|
||||
this.$toasted.global.error(error.message)
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
@ -25,7 +25,9 @@ describe('UserCard_FormUserData', () => {
|
||||
},
|
||||
$toasted: {
|
||||
success: toastSuccessMock,
|
||||
error: toastErrorMock,
|
||||
global: {
|
||||
error: toastErrorMock,
|
||||
},
|
||||
},
|
||||
$apollo: {
|
||||
mutate: mockAPIcall,
|
||||
|
||||
@ -124,7 +124,7 @@ export default {
|
||||
this.$toasted.success(this.$t('settings.name.change-success'))
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.error(error.message)
|
||||
this.$toasted.global.error(error.message)
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
@ -17,7 +17,9 @@ describe('UserCard_FormUserPasswort', () => {
|
||||
$t: jest.fn((t) => t),
|
||||
$toasted: {
|
||||
success: toastSuccessMock,
|
||||
error: toastErrorMock,
|
||||
global: {
|
||||
error: toastErrorMock,
|
||||
},
|
||||
},
|
||||
$apollo: {
|
||||
mutate: changePasswordProfileMock,
|
||||
|
||||
@ -85,7 +85,7 @@ export default {
|
||||
this.cancelEdit()
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.error(error.message)
|
||||
this.$toasted.global.error(error.message)
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
@ -31,7 +31,9 @@ describe('UserCard_FormUsername', () => {
|
||||
},
|
||||
$toasted: {
|
||||
success: toastSuccessMock,
|
||||
error: toastErrorMock,
|
||||
global: {
|
||||
error: toastErrorMock,
|
||||
},
|
||||
},
|
||||
$apollo: {
|
||||
mutate: mockAPIcall,
|
||||
|
||||
@ -100,7 +100,7 @@ export default {
|
||||
this.$toasted.success(this.$t('settings.name.change-success'))
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.error(error.message)
|
||||
this.$toasted.global.error(error.message)
|
||||
this.showUsername = true
|
||||
this.username = this.$store.state.username
|
||||
this.form.username = this.$store.state.username
|
||||
|
||||
@ -28,7 +28,9 @@ describe('UserCard_Language', () => {
|
||||
},
|
||||
$toasted: {
|
||||
success: toastSuccessMock,
|
||||
error: toastErrorMock,
|
||||
global: {
|
||||
error: toastErrorMock,
|
||||
},
|
||||
},
|
||||
$apollo: {
|
||||
mutate: mockAPIcall,
|
||||
|
||||
@ -101,7 +101,7 @@ export default {
|
||||
})
|
||||
.catch((error) => {
|
||||
this.language = this.$store.state.language
|
||||
this.$toasted.error(error.message)
|
||||
this.$toasted.global.error(error.message)
|
||||
})
|
||||
},
|
||||
buildTagFromLanguageString() {
|
||||
|
||||
@ -25,7 +25,9 @@ describe('UserCard_Newsletter', () => {
|
||||
},
|
||||
$toasted: {
|
||||
success: toastSuccessMock,
|
||||
error: toastErrorMock,
|
||||
global: {
|
||||
error: toastErrorMock,
|
||||
},
|
||||
},
|
||||
$apollo: {
|
||||
mutate: mockAPIcall,
|
||||
|
||||
@ -56,7 +56,7 @@ export default {
|
||||
})
|
||||
.catch((error) => {
|
||||
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