From 489743b6d6750b8e23fe063f39a863fcf7a4975b Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 5 Nov 2021 13:50:10 +0100 Subject: [PATCH 01/33] add navbar and routes --- admin/src/App.vue | 9 ++++++++- admin/src/components/NavBar.vue | 19 +++++++++++++++++++ admin/src/components/UserTable.vue | 24 ++++++++++++++++++++++++ admin/src/main.js | 2 ++ admin/src/router/routes.js | 29 ++++++++++++++++++++++++++--- admin/src/views/Creation.vue | 9 +++++++++ admin/src/views/Overview.vue | 21 +++++++++++++++++++++ admin/src/views/UserSearch.vue | 9 +++++++++ 8 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 admin/src/components/NavBar.vue create mode 100644 admin/src/components/UserTable.vue create mode 100644 admin/src/views/Creation.vue create mode 100644 admin/src/views/Overview.vue create mode 100644 admin/src/views/UserSearch.vue diff --git a/admin/src/App.vue b/admin/src/App.vue index 9267cc82b..1a15d5d7c 100644 --- a/admin/src/App.vue +++ b/admin/src/App.vue @@ -1,9 +1,16 @@ diff --git a/admin/src/components/NavBar.vue b/admin/src/components/NavBar.vue new file mode 100644 index 000000000..42bc2161c --- /dev/null +++ b/admin/src/components/NavBar.vue @@ -0,0 +1,19 @@ + diff --git a/admin/src/components/UserTable.vue b/admin/src/components/UserTable.vue new file mode 100644 index 000000000..55e9b5b3c --- /dev/null +++ b/admin/src/components/UserTable.vue @@ -0,0 +1,24 @@ + + + diff --git a/admin/src/main.js b/admin/src/main.js index 61f65129e..089e02352 100644 --- a/admin/src/main.js +++ b/admin/src/main.js @@ -14,6 +14,8 @@ import VueApollo from 'vue-apollo' import CONFIG from './config' import { BootstrapVue } from 'bootstrap-vue' +import 'bootstrap-vue/dist/bootstrap-vue.css' +import 'bootstrap/dist/css/bootstrap.css' const httpLink = new HttpLink({ uri: CONFIG.GRAPHQL_URI }) diff --git a/admin/src/router/routes.js b/admin/src/router/routes.js index 40f3ce325..71500eece 100644 --- a/admin/src/router/routes.js +++ b/admin/src/router/routes.js @@ -1,13 +1,36 @@ -import NotFound from '@/components/NotFoundPage.vue' - const routes = [ { path: '/', + component: () => import('@/views/Overview.vue'), meta: { requiresAuth: true, }, }, - { path: '*', component: NotFound }, + { + path: '/overview', + component: () => import('@/views/Overview.vue'), + meta: { + requiresAuth: true, + }, + }, + { + path: '/user', + component: () => import('@/views/UserSearch.vue'), + meta: { + requiresAuth: true, + }, + }, + { + path: '/creation', + component: () => import('@/views/Creation.vue'), + meta: { + requiresAuth: true, + }, + }, + { + path: '*', + component: () => import('@/components/NotFoundPage.vue'), + }, ] export default routes diff --git a/admin/src/views/Creation.vue b/admin/src/views/Creation.vue new file mode 100644 index 000000000..794218163 --- /dev/null +++ b/admin/src/views/Creation.vue @@ -0,0 +1,9 @@ + diff --git a/admin/src/views/Overview.vue b/admin/src/views/Overview.vue new file mode 100644 index 000000000..0cb8a106d --- /dev/null +++ b/admin/src/views/Overview.vue @@ -0,0 +1,21 @@ + + diff --git a/admin/src/views/UserSearch.vue b/admin/src/views/UserSearch.vue new file mode 100644 index 000000000..be6ce38c9 --- /dev/null +++ b/admin/src/views/UserSearch.vue @@ -0,0 +1,9 @@ + From 4cb7abdc9bfca2d601a66b417ef301c531d4cb59 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 11 Nov 2021 06:51:21 +0100 Subject: [PATCH 02/33] add momentjs, add component CreateFormular.vue formular for creating gdd --- admin/package.json | 2 + admin/src/components/CreateFormular.vue | 66 +++++++++++++++++++++ admin/src/components/UserTable.vue | 78 ++++++++++++++++++++++--- admin/src/locales/en.json | 17 +++++- admin/src/main.js | 4 ++ admin/src/views/Overview.vue | 7 ++- admin/yarn.lock | 12 ++++ 7 files changed, 177 insertions(+), 9 deletions(-) create mode 100644 admin/src/components/CreateFormular.vue diff --git a/admin/package.json b/admin/package.json index 2b4e33c91..5dff9145e 100644 --- a/admin/package.json +++ b/admin/package.json @@ -33,11 +33,13 @@ "dotenv-webpack": "^7.0.3", "graphql": "^15.6.1", "jest": "26.6.3", + "moment": "^2.29.1", "stats-webpack-plugin": "^0.7.0", "vue": "^2.6.11", "vue-apollo": "^3.0.8", "vue-i18n": "^8.26.5", "vue-jest": "^3.0.7", + "vue-moment": "^4.1.0", "vue-router": "^3.5.3", "vuex": "^3.6.2" }, diff --git a/admin/src/components/CreateFormular.vue b/admin/src/components/CreateFormular.vue new file mode 100644 index 000000000..5dd07a4c1 --- /dev/null +++ b/admin/src/components/CreateFormular.vue @@ -0,0 +1,66 @@ + + diff --git a/admin/src/components/UserTable.vue b/admin/src/components/UserTable.vue index 55e9b5b3c..2e92c9a7f 100644 --- a/admin/src/components/UserTable.vue +++ b/admin/src/components/UserTable.vue @@ -1,22 +1,86 @@ diff --git a/admin/src/components/CreationFormular.spec.js b/admin/src/components/CreationFormular.spec.js new file mode 100644 index 000000000..c2098768c --- /dev/null +++ b/admin/src/components/CreationFormular.spec.js @@ -0,0 +1,22 @@ +import { mount } from '@vue/test-utils' +import CreationFormular from './CreationFormular.vue' + +const localVue = global.localVue + +describe('CreationFormular', () => { + let wrapper + + const Wrapper = () => { + return mount(CreationFormular, { localVue }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('have a DIV element with the class.componente-creation-formular', () => { + expect(wrapper.find('.componente-creation-formular').exists()).toBeTruthy() + }) + }) +}) diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue new file mode 100644 index 000000000..dbc40c13c --- /dev/null +++ b/admin/src/components/CreationFormular.vue @@ -0,0 +1,114 @@ + + diff --git a/admin/src/components/NavBar.spec.js b/admin/src/components/NavBar.spec.js new file mode 100644 index 000000000..ab9be26e5 --- /dev/null +++ b/admin/src/components/NavBar.spec.js @@ -0,0 +1,22 @@ +import { mount } from '@vue/test-utils' +import NavBar from './NavBar.vue' + +const localVue = global.localVue + +describe('NavBar', () => { + let wrapper + + const Wrapper = () => { + return mount(NavBar, { localVue }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('have a DIV element with the class.componente-nabvar', () => { + expect(wrapper.find('.componente-nabvar').exists()).toBeTruthy() + }) + }) +}) diff --git a/admin/src/components/NavBar.vue b/admin/src/components/NavBar.vue index 42bc2161c..1efdffc04 100644 --- a/admin/src/components/NavBar.vue +++ b/admin/src/components/NavBar.vue @@ -1,19 +1,18 @@ diff --git a/admin/src/components/UserTable.spec.js b/admin/src/components/UserTable.spec.js new file mode 100644 index 000000000..935bd177c --- /dev/null +++ b/admin/src/components/UserTable.spec.js @@ -0,0 +1,22 @@ +import { mount } from '@vue/test-utils' +import UserTable from './UserTable.vue' + +const localVue = global.localVue + +describe('UserTable', () => { + let wrapper + + const Wrapper = () => { + return mount(UserTable, { localVue }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('have a DIV element with the class.componente-user-table', () => { + expect(wrapper.find('.componente-user-table').exists()).toBeTruthy() + }) + }) +}) diff --git a/admin/src/components/UserTable.vue b/admin/src/components/UserTable.vue index 2e92c9a7f..a376e0f67 100644 --- a/admin/src/components/UserTable.vue +++ b/admin/src/components/UserTable.vue @@ -1,24 +1,8 @@ diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index ac7159ece..0967ef424 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -1,16 +1 @@ -{ - "monthNames": { - "January": "", - "February": "", - "March": "", - "April": "", - "May": "", - "June": "", - "July": "", - "August": "", - "September": "", - "October": "", - "November": "", - "December": "" - } -} +{} diff --git a/admin/src/main.js b/admin/src/main.js index 197b82888..b3925c9fe 100644 --- a/admin/src/main.js +++ b/admin/src/main.js @@ -13,9 +13,9 @@ import VueApollo from 'vue-apollo' import CONFIG from './config' -import { BootstrapVue } from 'bootstrap-vue' -import 'bootstrap-vue/dist/bootstrap-vue.css' +import { BootstrapVue, IconsPlugin } from 'bootstrap-vue' import 'bootstrap/dist/css/bootstrap.css' +import 'bootstrap-vue/dist/bootstrap-vue.css' import moment from 'vue-moment' @@ -52,6 +52,8 @@ const apolloProvider = new VueApollo({ }) Vue.use(BootstrapVue) +Vue.use(IconsPlugin) + Vue.use(moment) addNavigationGuards(router, store) diff --git a/admin/src/main.test.js b/admin/src/main.test.js index 27c8898ab..b2d7fadc8 100644 --- a/admin/src/main.test.js +++ b/admin/src/main.test.js @@ -5,10 +5,13 @@ import CONFIG from './config' import Vue from 'vue' import Vuex from 'vuex' import VueI18n from 'vue-i18n' +import { BootstrapVue, IconsPlugin } from 'bootstrap-vue' +import moment from 'vue-moment' jest.mock('vue') jest.mock('vuex') jest.mock('vue-i18n') +jest.mock('moment') const storeMock = jest.fn() Vuex.Store = storeMock @@ -25,6 +28,16 @@ jest.mock('apollo-boost', () => { } }) +jest.mock('bootstrap-vue', () => { + return { + __esModule: true, + BootstrapVue: jest.fn(), + IconsPlugin: jest.fn(() => { + return { concat: jest.fn() } + }), + } +}) + describe('main', () => { it('calls the HttpLink', () => { expect(HttpLink).toBeCalledWith({ uri: CONFIG.GRAPHQL_URI }) @@ -50,6 +63,18 @@ describe('main', () => { expect(VueI18n).toBeCalled() }) + it('calls BootstrapVue', () => { + expect(BootstrapVue).toBeCalled() + }) + + it('calls IconsPlugin', () => { + expect(IconsPlugin).toBeCalled() + }) + + it('calls Moment', () => { + expect(moment).toBeCalled() + }) + it.skip('creates a store', () => { expect(storeMock).toBeCalled() }) diff --git a/admin/src/router/routes.js b/admin/src/router/routes.js index 71500eece..a13463e08 100644 --- a/admin/src/router/routes.js +++ b/admin/src/router/routes.js @@ -27,6 +27,13 @@ const routes = [ requiresAuth: true, }, }, + { + path: '/creation-confirm', + component: () => import('@/views/CreationConfirm.vue'), + meta: { + requiresAuth: true, + }, + }, { path: '*', component: () => import('@/components/NotFoundPage.vue'), diff --git a/admin/src/views/Creation.vue b/admin/src/views/Creation.vue index 794218163..02a060f74 100644 --- a/admin/src/views/Creation.vue +++ b/admin/src/views/Creation.vue @@ -1,9 +1,178 @@ + diff --git a/admin/src/views/CreationConfirm.vue b/admin/src/views/CreationConfirm.vue new file mode 100644 index 000000000..2d416e08f --- /dev/null +++ b/admin/src/views/CreationConfirm.vue @@ -0,0 +1,108 @@ + + diff --git a/admin/src/views/Overview.vue b/admin/src/views/Overview.vue index 55eca4aea..d529701e2 100644 --- a/admin/src/views/Overview.vue +++ b/admin/src/views/Overview.vue @@ -1,26 +1,71 @@ diff --git a/admin/src/views/UserSearch.vue b/admin/src/views/UserSearch.vue index be6ce38c9..c7ed5ffef 100644 --- a/admin/src/views/UserSearch.vue +++ b/admin/src/views/UserSearch.vue @@ -1,9 +1,73 @@ + From 686f9bfd4e6aeaaad9be451ddcdcf04f54e3cbe5 Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 19 Nov 2021 11:14:16 +0100 Subject: [PATCH 04/33] admin area extended according to concept and functions added and improved. workflow stands for the mass creation and for the confirmation of creations. all changes made which were indicated by moritz. all translations will be done in one step at a later date. --- admin/package.json | 3 +- admin/src/App.vue | 3 + admin/src/components/CreationFormular.spec.js | 8 +- admin/src/components/CreationFormular.vue | 201 +++++++++++++---- admin/src/components/Footer.vue | 10 + admin/src/components/NavBar.spec.js | 4 +- admin/src/components/NavBar.vue | 18 +- admin/src/components/UserTable.spec.js | 4 +- admin/src/components/UserTable.vue | 208 ++++++++++++++---- admin/src/store/store.js | 22 ++ admin/src/views/Creation.vue | 109 ++++----- admin/src/views/CreationConfirm.vue | 48 ++-- admin/src/views/Overview.vue | 31 ++- admin/yarn.lock | 13 ++ 14 files changed, 497 insertions(+), 185 deletions(-) create mode 100644 admin/src/components/Footer.vue diff --git a/admin/package.json b/admin/package.json index 5dff9145e..f3ba786bc 100644 --- a/admin/package.json +++ b/admin/package.json @@ -41,7 +41,8 @@ "vue-jest": "^3.0.7", "vue-moment": "^4.1.0", "vue-router": "^3.5.3", - "vuex": "^3.6.2" + "vuex": "^3.6.2", + "vuex-persistedstate": "^4.1.0" }, "devDependencies": { "@babel/eslint-parser": "^7.15.8", diff --git a/admin/src/App.vue b/admin/src/App.vue index 1a15d5d7c..70bc2978a 100644 --- a/admin/src/App.vue +++ b/admin/src/App.vue @@ -2,15 +2,18 @@
+
diff --git a/admin/src/components/CreationFormular.spec.js b/admin/src/components/CreationFormular.spec.js index c2098768c..9f4fc3f1b 100644 --- a/admin/src/components/CreationFormular.spec.js +++ b/admin/src/components/CreationFormular.spec.js @@ -3,11 +3,13 @@ import CreationFormular from './CreationFormular.vue' const localVue = global.localVue +const mocks = { $moment: jest.fn() } + describe('CreationFormular', () => { let wrapper const Wrapper = () => { - return mount(CreationFormular, { localVue }) + return mount(CreationFormular, { localVue, mocks }) } describe('mount', () => { @@ -15,8 +17,8 @@ describe('CreationFormular', () => { wrapper = Wrapper() }) - it('have a DIV element with the class.componente-creation-formular', () => { - expect(wrapper.find('.componente-creation-formular').exists()).toBeTruthy() + it('has a DIV element with the class.component-creation-formular', () => { + expect(wrapper.find('.component-creation-formular').exists()).toBeTruthy() }) }) }) diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index dbc40c13c..995640c72 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -1,72 +1,108 @@ @@ -149,7 +148,7 @@ export default { }, data() { return { - creationData: [], + creationData: {}, overlay: false, overlayBookmarkType: '', overlayItem: [], @@ -217,9 +216,6 @@ export default { alert(JSON.stringify(item)) this.$emit('remove-confirm-result', item, 'remove') }, - getCreationInMonths(creation) { - return creation.split(',') - }, editCreationUserTable(row, rowItem) { alert('editCreationUserTable') if (!row.detailsShowing) { diff --git a/admin/src/graphql/searchUsers.js b/admin/src/graphql/searchUsers.js index ceba5bc6e..86e333845 100644 --- a/admin/src/graphql/searchUsers.js +++ b/admin/src/graphql/searchUsers.js @@ -1,7 +1,7 @@ import gql from 'graphql-tag' export const searchUsers = gql` - query($searchText: String!) { + query ($searchText: String!) { searchUsers(searchText: $searchText) { firstName lastName diff --git a/admin/src/main.js b/admin/src/main.js index 46ee8a6f6..3be3ae0bf 100644 --- a/admin/src/main.js +++ b/admin/src/main.js @@ -25,7 +25,6 @@ import moment from 'vue-moment' const httpLink = new HttpLink({ uri: CONFIG.GRAPHQL_URI }) const authLink = new ApolloLink((operation, forward) => { - const token = store.state.token operation.setContext({ diff --git a/admin/src/views/Creation.vue b/admin/src/views/Creation.vue index 0f88199f8..d3379159b 100644 --- a/admin/src/views/Creation.vue +++ b/admin/src/views/Creation.vue @@ -44,6 +44,7 @@ diff --git a/admin/src/components/Footer.vue b/admin/src/components/ContentFooter.vue similarity index 75% rename from admin/src/components/Footer.vue rename to admin/src/components/ContentFooter.vue index 398f2e180..ade4e0a83 100644 --- a/admin/src/components/Footer.vue +++ b/admin/src/components/ContentFooter.vue @@ -8,3 +8,8 @@ + From 43f673bd8292aa3ad9a7e760d9bb3bf534f95198 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 24 Nov 2021 10:18:48 +0100 Subject: [PATCH 25/33] test i18n --- admin/src/i18n.test.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 admin/src/i18n.test.js diff --git a/admin/src/i18n.test.js b/admin/src/i18n.test.js new file mode 100644 index 000000000..e39e0e824 --- /dev/null +++ b/admin/src/i18n.test.js @@ -0,0 +1,30 @@ +import i18n from './i18n' +import VueI18n from 'vue-i18n' + +jest.mock('vue-i18n') + +describe('i18n', () => { + it('calls i18n with locale en', () => { + expect(VueI18n).toBeCalledWith( + expect.objectContaining({ + locale: 'en', + }), + ) + }) + + it('calls i18n with fallback locale en', () => { + expect(VueI18n).toBeCalledWith( + expect.objectContaining({ + fallbackLocale: 'en', + }), + ) + }) + + it('has a _t function', () => { + expect(i18n).toEqual( + expect.objectContaining({ + _t: expect.anything(), + }), + ) + }) +}) From c98d6151052d4d9409ee47e1baf1c9521a9bf5f8 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 24 Nov 2021 10:22:09 +0100 Subject: [PATCH 26/33] ignore assets for test coverage --- admin/jest.config.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/admin/jest.config.js b/admin/jest.config.js index ac132eed2..b7226bd8f 100644 --- a/admin/jest.config.js +++ b/admin/jest.config.js @@ -1,6 +1,11 @@ module.exports = { verbose: true, - collectCoverageFrom: ['src/**/*.{js,vue}', '!**/node_modules/**', '!**/?(*.)+(spec|test).js?(x)'], + collectCoverageFrom: [ + 'src/**/*.{js,vue}', + '!**/node_modules/**', + '!src/assets/**', + '!**/?(*.)+(spec|test).js?(x)', + ], moduleFileExtensions: [ 'js', // 'jsx', From 50e1a16f839907daf0776d1fb58a865eae4c1c35 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 24 Nov 2021 10:28:57 +0100 Subject: [PATCH 27/33] test store --- admin/src/store/store.js | 4 ++-- admin/src/store/store.test.js | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/admin/src/store/store.js b/admin/src/store/store.js index 38a210fe1..d199368fb 100644 --- a/admin/src/store/store.js +++ b/admin/src/store/store.js @@ -6,10 +6,10 @@ Vue.use(Vuex) export const mutations = { openCreationsPlus: (state, i) => { - state.openCreations = state.openCreations + i + state.openCreations += i }, openCreationsMinus: (state, i) => { - state.openCreations = state.openCreations - i + state.openCreations -= i }, resetOpenCreations: (state) => { state.openCreations = 0 diff --git a/admin/src/store/store.test.js b/admin/src/store/store.test.js index 9ab9d980b..81d75f05f 100644 --- a/admin/src/store/store.test.js +++ b/admin/src/store/store.test.js @@ -1,6 +1,6 @@ import { mutations } from './store' -const { token } = mutations +const { token, openCreationsPlus, openCreationsMinus, resetOpenCreations } = mutations describe('Vuex store', () => { describe('mutations', () => { @@ -11,5 +11,29 @@ describe('Vuex store', () => { expect(state.token).toEqual('1234') }) }) + + describe('openCreationsPlus', () => { + it('increases the open creations by a given number', () => { + const state = { openCreations: 0 } + openCreationsPlus(state, 12) + expect(state.openCreations).toEqual(12) + }) + }) + + describe('openCreationsMinus', () => { + it('decreases the open creations by a given number', () => { + const state = { openCreations: 12 } + openCreationsMinus(state, 2) + expect(state.openCreations).toEqual(10) + }) + }) + + describe('resetOpenCreations', () => { + it('sets the open creations to 0', () => { + const state = { openCreations: 24 } + resetOpenCreations(state) + expect(state.openCreations).toEqual(0) + }) + }) }) }) From fdc1c0bf8858b27261708f63c9fbec6300e00102 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 24 Nov 2021 11:16:36 +0100 Subject: [PATCH 28/33] more tests for CreationFormular. Fix update for properties --- admin/src/components/CreationFormular.spec.js | 101 +++++++++++++++++- admin/src/components/CreationFormular.vue | 13 ++- admin/src/components/UserTable.vue | 6 ++ 3 files changed, 114 insertions(+), 6 deletions(-) diff --git a/admin/src/components/CreationFormular.spec.js b/admin/src/components/CreationFormular.spec.js index f218cf8e2..fcdf97cfa 100644 --- a/admin/src/components/CreationFormular.spec.js +++ b/admin/src/components/CreationFormular.spec.js @@ -19,7 +19,7 @@ const mocks = { const propsData = { type: '', item: {}, - creation: {}, + creation: [], itemsMassCreation: {}, } @@ -38,5 +38,104 @@ describe('CreationFormular', () => { it('has a DIV element with the class.component-creation-formular', () => { expect(wrapper.find('.component-creation-formular').exists()).toBeTruthy() }) + + describe('radio buttons to selcet month', () => { + it('has three radio buttons', () => { + expect(wrapper.findAll('input[type="radio"]').length).toBe(3) + }) + + describe('with mass creation', () => { + beforeEach(async () => { + jest.clearAllMocks() + await wrapper.setProps({ type: 'massCreation' }) + }) + + describe('first radio button', () => { + beforeEach(async () => { + await wrapper.findAll('input[type="radio"]').at(0).setChecked() + }) + + it('emits update-radio-selected with index 0', () => { + expect(wrapper.emitted()['update-radio-selected']).toEqual([ + [expect.arrayContaining([0])], + ]) + }) + }) + + describe('second radio button', () => { + beforeEach(async () => { + await wrapper.findAll('input[type="radio"]').at(1).setChecked() + }) + + it('emits update-radio-selected with index 1', () => { + expect(wrapper.emitted()['update-radio-selected']).toEqual([ + [expect.arrayContaining([1])], + ]) + }) + }) + + describe('third radio button', () => { + beforeEach(async () => { + await wrapper.findAll('input[type="radio"]').at(2).setChecked() + }) + + it('emits update-radio-selected with index 2', () => { + expect(wrapper.emitted()['update-radio-selected']).toEqual([ + [expect.arrayContaining([2])], + ]) + }) + }) + }) + + 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/CreationFormular.vue b/admin/src/components/CreationFormular.vue index 9334f5d00..d6b637152 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -146,7 +146,7 @@ export default { required: false, }, creation: { - type: Object, + type: Array, required: true, }, itemsMassCreation: { @@ -198,9 +198,10 @@ export default { this.text = this.creationUserData.text break case 'range': - this.value = this.creationUserData.creation_gdd + this.value = this.creationUserData.creationGdd break default: + // TODO: Toast alert("I don't know such values") } }, @@ -262,9 +263,11 @@ export default { // hinweis das eine ein einzelne Schöpfung abgesendet wird an (email) alert('UPDATE EINZEL SCHÖPFUNG ABSENDEN FÜR >> ') // umschreiben, update eine bestehende Schöpfung eine - this.creationUserData.datum = this.radioSelected.long - this.creationUserData.creation_gdd = this.value - this.creationUserData.text = this.text + this.$emit('update-creation-data', { + datum: this.radioSelected.long, + creationGdd: this.value, + text: this.text, + }) } else { // hinweis das eine ein einzelne Schöpfung abgesendet wird an (email) alert('EINZEL SCHÖPFUNG ABSENDEN FÜR >> ' + this.item.firstName + '') diff --git a/admin/src/components/UserTable.vue b/admin/src/components/UserTable.vue index 92ee0cba0..d382af138 100644 --- a/admin/src/components/UserTable.vue +++ b/admin/src/components/UserTable.vue @@ -67,6 +67,7 @@ :creation="row.item.creation" :item="row.item" :creationUserData="creationData" + @update-creation-data="updateCreationData" /> @@ -226,6 +227,11 @@ export default { } row.toggleDetails() }, + updateCreationData(data) { + this.creationData = { + ...data, + } + }, }, } From 7a944306b9c3679d1e7f0db0f638992ec9130c84 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 24 Nov 2021 11:59:54 +0100 Subject: [PATCH 29/33] Icon in test setup, test for Creation --- admin/src/components/UserTable.spec.js | 2 +- admin/src/components/UserTable.vue | 2 +- admin/src/views/Creation.spec.js | 59 ++++++++++++++++++++++++++ admin/src/views/Creation.vue | 15 ++++--- admin/test/testSetup.js | 3 +- 5 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 admin/src/views/Creation.spec.js diff --git a/admin/src/components/UserTable.spec.js b/admin/src/components/UserTable.spec.js index a87497d81..3db0131a3 100644 --- a/admin/src/components/UserTable.spec.js +++ b/admin/src/components/UserTable.spec.js @@ -10,7 +10,7 @@ describe('UserTable', () => { type: 'Type', itemsUser: [], fieldsTable: [], - creation: {}, + creation: [], } const Wrapper = () => { diff --git a/admin/src/components/UserTable.vue b/admin/src/components/UserTable.vue index d382af138..265c2d12e 100644 --- a/admin/src/components/UserTable.vue +++ b/admin/src/components/UserTable.vue @@ -140,7 +140,7 @@ export default { default: '', }, creation: { - type: Object, + type: Array, required: false, }, }, diff --git a/admin/src/views/Creation.spec.js b/admin/src/views/Creation.spec.js new file mode 100644 index 000000000..02c2ed4ce --- /dev/null +++ b/admin/src/views/Creation.spec.js @@ -0,0 +1,59 @@ +import { mount } from '@vue/test-utils' +import Creation from './Creation.vue' + +const localVue = global.localVue + +const apolloQueryMock = jest.fn().mockResolvedValue({ + data: { + searchUsers: [ + { + firstName: 'Bibi', + lastName: 'Bloxberg', + email: 'bibi@bloxberg.de', + creation: [200, 400, 600], + }, + ], + }, +}) + +const toastErrorMock = jest.fn() + +const mocks = { + $apollo: { + query: apolloQueryMock, + }, + $toasted: { + error: toastErrorMock, + }, +} + +describe('Creation', () => { + let wrapper + + const Wrapper = () => { + return mount(Creation, { localVue, mocks }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('has a DIV element with the class.creation', () => { + expect(wrapper.find('div.creation').exists()).toBeTruthy() + }) + + describe('apollo returns error', () => { + beforeEach(() => { + apolloQueryMock.mockRejectedValue({ + message: 'Ouch', + }) + wrapper = Wrapper() + }) + + it('toasts an error message', () => { + expect(toastErrorMock).toBeCalledWith('Ouch') + }) + }) + }) +}) diff --git a/admin/src/views/Creation.vue b/admin/src/views/Creation.vue index df5bea28c..262d6299e 100644 --- a/admin/src/views/Creation.vue +++ b/admin/src/views/Creation.vue @@ -1,5 +1,5 @@