mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into fix_docker_file_descriptions
This commit is contained in:
commit
316334bd45
@ -17,6 +17,7 @@
|
|||||||
<p class="h2 ml-5">{{ $t('contributionLink.contributionLinks') }}</p>
|
<p class="h2 ml-5">{{ $t('contributionLink.contributionLinks') }}</p>
|
||||||
<contribution-link-form
|
<contribution-link-form
|
||||||
:contributionLinkData="contributionLinkData"
|
:contributionLinkData="contributionLinkData"
|
||||||
|
:editContributionLink="editContributionLink"
|
||||||
@get-contribution-links="$emit('get-contribution-links')"
|
@get-contribution-links="$emit('get-contribution-links')"
|
||||||
/>
|
/>
|
||||||
</b-card>
|
</b-card>
|
||||||
@ -58,12 +59,14 @@ export default {
|
|||||||
return {
|
return {
|
||||||
visible: false,
|
visible: false,
|
||||||
contributionLinkData: {},
|
contributionLinkData: {},
|
||||||
|
editContributionLink: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
editContributionLinkData(data) {
|
editContributionLinkData(data) {
|
||||||
if (!this.visible) this.$root.$emit('bv::toggle::collapse', 'newContribution')
|
if (!this.visible) this.$root.$emit('bv::toggle::collapse', 'newContribution')
|
||||||
this.contributionLinkData = data
|
this.contributionLinkData = data
|
||||||
|
this.editContributionLink = true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ global.alert = jest.fn()
|
|||||||
|
|
||||||
const propsData = {
|
const propsData = {
|
||||||
contributionLinkData: {},
|
contributionLinkData: {},
|
||||||
|
editContributionLink: false,
|
||||||
}
|
}
|
||||||
const apolloMutateMock = jest.fn().mockResolvedValue()
|
const apolloMutateMock = jest.fn().mockResolvedValue()
|
||||||
|
|
||||||
@ -108,6 +109,7 @@ describe('ContributionLinkForm', () => {
|
|||||||
cycle: 'ONCE',
|
cycle: 'ONCE',
|
||||||
maxPerCycle: 1,
|
maxPerCycle: 1,
|
||||||
maxAmountPerMonth: '0',
|
maxAmountPerMonth: '0',
|
||||||
|
id: null,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -102,7 +102,11 @@
|
|||||||
</b-form-group>
|
</b-form-group>
|
||||||
-->
|
-->
|
||||||
<div class="mt-6">
|
<div class="mt-6">
|
||||||
<b-button type="submit" variant="primary">{{ $t('contributionLink.create') }}</b-button>
|
<b-button type="submit" variant="primary">
|
||||||
|
{{
|
||||||
|
editContributionLink ? $t('contributionLink.saveChange') : $t('contributionLink.create')
|
||||||
|
}}
|
||||||
|
</b-button>
|
||||||
<b-button type="reset" variant="danger" @click.prevent="onReset">
|
<b-button type="reset" variant="danger" @click.prevent="onReset">
|
||||||
{{ $t('contributionLink.clear') }}
|
{{ $t('contributionLink.clear') }}
|
||||||
</b-button>
|
</b-button>
|
||||||
@ -112,6 +116,8 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { createContributionLink } from '@/graphql/createContributionLink.js'
|
import { createContributionLink } from '@/graphql/createContributionLink.js'
|
||||||
|
import { updateContributionLink } from '@/graphql/updateContributionLink.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ContributionLinkForm',
|
name: 'ContributionLinkForm',
|
||||||
props: {
|
props: {
|
||||||
@ -121,6 +127,7 @@ export default {
|
|||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
editContributionLink: { type: Boolean, required: true },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -157,23 +164,24 @@ export default {
|
|||||||
if (this.form.validFrom === null)
|
if (this.form.validFrom === null)
|
||||||
return this.toastError(this.$t('contributionLink.noStartDate'))
|
return this.toastError(this.$t('contributionLink.noStartDate'))
|
||||||
if (this.form.validTo === null) return this.toastError(this.$t('contributionLink.noEndDate'))
|
if (this.form.validTo === null) return this.toastError(this.$t('contributionLink.noEndDate'))
|
||||||
|
|
||||||
|
const variables = {
|
||||||
|
...this.form,
|
||||||
|
id: this.contributionLinkData.id ? this.contributionLinkData.id : null,
|
||||||
|
}
|
||||||
|
|
||||||
this.$apollo
|
this.$apollo
|
||||||
.mutate({
|
.mutate({
|
||||||
mutation: createContributionLink,
|
mutation: this.editContributionLink ? updateContributionLink : createContributionLink,
|
||||||
variables: {
|
variables: variables,
|
||||||
validFrom: this.form.validFrom,
|
|
||||||
validTo: this.form.validTo,
|
|
||||||
name: this.form.name,
|
|
||||||
amount: this.form.amount,
|
|
||||||
memo: this.form.memo,
|
|
||||||
cycle: this.form.cycle,
|
|
||||||
maxPerCycle: this.form.maxPerCycle,
|
|
||||||
maxAmountPerMonth: this.form.maxAmountPerMonth,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
this.link = result.data.createContributionLink.link
|
const link = this.editContributionLink
|
||||||
this.toastSuccess(this.link)
|
? result.data.updateContributionLink.link
|
||||||
|
: result.data.createContributionLink.link
|
||||||
|
this.toastSuccess(
|
||||||
|
this.editContributionLink ? this.$t('contributionLink.changeSaved') : link,
|
||||||
|
)
|
||||||
this.onReset()
|
this.onReset()
|
||||||
this.$root.$emit('bv::toggle::collapse', 'newContribution')
|
this.$root.$emit('bv::toggle::collapse', 'newContribution')
|
||||||
this.$emit('get-contribution-links')
|
this.$emit('get-contribution-links')
|
||||||
|
|||||||
40
admin/src/graphql/updateContributionLink.js
Normal file
40
admin/src/graphql/updateContributionLink.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const updateContributionLink = gql`
|
||||||
|
mutation (
|
||||||
|
$amount: Decimal!
|
||||||
|
$name: String!
|
||||||
|
$memo: String!
|
||||||
|
$cycle: String!
|
||||||
|
$validFrom: String
|
||||||
|
$validTo: String
|
||||||
|
$maxAmountPerMonth: Decimal
|
||||||
|
$maxPerCycle: Int! = 1
|
||||||
|
$id: Int!
|
||||||
|
) {
|
||||||
|
updateContributionLink(
|
||||||
|
amount: $amount
|
||||||
|
name: $name
|
||||||
|
memo: $memo
|
||||||
|
cycle: $cycle
|
||||||
|
validFrom: $validFrom
|
||||||
|
validTo: $validTo
|
||||||
|
maxAmountPerMonth: $maxAmountPerMonth
|
||||||
|
maxPerCycle: $maxPerCycle
|
||||||
|
id: $id
|
||||||
|
) {
|
||||||
|
id
|
||||||
|
amount
|
||||||
|
name
|
||||||
|
memo
|
||||||
|
code
|
||||||
|
link
|
||||||
|
createdAt
|
||||||
|
validFrom
|
||||||
|
validTo
|
||||||
|
maxAmountPerMonth
|
||||||
|
cycle
|
||||||
|
maxPerCycle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -3,6 +3,7 @@
|
|||||||
"back": "zurück",
|
"back": "zurück",
|
||||||
"contributionLink": {
|
"contributionLink": {
|
||||||
"amount": "Betrag",
|
"amount": "Betrag",
|
||||||
|
"changeSaved": "Änderungen gespeichert",
|
||||||
"clear": "Löschen",
|
"clear": "Löschen",
|
||||||
"contributionLinks": "Beitragslinks",
|
"contributionLinks": "Beitragslinks",
|
||||||
"create": "Anlegen",
|
"create": "Anlegen",
|
||||||
@ -23,6 +24,7 @@
|
|||||||
"once": "einmalig"
|
"once": "einmalig"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"saveChange": "Änderungen speichern",
|
||||||
"validFrom": "Startdatum",
|
"validFrom": "Startdatum",
|
||||||
"validTo": "Enddatum"
|
"validTo": "Enddatum"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
"back": "back",
|
"back": "back",
|
||||||
"contributionLink": {
|
"contributionLink": {
|
||||||
"amount": "Amount",
|
"amount": "Amount",
|
||||||
|
"changeSaved": "Changes saved",
|
||||||
"clear": "Clear",
|
"clear": "Clear",
|
||||||
"contributionLinks": "Contribution Links",
|
"contributionLinks": "Contribution Links",
|
||||||
"create": "Create",
|
"create": "Create",
|
||||||
@ -23,6 +24,7 @@
|
|||||||
"once": "once"
|
"once": "once"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"saveChange": "Save Changes",
|
||||||
"validFrom": "Start-date",
|
"validFrom": "Start-date",
|
||||||
"validTo": "End-Date"
|
"validTo": "End-Date"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -139,6 +139,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('user to get a new role does not exist', () => {
|
describe('user to get a new role does not exist', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: setUserRole, variables: { userId: admin.id + 1, isAdmin: true } }),
|
mutate({ mutation: setUserRole, variables: { userId: admin.id + 1, isAdmin: true } }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -195,6 +196,7 @@ describe('AdminResolver', () => {
|
|||||||
describe('change role with error', () => {
|
describe('change role with error', () => {
|
||||||
describe('is own role', () => {
|
describe('is own role', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: setUserRole, variables: { userId: admin.id, isAdmin: false } }),
|
mutate({ mutation: setUserRole, variables: { userId: admin.id, isAdmin: false } }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -211,6 +213,7 @@ describe('AdminResolver', () => {
|
|||||||
describe('user has already role to be set', () => {
|
describe('user has already role to be set', () => {
|
||||||
describe('to admin', () => {
|
describe('to admin', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: setUserRole,
|
mutation: setUserRole,
|
||||||
variables: { userId: user.id, isAdmin: true },
|
variables: { userId: user.id, isAdmin: true },
|
||||||
@ -231,6 +234,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('to usual user', () => {
|
describe('to usual user', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: setUserRole,
|
mutation: setUserRole,
|
||||||
variables: { userId: user.id, isAdmin: false },
|
variables: { userId: user.id, isAdmin: false },
|
||||||
@ -307,6 +311,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('user to be deleted does not exist', () => {
|
describe('user to be deleted does not exist', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: deleteUser, variables: { userId: admin.id + 1 } }),
|
mutate({ mutation: deleteUser, variables: { userId: admin.id + 1 } }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -323,6 +328,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('delete self', () => {
|
describe('delete self', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: deleteUser, variables: { userId: admin.id } }),
|
mutate({ mutation: deleteUser, variables: { userId: admin.id } }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -356,6 +362,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('delete deleted user', () => {
|
describe('delete deleted user', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: deleteUser, variables: { userId: user.id } }),
|
mutate({ mutation: deleteUser, variables: { userId: user.id } }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -427,6 +434,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('user to be undelete does not exist', () => {
|
describe('user to be undelete does not exist', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: unDeleteUser, variables: { userId: admin.id + 1 } }),
|
mutate({ mutation: unDeleteUser, variables: { userId: admin.id + 1 } }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -447,6 +455,7 @@ describe('AdminResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: unDeleteUser, variables: { userId: user.id } }),
|
mutate({ mutation: unDeleteUser, variables: { userId: user.id } }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -939,6 +948,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('user to create for does not exist', () => {
|
describe('user to create for does not exist', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: adminCreateContribution, variables }),
|
mutate({ mutation: adminCreateContribution, variables }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -962,6 +972,7 @@ describe('AdminResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: adminCreateContribution, variables }),
|
mutate({ mutation: adminCreateContribution, variables }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -987,6 +998,7 @@ describe('AdminResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: adminCreateContribution, variables }),
|
mutate({ mutation: adminCreateContribution, variables }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -1013,6 +1025,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('date of creation is not a date string', () => {
|
describe('date of creation is not a date string', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: adminCreateContribution, variables }),
|
mutate({ mutation: adminCreateContribution, variables }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -1034,6 +1047,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('date of creation is four months ago', () => {
|
describe('date of creation is four months ago', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
variables.creationDate = new Date(
|
variables.creationDate = new Date(
|
||||||
now.getFullYear(),
|
now.getFullYear(),
|
||||||
@ -1061,6 +1075,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('date of creation is in the future', () => {
|
describe('date of creation is in the future', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
variables.creationDate = new Date(
|
variables.creationDate = new Date(
|
||||||
now.getFullYear(),
|
now.getFullYear(),
|
||||||
@ -1088,6 +1103,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('amount of creation is too high', () => {
|
describe('amount of creation is too high', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
variables.creationDate = new Date().toString()
|
variables.creationDate = new Date().toString()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: adminCreateContribution, variables }),
|
mutate({ mutation: adminCreateContribution, variables }),
|
||||||
@ -1213,6 +1229,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('user for creation to update does not exist', () => {
|
describe('user for creation to update does not exist', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: adminUpdateContribution,
|
mutation: adminUpdateContribution,
|
||||||
@ -1242,6 +1259,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('user for creation to update is deleted', () => {
|
describe('user for creation to update is deleted', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: adminUpdateContribution,
|
mutation: adminUpdateContribution,
|
||||||
@ -1267,6 +1285,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('creation does not exist', () => {
|
describe('creation does not exist', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: adminUpdateContribution,
|
mutation: adminUpdateContribution,
|
||||||
@ -1292,6 +1311,7 @@ describe('AdminResolver', () => {
|
|||||||
|
|
||||||
describe('user email does not match creation user', () => {
|
describe('user email does not match creation user', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: adminUpdateContribution,
|
mutation: adminUpdateContribution,
|
||||||
@ -1326,6 +1346,7 @@ describe('AdminResolver', () => {
|
|||||||
describe('creation update is not valid', () => {
|
describe('creation update is not valid', () => {
|
||||||
// as this test has not clearly defined that date, it is a false positive
|
// as this test has not clearly defined that date, it is a false positive
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: adminUpdateContribution,
|
mutation: adminUpdateContribution,
|
||||||
@ -1502,6 +1523,7 @@ describe('AdminResolver', () => {
|
|||||||
describe('adminDeleteContribution', () => {
|
describe('adminDeleteContribution', () => {
|
||||||
describe('creation id does not exist', () => {
|
describe('creation id does not exist', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: adminDeleteContribution,
|
mutation: adminDeleteContribution,
|
||||||
@ -1538,6 +1560,7 @@ describe('AdminResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: adminDeleteContribution,
|
mutation: adminDeleteContribution,
|
||||||
@ -1583,6 +1606,7 @@ describe('AdminResolver', () => {
|
|||||||
describe('confirmContribution', () => {
|
describe('confirmContribution', () => {
|
||||||
describe('creation does not exits', () => {
|
describe('creation does not exits', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: confirmContribution,
|
mutation: confirmContribution,
|
||||||
|
|||||||
@ -74,6 +74,7 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
describe('input not valid', () => {
|
describe('input not valid', () => {
|
||||||
it('throws error when memo length smaller than 5 chars', async () => {
|
it('throws error when memo length smaller than 5 chars', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
@ -92,10 +93,11 @@ describe('ContributionResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('logs the error found', () => {
|
it('logs the error found', () => {
|
||||||
expect(logger.error).toBeCalledWith(`memo text is too short: memo.length=4 < (5)`)
|
expect(logger.error).toBeCalledWith(`memo text is too short: memo.length=4 < 5`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws error when memo length greater than 255 chars', async () => {
|
it('throws error when memo length greater than 255 chars', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
@ -114,10 +116,11 @@ describe('ContributionResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('logs the error found', () => {
|
it('logs the error found', () => {
|
||||||
expect(logger.error).toBeCalledWith(`memo text is too long: memo.length=259 > (255)`)
|
expect(logger.error).toBeCalledWith(`memo text is too long: memo.length=259 > 255`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws error when creationDate not-valid', async () => {
|
it('throws error when creationDate not-valid', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createContribution,
|
mutation: createContribution,
|
||||||
@ -144,6 +147,7 @@ describe('ContributionResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws error when creationDate 3 month behind', async () => {
|
it('throws error when creationDate 3 month behind', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
@ -375,6 +379,7 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
describe('wrong contribution id', () => {
|
describe('wrong contribution id', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: updateContribution,
|
mutation: updateContribution,
|
||||||
@ -399,6 +404,7 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
describe('Memo length smaller than 5 chars', () => {
|
describe('Memo length smaller than 5 chars', () => {
|
||||||
it('throws error', async () => {
|
it('throws error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
@ -418,12 +424,13 @@ describe('ContributionResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('logs the error found', () => {
|
it('logs the error found', () => {
|
||||||
expect(logger.error).toBeCalledWith('memo text is too short: memo.length=4 < (5)')
|
expect(logger.error).toBeCalledWith('memo text is too short: memo.length=4 < 5')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Memo length greater than 255 chars', () => {
|
describe('Memo length greater than 255 chars', () => {
|
||||||
it('throws error', async () => {
|
it('throws error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
@ -443,7 +450,7 @@ describe('ContributionResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('logs the error found', () => {
|
it('logs the error found', () => {
|
||||||
expect(logger.error).toBeCalledWith('memo text is too long: memo.length=259 > (255)')
|
expect(logger.error).toBeCalledWith('memo text is too long: memo.length=259 > 255')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -456,6 +463,7 @@ describe('ContributionResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: updateContribution,
|
mutation: updateContribution,
|
||||||
@ -486,6 +494,7 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
describe('admin tries to update a user contribution', () => {
|
describe('admin tries to update a user contribution', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: adminUpdateContribution,
|
mutation: adminUpdateContribution,
|
||||||
@ -516,6 +525,7 @@ describe('ContributionResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: updateContribution,
|
mutation: updateContribution,
|
||||||
@ -546,6 +556,7 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
describe('update creation to a date that is older than 3 months', () => {
|
describe('update creation to a date that is older than 3 months', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
@ -564,7 +575,7 @@ describe('ContributionResolver', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('logs the error found', () => {
|
it.skip('logs the error found', () => {
|
||||||
expect(logger.error).toBeCalledWith(
|
expect(logger.error).toBeCalledWith(
|
||||||
'No information for available creations with the given creationDate=',
|
'No information for available creations with the given creationDate=',
|
||||||
'Invalid Date',
|
'Invalid Date',
|
||||||
@ -830,6 +841,7 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
describe('User deletes already confirmed contribution', () => {
|
describe('User deletes already confirmed contribution', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: login,
|
mutation: login,
|
||||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||||
|
|||||||
@ -32,12 +32,12 @@ export class ContributionResolver {
|
|||||||
@Ctx() context: Context,
|
@Ctx() context: Context,
|
||||||
): Promise<UnconfirmedContribution> {
|
): Promise<UnconfirmedContribution> {
|
||||||
if (memo.length > MEMO_MAX_CHARS) {
|
if (memo.length > MEMO_MAX_CHARS) {
|
||||||
logger.error(`memo text is too long: memo.length=${memo.length} > (${MEMO_MAX_CHARS})`)
|
logger.error(`memo text is too long: memo.length=${memo.length} > ${MEMO_MAX_CHARS}`)
|
||||||
throw new Error(`memo text is too long (${MEMO_MAX_CHARS} characters maximum)`)
|
throw new Error(`memo text is too long (${MEMO_MAX_CHARS} characters maximum)`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memo.length < MEMO_MIN_CHARS) {
|
if (memo.length < MEMO_MIN_CHARS) {
|
||||||
logger.error(`memo text is too short: memo.length=${memo.length} < (${MEMO_MIN_CHARS})`)
|
logger.error(`memo text is too short: memo.length=${memo.length} < ${MEMO_MIN_CHARS}`)
|
||||||
throw new Error(`memo text is too short (${MEMO_MIN_CHARS} characters minimum)`)
|
throw new Error(`memo text is too short (${MEMO_MIN_CHARS} characters minimum)`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,12 +172,12 @@ export class ContributionResolver {
|
|||||||
@Ctx() context: Context,
|
@Ctx() context: Context,
|
||||||
): Promise<UnconfirmedContribution> {
|
): Promise<UnconfirmedContribution> {
|
||||||
if (memo.length > MEMO_MAX_CHARS) {
|
if (memo.length > MEMO_MAX_CHARS) {
|
||||||
logger.error(`memo text is too long: memo.length=${memo.length} > (${MEMO_MAX_CHARS}`)
|
logger.error(`memo text is too long: memo.length=${memo.length} > ${MEMO_MAX_CHARS}`)
|
||||||
throw new Error(`memo text is too long (${MEMO_MAX_CHARS} characters maximum)`)
|
throw new Error(`memo text is too long (${MEMO_MAX_CHARS} characters maximum)`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memo.length < MEMO_MIN_CHARS) {
|
if (memo.length < MEMO_MIN_CHARS) {
|
||||||
logger.error(`memo text is too short: memo.length=${memo.length} < (${MEMO_MIN_CHARS}`)
|
logger.error(`memo text is too short: memo.length=${memo.length} < ${MEMO_MIN_CHARS}`)
|
||||||
throw new Error(`memo text is too short (${MEMO_MIN_CHARS} characters minimum)`)
|
throw new Error(`memo text is too short (${MEMO_MIN_CHARS} characters minimum)`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -67,6 +67,7 @@ describe('send coins', () => {
|
|||||||
|
|
||||||
describe('unknown recipient', () => {
|
describe('unknown recipient', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: login,
|
mutation: login,
|
||||||
variables: bobData,
|
variables: bobData,
|
||||||
@ -93,6 +94,7 @@ describe('send coins', () => {
|
|||||||
|
|
||||||
describe('deleted recipient', () => {
|
describe('deleted recipient', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: login,
|
mutation: login,
|
||||||
variables: peterData,
|
variables: peterData,
|
||||||
@ -125,6 +127,7 @@ describe('send coins', () => {
|
|||||||
|
|
||||||
describe('recipient account not activated', () => {
|
describe('recipient account not activated', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: login,
|
mutation: login,
|
||||||
variables: peterData,
|
variables: peterData,
|
||||||
@ -166,6 +169,7 @@ describe('send coins', () => {
|
|||||||
|
|
||||||
describe('sender and recipient are the same', () => {
|
describe('sender and recipient are the same', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
expect(
|
expect(
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: sendCoins,
|
mutation: sendCoins,
|
||||||
@ -189,6 +193,7 @@ describe('send coins', () => {
|
|||||||
|
|
||||||
describe('memo text is too long', () => {
|
describe('memo text is too long', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
expect(
|
expect(
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: sendCoins,
|
mutation: sendCoins,
|
||||||
@ -212,6 +217,7 @@ describe('send coins', () => {
|
|||||||
|
|
||||||
describe('memo text is too short', () => {
|
describe('memo text is too short', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
expect(
|
expect(
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: sendCoins,
|
mutation: sendCoins,
|
||||||
@ -235,6 +241,7 @@ describe('send coins', () => {
|
|||||||
|
|
||||||
describe('user has not enough GDD', () => {
|
describe('user has not enough GDD', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
expect(
|
expect(
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: sendCoins,
|
mutation: sendCoins,
|
||||||
@ -260,6 +267,7 @@ describe('send coins', () => {
|
|||||||
|
|
||||||
describe('sending negative amount', () => {
|
describe('sending negative amount', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
expect(
|
expect(
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: sendCoins,
|
mutation: sendCoins,
|
||||||
|
|||||||
@ -514,18 +514,20 @@ describe('UserResolver', () => {
|
|||||||
await mutate({ mutation: createUser, variables: createUserVariables })
|
await mutate({ mutation: createUser, variables: createUserVariables })
|
||||||
const emailContact = await UserContact.findOneOrFail({ email: createUserVariables.email })
|
const emailContact = await UserContact.findOneOrFail({ email: createUserVariables.email })
|
||||||
emailVerificationCode = emailContact.emailVerificationCode.toString()
|
emailVerificationCode = emailContact.emailVerificationCode.toString()
|
||||||
result = await mutate({
|
|
||||||
mutation: setPassword,
|
|
||||||
variables: { code: emailVerificationCode, password: 'not-valid' },
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await cleanDB()
|
await cleanDB()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error', () => {
|
it('throws an error', async () => {
|
||||||
expect(result).toEqual(
|
jest.clearAllMocks()
|
||||||
|
expect(
|
||||||
|
await mutate({
|
||||||
|
mutation: setPassword,
|
||||||
|
variables: { code: emailVerificationCode, password: 'not-valid' },
|
||||||
|
}),
|
||||||
|
).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
errors: [
|
errors: [
|
||||||
new GraphQLError(
|
new GraphQLError(
|
||||||
@ -544,18 +546,20 @@ describe('UserResolver', () => {
|
|||||||
describe('no valid optin code', () => {
|
describe('no valid optin code', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await mutate({ mutation: createUser, variables: createUserVariables })
|
await mutate({ mutation: createUser, variables: createUserVariables })
|
||||||
result = await mutate({
|
|
||||||
mutation: setPassword,
|
|
||||||
variables: { code: 'not valid', password: 'Aa12345_' },
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await cleanDB()
|
await cleanDB()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error', () => {
|
it('throws an error', async () => {
|
||||||
expect(result).toEqual(
|
jest.clearAllMocks()
|
||||||
|
expect(
|
||||||
|
await mutate({
|
||||||
|
mutation: setPassword,
|
||||||
|
variables: { code: 'not valid', password: 'Aa12345_' },
|
||||||
|
}),
|
||||||
|
).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
errors: [new GraphQLError('Could not login with emailVerificationCode')],
|
errors: [new GraphQLError('Could not login with emailVerificationCode')],
|
||||||
}),
|
}),
|
||||||
@ -582,13 +586,9 @@ describe('UserResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('no users in database', () => {
|
describe('no users in database', () => {
|
||||||
beforeAll(async () => {
|
it('throws an error', async () => {
|
||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
result = await mutate({ mutation: login, variables })
|
expect(await mutate({ mutation: login, variables })).toEqual(
|
||||||
})
|
|
||||||
|
|
||||||
it('throws an error', () => {
|
|
||||||
expect(result).toEqual(
|
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
errors: [new GraphQLError('No user with this credentials')],
|
errors: [new GraphQLError('No user with this credentials')],
|
||||||
}),
|
}),
|
||||||
@ -666,6 +666,7 @@ describe('UserResolver', () => {
|
|||||||
describe('logout', () => {
|
describe('logout', () => {
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
resetToken()
|
resetToken()
|
||||||
await expect(mutate({ mutation: logout })).resolves.toEqual(
|
await expect(mutate({ mutation: logout })).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@ -704,6 +705,7 @@ describe('UserResolver', () => {
|
|||||||
describe('verifyLogin', () => {
|
describe('verifyLogin', () => {
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
resetToken()
|
resetToken()
|
||||||
await expect(query({ query: verifyLogin })).resolves.toEqual(
|
await expect(query({ query: verifyLogin })).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@ -723,6 +725,7 @@ describe('UserResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
resetToken()
|
resetToken()
|
||||||
await expect(query({ query: verifyLogin })).resolves.toEqual(
|
await expect(query({ query: verifyLogin })).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@ -883,6 +886,7 @@ describe('UserResolver', () => {
|
|||||||
|
|
||||||
describe('wrong optin code', () => {
|
describe('wrong optin code', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
query({ query: queryOptIn, variables: { optIn: 'not-valid' } }),
|
query({ query: queryOptIn, variables: { optIn: 'not-valid' } }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -919,6 +923,7 @@ describe('UserResolver', () => {
|
|||||||
describe('updateUserInfos', () => {
|
describe('updateUserInfos', () => {
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
resetToken()
|
resetToken()
|
||||||
await expect(mutate({ mutation: updateUserInfos })).resolves.toEqual(
|
await expect(mutate({ mutation: updateUserInfos })).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@ -976,6 +981,7 @@ describe('UserResolver', () => {
|
|||||||
|
|
||||||
describe('language is not valid', () => {
|
describe('language is not valid', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: updateUserInfos,
|
mutation: updateUserInfos,
|
||||||
@ -998,6 +1004,7 @@ describe('UserResolver', () => {
|
|||||||
describe('password', () => {
|
describe('password', () => {
|
||||||
describe('wrong old password', () => {
|
describe('wrong old password', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: updateUserInfos,
|
mutation: updateUserInfos,
|
||||||
@ -1020,6 +1027,7 @@ describe('UserResolver', () => {
|
|||||||
|
|
||||||
describe('invalid new password', () => {
|
describe('invalid new password', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: updateUserInfos,
|
mutation: updateUserInfos,
|
||||||
@ -1108,6 +1116,7 @@ describe('UserResolver', () => {
|
|||||||
describe('searchAdminUsers', () => {
|
describe('searchAdminUsers', () => {
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
resetToken()
|
resetToken()
|
||||||
await expect(mutate({ mutation: searchAdminUsers })).resolves.toEqual(
|
await expect(mutate({ mutation: searchAdminUsers })).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user