diff --git a/admin/src/components/ContributionMessages/ContributionMessagesFormular.spec.js b/admin/src/components/ContributionMessages/ContributionMessagesFormular.spec.js index b7f01f8b8..60395c68b 100644 --- a/admin/src/components/ContributionMessages/ContributionMessagesFormular.spec.js +++ b/admin/src/components/ContributionMessages/ContributionMessagesFormular.spec.js @@ -12,6 +12,7 @@ describe('ContributionMessagesFormular', () => { const propsData = { contributionId: 42, + contributionMemo: 'It is a test memo', } const mocks = { @@ -52,9 +53,10 @@ describe('ContributionMessagesFormular', () => { await wrapper.find('form').trigger('reset') }) - it('form has empty text', () => { + it('form has empty text and memo reset to contribution memo input', () => { expect(wrapper.vm.form).toEqual({ text: '', + memo: 'It is a test memo', }) }) }) diff --git a/admin/src/components/ContributionMessages/ContributionMessagesFormular.vue b/admin/src/components/ContributionMessages/ContributionMessagesFormular.vue index b61a65447..96ecef6c1 100644 --- a/admin/src/components/ContributionMessages/ContributionMessagesFormular.vue +++ b/admin/src/components/ContributionMessages/ContributionMessagesFormular.vue @@ -148,6 +148,7 @@ export default { }, onReset(event) { this.form.text = '' + this.form.memo = this.contributionMemo }, enableMemo() { this.chatOrMemo = 1 diff --git a/admin/src/components/ContributionMessages/ContributionMessagesList.spec.js b/admin/src/components/ContributionMessages/ContributionMessagesList.spec.js index 023f65974..671a05f83 100644 --- a/admin/src/components/ContributionMessages/ContributionMessagesList.spec.js +++ b/admin/src/components/ContributionMessages/ContributionMessagesList.spec.js @@ -86,6 +86,7 @@ describe('ContributionMessagesList', () => { const propsData = { contributionId: 42, + contributionMemo: 'test memo', contributionUserId: 108, contributionStatus: 'PENDING', } diff --git a/admin/src/components/CreationTransactionList.spec.js b/admin/src/components/CreationTransactionList.spec.js index 28aa1707d..394cfd9ea 100644 --- a/admin/src/components/CreationTransactionList.spec.js +++ b/admin/src/components/CreationTransactionList.spec.js @@ -38,6 +38,8 @@ const defaultData = () => { contributionDate: new Date(), deletedBy: null, deletedAt: null, + updatedAt: null, + updatedBy: null, createdAt: new Date(), moderatorId: null, }, @@ -61,6 +63,8 @@ const defaultData = () => { contributionDate: new Date(), deletedBy: null, deletedAt: null, + updatedAt: null, + updatedBy: null, createdAt: new Date(), moderatorId: null, }, diff --git a/admin/src/graphql/getContribution.js b/admin/src/graphql/getContribution.js new file mode 100644 index 000000000..bc42bceb1 --- /dev/null +++ b/admin/src/graphql/getContribution.js @@ -0,0 +1,27 @@ +import gql from 'graphql-tag' + +export const getContribution = gql` + query ($id: Int!) { + contribution(id: $id) { + id + firstName + lastName + amount + memo + createdAt + contributionDate + confirmedAt + confirmedBy + updatedAt + updatedBy + status + messagesCount + deniedAt + deniedBy + deletedAt + deletedBy + moderatorId + userId + } + } +` \ No newline at end of file diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index 36e2479aa..d26b183e6 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -4,6 +4,7 @@ import { adminDeleteContribution } from '../graphql/adminDeleteContribution' import { denyContribution } from '../graphql/denyContribution' import { adminListContributions } from '../graphql/adminListContributions' import { confirmContribution } from '../graphql/confirmContribution' +import { getContribution } from '../graphql/getContribution' import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' import VueApollo from 'vue-apollo' import { createMockClient } from 'mock-apollo-client' @@ -61,6 +62,8 @@ const defaultData = () => { contributionDate: new Date(), deletedBy: null, deletedAt: null, + updatedAt: null, + updatedBy: null, createdAt: new Date(), }, { @@ -83,6 +86,8 @@ const defaultData = () => { contributionDate: new Date(), deletedBy: null, deletedAt: null, + updatedAt: null, + updatedBy: null, createdAt: new Date(), }, ], @@ -96,6 +101,7 @@ describe('CreationConfirm', () => { const adminDeleteContributionMock = jest.fn() const adminDenyContributionMock = jest.fn() const confirmContributionMock = jest.fn() + const getContributionMock = jest.fn() mockClient.setRequestHandler( adminListContributions, @@ -121,6 +127,11 @@ describe('CreationConfirm', () => { confirmContributionMock.mockResolvedValue({ data: { confirmContribution: true } }), ) + mockClient.setRequestHandler( + getContribution, + getContributionMock.mockResolvedValue({ data: {} }), + ) + const Wrapper = () => { return mount(CreationConfirm, { localVue, mocks, apolloProvider }) } @@ -141,7 +152,7 @@ describe('CreationConfirm', () => { }) }) - describe('server response is succes', () => { + describe('server response is success', () => { it('has a DIV element with the class.creation-confirm', () => { expect(wrapper.find('div.creation-confirm').exists()).toBeTruthy() }) @@ -150,7 +161,7 @@ describe('CreationConfirm', () => { expect(wrapper.find('tbody').findAll('tr')).toHaveLength(2) }) }) - + describe('actions in overlay', () => { describe('delete creation', () => { beforeEach(async () => { @@ -219,7 +230,7 @@ describe('CreationConfirm', () => { expect(wrapper.find('#overlay').isVisible()).toBeTruthy() }) - describe('with succes', () => { + describe('with success', () => { describe('cancel confirmation', () => { beforeEach(async () => { await wrapper.find('#overlay').findAll('button').at(0).trigger('click') @@ -278,7 +289,7 @@ describe('CreationConfirm', () => { expect(wrapper.find('#overlay').isVisible()).toBeTruthy() }) - describe('with succes', () => { + describe('with success', () => { describe('cancel deny', () => { beforeEach(async () => { await wrapper.find('#overlay').findAll('button').at(0).trigger('click') @@ -510,6 +521,18 @@ describe('CreationConfirm', () => { }) }) + describe('reload contribution', () => { + beforeEach(async () => { + await wrapper.findComponent({ name: 'OpenCreationsTable' }).vm.$emit('reload-contribution', 1) + }) + + it('reloaded contribution', () => { + expect(getContributionMock).toBeCalledWith({ + id: 1 + }) + }) + }) + describe('unknown variant', () => { beforeEach(async () => { await wrapper.setData({ variant: 'unknown' }) diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index 593603e43..3ca382c43 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -3,7 +3,7 @@