From f83c364d1de9e517afb564cab7317b947c3121d9 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 28 Feb 2023 17:19:12 +0100 Subject: [PATCH 1/5] feat(admin): deleted contributions visible --- backend/src/graphql/model/Contribution.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts index d71d2ce6b..b966b714e 100644 --- a/backend/src/graphql/model/Contribution.ts +++ b/backend/src/graphql/model/Contribution.ts @@ -12,7 +12,6 @@ export class Contribution { this.amount = contribution.amount this.memo = contribution.memo this.createdAt = contribution.createdAt - this.deletedAt = contribution.deletedAt this.confirmedAt = contribution.confirmedAt this.confirmedBy = contribution.confirmedBy this.contributionDate = contribution.contributionDate @@ -20,6 +19,8 @@ export class Contribution { this.messagesCount = contribution.messages ? contribution.messages.length : 0 this.deniedAt = contribution.deniedAt this.deniedBy = contribution.deniedBy + this.deletedAt = contribution.deletedAt + this.deletedBy = contribution.deletedBy } @Field(() => Number) @@ -40,9 +41,6 @@ export class Contribution { @Field(() => Date) createdAt: Date - @Field(() => Date, { nullable: true }) - deletedAt: Date | null - @Field(() => Date, { nullable: true }) confirmedAt: Date | null @@ -55,6 +53,12 @@ export class Contribution { @Field(() => Number, { nullable: true }) deniedBy: number | null + @Field(() => Date, { nullable: true }) + deletedAt: Date | null + + @Field(() => Number, { nullable: true }) + deletedBy: number | null + @Field(() => Date) contributionDate: Date From 457cea46193b53f0727883ccb935cc251bcb4a3a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 28 Feb 2023 17:20:56 +0100 Subject: [PATCH 2/5] add deleted contribution table --- admin/src/graphql/listAllContributions.js | 4 +- admin/src/pages/CreationConfirm.vue | 55 ++++++++++++++++++----- admin/src/pages/Overview.vue | 4 +- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/admin/src/graphql/listAllContributions.js b/admin/src/graphql/listAllContributions.js index 655ab679c..319433fc2 100644 --- a/admin/src/graphql/listAllContributions.js +++ b/admin/src/graphql/listAllContributions.js @@ -7,7 +7,7 @@ export const listAllContributions = gql` $order: Order = DESC $statusFilter: [ContributionStatus!] ) { - listAllContributions( + adminListAllContributions( currentPage: $currentPage pageSize: $pageSize order: $order @@ -28,6 +28,8 @@ export const listAllContributions = gql` messagesCount deniedAt deniedBy + deletedAt + deletedBy } } } diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index 7c354fc85..3d63aa735 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -173,15 +173,11 @@ export default { this.items.find((obj) => obj.id === id).state = 'IN_PROGRESS' }, }, - watch: { - statusFilter() { - this.$apollo.queries.ListAllContributions.refetch() - }, - }, computed: { fields() { return [ [ + // open contributions { key: 'bookmark', label: this.$t('delete') }, { key: 'deny', label: this.$t('deny') }, { key: 'email', label: this.$t('e_mail') }, @@ -207,6 +203,7 @@ export default { { key: 'confirm', label: this.$t('save') }, ], [ + // confirmed contributions { key: 'firstName', label: this.$t('firstname') }, { key: 'lastName', label: this.$t('lastname') }, { @@ -241,6 +238,7 @@ export default { { key: 'chatCreation', label: this.$t('chat') }, ], [ + // denied contributions { key: 'reActive', label: 'reActive' }, { key: 'firstName', label: this.$t('firstname') }, { key: 'lastName', label: this.$t('lastname') }, @@ -276,8 +274,45 @@ export default { { key: 'deniedBy', label: this.$t('mod') }, { key: 'chatCreation', label: this.$t('chat') }, ], - [], [ + // deleted contributions + { key: 'reActive', label: 'reActive' }, + { key: 'firstName', label: this.$t('firstname') }, + { key: 'lastName', label: this.$t('lastname') }, + { + key: 'amount', + label: this.$t('creation'), + formatter: (value) => { + return value + ' GDD' + }, + }, + { key: 'memo', label: this.$t('text'), class: 'text-break' }, + { + key: 'contributionDate', + label: this.$t('created'), + formatter: (value) => { + return this.$d(new Date(value), 'short') + }, + }, + { + key: 'createdAt', + label: this.$t('createdAt'), + formatter: (value) => { + return this.$d(new Date(value), 'short') + }, + }, + { + key: 'deletedAt', + label: this.$t('contributions.denied'), + formatter: (value) => { + return this.$d(new Date(value), 'short') + }, + }, + { key: 'deletedBy', label: this.$t('mod') }, + { key: 'chatCreation', label: this.$t('chat') }, + ], + [ + // all contributions { key: 'state', label: 'state' }, { key: 'firstName', label: this.$t('firstname') }, { key: 'lastName', label: this.$t('lastname') }, @@ -352,16 +387,16 @@ export default { return listAllContributions }, variables() { - // may be at some point we need a pagination here return { currentPage: this.currentPage, pageSize: this.pageSize, statusFilter: this.statusFilter, } }, - update({ listAllContributions }) { - this.rows = listAllContributions.contributionCount - this.items = listAllContributions.contributionList + fetchPolicy: 'no-cache', + update({ adminListAllContributions }) { + this.rows = adminListAllContributions.contributionCount + this.items = adminListAllContributions.contributionList }, error({ message }) { this.toastError(message) diff --git a/admin/src/pages/Overview.vue b/admin/src/pages/Overview.vue index cd4d97ba8..64e832bd0 100644 --- a/admin/src/pages/Overview.vue +++ b/admin/src/pages/Overview.vue @@ -51,8 +51,8 @@ export default { statusFilter: this.statusFilter, } }, - update({ listAllContributions }) { - this.$store.commit('setOpenCreations', listAllContributions.contributionCount) + update({ adminListAllContributions }) { + this.$store.commit('setOpenCreations', adminListAllContributions.contributionCount) }, error({ message }) { this.toastError(message) From a811b2bf2d282684064db4145e875e170d4d4173 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 28 Feb 2023 18:28:52 +0100 Subject: [PATCH 3/5] rename query file and query, update specs --- ...utions.js => adminListAllContributions.js} | 2 +- admin/src/pages/CreationConfirm.spec.js | 84 +++++++++++++------ admin/src/pages/CreationConfirm.vue | 4 +- admin/src/pages/Overview.spec.js | 14 ++-- admin/src/pages/Overview.vue | 4 +- 5 files changed, 70 insertions(+), 38 deletions(-) rename admin/src/graphql/{listAllContributions.js => adminListAllContributions.js} (93%) diff --git a/admin/src/graphql/listAllContributions.js b/admin/src/graphql/adminListAllContributions.js similarity index 93% rename from admin/src/graphql/listAllContributions.js rename to admin/src/graphql/adminListAllContributions.js index 319433fc2..cd47cd1d4 100644 --- a/admin/src/graphql/listAllContributions.js +++ b/admin/src/graphql/adminListAllContributions.js @@ -1,6 +1,6 @@ import gql from 'graphql-tag' -export const listAllContributions = gql` +export const adminListAllContributions = gql` query ( $currentPage: Int = 1 $pageSize: Int = 25 diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index 710f2b26f..5632db0bd 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils' import CreationConfirm from './CreationConfirm' import { adminDeleteContribution } from '../graphql/adminDeleteContribution' import { denyContribution } from '../graphql/denyContribution' -import { listAllContributions } from '../graphql/listAllContributions' +import { adminListAllContributions } from '../graphql/adminListAllContributions' import { confirmContribution } from '../graphql/confirmContribution' import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' import VueApollo from 'vue-apollo' @@ -38,7 +38,7 @@ const mocks = { const defaultData = () => { return { - listAllContributions: { + adminListAllContributions: { contributionCount: 2, contributionList: [ { @@ -97,7 +97,7 @@ describe('CreationConfirm', () => { const confirmContributionMock = jest.fn() mockClient.setRequestHandler( - listAllContributions, + adminListAllContributions, jest .fn() .mockRejectedValueOnce({ message: 'Ouch!' }) @@ -331,67 +331,93 @@ describe('CreationConfirm', () => { describe('filter tabs', () => { describe('click tab "confirmed"', () => { - let refetchSpy + let requestIdCounter beforeEach(async () => { - jest.clearAllMocks() - refetchSpy = jest.spyOn(wrapper.vm.$apollo.queries.ListAllContributions, 'refetch') + requestIdCounter = wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId await wrapper.find('a[data-test="confirmed"]').trigger('click') }) + it('refetches contributions', () => { + expect(wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId).toBe( + `${Number(requestIdCounter) + 1}`, + ) + }) + it('has statusFilter set to ["CONFIRMED"]', () => { expect( wrapper.vm.$apollo.queries.ListAllContributions.observer.options.variables, ).toMatchObject({ statusFilter: ['CONFIRMED'] }) }) - it('refetches contributions', () => { - expect(refetchSpy).toBeCalled() - }) - describe('click tab "open"', () => { beforeEach(async () => { - jest.clearAllMocks() - refetchSpy = jest.spyOn(wrapper.vm.$apollo.queries.ListAllContributions, 'refetch') + requestIdCounter = wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId await wrapper.find('a[data-test="open"]').trigger('click') }) + it('refetches contributions', () => { + expect(wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId).toBe( + `${Number(requestIdCounter) + 1}`, + ) + }) + it('has statusFilter set to ["IN_PROGRESS", "PENDING"]', () => { expect( wrapper.vm.$apollo.queries.ListAllContributions.observer.options.variables, ).toMatchObject({ statusFilter: ['IN_PROGRESS', 'PENDING'] }) }) - - it('refetches contributions', () => { - expect(refetchSpy).toBeCalled() - }) }) describe('click tab "denied"', () => { beforeEach(async () => { - jest.clearAllMocks() - refetchSpy = jest.spyOn(wrapper.vm.$apollo.queries.ListAllContributions, 'refetch') + requestIdCounter = wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId await wrapper.find('a[data-test="denied"]').trigger('click') }) + it('refetches contributions', () => { + expect(wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId).toBe( + `${Number(requestIdCounter) + 1}`, + ) + }) + it('has statusFilter set to ["DENIED"]', () => { expect( wrapper.vm.$apollo.queries.ListAllContributions.observer.options.variables, ).toMatchObject({ statusFilter: ['DENIED'] }) }) + }) + + describe('click tab "deleted"', () => { + beforeEach(async () => { + requestIdCounter = wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId + await wrapper.find('a[data-test="deleted"]').trigger('click') + }) it('refetches contributions', () => { - expect(refetchSpy).toBeCalled() + expect(wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId).toBe( + `${Number(requestIdCounter) + 1}`, + ) + }) + + it('has statusFilter set to ["DELETED"]', () => { + expect( + wrapper.vm.$apollo.queries.ListAllContributions.observer.options.variables, + ).toMatchObject({ statusFilter: ['DELETED'] }) }) }) describe('click tab "all"', () => { beforeEach(async () => { - jest.clearAllMocks() - refetchSpy = jest.spyOn(wrapper.vm.$apollo.queries.ListAllContributions, 'refetch') + requestIdCounter = wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId await wrapper.find('a[data-test="all"]').trigger('click') }) + it('refetches contributions', () => { + expect(wrapper.vm.$apollo.queries.ListAllContributions.observer.queryId).toBe( + `${Number(requestIdCounter) + 1}`, + ) + }) it('has statusFilter set to ["IN_PROGRESS", "PENDING", "CONFIRMED", "DENIED", "DELETED"]', () => { expect( wrapper.vm.$apollo.queries.ListAllContributions.observer.options.variables, @@ -399,10 +425,6 @@ describe('CreationConfirm', () => { statusFilter: ['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'], }) }) - - it('refetches contributions', () => { - expect(refetchSpy).toBeCalled() - }) }) }) }) @@ -412,10 +434,20 @@ describe('CreationConfirm', () => { await wrapper.findComponent({ name: 'OpenCreationsTable' }).vm.$emit('update-state', 2) }) - it.skip('updates the status', () => { + it('updates the status', () => { expect(wrapper.vm.items.find((obj) => obj.id === 2).messagesCount).toBe(1) expect(wrapper.vm.items.find((obj) => obj.id === 2).state).toBe('IN_PROGRESS') }) }) + + describe('unknown variant', () => { + beforeEach(async () => { + await wrapper.setData({ variant: 'unknown' }) + }) + + it('has overlay icon "info"', () => { + expect(wrapper.vm.overlayIcon).toBe('info') + }) + }) }) }) diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index 3d63aa735..c0b829e30 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -73,7 +73,7 @@