mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Merge pull request #761 from Human-Connection/undo_location_reload
Disable the location.reloads
This commit is contained in:
commit
0d4433a79f
@ -26,12 +26,15 @@ describe('DisableModal.vue', () => {
|
||||
truncate: a => a,
|
||||
},
|
||||
$toast: {
|
||||
success: () => {},
|
||||
error: () => {},
|
||||
success: jest.fn(),
|
||||
error: jest.fn(),
|
||||
},
|
||||
$t: jest.fn(),
|
||||
$apollo: {
|
||||
mutate: jest.fn().mockResolvedValue(),
|
||||
mutate: jest
|
||||
.fn()
|
||||
.mockResolvedValueOnce({ enable: 'u4711' })
|
||||
.mockRejectedValue({ message: 'Not Authorised!' }),
|
||||
},
|
||||
location: {
|
||||
reload: jest.fn(),
|
||||
@ -151,6 +154,10 @@ describe('DisableModal.vue', () => {
|
||||
await wrapper.find('button.confirm').trigger('click')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
it('calls mutation', () => {
|
||||
expect(mocks.$apollo.mutate).toHaveBeenCalled()
|
||||
})
|
||||
@ -174,6 +181,18 @@ describe('DisableModal.vue', () => {
|
||||
expect(wrapper.emitted().close).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
describe('handles errors', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
// second submission causes mutation to reject
|
||||
wrapper.find('button.confirm').trigger('click')
|
||||
})
|
||||
|
||||
it('shows an error toaster when mutation rejects', async () => {
|
||||
await expect(mocks.$toast.error).toHaveBeenCalledWith('Not Authorised!')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -68,9 +68,6 @@ export default {
|
||||
setTimeout(() => {
|
||||
this.$emit('close')
|
||||
}, 1000)
|
||||
setTimeout(() => {
|
||||
location.reload()
|
||||
}, 250)
|
||||
} catch (err) {
|
||||
this.$toast.error(err.message)
|
||||
}
|
||||
|
||||
@ -23,12 +23,15 @@ describe('ReleaseModal.vue', () => {
|
||||
truncate: a => a,
|
||||
},
|
||||
$toast: {
|
||||
success: () => {},
|
||||
error: () => {},
|
||||
success: jest.fn(),
|
||||
error: jest.fn(),
|
||||
},
|
||||
$t: jest.fn(),
|
||||
$apollo: {
|
||||
mutate: jest.fn().mockResolvedValue(),
|
||||
mutate: jest
|
||||
.fn()
|
||||
.mockResolvedValueOnce({ enable: 'u4711' })
|
||||
.mockRejectedValue({ message: 'Not Authorised!' }),
|
||||
},
|
||||
location: {
|
||||
reload: jest.fn(),
|
||||
@ -146,6 +149,10 @@ describe('ReleaseModal.vue', () => {
|
||||
wrapper.find('button.confirm').trigger('click')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
it('calls mutation', () => {
|
||||
expect(mocks.$apollo.mutate).toHaveBeenCalled()
|
||||
})
|
||||
@ -169,6 +176,18 @@ describe('ReleaseModal.vue', () => {
|
||||
expect(wrapper.emitted().close).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
describe('handles errors', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
// second submission causes mutation to reject
|
||||
wrapper.find('button.confirm').trigger('click')
|
||||
})
|
||||
|
||||
it('shows an error toaster when mutation rejects', async () => {
|
||||
await expect(mocks.$toast.error).toHaveBeenCalledWith('Not Authorised!')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -57,17 +57,9 @@ export default {
|
||||
})
|
||||
this.$toast.success(this.$t('release.success'))
|
||||
this.isOpen = false
|
||||
/*
|
||||
setTimeout(() => {
|
||||
location.reload()
|
||||
}, 1500)
|
||||
*/
|
||||
setTimeout(() => {
|
||||
this.$emit('close')
|
||||
}, 1000)
|
||||
setTimeout(() => {
|
||||
location.reload()
|
||||
}, 250)
|
||||
} catch (err) {
|
||||
this.$toast.error(err.message)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user