mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into migration_0006-login_users_collation
This commit is contained in:
commit
aad32e16f3
@ -237,7 +237,7 @@ export default {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$emit('remove-confirm-result', item, 'remove')
|
this.$emit('remove-confirm-result', item, 'confirmed')
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.error(error.message)
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import gql from 'graphql-tag'
|
|||||||
export const createPendingCreation = gql`
|
export const createPendingCreation = gql`
|
||||||
mutation (
|
mutation (
|
||||||
$email: String!
|
$email: String!
|
||||||
$amount: Int!
|
$amount: Float!
|
||||||
$memo: String!
|
$memo: String!
|
||||||
$creationDate: String!
|
$creationDate: String!
|
||||||
$moderator: Int!
|
$moderator: Int!
|
||||||
|
|||||||
@ -4,7 +4,7 @@ export const updatePendingCreation = gql`
|
|||||||
mutation (
|
mutation (
|
||||||
$id: Int!
|
$id: Int!
|
||||||
$email: String!
|
$email: String!
|
||||||
$amount: Int!
|
$amount: Float!
|
||||||
$memo: String!
|
$memo: String!
|
||||||
$creationDate: String!
|
$creationDate: String!
|
||||||
$moderator: Int!
|
$moderator: Int!
|
||||||
|
|||||||
@ -81,7 +81,7 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('confirm creation delete with success', () => {
|
describe('delete creation delete with success', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
apolloQueryMock.mockResolvedValue({
|
apolloQueryMock.mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
@ -130,7 +130,7 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('confirm creation delete with error', () => {
|
describe('delete creation delete with error', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' })
|
apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' })
|
||||||
await wrapper
|
await wrapper
|
||||||
@ -143,6 +143,67 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('confirm creation delete with success', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
apolloQueryMock.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
getPendingCreations: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
firstName: 'Bibi',
|
||||||
|
lastName: 'Bloxberg',
|
||||||
|
email: 'bibi@bloxberg.de',
|
||||||
|
amount: 500,
|
||||||
|
memo: 'Danke für alles',
|
||||||
|
date: new Date(),
|
||||||
|
moderator: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
firstName: 'Räuber',
|
||||||
|
lastName: 'Hotzenplotz',
|
||||||
|
email: 'raeuber@hotzenplotz.de',
|
||||||
|
amount: 1000000,
|
||||||
|
memo: 'Gut Ergatert',
|
||||||
|
date: new Date(),
|
||||||
|
moderator: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
await wrapper
|
||||||
|
.findComponent({ name: 'UserTable' })
|
||||||
|
.vm.$emit('remove-confirm-result', { id: 1 }, 'confirmed')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('calls the deletePendingCreation mutation', () => {
|
||||||
|
expect(apolloMutateMock).not.toBeCalledWith({
|
||||||
|
mutation: deletePendingCreation,
|
||||||
|
variables: { id: 1 },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('commits openCreationsMinus to store', () => {
|
||||||
|
expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('toasts a success message', () => {
|
||||||
|
expect(toastedSuccessMock).toBeCalledWith('Pending Creation has been deleted')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('delete creation delete with error', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await wrapper
|
||||||
|
.findComponent({ name: 'UserTable' })
|
||||||
|
.vm.$emit('remove-confirm-result', { id: 1 }, 'confirm')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('toasts an error message', () => {
|
||||||
|
expect(toastedErrorMock).toBeCalledWith('Case confirm is not supported')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('server response is error', () => {
|
describe('server response is error', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
|
|||||||
@ -51,9 +51,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
removeConfirmResult(e, event) {
|
removeConfirmResult(e, event) {
|
||||||
if (event === 'remove') {
|
|
||||||
let index = 0
|
let index = 0
|
||||||
const findArr = this.confirmResult.find((arr) => arr.id === e.id)
|
const findArr = this.confirmResult.find((arr) => arr.id === e.id)
|
||||||
|
switch (event) {
|
||||||
|
case 'remove':
|
||||||
this.$apollo
|
this.$apollo
|
||||||
.mutate({
|
.mutate({
|
||||||
mutation: deletePendingCreation,
|
mutation: deletePendingCreation,
|
||||||
@ -70,6 +71,14 @@ export default {
|
|||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.error(error.message)
|
||||||
})
|
})
|
||||||
|
break
|
||||||
|
case 'confirmed':
|
||||||
|
this.confirmResult.splice(index, 1)
|
||||||
|
this.$store.commit('openCreationsMinus', 1)
|
||||||
|
this.$toasted.success('Pending Creation has been deleted')
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
this.$toasted.error('Case ' + event + ' is not supported')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getPendingCreations() {
|
getPendingCreations() {
|
||||||
@ -80,7 +89,7 @@ export default {
|
|||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
this.$store.commit('resetOpenCreations')
|
this.$store.commit('resetOpenCreations')
|
||||||
this.confirmResult = result.data.getPendingCreations.reverse()
|
this.confirmResult = result.data.getPendingCreations
|
||||||
this.$store.commit('setOpenCreations', result.data.getPendingCreations.length)
|
this.$store.commit('setOpenCreations', result.data.getPendingCreations.length)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { ArgsType, Field, Int } from 'type-graphql'
|
import { ArgsType, Field, Float, Int } from 'type-graphql'
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
export default class CreatePendingCreationArgs {
|
export default class CreatePendingCreationArgs {
|
||||||
@Field(() => String)
|
@Field(() => String)
|
||||||
email: string
|
email: string
|
||||||
|
|
||||||
@Field(() => Int)
|
@Field(() => Float)
|
||||||
amount: number
|
amount: number
|
||||||
|
|
||||||
@Field(() => String)
|
@Field(() => String)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { ArgsType, Field, Int } from 'type-graphql'
|
import { ArgsType, Field, Float, Int } from 'type-graphql'
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
export default class CreatePendingCreationArgs {
|
export default class CreatePendingCreationArgs {
|
||||||
@ -8,7 +8,7 @@ export default class CreatePendingCreationArgs {
|
|||||||
@Field(() => String)
|
@Field(() => String)
|
||||||
email: string
|
email: string
|
||||||
|
|
||||||
@Field(() => Int)
|
@Field(() => Float)
|
||||||
amount: number
|
amount: number
|
||||||
|
|
||||||
@Field(() => String)
|
@Field(() => String)
|
||||||
|
|||||||
@ -133,7 +133,7 @@ export class AdminResolver {
|
|||||||
return newPendingCreation
|
return newPendingCreation
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
return pendingCreationsPromise
|
return pendingCreationsPromise.reverse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => Boolean)
|
@Mutation(() => Boolean)
|
||||||
|
|||||||
@ -251,6 +251,44 @@ describe('Login', () => {
|
|||||||
it('toasts an error message', () => {
|
it('toasts an error message', () => {
|
||||||
expect(toastErrorMock).toBeCalledWith('error.no-account')
|
expect(toastErrorMock).toBeCalledWith('error.no-account')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('login fails with "User email not validated"', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
apolloQueryMock.mockRejectedValue({
|
||||||
|
message: 'User email not validated',
|
||||||
|
})
|
||||||
|
wrapper = Wrapper()
|
||||||
|
jest.clearAllMocks()
|
||||||
|
await wrapper.find('input[placeholder="Email"]').setValue('user@example.org')
|
||||||
|
await wrapper.find('input[placeholder="form.password"]').setValue('1234')
|
||||||
|
await flushPromises()
|
||||||
|
await wrapper.find('form').trigger('submit')
|
||||||
|
await flushPromises()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('redirects to /thx/login', () => {
|
||||||
|
expect(mockRouterPush).toBeCalledWith('/thx/login')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('login fails with "User has no password set yet"', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
apolloQueryMock.mockRejectedValue({
|
||||||
|
message: 'User has no password set yet',
|
||||||
|
})
|
||||||
|
wrapper = Wrapper()
|
||||||
|
jest.clearAllMocks()
|
||||||
|
await wrapper.find('input[placeholder="Email"]').setValue('user@example.org')
|
||||||
|
await wrapper.find('input[placeholder="form.password"]').setValue('1234')
|
||||||
|
await flushPromises()
|
||||||
|
await wrapper.find('form').trigger('submit')
|
||||||
|
await flushPromises()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('redirects to /reset/login', () => {
|
||||||
|
expect(mockRouterPush).toBeCalledWith('/reset/login')
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -105,10 +105,10 @@ export default {
|
|||||||
loader.hide()
|
loader.hide()
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (error.message.includes('No user with this credentials')) {
|
|
||||||
this.$toasted.global.error(this.$t('error.no-account'))
|
this.$toasted.global.error(this.$t('error.no-account'))
|
||||||
} else {
|
if (error.message.includes('User email not validated')) {
|
||||||
// : this.$t('error.no-email-verify')
|
this.$router.push('/thx/login')
|
||||||
|
} else if (error.message.includes('User has no password set yet')) {
|
||||||
this.$router.push('/reset/login')
|
this.$router.push('/reset/login')
|
||||||
}
|
}
|
||||||
loader.hide()
|
loader.hide()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user