diff --git a/admin/src/components/CreationFormular.spec.js b/admin/src/components/CreationFormular.spec.js
index fcdf97cfa..e1bbff1cc 100644
--- a/admin/src/components/CreationFormular.spec.js
+++ b/admin/src/components/CreationFormular.spec.js
@@ -3,6 +3,16 @@ import CreationFormular from './CreationFormular.vue'
const localVue = global.localVue
+const apolloMock = jest.fn().mockResolvedValue({
+ data: {
+ verifyLogin: {
+ name: 'success',
+ id: 0,
+ },
+ },
+})
+const stateCommitMock = jest.fn()
+
const mocks = {
$moment: jest.fn(() => {
return {
@@ -14,6 +24,12 @@ const mocks = {
}),
}
}),
+ $apollo: {
+ query: apolloMock,
+ },
+ $store: {
+ commit: stateCommitMock,
+ },
}
const propsData = {
@@ -39,6 +55,23 @@ describe('CreationFormular', () => {
expect(wrapper.find('.component-creation-formular').exists()).toBeTruthy()
})
+ describe('server sends back moderator data', () => {
+ it('called store commit with mocked data', () => {
+ expect(stateCommitMock).toBeCalledWith('moderator', { name: 'success', id: 0 })
+ })
+ })
+
+ describe('server throws error for moderator data call', () => {
+ beforeEach(() => {
+ jest.clearAllMocks()
+ apolloMock.mockRejectedValue({ message: 'Ouch!' })
+ wrapper = Wrapper()
+ })
+ it('has called store commit with fake data', () => {
+ expect(stateCommitMock).toBeCalledWith('moderator', { id: 0, name: 'Test Moderator' })
+ })
+ })
+
describe('radio buttons to selcet month', () => {
it('has three radio buttons', () => {
expect(wrapper.findAll('input[type="radio"]').length).toBe(3)
diff --git a/admin/src/components/EditCreationFormular.spec.js b/admin/src/components/EditCreationFormular.spec.js
new file mode 100644
index 000000000..2f29cb812
--- /dev/null
+++ b/admin/src/components/EditCreationFormular.spec.js
@@ -0,0 +1,143 @@
+import { mount } from '@vue/test-utils'
+import EditCreationFormular from './EditCreationFormular.vue'
+
+const localVue = global.localVue
+
+const apolloMock = jest.fn().mockResolvedValue({
+ data: {
+ verifyLogin: {
+ name: 'success',
+ id: 0,
+ },
+ },
+})
+const apolloMutateMock = jest.fn().mockResolvedValue({
+ data: {
+ updatePendingCreation: {
+ creation: [0, 0, 0],
+ date: new Date(),
+ memo: 'qwertzuiopasdfghjkl',
+ moderator: 0,
+ },
+ },
+})
+const stateCommitMock = jest.fn()
+
+const mocks = {
+ $moment: jest.fn(() => {
+ return {
+ format: jest.fn((m) => m),
+ subtract: jest.fn(() => {
+ return {
+ format: jest.fn((m) => m),
+ }
+ }),
+ }
+ }),
+ $apollo: {
+ query: apolloMock,
+ mutate: apolloMutateMock,
+ },
+ $store: {
+ commit: stateCommitMock,
+ },
+}
+
+const propsData = {
+ type: '',
+ item: {},
+ row: [],
+ creation: [],
+ itemsMassCreation: {},
+}
+
+describe('EditCreationFormular', () => {
+ let wrapper
+
+ const Wrapper = () => {
+ return mount(EditCreationFormular, { localVue, mocks, propsData })
+ }
+
+ describe('mount', () => {
+ beforeEach(() => {
+ wrapper = Wrapper()
+ })
+
+ it('has a DIV element with the class.component-edit-creation-formular', () => {
+ expect(wrapper.find('.component-edit-creation-formular').exists()).toBeTruthy()
+ })
+
+ describe('server sends back moderator data', () => {
+ it('called store commit with mocked data', () => {
+ expect(stateCommitMock).toBeCalledWith('moderator', { name: 'success', id: 0 })
+ })
+ })
+
+ describe('server throws error for moderator data call', () => {
+ beforeEach(() => {
+ jest.clearAllMocks()
+ apolloMock.mockRejectedValue({ message: 'Ouch!' })
+ wrapper = Wrapper()
+ })
+ it('has called store commit with fake data', () => {
+ expect(stateCommitMock).toBeCalledWith('moderator', { id: 0, name: 'Test Moderator' })
+ })
+ })
+
+ describe('radio buttons to selcet month', () => {
+ it('has three radio buttons', () => {
+ expect(wrapper.findAll('input[type="radio"]').length).toBe(3)
+ })
+
+ describe('with single creation', () => {
+ beforeEach(async () => {
+ jest.clearAllMocks()
+ await wrapper.setProps({ type: 'singleCreation', creation: [200, 400, 600] })
+ await wrapper.setData({ rangeMin: 180 })
+ })
+
+ describe('first radio button', () => {
+ beforeEach(async () => {
+ await wrapper.findAll('input[type="radio"]').at(0).setChecked()
+ })
+
+ it('sets rangeMin to 0', () => {
+ expect(wrapper.vm.rangeMin).toBe(0)
+ })
+
+ it('sets rangeMax to 200', () => {
+ expect(wrapper.vm.rangeMax).toBe(200)
+ })
+ })
+
+ describe('second radio button', () => {
+ beforeEach(async () => {
+ await wrapper.findAll('input[type="radio"]').at(1).setChecked()
+ })
+
+ it('sets rangeMin to 0', () => {
+ expect(wrapper.vm.rangeMin).toBe(0)
+ })
+
+ it('sets rangeMax to 400', () => {
+ expect(wrapper.vm.rangeMax).toBe(400)
+ })
+ })
+
+ describe('third radio button', () => {
+ beforeEach(async () => {
+ await wrapper.findAll('input[type="radio"]').at(2).setChecked()
+ })
+
+ it('sets rangeMin to 0', () => {
+ expect(wrapper.vm.rangeMin).toBe(0)
+ })
+
+ it('sets rangeMax to 400', () => {
+ expect(wrapper.vm.rangeMax).toBe(600)
+ })
+ })
+ })
+ })
+ })
+})
diff --git a/admin/src/components/EditCreationFormular.vue b/admin/src/components/EditCreationFormular.vue
index cfad75e6f..d3e362b5d 100644
--- a/admin/src/components/EditCreationFormular.vue
+++ b/admin/src/components/EditCreationFormular.vue
@@ -120,8 +120,9 @@
diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js
index 6598738f1..cd7edf680 100644
--- a/admin/src/pages/CreationConfirm.spec.js
+++ b/admin/src/pages/CreationConfirm.spec.js
@@ -60,8 +60,11 @@ describe('CreationConfirm', () => {
})
describe('store', () => {
- it('commits openCreationsPlus to store', () => {
- expect(storeCommitMock).toBeCalledWith('openCreationsPlus', 2)
+ it('commits resetOpenCreations to store', () => {
+ expect(storeCommitMock).toBeCalledWith('resetOpenCreations')
+ })
+ it('commits setOpenCreations to store', () => {
+ expect(storeCommitMock).toBeCalledWith('setOpenCreations', 2)
})
})
diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue
index cf15fb64f..3aef891eb 100644
--- a/admin/src/pages/CreationConfirm.vue
+++ b/admin/src/pages/CreationConfirm.vue
@@ -64,15 +64,15 @@ export default {
this.$store.commit('openCreationsMinus', 1)
}
},
- async getPendingCreations() {
+ getPendingCreations() {
this.$apollo
.query({
query: getPendingCreations,
})
.then((result) => {
- this.confirmResult = result.data.getPendingCreations
this.$store.commit('resetOpenCreations')
- this.$store.commit('openCreationsPlus', result.data.getPendingCreations.length)
+ this.confirmResult = result.data.getPendingCreations.reverse()
+ this.$store.commit('setOpenCreations', result.data.getPendingCreations.length)
})
.catch((error) => {
this.$toasted.error(error.message)
diff --git a/admin/src/pages/Overview.vue b/admin/src/pages/Overview.vue
index b9b9e1723..8d05e03e8 100644
--- a/admin/src/pages/Overview.vue
+++ b/admin/src/pages/Overview.vue
@@ -64,11 +64,7 @@ export default {
query: getPendingCreations,
})
.then((result) => {
- this.$store.commit('resetOpenCreations')
- this.$store.commit('openCreationsPlus', result.data.getPendingCreations.length)
- })
- .catch((error) => {
- this.$toasted.error(error.message)
+ this.$store.commit('setOpenCreations', result.data.getPendingCreations.length)
})
},
},
diff --git a/backend/src/webhook/elopage.ts b/backend/src/webhook/elopage.ts
index 9e2ddeb81..eb46b10e8 100644
--- a/backend/src/webhook/elopage.ts
+++ b/backend/src/webhook/elopage.ts
@@ -1,3 +1,5 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
+/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/*
Elopage Webhook
diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json
index b0dfe36d4..1e8bfb621 100644
--- a/frontend/src/locales/de.json
+++ b/frontend/src/locales/de.json
@@ -114,6 +114,11 @@
"message": "hallo gradido !!",
"overview": "Übersicht",
"privacy_policy": "Datenschutzerklärung",
+ "publisher": {
+ "infoNoRegister": "Dies ist für die Registrieung nicht nötig!",
+ "infoText": "Trage hier die ID des Herausgebers ein. Wenn du keine ID hast dann bitte leer lassen.",
+ "publisherId": "PublisherID"
+ },
"send": "Senden",
"settings": {
"coinanimation": {
diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json
index 135729ffa..f473ff798 100644
--- a/frontend/src/locales/en.json
+++ b/frontend/src/locales/en.json
@@ -114,6 +114,11 @@
"message": "hello gradido !!",
"overview": "Overview",
"privacy_policy": "Privacy policy",
+ "publisher": {
+ "infoNoRegister": "This is not necessary for registration!",
+ "infoText": "Enter the ID of the publisher here. If you do not have an ID, please leave it blank.",
+ "publisherId": "PublisherID"
+ },
"send": "Send",
"settings": {
"coinanimation": {
diff --git a/frontend/src/store/store.test.js b/frontend/src/store/store.test.js
index 829678b44..4f25f5352 100644
--- a/frontend/src/store/store.test.js
+++ b/frontend/src/store/store.test.js
@@ -11,6 +11,7 @@ const {
coinanimation,
newsletterState,
publisherId,
+ isAdmin,
community,
hasElopage,
} = mutations
@@ -104,6 +105,14 @@ describe('Vuex store', () => {
})
})
+ describe('isAdmin', () => {
+ it('sets the state of isAdmin', () => {
+ const state = { isAdmin: null }
+ isAdmin(state, true)
+ expect(state.isAdmin).toEqual(true)
+ })
+ })
+
describe('community', () => {
it('sets the state of community', () => {
const state = {}
diff --git a/frontend/src/views/Pages/Register.spec.js b/frontend/src/views/Pages/Register.spec.js
index c63de66cf..d6814bd49 100644
--- a/frontend/src/views/Pages/Register.spec.js
+++ b/frontend/src/views/Pages/Register.spec.js
@@ -170,6 +170,11 @@ describe('Register', () => {
expect(wrapper.find('#registerCheckbox').exists()).toBeTruthy()
})
+ it('has PublisherId input fields', () => {
+ wrapper.find('.publisherCollaps').trigger('click')
+ expect(wrapper.find('#publisherid').exists()).toBe(true)
+ })
+
it('has disabled submit button when not completely filled', () => {
expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe('disabled')
})
@@ -221,6 +226,11 @@ describe('Register', () => {
wrapper.find('input[name="form.password"]').setValue('Aa123456_')
wrapper.find('input[name="form.passwordRepeat"]').setValue('Aa123456_')
wrapper.find('.language-switch-select').findAll('option').at(1).setSelected()
+ wrapper.find('#publisherid').setValue('12345')
+ })
+
+ it('commits publisherId to store', () => {
+ expect(mockStoreCommit).toBeCalledWith('publisherId', 12345)
})
it('has enabled submit button when completely filled', () => {
diff --git a/frontend/src/views/Pages/Register.vue b/frontend/src/views/Pages/Register.vue
index ea4000cff..8669781a4 100755
--- a/frontend/src/views/Pages/Register.vue
+++ b/frontend/src/views/Pages/Register.vue
@@ -121,8 +121,44 @@
{{ messageError }}
+