From e5ad0b1c500d11cecd269c605ce2cfa81956ab01 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 2 Feb 2023 18:18:57 +0100 Subject: [PATCH 01/25] remove overview and multi creation from navbar --- admin/src/components/NavBar.vue | 2 - .../components/Tables/SelectUsersTable.vue | 35 -- .../components/Tables/SelectedUsersTable.vue | 26 -- admin/src/pages/Creation.spec.js | 337 ------------------ admin/src/pages/Creation.vue | 200 ----------- admin/src/router/routes.js | 4 - 6 files changed, 604 deletions(-) delete mode 100644 admin/src/components/Tables/SelectUsersTable.vue delete mode 100644 admin/src/components/Tables/SelectedUsersTable.vue delete mode 100644 admin/src/pages/Creation.spec.js delete mode 100644 admin/src/pages/Creation.vue diff --git a/admin/src/components/NavBar.vue b/admin/src/components/NavBar.vue index 6bed8e6e4..f8bc2b280 100644 --- a/admin/src/components/NavBar.vue +++ b/admin/src/components/NavBar.vue @@ -9,9 +9,7 @@ - {{ $t('navbar.overview') }} {{ $t('navbar.user_search') }} - {{ $t('navbar.multi_creation') }} -
- - - -
- - diff --git a/admin/src/components/Tables/SelectedUsersTable.vue b/admin/src/components/Tables/SelectedUsersTable.vue deleted file mode 100644 index 810f8dac8..000000000 --- a/admin/src/components/Tables/SelectedUsersTable.vue +++ /dev/null @@ -1,26 +0,0 @@ - - diff --git a/admin/src/pages/Creation.spec.js b/admin/src/pages/Creation.spec.js deleted file mode 100644 index 9524fc5d6..000000000 --- a/admin/src/pages/Creation.spec.js +++ /dev/null @@ -1,337 +0,0 @@ -import { mount } from '@vue/test-utils' -import Creation from './Creation.vue' -import { toastErrorSpy } from '../../test/testSetup' - -const localVue = global.localVue - -const apolloQueryMock = jest.fn().mockResolvedValue({ - data: { - searchUsers: { - userCount: 2, - userList: [ - { - userId: 1, - firstName: 'Bibi', - lastName: 'Bloxberg', - email: 'bibi@bloxberg.de', - creation: [200, 400, 600], - emailChecked: true, - }, - { - userId: 2, - firstName: 'Benjamin', - lastName: 'Blümchen', - email: 'benjamin@bluemchen.de', - creation: [800, 600, 400], - emailChecked: true, - }, - ], - }, - }, -}) - -const storeCommitMock = jest.fn() - -const mocks = { - $t: jest.fn((t, options) => (options ? [t, options] : t)), - $d: jest.fn((d) => d), - $apollo: { - query: apolloQueryMock, - }, - $store: { - commit: storeCommitMock, - state: { - userSelectedInMassCreation: [], - }, - }, -} - -describe('Creation', () => { - let wrapper - - const Wrapper = () => { - return mount(Creation, { localVue, mocks }) - } - - describe('mount', () => { - beforeEach(() => { - jest.clearAllMocks() - wrapper = Wrapper() - }) - - it('has a DIV element with the class.creation', () => { - expect(wrapper.find('div.creation').exists()).toBeTruthy() - }) - - describe('apollo returns user array', () => { - it('calls the searchUser query', () => { - expect(apolloQueryMock).toBeCalledWith( - expect.objectContaining({ - variables: { - searchText: '', - currentPage: 1, - pageSize: 25, - filters: { - byActivated: true, - byDeleted: false, - }, - }, - }), - ) - }) - - it('has two rows in the left table', () => { - expect(wrapper.findAll('table').at(0).findAll('tbody > tr')).toHaveLength(2) - }) - - it('has nwo rows in the right table', () => { - expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(0) - }) - - it('has correct data in first row ', () => { - expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain('Bibi') - expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain( - 'Bloxberg', - ) - expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain( - '200 | 400 | 600', - ) - expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain( - 'bibi@bloxberg.de', - ) - }) - - it('has correct data in second row ', () => { - expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(1).text()).toContain( - 'Benjamin', - ) - expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(1).text()).toContain( - 'Blümchen', - ) - expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(1).text()).toContain( - '800 | 600 | 400', - ) - expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(1).text()).toContain( - 'benjamin@bluemchen.de', - ) - }) - }) - - describe('push item', () => { - beforeEach(() => { - wrapper.findAll('table').at(0).findAll('tbody > tr').at(1).find('button').trigger('click') - }) - - it('has one item in left table', () => { - expect(wrapper.findAll('table').at(0).findAll('tbody > tr')).toHaveLength(1) - }) - - it('has one item in right table', () => { - expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(1) - }) - - it('has the correct user in left table', () => { - expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain( - 'bibi@bloxberg.de', - ) - }) - - it('has the correct user in right table', () => { - expect(wrapper.findAll('table').at(1).findAll('tbody > tr').at(0).text()).toContain( - 'benjamin@bluemchen.de', - ) - }) - - it('updates userSelectedInMassCreation in store', () => { - expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', [ - { - userId: 2, - firstName: 'Benjamin', - lastName: 'Blümchen', - email: 'benjamin@bluemchen.de', - creation: [800, 600, 400], - showDetails: false, - emailChecked: true, - }, - ]) - }) - - describe('remove item', () => { - beforeEach(async () => { - await wrapper - .findAll('table') - .at(1) - .findAll('tbody > tr') - .at(0) - .find('button') - .trigger('click') - }) - - it('has two items in left table', () => { - expect(wrapper.findAll('table').at(0).findAll('tbody > tr')).toHaveLength(2) - }) - - it('has the removed user in first row', () => { - expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain( - 'benjamin@bluemchen.de', - ) - }) - - it('has no items in right table', () => { - expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(0) - }) - - it('commits empty array as userSelectedInMassCreation', () => { - expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', []) - }) - }) - - describe('remove all bookmarks', () => { - beforeEach(async () => { - jest.clearAllMocks() - await wrapper.find('button.btn-light').trigger('click') - }) - - it('has no items in right table', () => { - expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(0) - }) - - it('commits empty array to userSelectedInMassCreation', () => { - expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', []) - }) - - it('calls searchUsers', () => { - expect(apolloQueryMock).toBeCalled() - }) - }) - }) - - describe('store has items in userSelectedInMassCreation', () => { - beforeEach(() => { - mocks.$store.state.userSelectedInMassCreation = [ - { - userId: 2, - firstName: 'Benjamin', - lastName: 'Blümchen', - email: 'benjamin@bluemchen.de', - creation: [800, 600, 400], - showDetails: false, - emailChecked: true, - }, - ] - wrapper = Wrapper() - }) - - it('has one item in left table', () => { - expect(wrapper.findAll('table').at(0).findAll('tbody > tr')).toHaveLength(1) - }) - - it('has one item in right table', () => { - expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(1) - }) - - it('has the stored user in second row', () => { - expect(wrapper.findAll('table').at(1).findAll('tbody > tr').at(0).text()).toContain( - 'benjamin@bluemchen.de', - ) - }) - }) - - describe('failed creations', () => { - beforeEach(async () => { - await wrapper - .findComponent({ name: 'CreationFormular' }) - .vm.$emit('toast-failed-creations', ['bibi@bloxberg.de', 'benjamin@bluemchen.de']) - }) - - it('toasts two error messages', () => { - expect(toastErrorSpy).toBeCalledWith([ - 'creation_form.creation_failed', - { email: 'bibi@bloxberg.de' }, - ]) - expect(toastErrorSpy).toBeCalledWith([ - 'creation_form.creation_failed', - { email: 'benjamin@bluemchen.de' }, - ]) - }) - }) - - describe('watchers', () => { - beforeEach(() => { - jest.clearAllMocks() - }) - - describe('search criteria', () => { - beforeEach(async () => { - await wrapper.setData({ criteria: 'XX' }) - }) - - it('calls API when criteria changes', async () => { - expect(apolloQueryMock).toBeCalledWith( - expect.objectContaining({ - variables: { - searchText: 'XX', - currentPage: 1, - pageSize: 25, - filters: { - byActivated: true, - byDeleted: false, - }, - }, - }), - ) - }) - - describe('reset search criteria', () => { - it('calls the API', async () => { - jest.clearAllMocks() - await wrapper.find('.test-click-clear-criteria').trigger('click') - expect(apolloQueryMock).toBeCalledWith( - expect.objectContaining({ - variables: { - searchText: '', - currentPage: 1, - pageSize: 25, - filters: { - byActivated: true, - byDeleted: false, - }, - }, - }), - ) - }) - }) - }) - - it('calls API when currentPage changes', async () => { - await wrapper.setData({ currentPage: 2 }) - expect(apolloQueryMock).toBeCalledWith( - expect.objectContaining({ - variables: { - searchText: '', - currentPage: 2, - pageSize: 25, - filters: { - byActivated: true, - byDeleted: false, - }, - }, - }), - ) - }) - }) - - describe('apollo returns error', () => { - beforeEach(() => { - apolloQueryMock.mockRejectedValue({ - message: 'Ouch', - }) - wrapper = Wrapper() - }) - - it('toasts an error message', () => { - expect(toastErrorSpy).toBeCalledWith('Ouch') - }) - }) - }) -}) diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue deleted file mode 100644 index 26d44fd3e..000000000 --- a/admin/src/pages/Creation.vue +++ /dev/null @@ -1,200 +0,0 @@ - - diff --git a/admin/src/router/routes.js b/admin/src/router/routes.js index e365a6e40..b01466cfc 100644 --- a/admin/src/router/routes.js +++ b/admin/src/router/routes.js @@ -19,10 +19,6 @@ const routes = [ path: '/user', component: () => import('@/pages/UserSearch.vue'), }, - { - path: '/creation', - component: () => import('@/pages/Creation.vue'), - }, { path: '/creation-confirm', component: () => import('@/pages/CreationConfirm.vue'), From 484f03a53a539708eee82ce3d1f25e4a18737967 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 2 Feb 2023 18:22:35 +0100 Subject: [PATCH 02/25] remove unused keys from locals --- admin/src/locales/de.json | 7 ------- admin/src/locales/en.json | 7 ------- 2 files changed, 14 deletions(-) diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index 9612e3247..4f4a0c5bc 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -32,7 +32,6 @@ "creation": "Schöpfung", "creationList": "Schöpfungsliste", "creation_form": { - "creation_failed": "Ausstehende Schöpfung für {email} konnte nicht erzeugt werden.", "creation_for": "Aktives Grundeinkommen für", "enter_text": "Text eintragen", "form": "Schöpfungsformular", @@ -87,7 +86,6 @@ "lastname": "Nachname", "math": { "equals": "=", - "exclaim": "!", "pipe": "|", "plus": "+" }, @@ -95,15 +93,12 @@ "request": "Die Anfrage wurde gesendet." }, "moderator": "Moderator", - "multiple_creation_text": "Bitte wähle ein oder mehrere Mitglieder aus für die du Schöpfen möchtest.", "name": "Name", "navbar": { "automaticContributions": "Automatische Beiträge", "logout": "Abmelden", - "multi_creation": "Mehrfachschöpfung", "my-account": "Mein Konto", "open_creation": "Offene Schöpfungen", - "overview": "Übersicht", "statistic": "Statistik", "user_search": "Nutzersuche" }, @@ -132,9 +127,7 @@ } }, "redeemed": "eingelöst", - "remove": "Entfernen", "removeNotSelf": "Als Admin/Moderator kannst du dich nicht selber löschen.", - "remove_all": "alle Nutzer entfernen", "save": "Speichern", "statistic": { "activeUsers": "Aktive Mitglieder", diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index f9598d006..566273415 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -32,7 +32,6 @@ "creation": "Creation", "creationList": "Creation list", "creation_form": { - "creation_failed": "Could not create pending creation for {email}", "creation_for": "Active Basic Income for", "enter_text": "Enter text", "form": "Creation form", @@ -87,7 +86,6 @@ "lastname": "Lastname", "math": { "equals": "=", - "exclaim": "!", "pipe": "|", "plus": "+" }, @@ -95,15 +93,12 @@ "request": "Request has been sent." }, "moderator": "Moderator", - "multiple_creation_text": "Please select one or more members for which you would like to perform creations.", "name": "Name", "navbar": { "automaticContributions": "Automatic Contributions", "logout": "Logout", - "multi_creation": "Multiple creation", "my-account": "My Account", "open_creation": "Open creations", - "overview": "Overview", "statistic": "Statistic", "user_search": "User search" }, @@ -132,9 +127,7 @@ } }, "redeemed": "redeemed", - "remove": "Remove", "removeNotSelf": "As an admin/moderator, you cannot delete yourself.", - "remove_all": "Remove all users", "save": "Speichern", "statistic": { "activeUsers": "Active members", From 19475750340d7ef853bb226f457614e06422bc6c Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 2 Feb 2023 18:34:31 +0100 Subject: [PATCH 03/25] fix test --- admin/src/components/NavBar.spec.js | 20 ++++++-------------- admin/src/router/router.test.js | 9 +-------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/admin/src/components/NavBar.spec.js b/admin/src/components/NavBar.spec.js index 139172c30..96b7cba9c 100644 --- a/admin/src/components/NavBar.spec.js +++ b/admin/src/components/NavBar.spec.js @@ -46,39 +46,31 @@ describe('NavBar', () => { }) describe('Navbar Menu', () => { - it('has a link to overview', () => { - expect(wrapper.findAll('.nav-item').at(0).find('a').attributes('href')).toBe('/') - }) - it('has a link to /user', () => { - expect(wrapper.findAll('.nav-item').at(1).find('a').attributes('href')).toBe('/user') - }) - - it('has a link to /creation', () => { - expect(wrapper.findAll('.nav-item').at(2).find('a').attributes('href')).toBe('/creation') + expect(wrapper.findAll('.nav-item').at(0).find('a').attributes('href')).toBe('/user') }) it('has a link to /creation-confirm', () => { - expect(wrapper.findAll('.nav-item').at(3).find('a').attributes('href')).toBe( + expect(wrapper.findAll('.nav-item').at(1).find('a').attributes('href')).toBe( '/creation-confirm', ) }) it('has a link to /contribution-links', () => { - expect(wrapper.findAll('.nav-item').at(4).find('a').attributes('href')).toBe( + expect(wrapper.findAll('.nav-item').at(2).find('a').attributes('href')).toBe( '/contribution-links', ) }) it('has a link to /statistic', () => { - expect(wrapper.findAll('.nav-item').at(5).find('a').attributes('href')).toBe('/statistic') + expect(wrapper.findAll('.nav-item').at(3).find('a').attributes('href')).toBe('/statistic') }) }) describe('wallet', () => { const assignLocationSpy = jest.fn() beforeEach(async () => { - await wrapper.findAll('.nav-item').at(6).find('a').trigger('click') + await wrapper.findAll('.nav-item').at(5).find('a').trigger('click') }) it.skip('changes window location to wallet', () => { @@ -97,7 +89,7 @@ describe('NavBar', () => { window.location = { assign: windowLocationMock, } - await wrapper.findAll('.nav-item').at(7).find('a').trigger('click') + await wrapper.findAll('.nav-item').at(5).find('a').trigger('click') }) it('redirects to /logout', () => { diff --git a/admin/src/router/router.test.js b/admin/src/router/router.test.js index fdc4b0b83..ad1ad1245 100644 --- a/admin/src/router/router.test.js +++ b/admin/src/router/router.test.js @@ -45,7 +45,7 @@ describe('router', () => { describe('routes', () => { it('has nine routes defined', () => { - expect(routes).toHaveLength(9) + expect(routes).toHaveLength(8) }) it('has "/overview" as default', async () => { @@ -67,13 +67,6 @@ describe('router', () => { }) }) - describe('creation', () => { - it('loads the "Creation" component', async () => { - const component = await routes.find((r) => r.path === '/creation').component() - expect(component.default.name).toBe('Creation') - }) - }) - describe('creation-confirm', () => { it('loads the "CreationConfirm" component', async () => { const component = await routes.find((r) => r.path === '/creation-confirm').component() From a8c6534347d4961acad4328914d371cf2599165a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 3 Feb 2023 01:17:15 +0100 Subject: [PATCH 04/25] fix logger on contributionResolver --- .../resolver/ContributionResolver.test.ts | 124 +++++++++------- .../graphql/resolver/ContributionResolver.ts | 135 +++++++----------- 2 files changed, 123 insertions(+), 136 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index d48502c69..0078ecafd 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -132,13 +132,13 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('memo text is too short (5 characters minimum)')], + errors: [new GraphQLError('Memo text is too short')], }), ) }) 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', 4) }) it('throws error when memo length greater than 255 chars', async () => { @@ -155,13 +155,13 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('memo text is too long (255 characters maximum)')], + errors: [new GraphQLError('Memo text is too long')], }), ) }) 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', 259) }) it('throws error when creationDate not-valid', async () => { @@ -437,13 +437,13 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('No contribution found to given id.')], + errors: [new GraphQLError('Contribution not found')], }), ) }) it('logs the error found', () => { - expect(logger.error).toBeCalledWith('No contribution found to given id') + expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -463,13 +463,13 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('memo text is too short (5 characters minimum)')], + errors: [new GraphQLError('Memo text is too short')], }), ) }) 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', 4) }) }) @@ -489,13 +489,13 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('memo text is too long (255 characters maximum)')], + errors: [new GraphQLError('Memo text is too long')], }), ) }) 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', 259) }) }) @@ -521,18 +521,16 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [ - new GraphQLError( - 'user of the pending contribution and send user does not correspond', - ), - ], + errors: [new GraphQLError('Can not update contribution of another user')], }), ) }) it('logs the error found', () => { expect(logger.error).toBeCalledWith( - 'user of the pending contribution and send user does not correspond', + 'Can not update contribution of another user', + expect.any(Object), + expect.any(Number), ) }) }) @@ -553,12 +551,16 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('An admin is not allowed to update a user contribution.')], + errors: [new GraphQLError('An admin is not allowed to update an user contribution')], }), ) }) - // TODO check that the error is logged (need to modify AdminResolver, avoid conflicts) + it('logs the error found', () => { + expect(logger.error).toBeCalledWith( + 'An admin is not allowed to update an user contribution', + ) + }) }) describe('update too much so that the limit is exceeded', () => { @@ -615,16 +617,13 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('Currently the month of the contribution cannot change.')], + errors: [new GraphQLError('Month of contribution can not be changed')], }), ) }) - it.skip('logs the error found', () => { - expect(logger.error).toBeCalledWith( - 'No information for available creations with the given creationDate=', - 'Invalid Date', - ) + it('logs the error found', () => { + expect(logger.error).toBeCalledWith('Month of contribution can not be changed') }) }) @@ -1158,6 +1157,7 @@ describe('ContributionResolver', () => { describe('wrong contribution id', () => { it('returns an error', async () => { + jest.clearAllMocks() await expect( mutate({ mutation: deleteContribution, @@ -1167,18 +1167,19 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('Contribution not found for given id.')], + errors: [new GraphQLError('Contribution not found')], }), ) }) it('logs the error found', () => { - expect(logger.error).toBeCalledWith('Contribution not found for given id') + expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) describe('other user sends a deleteContribution', () => { it('returns an error', async () => { + jest.clearAllMocks() await mutate({ mutation: login, variables: { email: 'peter@lustig.de', password: 'Aa12345_' }, @@ -1198,7 +1199,11 @@ describe('ContributionResolver', () => { }) it('logs the error found', () => { - expect(logger.error).toBeCalledWith('Can not delete contribution of another user') + expect(logger.error).toBeCalledWith( + 'Can not delete contribution of another user', + expect.any(Object), + expect.any(Number), + ) }) }) @@ -1274,7 +1279,10 @@ describe('ContributionResolver', () => { }) it('logs the error found', () => { - expect(logger.error).toBeCalledWith('A confirmed contribution can not be deleted') + expect(logger.error).toBeCalledWith( + 'A confirmed contribution can not be deleted', + expect.objectContaining({ contributionStatus: 'CONFIRMED' }), + ) }) }) }) @@ -1540,15 +1548,13 @@ describe('ContributionResolver', () => { mutate({ mutation: adminCreateContribution, variables }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('Could not find user with email: bibi@bloxberg.de')], + errors: [new GraphQLError('Could not find user')], }), ) }) it('logs the error thrown', () => { - expect(logger.error).toBeCalledWith( - 'Could not find user with email: bibi@bloxberg.de', - ) + expect(logger.error).toBeCalledWith('Could not find user', 'bibi@bloxberg.de') }) }) @@ -1568,7 +1574,7 @@ describe('ContributionResolver', () => { ).resolves.toEqual( expect.objectContaining({ errors: [ - new GraphQLError('This user was deleted. Cannot create a contribution.'), + new GraphQLError('Cannot create contribution since the user was deleted'), ], }), ) @@ -1576,7 +1582,8 @@ describe('ContributionResolver', () => { it('logs the error thrown', () => { expect(logger.error).toBeCalledWith( - 'This user was deleted. Cannot create a contribution.', + 'Cannot create contribution since the user was deleted', + expect.objectContaining({ deletedAt: new Date('2018-03-14T09:17:52.000Z') }), ) }) }) @@ -1597,7 +1604,9 @@ describe('ContributionResolver', () => { ).resolves.toEqual( expect.objectContaining({ errors: [ - new GraphQLError('Contribution could not be saved, Email is not activated'), + new GraphQLError( + 'Cannot create contribution since the users email is not activated', + ), ], }), ) @@ -1605,7 +1614,8 @@ describe('ContributionResolver', () => { it('logs the error thrown', () => { expect(logger.error).toBeCalledWith( - 'Contribution could not be saved, Email is not activated', + 'Cannot create contribution since the users email is not activated', + expect.objectContaining({ emailChecked: false }), ) }) }) @@ -1624,13 +1634,13 @@ describe('ContributionResolver', () => { mutate({ mutation: adminCreateContribution, variables }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError(`invalid Date for creationDate=invalid-date`)], + errors: [new GraphQLError('CreationDate is invalid')], }), ) }) it('logs the error thrown', () => { - expect(logger.error).toBeCalledWith(`invalid Date for creationDate=invalid-date`) + expect(logger.error).toBeCalledWith('CreationDate is invalid', 'invalid-date') }) }) @@ -1826,17 +1836,13 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [ - new GraphQLError('Could not find UserContact with email: bob@baumeister.de'), - ], + errors: [new GraphQLError('Could not find UserContact')], }), ) }) it('logs the error thrown', () => { - expect(logger.error).toBeCalledWith( - 'Could not find UserContact with email: bob@baumeister.de', - ) + expect(logger.error).toBeCalledWith('Could not find UserContact', 'bob@baumeister.de') }) }) @@ -1856,13 +1862,13 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('User was deleted (stephen@hawking.uk)')], + errors: [new GraphQLError('User was deleted')], }), ) }) it('logs the error thrown', () => { - expect(logger.error).toBeCalledWith('User was deleted (stephen@hawking.uk)') + expect(logger.error).toBeCalledWith('User was deleted', 'stephen@hawking.uk') }) }) @@ -1882,13 +1888,13 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('No contribution found to given id.')], + errors: [new GraphQLError('Contribution not found')], }), ) }) it('logs the error thrown', () => { - expect(logger.error).toBeCalledWith('No contribution found to given id.') + expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -1912,7 +1918,7 @@ describe('ContributionResolver', () => { expect.objectContaining({ errors: [ new GraphQLError( - 'user of the pending contribution and send user does not correspond', + 'User of the pending contribution and send user does not correspond', ), ], }), @@ -1921,7 +1927,7 @@ describe('ContributionResolver', () => { it('logs the error thrown', () => { expect(logger.error).toBeCalledWith( - 'user of the pending contribution and send user does not correspond', + 'User of the pending contribution and send user does not correspond', ) }) }) @@ -2116,13 +2122,13 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('Contribution not found for given id.')], + errors: [new GraphQLError('Contribution not found')], }), ) }) it('logs the error thrown', () => { - expect(logger.error).toBeCalledWith('Contribution not found for given id: -1') + expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -2242,13 +2248,13 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('Contribution not found to given id.')], + errors: [new GraphQLError('Contribution not found')], }), ) }) it('logs the error thrown', () => { - expect(logger.error).toBeCalledWith('Contribution not found for given id: -1') + expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -2359,6 +2365,7 @@ describe('ContributionResolver', () => { describe('confirm same contribution again', () => { it('throws an error', async () => { + jest.clearAllMocks() await expect( mutate({ mutation: confirmContribution, @@ -2368,11 +2375,18 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('Contribution already confirmd.')], + errors: [new GraphQLError('Contribution already confirmed')], }), ) }) }) + + it('logs the error thrown', () => { + expect(logger.error).toBeCalledWith( + 'Contribution already confirmed', + expect.any(Number), + ) + }) }) describe('confirm two creations one after the other quickly', () => { diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index c7946d2c8..8765d29a8 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -53,6 +53,7 @@ import { sendContributionDeniedEmail, } from '@/emails/sendEmailVariants' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' +import LogError from '@/server/LogError' @Resolver() export class ContributionResolver { @@ -63,14 +64,11 @@ export class ContributionResolver { @Ctx() context: Context, ): Promise { const clientTimezoneOffset = getClientTimezoneOffset(context) - if (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)`) - } - if (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 LogError('Memo text is too short', memo.length) + } + if (memo.length > MEMO_MAX_CHARS) { + throw new LogError('Memo text is too long', memo.length) } const event = new Event() @@ -112,16 +110,13 @@ export class ContributionResolver { const user = getUser(context) const contribution = await DbContribution.findOne(id) if (!contribution) { - logger.error('Contribution not found for given id') - throw new Error('Contribution not found for given id.') + throw new LogError('Contribution not found', id) } if (contribution.userId !== user.id) { - logger.error('Can not delete contribution of another user') - throw new Error('Can not delete contribution of another user') + throw new LogError('Can not delete contribution of another user', contribution, user.id) } if (contribution.confirmedAt) { - logger.error('A confirmed contribution can not be deleted') - throw new Error('A confirmed contribution can not be deleted') + throw new LogError('A confirmed contribution can not be deleted', contribution) } contribution.contributionStatus = ContributionStatus.DELETED @@ -215,14 +210,11 @@ export class ContributionResolver { @Ctx() context: Context, ): Promise { const clientTimezoneOffset = getClientTimezoneOffset(context) - if (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)`) - } - if (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 LogError('Memo text is too short', memo.length) + } + if (memo.length > MEMO_MAX_CHARS) { + throw new LogError('Memo text is too long', memo.length) } const user = getUser(context) @@ -231,22 +223,22 @@ export class ContributionResolver { where: { id: contributionId, confirmedAt: IsNull(), deniedAt: IsNull() }, }) if (!contributionToUpdate) { - logger.error('No contribution found to given id') - throw new Error('No contribution found to given id.') + throw new LogError('Contribution not found', contributionId) } if (contributionToUpdate.userId !== user.id) { - logger.error('user of the pending contribution and send user does not correspond') - throw new Error('user of the pending contribution and send user does not correspond') + throw new LogError( + 'Can not update contribution of another user', + contributionToUpdate, + user.id, + ) } if ( contributionToUpdate.contributionStatus !== ContributionStatus.IN_PROGRESS && contributionToUpdate.contributionStatus !== ContributionStatus.PENDING ) { - logger.error( - `Contribution can not be updated since the state is ${contributionToUpdate.contributionStatus}`, - ) - throw new Error( - `Contribution can not be updated since the state is ${contributionToUpdate.contributionStatus}`, + throw new LogError( + 'Contribution can not be updated due to status', + contributionToUpdate.contributionStatus, ) } const creationDateObj = new Date(creationDate) @@ -254,8 +246,7 @@ export class ContributionResolver { if (contributionToUpdate.contributionDate.getMonth() === creationDateObj.getMonth()) { creations = updateCreations(creations, contributionToUpdate, clientTimezoneOffset) } else { - logger.error('Currently the month of the contribution cannot change.') - throw new Error('Currently the month of the contribution cannot change.') + throw new LogError('Month of contribution can not be changed') } // all possible cases not to be true are thrown in this function @@ -306,8 +297,7 @@ export class ContributionResolver { ) const clientTimezoneOffset = getClientTimezoneOffset(context) if (!isValidDateString(creationDate)) { - logger.error(`invalid Date for creationDate=${creationDate}`) - throw new Error(`invalid Date for creationDate=${creationDate}`) + throw new LogError('CreationDate is invalid', creationDate) } const emailContact = await UserContact.findOne({ where: { email }, @@ -315,20 +305,22 @@ export class ContributionResolver { relations: ['user'], }) if (!emailContact) { - logger.error(`Could not find user with email: ${email}`) - throw new Error(`Could not find user with email: ${email}`) + throw new LogError('Could not find user', email) } if (emailContact.deletedAt) { - logger.error('This emailContact was deleted. Cannot create a contribution.') - throw new Error('This emailContact was deleted. Cannot create a contribution.') + throw new LogError( + 'Cannot create contribution since the emailContact was deleted', + emailContact, + ) } if (emailContact.user.deletedAt) { - logger.error('This user was deleted. Cannot create a contribution.') - throw new Error('This user was deleted. Cannot create a contribution.') + throw new LogError('Cannot create contribution since the user was deleted', emailContact.user) } if (!emailContact.emailChecked) { - logger.error('Contribution could not be saved, Email is not activated') - throw new Error('Contribution could not be saved, Email is not activated') + throw new LogError( + 'Cannot create contribution since the users email is not activated', + emailContact, + ) } const event = new Event() @@ -404,17 +396,14 @@ export class ContributionResolver { relations: ['user'], }) if (!emailContact) { - logger.error(`Could not find UserContact with email: ${email}`) - throw new Error(`Could not find UserContact with email: ${email}`) + throw new LogError('Could not find UserContact', email) } const user = emailContact.user if (!user) { - logger.error(`Could not find User to emailContact: ${email}`) - throw new Error(`Could not find User to emailContact: ${email}`) + throw new LogError('Could not find User', email) } if (user.deletedAt) { - logger.error(`User was deleted (${email})`) - throw new Error(`User was deleted (${email})`) + throw new LogError('User was deleted', email) } const moderator = getUser(context) @@ -423,18 +412,15 @@ export class ContributionResolver { where: { id, confirmedAt: IsNull(), deniedAt: IsNull() }, }) if (!contributionToUpdate) { - logger.error('No contribution found to given id.') - throw new Error('No contribution found to given id.') + throw new LogError('Contribution not found', id) } if (contributionToUpdate.userId !== user.id) { - logger.error('user of the pending contribution and send user does not correspond') - throw new Error('user of the pending contribution and send user does not correspond') + throw new LogError('User of the pending contribution and send user does not correspond') } if (contributionToUpdate.moderatorId === null) { - logger.error('An admin is not allowed to update a user contribution.') - throw new Error('An admin is not allowed to update a user contribution.') + throw new LogError('An admin is not allowed to update an user contribution') } const creationDateObj = new Date(creationDate) @@ -443,8 +429,7 @@ export class ContributionResolver { if (contributionToUpdate.contributionDate.getMonth() === creationDateObj.getMonth()) { creations = updateCreations(creations, contributionToUpdate, clientTimezoneOffset) } else { - logger.error('Currently the month of the contribution cannot change.') - throw new Error('Currently the month of the contribution cannot change.') + throw new LogError('Month of contribution can not be changed') } // all possible cases not to be true are thrown in this function @@ -521,19 +506,17 @@ export class ContributionResolver { ): Promise { const contribution = await DbContribution.findOne(id) if (!contribution) { - logger.error(`Contribution not found for given id: ${id}`) - throw new Error('Contribution not found for given id.') + throw new LogError('Contribution not found', id) } if (contribution.confirmedAt) { - logger.error('A confirmed contribution can not be deleted') - throw new Error('A confirmed contribution can not be deleted') + throw new LogError('A confirmed contribution can not be deleted') } const moderator = getUser(context) if ( contribution.contributionType === ContributionType.USER && contribution.userId === moderator.id ) { - throw new Error('Own contribution can not be deleted as admin') + throw new LogError('Own contribution can not be deleted as admin') } const user = await DbUser.findOneOrFail( { id: contribution.userId }, @@ -577,29 +560,24 @@ export class ContributionResolver { const clientTimezoneOffset = getClientTimezoneOffset(context) const contribution = await DbContribution.findOne(id) if (!contribution) { - logger.error(`Contribution not found for given id: ${id}`) - throw new Error('Contribution not found to given id.') + throw new LogError('Contribution not found', id) } if (contribution.confirmedAt) { - logger.error(`Contribution already confirmd: ${id}`) - throw new Error('Contribution already confirmd.') + throw new LogError('Contribution already confirmed', id) } if (contribution.contributionStatus === 'DENIED') { - logger.error(`Contribution already denied: ${id}`) - throw new Error('Contribution already denied.') + throw new LogError('Contribution already denied', id) } const moderatorUser = getUser(context) if (moderatorUser.id === contribution.userId) { - logger.error('Moderator can not confirm own contribution') - throw new Error('Moderator can not confirm own contribution') + throw new LogError('Moderator can not confirm own contribution') } const user = await DbUser.findOneOrFail( { id: contribution.userId }, { withDeleted: true, relations: ['emailContact'] }, ) if (user.deletedAt) { - logger.error('This user was deleted. Cannot confirm a contribution.') - throw new Error('This user was deleted. Cannot confirm a contribution.') + throw new LogError('Can not confirm contribution since the user was deleted') } const creations = await getUserCreation(contribution.userId, clientTimezoneOffset, false) validateContribution( @@ -668,8 +646,7 @@ export class ContributionResolver { }) } catch (e) { await queryRunner.rollbackTransaction() - logger.error('Creation was not successful', e) - throw new Error('Creation was not successful.') + throw new LogError('Creation was not successful', e) } finally { await queryRunner.release() } @@ -744,17 +721,16 @@ export class ContributionResolver { deniedBy: IsNull(), }) if (!contributionToUpdate) { - logger.error(`Contribution not found for given id: ${id}`) - throw new Error(`Contribution not found for given id.`) + throw new LogError('Contribution not found', id) } if ( contributionToUpdate.contributionStatus !== ContributionStatus.IN_PROGRESS && contributionToUpdate.contributionStatus !== ContributionStatus.PENDING ) { - logger.error( - `Contribution state (${contributionToUpdate.contributionStatus}) is not allowed.`, + throw new LogError( + 'Status of the contribution is not allowed', + contributionToUpdate.contributionStatus, ) - throw new Error(`State of the contribution is not allowed.`) } const moderator = getUser(context) const user = await DbUser.findOne( @@ -762,10 +738,7 @@ export class ContributionResolver { { relations: ['emailContact'] }, ) if (!user) { - logger.error( - `Could not find User for the Contribution (userId: ${contributionToUpdate.userId}).`, - ) - throw new Error('Could not find User for the Contribution.') + throw new LogError('Could not find User of the Contribution', contributionToUpdate.userId) } contributionToUpdate.contributionStatus = ContributionStatus.DENIED From a918735630982175ba5684d1a7ff4132b9ff43b9 Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 3 Feb 2023 11:31:16 +0100 Subject: [PATCH 05/25] fix test over 96% --- .../ContributionLink/ContributionLink.spec.js | 28 +++++++++++++---- .../CreationTransactionList.spec.js | 11 +++++++ admin/src/locales/index.test.js | 18 +++++++++++ admin/src/pages/ContributionLinks.spec.js | 31 +++++++++++++++---- 4 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 admin/src/locales/index.test.js diff --git a/admin/src/components/ContributionLink/ContributionLink.spec.js b/admin/src/components/ContributionLink/ContributionLink.spec.js index b72a0347c..e0f09f9fd 100644 --- a/admin/src/components/ContributionLink/ContributionLink.spec.js +++ b/admin/src/components/ContributionLink/ContributionLink.spec.js @@ -42,14 +42,30 @@ describe('ContributionLink', () => { expect(wrapper.find('div.contribution-link').exists()).toBe(true) }) - it('emits toggle::collapse new Contribution', async () => { - wrapper.vm.editContributionLinkData() - expect(wrapper.vm.$root.$emit('bv::toggle::collapse', 'newContribution')).toBeTruthy() + describe('function editContributionLinkData', () => { + beforeEach(() => { + wrapper.vm.editContributionLinkData() + }) + it('emits toggle::collapse new Contribution', async () => { + await expect(wrapper.vm.$root.$emit('bv::toggle::collapse', 'newContribution')).toBeTruthy() + }) }) - it('emits toggle::collapse close Contribution-Form ', async () => { - wrapper.vm.closeContributionForm() - expect(wrapper.vm.$root.$emit('bv::toggle::collapse', 'newContribution')).toBeTruthy() + describe('function closeContributionForm', () => { + beforeEach(async () => { + await wrapper.setData({ visible: true }) + wrapper.vm.closeContributionForm() + }) + + it('emits toggle::collapse close Contribution-Form ', async () => { + await expect(wrapper.vm.$root.$emit('bv::toggle::collapse', 'newContribution')).toBeTruthy() + }) + it('editContributionLink is false', async () => { + await expect(wrapper.vm.editContributionLink).toBe(false) + }) + it('contributionLinkData is empty', async () => { + await expect(wrapper.vm.contributionLinkData).toEqual({}) + }) }) }) }) diff --git a/admin/src/components/CreationTransactionList.spec.js b/admin/src/components/CreationTransactionList.spec.js index ff9607424..9613942f8 100644 --- a/admin/src/components/CreationTransactionList.spec.js +++ b/admin/src/components/CreationTransactionList.spec.js @@ -88,5 +88,16 @@ describe('CreationTransactionList', () => { expect(toastErrorSpy).toBeCalledWith('OUCH!') }) }) + + describe('watch currentPage', () => { + beforeEach(async () => { + jest.clearAllMocks() + await wrapper.setData({ currentPage: 2 }) + }) + + it('returns the string in normal order if reversed property is not true', () => { + expect(wrapper.vm.currentPage).toBe(2) + }) + }) }) }) diff --git a/admin/src/locales/index.test.js b/admin/src/locales/index.test.js new file mode 100644 index 000000000..1abcadbec --- /dev/null +++ b/admin/src/locales/index.test.js @@ -0,0 +1,18 @@ +import locales from './index.js' + +describe('locales', () => { + it('should contain 2 locales', () => { + expect(locales).toHaveLength(2) + }) + + it('should contain a German locale', () => { + expect(locales).toContainEqual( + expect.objectContaining({ + name: 'Deutsch', + code: 'de', + iso: 'de-DE', + enabled: true, + }), + ) + }) +}) diff --git a/admin/src/pages/ContributionLinks.spec.js b/admin/src/pages/ContributionLinks.spec.js index fb60a99cf..3d91fdbe9 100644 --- a/admin/src/pages/ContributionLinks.spec.js +++ b/admin/src/pages/ContributionLinks.spec.js @@ -1,6 +1,7 @@ import { mount } from '@vue/test-utils' import ContributionLinks from './ContributionLinks.vue' import { listContributionLinks } from '@/graphql/listContributionLinks.js' +import { toastErrorSpy } from '../../test/testSetup' const localVue = global.localVue @@ -46,13 +47,31 @@ describe('ContributionLinks', () => { beforeEach(() => { wrapper = Wrapper() }) + describe('apollo returns', () => { + it('calls listContributionLinks', () => { + expect(apolloQueryMock).toBeCalledWith( + expect.objectContaining({ + query: listContributionLinks, + }), + ) + }) + }) - it('calls listContributionLinks', () => { - expect(apolloQueryMock).toBeCalledWith( - expect.objectContaining({ - query: listContributionLinks, - }), - ) + describe.skip('query transaction with error', () => { + beforeEach(() => { + apolloQueryMock.mockRejectedValue({ message: 'OUCH!' }) + wrapper = Wrapper() + }) + + it('calls the API', () => { + expect(apolloQueryMock).toBeCalled() + }) + + it('toast error', () => { + expect(toastErrorSpy).toBeCalledWith( + 'listContributionLinks has no result, use default data', + ) + }) }) }) }) From 3724295b6f2a959ce7615ae56191f6b9643fad7a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 6 Feb 2023 20:37:51 +0100 Subject: [PATCH 06/25] test another error case --- .../resolver/ContributionResolver.test.ts | 100 +++++++++++++----- 1 file changed, 75 insertions(+), 25 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 0078ecafd..dcbf0d52e 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -46,6 +46,7 @@ import { User } from '@entity/User' import { EventProtocolType } from '@/event/EventProtocolType' import { logger, i18n as localization } from '@test/testSetup' import { UserInputError } from 'apollo-server-express' +import { ContributionStatus } from '../enum/ContributionStatus' // mock account activation email to avoid console spam // mock account activation email to avoid console spam @@ -422,31 +423,6 @@ describe('ContributionResolver', () => { resetToken() }) - describe('wrong contribution id', () => { - it('throws an error', async () => { - jest.clearAllMocks() - await expect( - mutate({ - mutation: updateContribution, - variables: { - contributionId: -1, - amount: 100.0, - memo: 'Test env contribution', - creationDate: new Date().toString(), - }, - }), - ).resolves.toEqual( - expect.objectContaining({ - errors: [new GraphQLError('Contribution not found')], - }), - ) - }) - - it('logs the error found', () => { - expect(logger.error).toBeCalledWith('Contribution not found', -1) - }) - }) - describe('Memo length smaller than 5 chars', () => { it('throws error', async () => { jest.clearAllMocks() @@ -499,6 +475,31 @@ describe('ContributionResolver', () => { }) }) + describe('wrong contribution id', () => { + it('throws an error', async () => { + jest.clearAllMocks() + await expect( + mutate({ + mutation: updateContribution, + variables: { + contributionId: -1, + amount: 100.0, + memo: 'Test env contribution', + creationDate: new Date().toString(), + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('Contribution not found')], + }), + ) + }) + + it('logs the error found', () => { + expect(logger.error).toBeCalledWith('Contribution not found', -1) + }) + }) + describe('wrong user tries to update the contribution', () => { beforeAll(async () => { await mutate({ @@ -535,6 +536,7 @@ describe('ContributionResolver', () => { }) }) + // TODO: why is this here - this is a different call `adminUpdateContribution` not `updateContribution` describe('admin tries to update a user contribution', () => { it('throws an error', async () => { jest.clearAllMocks() @@ -563,6 +565,54 @@ describe('ContributionResolver', () => { }) }) + describe('contribution has wrong status', () => { + beforeAll(async () => { + const contribution = await Contribution.findOneOrFail({ + id: result.data.createContribution.id, + }) + contribution.contributionStatus = ContributionStatus.DELETED + contribution.save() + await mutate({ + mutation: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + }) + + afterAll(async () => { + const contribution = await Contribution.findOneOrFail({ + id: result.data.createContribution.id, + }) + contribution.contributionStatus = ContributionStatus.PENDING + contribution.save() + }) + + it('throws an error', async () => { + jest.clearAllMocks() + await expect( + mutate({ + mutation: updateContribution, + variables: { + contributionId: result.data.createContribution.id, + amount: 10.0, + memo: 'Test env contribution', + creationDate: new Date().toString(), + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('Contribution can not be updated due to status')], + }), + ) + }) + + it('logs the error found', () => { + expect(logger.error).toBeCalledWith( + 'Contribution can not be updated due to status', + ContributionStatus.DELETED, + ) + }) + }) + describe('update too much so that the limit is exceeded', () => { beforeAll(async () => { await mutate({ From 225652ecc77e4d221f1de3d3b19ca65589d3d065 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 6 Feb 2023 22:30:23 +0100 Subject: [PATCH 07/25] refactor adminCreateContribution to check for deleted users --- .../src/graphql/resolver/ContributionResolver.test.ts | 6 +++++- backend/src/graphql/resolver/ContributionResolver.ts | 10 ++-------- backend/src/seeds/users/stephen-hawking.ts | 1 + 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index dcbf0d52e..c3df9bd1d 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -1633,7 +1633,11 @@ describe('ContributionResolver', () => { it('logs the error thrown', () => { expect(logger.error).toBeCalledWith( 'Cannot create contribution since the user was deleted', - expect.objectContaining({ deletedAt: new Date('2018-03-14T09:17:52.000Z') }), + expect.objectContaining({ + user: expect.objectContaining({ + deletedAt: new Date('2018-03-14T09:17:52.000Z'), + }), + }), ) }) }) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 8765d29a8..340d99524 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -307,14 +307,8 @@ export class ContributionResolver { if (!emailContact) { throw new LogError('Could not find user', email) } - if (emailContact.deletedAt) { - throw new LogError( - 'Cannot create contribution since the emailContact was deleted', - emailContact, - ) - } - if (emailContact.user.deletedAt) { - throw new LogError('Cannot create contribution since the user was deleted', emailContact.user) + if (emailContact.deletedAt || emailContact.user.deletedAt) { + throw new LogError('Cannot create contribution since the user was deleted', emailContact) } if (!emailContact.emailChecked) { throw new LogError( diff --git a/backend/src/seeds/users/stephen-hawking.ts b/backend/src/seeds/users/stephen-hawking.ts index a683b7579..6c4f34d10 100644 --- a/backend/src/seeds/users/stephen-hawking.ts +++ b/backend/src/seeds/users/stephen-hawking.ts @@ -1,5 +1,6 @@ import { UserInterface } from './UserInterface' +// TODO: the generated email_contact is not deleted export const stephenHawking: UserInterface = { email: 'stephen@hawking.uk', firstName: 'Stephen', From bf24d15d96628615bcb6d3bb230c0cd722fc92e2 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 6 Feb 2023 22:37:38 +0100 Subject: [PATCH 08/25] unify checks on adminCreateContribution and adminUpdateContribution --- .../resolver/ContributionResolver.test.ts | 4 ++-- .../graphql/resolver/ContributionResolver.ts | 18 +++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index c3df9bd1d..1e0930d91 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -1890,13 +1890,13 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('Could not find UserContact')], + errors: [new GraphQLError('Could not find User')], }), ) }) it('logs the error thrown', () => { - expect(logger.error).toBeCalledWith('Could not find UserContact', 'bob@baumeister.de') + expect(logger.error).toBeCalledWith('Could not find User', 'bob@baumeister.de') }) }) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 340d99524..a845af022 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -304,7 +304,7 @@ export class ContributionResolver { withDeleted: true, relations: ['user'], }) - if (!emailContact) { + if (!emailContact || !emailContact.user) { throw new LogError('Could not find user', email) } if (emailContact.deletedAt || emailContact.user.deletedAt) { @@ -389,14 +389,10 @@ export class ContributionResolver { withDeleted: true, relations: ['user'], }) - if (!emailContact) { - throw new LogError('Could not find UserContact', email) - } - const user = emailContact.user - if (!user) { + if (!emailContact || !emailContact.user) { throw new LogError('Could not find User', email) } - if (user.deletedAt) { + if (emailContact.deletedAt || emailContact.user.deletedAt) { throw new LogError('User was deleted', email) } @@ -409,7 +405,7 @@ export class ContributionResolver { throw new LogError('Contribution not found', id) } - if (contributionToUpdate.userId !== user.id) { + if (contributionToUpdate.userId !== emailContact.user.id) { throw new LogError('User of the pending contribution and send user does not correspond') } @@ -418,7 +414,7 @@ export class ContributionResolver { } const creationDateObj = new Date(creationDate) - let creations = await getUserCreation(user.id, clientTimezoneOffset) + let creations = await getUserCreation(emailContact.user.id, clientTimezoneOffset) if (contributionToUpdate.contributionDate.getMonth() === creationDateObj.getMonth()) { creations = updateCreations(creations, contributionToUpdate, clientTimezoneOffset) @@ -441,11 +437,11 @@ export class ContributionResolver { result.memo = contributionToUpdate.memo result.date = contributionToUpdate.contributionDate - result.creation = await getUserCreation(user.id, clientTimezoneOffset) + result.creation = await getUserCreation(emailContact.user.id, clientTimezoneOffset) const event = new Event() const eventAdminContributionUpdate = new EventAdminContributionUpdate() - eventAdminContributionUpdate.userId = user.id + eventAdminContributionUpdate.userId = emailContact.user.id eventAdminContributionUpdate.amount = amount eventAdminContributionUpdate.contributionId = contributionToUpdate.id await eventProtocol.writeEvent( From 741d0c2b9717d1b1994bb251d33d10a0a66a42f6 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 6 Feb 2023 22:38:45 +0100 Subject: [PATCH 09/25] choose todo over coverage --- backend/src/graphql/resolver/ContributionResolver.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index a845af022..c68c34f99 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -416,6 +416,7 @@ export class ContributionResolver { const creationDateObj = new Date(creationDate) let creations = await getUserCreation(emailContact.user.id, clientTimezoneOffset) + // TODO: remove this restriction if (contributionToUpdate.contributionDate.getMonth() === creationDateObj.getMonth()) { creations = updateCreations(creations, contributionToUpdate, clientTimezoneOffset) } else { From 2773e270b73b1e54c00f65be9ad7ef65976622a3 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Feb 2023 14:12:44 +0100 Subject: [PATCH 10/25] Update backend/src/seeds/users/stephen-hawking.ts --- backend/src/seeds/users/stephen-hawking.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/seeds/users/stephen-hawking.ts b/backend/src/seeds/users/stephen-hawking.ts index 6c4f34d10..a683b7579 100644 --- a/backend/src/seeds/users/stephen-hawking.ts +++ b/backend/src/seeds/users/stephen-hawking.ts @@ -1,6 +1,5 @@ import { UserInterface } from './UserInterface' -// TODO: the generated email_contact is not deleted export const stephenHawking: UserInterface = { email: 'stephen@hawking.uk', firstName: 'Stephen', From 0caff31e0729dda4c15ac581ae6f4032fc811378 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Feb 2023 14:16:49 +0100 Subject: [PATCH 11/25] Update backend/src/graphql/resolver/ContributionResolver.test.ts --- backend/src/graphql/resolver/ContributionResolver.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 1e0930d91..c75f71f13 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -536,7 +536,6 @@ describe('ContributionResolver', () => { }) }) - // TODO: why is this here - this is a different call `adminUpdateContribution` not `updateContribution` describe('admin tries to update a user contribution', () => { it('throws an error', async () => { jest.clearAllMocks() From 5a987b5d09a494d0be96178e57e3ef5397e9df80 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 10 Feb 2023 08:16:55 +0100 Subject: [PATCH 12/25] add yarn locales functionality to backend --- backend/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/package.json b/backend/package.json index f58a1ddd3..413ddeb4c 100644 --- a/backend/package.json +++ b/backend/package.json @@ -15,7 +15,8 @@ "lint": "eslint --max-warnings=0 --ext .js,.ts .", "test": "cross-env TZ=UTC NODE_ENV=development jest --runInBand --coverage --forceExit --detectOpenHandles", "seed": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/index.ts", - "klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/klicktipp.ts" + "klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/klicktipp.ts", + "locales": "scripts/sort.sh" }, "dependencies": { "@hyperswarm/dht": "^6.2.0", From fa72f9666a0038071c575034cc6092be8932a7c1 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 10 Feb 2023 08:21:39 +0100 Subject: [PATCH 13/25] sort backend locales using yarn lint --fix --- backend/src/locales/de.json | 10 +++++----- backend/src/locales/en.json | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/src/locales/de.json b/backend/src/locales/de.json index 304ae2adc..530e8db10 100644 --- a/backend/src/locales/de.json +++ b/backend/src/locales/de.json @@ -1,10 +1,5 @@ { "emails": { - "addedContributionMessage": { - "commonGoodContributionMessage": "du hast zu deinem Gemeinwohl-Beitrag „{contributionMemo}“ eine Nachricht von {senderFirstName} {senderLastName} erhalten.", - "subject": "Gradido: Nachricht zu deinem Gemeinwohl-Beitrag", - "toSeeAndAnswerMessage": "Um die Nachricht zu sehen und darauf zu antworten, gehe in deinem Gradido-Konto ins Menü „Gemeinschaft“ auf den Tab „Meine Beiträge zum Gemeinwohl“!" - }, "accountActivation": { "duration": "Der Link hat eine Gültigkeit von {hours} Stunden und {minutes} Minuten. Sollte die Gültigkeit des Links bereits abgelaufen sein, kannst du dir hier einen neuen Link schicken lassen:", "emailRegistered": "deine E-Mail-Adresse wurde soeben bei Gradido registriert.", @@ -19,6 +14,11 @@ "onForgottenPasswordCopyLink": "oder kopiere den obigen Link in dein Browserfenster.", "subject": "Gradido: Erneuter Registrierungsversuch mit deiner E-Mail" }, + "addedContributionMessage": { + "commonGoodContributionMessage": "du hast zu deinem Gemeinwohl-Beitrag „{contributionMemo}“ eine Nachricht von {senderFirstName} {senderLastName} erhalten.", + "subject": "Gradido: Nachricht zu deinem Gemeinwohl-Beitrag", + "toSeeAndAnswerMessage": "Um die Nachricht zu sehen und darauf zu antworten, gehe in deinem Gradido-Konto ins Menü „Gemeinschaft“ auf den Tab „Meine Beiträge zum Gemeinwohl“!" + }, "contributionConfirmed": { "commonGoodContributionConfirmed": "dein Gemeinwohl-Beitrag „{contributionMemo}“ wurde soeben von {senderFirstName} {senderLastName} bestätigt und in deinem Gradido-Konto gutgeschrieben.", "subject": "Gradido: Dein Gemeinwohl-Beitrag wurde bestätigt" diff --git a/backend/src/locales/en.json b/backend/src/locales/en.json index bdc92b2cf..269c38629 100644 --- a/backend/src/locales/en.json +++ b/backend/src/locales/en.json @@ -1,10 +1,5 @@ { "emails": { - "addedContributionMessage": { - "commonGoodContributionMessage": "you have received a message from {senderFirstName} {senderLastName} regarding your common good contribution “{contributionMemo}”.", - "subject": "Gradido: Message about your common good contribution", - "toSeeAndAnswerMessage": "To view and reply to the message, go to the “Community” menu in your Gradido account and click on the “My contributions to the common good” tab!" - }, "accountActivation": { "duration": "The link has a validity of {hours} hours and {minutes} minutes. If the validity of the link has already expired, you can have a new link sent to you here:", "emailRegistered": "Your email address has just been registered with Gradido.", @@ -19,6 +14,11 @@ "onForgottenPasswordCopyLink": "or copy the link above into your browser window.", "subject": "Gradido: Try To Register Again With Your Email" }, + "addedContributionMessage": { + "commonGoodContributionMessage": "you have received a message from {senderFirstName} {senderLastName} regarding your common good contribution “{contributionMemo}”.", + "subject": "Gradido: Message about your common good contribution", + "toSeeAndAnswerMessage": "To view and reply to the message, go to the “Community” menu in your Gradido account and click on the “My contributions to the common good” tab!" + }, "contributionConfirmed": { "commonGoodContributionConfirmed": "Your public good contribution “{contributionMemo}” has just been confirmed by {senderFirstName} {senderLastName} and credited to your Gradido account.", "subject": "Gradido: Your contribution to the common good was confirmed" From a3e2b34ff33f778d0bae754a5a7ff63aec27dc62 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 10 Feb 2023 08:30:58 +0100 Subject: [PATCH 14/25] add backend linting to github test workflow --- .github/workflows/test.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index da8521a76..695011c11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -360,6 +360,35 @@ jobs: - name: backend | Lint run: docker run --rm gradido/backend:test yarn run lint + ############################################################################## + # JOB: LOCALES BACKEND ####################################################### + ############################################################################## + locales_frontend: + name: Locales - Backend + runs-on: ubuntu-latest + needs: [build_test_backend] + steps: + ########################################################################## + # CHECKOUT CODE ########################################################## + ########################################################################## + - name: Checkout code + uses: actions/checkout@v3 + ########################################################################## + # DOWNLOAD DOCKER IMAGE ################################################## + ########################################################################## + - name: Download Docker Image (Backend) + uses: actions/download-artifact@v3 + with: + name: docker-backendend-test + path: /tmp + - name: Load Docker Image + run: docker load < /tmp/backend.tar + ########################################################################## + # LOCALES FRONTEND ####################################################### + ########################################################################## + - name: Backendend | Locales + run: docker run --rm gradido/backend:test yarn run locales + ############################################################################## # JOB: LINT DATABASE UP ###################################################### ############################################################################## From ee5aea4c85dc85b6b42ac794c2edf1b52708379d Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 10 Feb 2023 08:47:28 +0100 Subject: [PATCH 15/25] fix typo in github test workflow --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 695011c11..7b9bf09f2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -363,7 +363,7 @@ jobs: ############################################################################## # JOB: LOCALES BACKEND ####################################################### ############################################################################## - locales_frontend: + locales_backend: name: Locales - Backend runs-on: ubuntu-latest needs: [build_test_backend] From 592e1c11c51515ff93af70d1b4590db5848d102e Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 10 Feb 2023 08:47:28 +0100 Subject: [PATCH 16/25] fix typo in github test workflow --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7b9bf09f2..c1ff5b97c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -379,7 +379,7 @@ jobs: - name: Download Docker Image (Backend) uses: actions/download-artifact@v3 with: - name: docker-backendend-test + name: docker-backend-test path: /tmp - name: Load Docker Image run: docker load < /tmp/backend.tar From cf0e7f18ff4a5d7e37c6b847107d5fcff72644f5 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 10 Feb 2023 09:04:36 +0100 Subject: [PATCH 17/25] add scripts for locales check to backend --- backend/scripts/sort.sh | 25 +++++++++++++++++++++++++ backend/scripts/sort_filter.jq | 13 +++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 backend/scripts/sort.sh create mode 100644 backend/scripts/sort_filter.jq diff --git a/backend/scripts/sort.sh b/backend/scripts/sort.sh new file mode 100755 index 000000000..e5c5c41c6 --- /dev/null +++ b/backend/scripts/sort.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +ROOT_DIR=$(dirname "$0")/.. + +tmp=$(mktemp) +exit_code=0 + +for locale_file in $ROOT_DIR/src/locales/*.json +do + jq -f $(dirname "$0")/sort_filter.jq $locale_file > "$tmp" + if [ "$*" == "--fix" ] + then + mv "$tmp" $locale_file + else + if diff -q "$tmp" $locale_file > /dev/null ; + then + : # all good + else + exit_code=$? + echo "$(basename -- $locale_file) is not sorted by keys" + fi + fi +done + +exit $exit_code diff --git a/backend/scripts/sort_filter.jq b/backend/scripts/sort_filter.jq new file mode 100644 index 000000000..9d108f8f0 --- /dev/null +++ b/backend/scripts/sort_filter.jq @@ -0,0 +1,13 @@ +def walk(f): + . as $in + | if type == "object" then + reduce keys_unsorted[] as $key + ( {}; . + { ($key): ($in[$key] | walk(f)) } ) | f + elif type == "array" then map( walk(f) ) | f + else f + end; + +def keys_sort_by(f): + to_entries | sort_by(.key|f ) | from_entries; + +walk(if type == "object" then keys_sort_by(ascii_upcase) else . end) \ No newline at end of file From 7be46f5e681a49d2a5d8f3dd1ead93666d4da385 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 10 Feb 2023 12:25:42 +0100 Subject: [PATCH 18/25] Add pwd before yarn run locales --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1ff5b97c..83a3f5cd6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -358,7 +358,7 @@ jobs: # LINT BACKEND ########################################################### ########################################################################## - name: backend | Lint - run: docker run --rm gradido/backend:test yarn run lint + run: docker run --rm gradido/backend:test pwd && yarn run lint ############################################################################## # JOB: LOCALES BACKEND ####################################################### From 73c38d7ecbfe1fafa9f4172d56dc4104869c30cb Mon Sep 17 00:00:00 2001 From: Hannes Heine Date: Fri, 10 Feb 2023 13:56:55 +0100 Subject: [PATCH 19/25] Update .github/workflows/test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83a3f5cd6..c1ff5b97c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -358,7 +358,7 @@ jobs: # LINT BACKEND ########################################################### ########################################################################## - name: backend | Lint - run: docker run --rm gradido/backend:test pwd && yarn run lint + run: docker run --rm gradido/backend:test yarn run lint ############################################################################## # JOB: LOCALES BACKEND ####################################################### From 5fdd056623974b7aa035fe7bef3c468488f8aa17 Mon Sep 17 00:00:00 2001 From: Hannes Heine Date: Fri, 10 Feb 2023 13:57:02 +0100 Subject: [PATCH 20/25] Update .github/workflows/test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1ff5b97c..db1fc6099 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -387,7 +387,7 @@ jobs: # LOCALES FRONTEND ####################################################### ########################################################################## - name: Backendend | Locales - run: docker run --rm gradido/backend:test yarn run locales + run: docker run --rm gradido/backend:test pwd && yarn run locales ############################################################################## # JOB: LINT DATABASE UP ###################################################### From da8f371823a434b95edd4b79e9ca9c2b8df7b06c Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 10 Feb 2023 14:11:49 +0100 Subject: [PATCH 21/25] Debugging docker... --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index db1fc6099..548a858a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -387,7 +387,7 @@ jobs: # LOCALES FRONTEND ####################################################### ########################################################################## - name: Backendend | Locales - run: docker run --rm gradido/backend:test pwd && yarn run locales + run: docker run --rm gradido/backend:test pwd && ls -halt && yarn run locales ############################################################################## # JOB: LINT DATABASE UP ###################################################### From 786876a46deac1bc886103dace18720d8f6822de Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 10 Feb 2023 14:24:50 +0100 Subject: [PATCH 22/25] Yarn locales is in backend not under gradido. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 548a858a6..b9d9edd5f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -387,7 +387,7 @@ jobs: # LOCALES FRONTEND ####################################################### ########################################################################## - name: Backendend | Locales - run: docker run --rm gradido/backend:test pwd && ls -halt && yarn run locales + run: docker run --rm gradido/backend:test cd backend && yarn run locales ############################################################################## # JOB: LINT DATABASE UP ###################################################### From a88968d3da3f1996500382b1ca297b2bd5c66ad8 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 10 Feb 2023 15:14:13 +0100 Subject: [PATCH 23/25] Change structure to locales check --- .github/workflows/test.yml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b9d9edd5f..c204eb321 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -374,20 +374,10 @@ jobs: - name: Checkout code uses: actions/checkout@v3 ########################################################################## - # DOWNLOAD DOCKER IMAGE ################################################## + # LOCALES BACKEND ##################################################### ########################################################################## - - name: Download Docker Image (Backend) - uses: actions/download-artifact@v3 - with: - name: docker-backend-test - path: /tmp - - name: Load Docker Image - run: docker load < /tmp/backend.tar - ########################################################################## - # LOCALES FRONTEND ####################################################### - ########################################################################## - - name: Backendend | Locales - run: docker run --rm gradido/backend:test cd backend && yarn run locales + - name: Backend | Locales + run: cd backend && yarn && yarn locales ############################################################################## # JOB: LINT DATABASE UP ###################################################### From 25b1a6de447c21b6c836fcd25a68c6b362885853 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Feb 2023 15:55:16 +0100 Subject: [PATCH 24/25] fix(admin): deny contribution button to left --- admin/src/pages/CreationConfirm.spec.js | 2 +- admin/src/pages/CreationConfirm.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index d47233ded..99dbda219 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -259,7 +259,7 @@ describe('CreationConfirm', () => { describe('deny creation', () => { beforeEach(async () => { - await wrapper.findAll('tr').at(1).findAll('button').at(2).trigger('click') + await wrapper.findAll('tr').at(1).findAll('button').at(1).trigger('click') }) it('opens the overlay', () => { diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index e87dfc247..c6576e5ba 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -129,6 +129,7 @@ export default { fields() { return [ { key: 'bookmark', label: this.$t('delete') }, + { key: 'deny', label: this.$t('deny') }, { key: 'email', label: this.$t('e_mail') }, { key: 'firstName', label: this.$t('firstname') }, { key: 'lastName', label: this.$t('lastname') }, @@ -149,7 +150,6 @@ export default { }, { key: 'moderator', label: this.$t('moderator') }, { key: 'editCreation', label: this.$t('edit') }, - { key: 'deny', label: this.$t('deny') }, { key: 'confirm', label: this.$t('save') }, ] }, From ac250181ef3ed7f50a34be1f59386c1de403063c Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Feb 2023 16:09:33 +0100 Subject: [PATCH 25/25] chore(release): version 1.18.2 --- CHANGELOG.md | 7 +++++++ admin/package.json | 2 +- backend/package.json | 2 +- database/package.json | 2 +- frontend/package.json | 2 +- package.json | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 366339834..4bfc66e39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,15 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.18.2](https://github.com/gradido/gradido/compare/1.18.1...1.18.2) + +- fix(admin): deny contribution button to left [`#2699`](https://github.com/gradido/gradido/pull/2699) + #### [1.18.1](https://github.com/gradido/gradido/compare/1.18.0...1.18.1) +> 10 February 2023 + +- chore(release): version 1.18.1 [`#2698`](https://github.com/gradido/gradido/pull/2698) - fix(frontend): fix is last month for empty form date [`#2697`](https://github.com/gradido/gradido/pull/2697) - fix(frontend): community link [`#2696`](https://github.com/gradido/gradido/pull/2696) diff --git a/admin/package.json b/admin/package.json index e443e7f9e..941a9bf69 100644 --- a/admin/package.json +++ b/admin/package.json @@ -3,7 +3,7 @@ "description": "Administraion Interface for Gradido", "main": "index.js", "author": "Moriz Wahl", - "version": "1.18.1", + "version": "1.18.2", "license": "Apache-2.0", "private": false, "scripts": { diff --git a/backend/package.json b/backend/package.json index 5357a7217..320f4ded6 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "gradido-backend", - "version": "1.18.1", + "version": "1.18.2", "description": "Gradido unified backend providing an API-Service for Gradido Transactions", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/backend", diff --git a/database/package.json b/database/package.json index 7fad11216..5be01a5d5 100644 --- a/database/package.json +++ b/database/package.json @@ -1,6 +1,6 @@ { "name": "gradido-database", - "version": "1.18.1", + "version": "1.18.2", "description": "Gradido Database Tool to execute database migrations", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/database", diff --git a/frontend/package.json b/frontend/package.json index 64fde2b19..9aa457c19 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap-vue-gradido-wallet", - "version": "1.18.1", + "version": "1.18.2", "private": true, "scripts": { "start": "node run/server.js", diff --git a/package.json b/package.json index 2cb1b5dc5..2220c1a85 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gradido", - "version": "1.18.1", + "version": "1.18.2", "description": "Gradido", "main": "index.js", "repository": "git@github.com:gradido/gradido.git",