fix linting, raise coverage

This commit is contained in:
Moriz Wahl 2023-02-14 17:17:17 +01:00
parent f8fca7ab0c
commit 3e894d36bd
4 changed files with 300 additions and 301 deletions

View File

@ -108,7 +108,6 @@
"automaticContributions": "Automatische Beiträge", "automaticContributions": "Automatische Beiträge",
"logout": "Abmelden", "logout": "Abmelden",
"my-account": "Mein Konto", "my-account": "Mein Konto",
"open_creation": "Offene Schöpfungen",
"statistic": "Statistik", "statistic": "Statistik",
"user_search": "Nutzersuche" "user_search": "Nutzersuche"
}, },

View File

@ -108,7 +108,6 @@
"automaticContributions": "Automatic Contributions", "automaticContributions": "Automatic Contributions",
"logout": "Logout", "logout": "Logout",
"my-account": "My Account", "my-account": "My Account",
"open_creation": "Open creations",
"statistic": "Statistic", "statistic": "Statistic",
"user_search": "User search" "user_search": "User search"
}, },

View File

@ -5,7 +5,7 @@ import { toastErrorSpy } from '../../test/testSetup'
const localVue = global.localVue const localVue = global.localVue
const apolloQueryMock = jest.fn().mockResolvedValueOnce({ const apolloQueryMock = jest.fn().mockResolvedValue({
data: { data: {
listContributionLinks: { listContributionLinks: {
links: [ links: [
@ -47,6 +47,7 @@ describe('ContributionLinks', () => {
beforeEach(() => { beforeEach(() => {
wrapper = Wrapper() wrapper = Wrapper()
}) })
describe('apollo returns', () => { describe('apollo returns', () => {
it('calls listContributionLinks', () => { it('calls listContributionLinks', () => {
expect(apolloQueryMock).toBeCalledWith( expect(apolloQueryMock).toBeCalledWith(
@ -57,7 +58,7 @@ describe('ContributionLinks', () => {
}) })
}) })
describe.skip('query transaction with error', () => { describe('query transaction with error', () => {
beforeEach(() => { beforeEach(() => {
apolloQueryMock.mockRejectedValue({ message: 'OUCH!' }) apolloQueryMock.mockRejectedValue({ message: 'OUCH!' })
wrapper = Wrapper() wrapper = Wrapper()

View File

@ -71,305 +71,305 @@
</div> </div>
</template> </template>
<script> <script>
import Overlay from '../components/Overlay.vue' import Overlay from '../components/Overlay.vue'
import OpenCreationsTable from '../components/Tables/OpenCreationsTable.vue' import OpenCreationsTable from '../components/Tables/OpenCreationsTable.vue'
import { listAllContributions } from '../graphql/listAllContributions' import { listAllContributions } from '../graphql/listAllContributions'
import { adminDeleteContribution } from '../graphql/adminDeleteContribution' import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
import { confirmContribution } from '../graphql/confirmContribution' import { confirmContribution } from '../graphql/confirmContribution'
import { denyContribution } from '../graphql/denyContribution' import { denyContribution } from '../graphql/denyContribution'
const FILTER_TAB_MAP = [ const FILTER_TAB_MAP = [
['IN_PROGRESS', 'PENDING'], ['IN_PROGRESS', 'PENDING'],
['CONFIRMED'], ['CONFIRMED'],
['DENIED'], ['DENIED'],
['DELETED'], ['DELETED'],
['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'], ['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'],
] ]
export default { export default {
name: 'CreationConfirm', name: 'CreationConfirm',
components: { components: {
OpenCreationsTable, OpenCreationsTable,
Overlay, Overlay,
}, },
data() { data() {
return { return {
tabIndex: 0, tabIndex: 0,
items: [], items: [],
overlay: false, overlay: false,
item: {}, item: {},
variant: 'confirm', variant: 'confirm',
rows: 0, rows: 0,
currentPage: 1, currentPage: 1,
pageSize: 25, pageSize: 25,
} }
}, },
methods: { methods: {
deleteCreation() { deleteCreation() {
this.$apollo this.$apollo
.mutate({ .mutate({
mutation: adminDeleteContribution, mutation: adminDeleteContribution,
variables: { variables: {
id: this.item.id, id: this.item.id,
}, },
}) })
.then((result) => { .then((result) => {
this.overlay = false this.overlay = false
this.updatePendingCreations(this.item.id) this.updatePendingCreations(this.item.id)
this.toastSuccess(this.$t('creation_form.toasted_delete')) this.toastSuccess(this.$t('creation_form.toasted_delete'))
}) })
.catch((error) => { .catch((error) => {
this.overlay = false this.overlay = false
this.toastError(error.message) this.toastError(error.message)
}) })
}, },
denyCreation() { denyCreation() {
this.$apollo this.$apollo
.mutate({ .mutate({
mutation: denyContribution, mutation: denyContribution,
variables: { variables: {
id: this.item.id, id: this.item.id,
}, },
}) })
.then((result) => { .then((result) => {
this.overlay = false this.overlay = false
this.updatePendingCreations(this.item.id) this.updatePendingCreations(this.item.id)
this.toastSuccess(this.$t('creation_form.toasted_denied')) this.toastSuccess(this.$t('creation_form.toasted_denied'))
}) })
.catch((error) => { .catch((error) => {
this.overlay = false this.overlay = false
this.toastError(error.message) this.toastError(error.message)
}) })
}, },
confirmCreation() { confirmCreation() {
this.$apollo this.$apollo
.mutate({ .mutate({
mutation: confirmContribution, mutation: confirmContribution,
variables: { variables: {
id: this.item.id, id: this.item.id,
}, },
}) })
.then((result) => { .then((result) => {
this.overlay = false this.overlay = false
this.updatePendingCreations(this.item.id) this.updatePendingCreations(this.item.id)
this.toastSuccess(this.$t('creation_form.toasted_created')) this.toastSuccess(this.$t('creation_form.toasted_created'))
}) })
.catch((error) => { .catch((error) => {
this.overlay = false this.overlay = false
this.toastError(error.message) this.toastError(error.message)
}) })
}, },
updatePendingCreations(id) { updatePendingCreations(id) {
this.items = this.items.filter((obj) => obj.id !== id) this.items = this.items.filter((obj) => obj.id !== id)
this.$store.commit('openCreationsMinus', 1) this.$store.commit('openCreationsMinus', 1)
}, },
showOverlay(item, variant) { showOverlay(item, variant) {
this.overlay = true this.overlay = true
this.item = item this.item = item
this.variant = variant this.variant = variant
}, },
updateStatus(id) { updateStatus(id) {
this.items.find((obj) => obj.id === id).messagesCount++ this.items.find((obj) => obj.id === id).messagesCount++
this.items.find((obj) => obj.id === id).state = 'IN_PROGRESS' this.items.find((obj) => obj.id === id).state = 'IN_PROGRESS'
}, },
}, },
watch: { watch: {
statusFilter() { statusFilter() {
// console.log('statusFilter', this.statusFilter) // console.log('statusFilter', this.statusFilter)
this.$apollo.queries.ListAllContributions.refetch() this.$apollo.queries.ListAllContributions.refetch()
}, },
}, },
computed: { computed: {
fields() { fields() {
return [ return [
[ [
{ key: 'bookmark', label: this.$t('delete') }, { key: 'bookmark', label: this.$t('delete') },
{ key: 'deny', label: this.$t('deny') }, { key: 'deny', label: this.$t('deny') },
{ key: 'email', label: this.$t('e_mail') }, { key: 'email', label: this.$t('e_mail') },
{ key: 'firstName', label: this.$t('firstname') }, { key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') }, { key: 'lastName', label: this.$t('lastname') },
{ {
key: 'amount', key: 'amount',
label: this.$t('creation'), label: this.$t('creation'),
formatter: (value) => { formatter: (value) => {
return value + ' GDD' return value + ' GDD'
}, },
}, },
{ key: 'memo', label: this.$t('text'), class: 'text-break' }, { key: 'memo', label: this.$t('text'), class: 'text-break' },
{ {
key: 'contributionDate', key: 'contributionDate',
label: this.$t('created'), label: this.$t('created'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.$d(new Date(value), 'short')
}, },
}, },
{ key: 'moderator', label: this.$t('moderator') }, { key: 'moderator', label: this.$t('moderator') },
{ key: 'editCreation', label: this.$t('edit') }, { key: 'editCreation', label: this.$t('edit') },
{ key: 'confirm', label: this.$t('save') }, { key: 'confirm', label: this.$t('save') },
], ],
[ [
{ key: 'firstName', label: this.$t('firstname') }, { key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') }, { key: 'lastName', label: this.$t('lastname') },
{ {
key: 'amount', key: 'amount',
label: this.$t('creation'), label: this.$t('creation'),
formatter: (value) => { formatter: (value) => {
return value + ' GDD' return value + ' GDD'
}, },
}, },
{ key: 'memo', label: this.$t('text'), class: 'text-break' }, { key: 'memo', label: this.$t('text'), class: 'text-break' },
{ {
key: 'contributionDate', key: 'contributionDate',
label: this.$t('created'), label: this.$t('created'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.$d(new Date(value), 'short')
}, },
}, },
{ {
key: 'createdAt', key: 'createdAt',
label: this.$t('createdAt'), label: this.$t('createdAt'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.$d(new Date(value), 'short')
}, },
}, },
{ {
key: 'confirmedAt', key: 'confirmedAt',
label: this.$t('contributions.confirms'), label: this.$t('contributions.confirms'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.$d(new Date(value), 'short')
}, },
}, },
{ key: 'chatCreation', label: this.$t('chat') }, { key: 'chatCreation', label: this.$t('chat') },
], ],
[ [
{ key: 'reActive', label: 'reActive' }, { key: 'reActive', label: 'reActive' },
{ key: 'firstName', label: this.$t('firstname') }, { key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') }, { key: 'lastName', label: this.$t('lastname') },
{ {
key: 'amount', key: 'amount',
label: this.$t('creation'), label: this.$t('creation'),
formatter: (value) => { formatter: (value) => {
return value + ' GDD' return value + ' GDD'
}, },
}, },
{ key: 'memo', label: this.$t('text'), class: 'text-break' }, { key: 'memo', label: this.$t('text'), class: 'text-break' },
{ {
key: 'contributionDate', key: 'contributionDate',
label: this.$t('created'), label: this.$t('created'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.$d(new Date(value), 'short')
}, },
}, },
{ {
key: 'createdAt', key: 'createdAt',
label: this.$t('createdAt'), label: this.$t('createdAt'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.$d(new Date(value), 'short')
}, },
}, },
{ {
key: 'deniedAt', key: 'deniedAt',
label: this.$t('contributions.denied'), label: this.$t('contributions.denied'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.$d(new Date(value), 'short')
}, },
}, },
{ key: 'deniedBy', label: this.$t('mod') }, { key: 'deniedBy', label: this.$t('mod') },
{ key: 'chatCreation', label: this.$t('chat') }, { key: 'chatCreation', label: this.$t('chat') },
], ],
[], [],
[ [
{ key: 'state', label: 'state' }, { key: 'state', label: 'state' },
{ key: 'firstName', label: this.$t('firstname') }, { key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') }, { key: 'lastName', label: this.$t('lastname') },
{ {
key: 'amount', key: 'amount',
label: this.$t('creation'), label: this.$t('creation'),
formatter: (value) => { formatter: (value) => {
return value + ' GDD' return value + ' GDD'
}, },
}, },
{ key: 'memo', label: this.$t('text'), class: 'text-break' }, { key: 'memo', label: this.$t('text'), class: 'text-break' },
{ {
key: 'contributionDate', key: 'contributionDate',
label: this.$t('created'), label: this.$t('created'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.$d(new Date(value), 'short')
}, },
}, },
{ {
key: 'createdAt', key: 'createdAt',
label: this.$t('createdAt'), label: this.$t('createdAt'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.$d(new Date(value), 'short')
}, },
}, },
{ {
key: 'confirmedAt', key: 'confirmedAt',
label: this.$t('contributions.confirms'), label: this.$t('contributions.confirms'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.$d(new Date(value), 'short')
}, },
}, },
{ key: 'confirmedBy', label: this.$t('mod') }, { key: 'confirmedBy', label: this.$t('mod') },
{ key: 'chatCreation', label: this.$t('chat') }, { key: 'chatCreation', label: this.$t('chat') },
], ],
][this.tabIndex] ][this.tabIndex]
}, },
statusFilter() { statusFilter() {
return FILTER_TAB_MAP[this.tabIndex] return FILTER_TAB_MAP[this.tabIndex]
}, },
overlayTitle() { overlayTitle() {
return `overlay.${this.variant}.title` return `overlay.${this.variant}.title`
}, },
overlayText() { overlayText() {
return `overlay.${this.variant}.text` return `overlay.${this.variant}.text`
}, },
overlayQuestion() { overlayQuestion() {
return `overlay.${this.variant}.question` return `overlay.${this.variant}.question`
}, },
overlayBtnText() { overlayBtnText() {
return `overlay.${this.variant}.yes` return `overlay.${this.variant}.yes`
}, },
overlayEvent() { overlayEvent() {
return this[`${this.variant}Creation`] return this[`${this.variant}Creation`]
}, },
overlayIcon() { overlayIcon() {
switch (this.variant) { switch (this.variant) {
case 'confirm': case 'confirm':
return 'success' return 'success'
case 'deny': case 'deny':
return 'warning' return 'warning'
case 'delete': case 'delete':
return 'danger' return 'danger'
default: default:
return 'info' return 'info'
} }
}, },
}, },
apollo: { apollo: {
ListAllContributions: { ListAllContributions: {
query() { query() {
return listAllContributions return listAllContributions
}, },
variables() { variables() {
// may be at some point we need a pagination here // may be at some point we need a pagination here
return { return {
currentPage: this.currentPage, currentPage: this.currentPage,
pageSize: this.pageSize, pageSize: this.pageSize,
statusFilter: this.statusFilter, statusFilter: this.statusFilter,
} }
}, },
update({ listAllContributions }) { update({ listAllContributions }) {
this.rows = listAllContributions.contributionCount this.rows = listAllContributions.contributionCount
this.items = listAllContributions.contributionList this.items = listAllContributions.contributionList
}, },
error({ message }) { error({ message }) {
this.toastError(message) this.toastError(message)
}, },
}, },
}, },
} }
</script> </script>
<style> <style>
#overlay { #overlay {