diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c57da1964..9c7f9b7c2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -422,7 +422,7 @@ jobs: report_name: Coverage Admin Interface type: lcov result_path: ./coverage/lcov.info - min_coverage: 93 + min_coverage: 94 token: ${{ github.token }} ############################################################################## diff --git a/admin/src/components/Tables/OpenCreationsTable.vue b/admin/src/components/Tables/OpenCreationsTable.vue new file mode 100644 index 000000000..d46515fe1 --- /dev/null +++ b/admin/src/components/Tables/OpenCreationsTable.vue @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/admin/src/components/Tables/SearchUserTable.vue b/admin/src/components/Tables/SearchUserTable.vue new file mode 100644 index 000000000..f463b000b --- /dev/null +++ b/admin/src/components/Tables/SearchUserTable.vue @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/admin/src/components/Tables/SelectUsersTable.vue b/admin/src/components/Tables/SelectUsersTable.vue new file mode 100644 index 000000000..5bc49823a --- /dev/null +++ b/admin/src/components/Tables/SelectUsersTable.vue @@ -0,0 +1,35 @@ + + + + + + + + + {{ $t('e_mail') }}! + + + + + + diff --git a/admin/src/components/Tables/SelectedUsersTable.vue b/admin/src/components/Tables/SelectedUsersTable.vue new file mode 100644 index 000000000..810f8dac8 --- /dev/null +++ b/admin/src/components/Tables/SelectedUsersTable.vue @@ -0,0 +1,26 @@ + + + + + + + + + + + + diff --git a/admin/src/components/UserTable.spec.js b/admin/src/components/UserTable.spec.js deleted file mode 100644 index d900b126d..000000000 --- a/admin/src/components/UserTable.spec.js +++ /dev/null @@ -1,343 +0,0 @@ -import { mount } from '@vue/test-utils' -import UserTable from './UserTable.vue' - -const localVue = global.localVue - -const apolloQueryMock = jest.fn() -apolloQueryMock.mockResolvedValue() - -describe('UserTable', () => { - let wrapper - - const defaultItemsUser = [ - { - 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: [1000, 1000, 1000], - emailChecked: true, - }, - { - userId: 3, - firstName: 'Peter', - lastName: 'Lustig', - email: 'peter@lustig.de', - creation: [0, 0, 0], - emailChecked: true, - }, - { - userId: 4, - firstName: 'New', - lastName: 'User', - email: 'new@user.ch', - creation: [1000, 1000, 1000], - emailChecked: false, - }, - ] - - const confirmationItemsUser = [ - { - email: 'bibi@bloxberg.de', - firstName: 'Bibi', - lastName: 'Bloxberg', - amount: 10, - memo: 'Test 1', - date: '11-09-2001', - moderator: 1, - }, - { - email: 'bibi@bloxberg.de', - firstName: 'Bibi', - lastName: 'Bloxberg', - amount: 10, - memo: 'Test 2', - date: '21-09-2001', - moderator: 1, - }, - { - email: 'bibi@bloxberg.de', - firstName: 'Bibi', - lastName: 'Bloxberg', - amount: 10, - memo: 'Test 3', - date: '30-09-2001', - moderator: 1, - }, - ] - - const propsDataPageUserSearch = { - type: 'PageUserSearch', - itemsUser: defaultItemsUser, - fieldsTable: [ - 'email', - 'firstName', - 'lastName', - 'creation', - 'show_details', - 'confirm_mail', - 'transactions_list', - ], - } - - const propsDataUserListSearch = { - type: 'UserListSearch', - itemsUser: defaultItemsUser, - fieldsTable: ['bookmark', 'email', 'firstName', 'lastName', 'creation'], - creation: [1000, 1000, 1000], - } - - const propsDataUserListMassCreation = { - type: 'UserListMassCreation', - itemsUser: defaultItemsUser, - fieldsTable: ['email', 'firstName', 'lastName', 'creation', 'bookmark'], - creation: [1000, 1000, 1000], - } - - const propsDataPageCreationConfirm = { - type: 'PageCreationConfirm', - itemsUser: confirmationItemsUser, - fieldsTable: [ - 'bookmark', - 'email', - 'firstName', - 'lastName', - 'amount', - 'memo', - 'date', - 'moderator', - 'edit_creation', - 'confirm', - ], - } - - const mocks = { - $t: jest.fn((t) => t), - $d: jest.fn((d) => String(d)), - $apollo: { - query: apolloQueryMock, - }, - $store: { - commit: jest.fn(), - }, - } - - const Wrapper = (propsData) => { - return mount(UserTable, { localVue, propsData, mocks }) - } - - describe('mount', () => { - describe('type PageUserSearch', () => { - beforeEach(async () => { - wrapper = Wrapper(propsDataPageUserSearch) - }) - - it('has a DIV element with the class.component-user-table', () => { - expect(wrapper.find('.component-user-table').exists()).toBeTruthy() - }) - - it('has a DIV element with the id overlay that is not displayed', () => { - expect(wrapper.find('#overlay').exists()).toBeTruthy() - expect(wrapper.find('#overlay').attributes('style')).toBe('display: none;') - }) - - describe('table', () => { - it('has a table', () => { - expect(wrapper.find('table').exists()).toBeTruthy() - }) - - describe('header definition', () => { - it('has 4 column', () => { - expect(wrapper.findAll('th').length).toBe(7) - }) - - it('has Email as first column', () => { - expect(wrapper.find('th[aria-colindex="1"] div').text()).toBe('Email') - }) - - it('has First Name as second column', () => { - expect(wrapper.find('th[aria-colindex="2"] div').text()).toBe('First Name') - }) - - it('has Last Name as third column', () => { - expect(wrapper.find('th[aria-colindex="3"] div').text()).toBe('Last Name') - }) - - it('has Creation as fourth column', () => { - expect(wrapper.find('th[aria-colindex="4"] div').text()).toBe('Creation') - }) - - it('has Creation as fifth column', () => { - expect(wrapper.find('th[aria-colindex="5"] div').text()).toBe('Show Details') - }) - - it('has Creation as sixth column', () => { - expect(wrapper.find('th[aria-colindex="6"] div').text()).toBe('Confirm Mail') - }) - - it('has Creation as seventh column', () => { - expect(wrapper.find('th[aria-colindex="7"] div').text()).toBe('Transactions List') - }) - }) - - describe('content', () => { - it('has 4 rows', () => { - expect(wrapper.findAll('tbody tr')).toHaveLength(4) - }) - - it('has 7 columns', () => { - expect(wrapper.findAll('tr:nth-child(1) > td')).toHaveLength(7) - }) - - it('find button on fifth column', () => { - expect( - wrapper.findAll('tr:nth-child(1) > td').at(5).find('button').isVisible(), - ).toBeTruthy() - }) - }) - - describe('row toggling', () => { - describe('user with email not activated', () => { - it('has no details button', () => { - expect( - wrapper.findAll('tbody > tr').at(3).findAll('td').at(4).find('button').exists(), - ).toBeFalsy() - }) - - it('has a red confirmed button with envelope item', () => { - const row = wrapper.findAll('tbody > tr').at(3) - expect(row.findAll('td').at(5).find('button').exists()).toBeTruthy() - expect(row.findAll('td').at(5).find('button').classes('btn-danger')).toBeTruthy() - expect(row.findAll('td').at(5).find('svg').classes('bi-envelope')).toBeTruthy() - }) - - describe('click on envelope', () => { - beforeEach(async () => { - await wrapper - .findAll('tbody > tr') - .at(3) - .findAll('td') - .at(5) - .find('button') - .trigger('click') - }) - - it('opens the details', async () => { - expect(wrapper.findAll('tbody > tr')).toHaveLength(6) - expect(wrapper.findAll('tbody > tr').at(5).find('input').element.value).toBe( - 'new@user.ch', - ) - expect(wrapper.findAll('tbody > tr').at(5).text()).toContain( - 'unregister_mail.text_false', - ) - // HACK: for some reason we need to close the row details after this test - await wrapper - .findAll('tbody > tr') - .at(3) - .findAll('td') - .at(5) - .find('button') - .trigger('click') - }) - - describe('click on envelope again', () => { - beforeEach(async () => { - await wrapper - .findAll('tbody > tr') - .at(3) - .findAll('td') - .at(5) - .find('button') - .trigger('click') - }) - - it('closes the details', () => { - expect(wrapper.findAll('tbody > tr')).toHaveLength(4) - }) - }) - - describe('click on close details', () => { - beforeEach(async () => { - await wrapper.findAll('tbody > tr').at(5).findAll('button').at(1).trigger('click') - }) - - it('closes the details', () => { - expect(wrapper.findAll('tbody > tr')).toHaveLength(4) - }) - }) - }) - }) - - describe('different details', () => { - it.skip('shows the creation formular for second user', async () => { - await wrapper - .findAll('tbody > tr') - .at(1) - .findAll('td') - .at(4) - .find('button') - .trigger('click') - expect(wrapper.findAll('tbody > tr')).toHaveLength(6) - expect( - wrapper - .findAll('tbody > tr') - .at(3) - .find('div.component-creation-formular') - .exists(), - ).toBeTruthy() - }) - - it.skip('shows the transactions for third user', async () => { - await wrapper - .findAll('tbody > tr') - .at(4) - .findAll('td') - .at(6) - .find('button') - .trigger('click') - expect(wrapper.findAll('tbody > tr')).toHaveLength(6) - }) - }) - }) - }) - }) - - describe('type UserListSearch', () => { - beforeEach(() => { - wrapper = Wrapper(propsDataUserListSearch) - }) - - it('has a DIV element with the class.component-user-table', () => { - expect(wrapper.find('.component-user-table').exists()).toBeTruthy() - }) - }) - - describe('type UserListMassCreation', () => { - beforeEach(() => { - wrapper = Wrapper(propsDataUserListMassCreation) - }) - - it('has a DIV element with the class.component-user-table', () => { - expect(wrapper.find('.component-user-table').exists()).toBeTruthy() - }) - }) - - describe('type PageCreationConfirm', () => { - beforeEach(() => { - wrapper = Wrapper(propsDataPageCreationConfirm) - }) - - it('has a DIV element with the class.component-user-table', () => { - expect(wrapper.find('.component-user-table').exists()).toBeTruthy() - }) - }) - }) -}) diff --git a/admin/src/components/UserTable.vue b/admin/src/components/UserTable.vue deleted file mode 100644 index 15fc290aa..000000000 --- a/admin/src/components/UserTable.vue +++ /dev/null @@ -1,320 +0,0 @@ - - - - - {{ overlayText.header }} - - - {{ overlayText.text1 }} - - - - - - {{ overlayText.text2 }} - - - - {{ overlayText.button_cancel }} - - - {{ overlayText.button_ok }} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{ $t('e_mail') }}! - - - - - - - - - - - - - - - - - diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index 733c30572..a490599c8 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -2,6 +2,7 @@ "all_emails": "Alle Nutzer", "bookmark": "bookmark", "confirmed": "bestätigt", + "creation": "Schöpfung", "creation_form": { "creation_for": "Aktives Grundeinkommen für", "enter_text": "Text eintragen", @@ -19,12 +20,15 @@ "update_creation": "Schöpfung aktualisieren" }, "date": "Datum", + "delete": "Löschen", "details": "Details", + "edit": "Bearbeiten", "e_mail": "E-Mail", "firstname": "Vorname", "gradido_admin_footer": "Gradido Akademie Adminkonsole", "hide_details": "Details verbergen von", "lastname": "Nachname", + "moderator": "Moderator", "multiple_creation_text": "Bitte wähle ein oder mehrere Mitglieder aus für die du Schöpfen möchtest.", "navbar": { "logout": "Abmelden", @@ -55,6 +59,8 @@ }, "remove": "Entfernen", "remove_all": "alle Nutzer entfernen", + "save": "Speichern", + "text": "Text", "transaction": "Transaktion", "transactionlist": { "amount": "Betrag", diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index a4dc9fd9b..d98954760 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -2,6 +2,7 @@ "all_emails": "All users", "bookmark": "Remember", "confirmed": "confirmed", + "creation": "Creation", "creation_form": { "creation_for": "Active Basic Income for", "enter_text": "Enter text", @@ -19,12 +20,15 @@ "update_creation": "Creation update" }, "date": "Date", + "delete": "Delete", "details": "Details", + "edit": "Edit", "e_mail": "E-mail", "firstname": "Firstname", "gradido_admin_footer": "Gradido Academy Admin Console", "hide_details": "Hide details from", "lastname": "Lastname", + "moderator": "Moderator", "multiple_creation_text": "Please select one or more members for which you would like to perform creations.", "navbar": { "logout": "Logout", @@ -55,6 +59,8 @@ }, "remove": "Remove", "remove_all": "Remove all users", + "save": "Speichern", + "text": "Text", "transaction": "Transaction", "transactionlist": { "amount": "Amount", diff --git a/admin/src/mixins/toggleRowDetails.js b/admin/src/mixins/toggleRowDetails.js new file mode 100644 index 000000000..d73810ae7 --- /dev/null +++ b/admin/src/mixins/toggleRowDetails.js @@ -0,0 +1,34 @@ +export const toggleRowDetails = { + data() { + return { + slotIndex: 0, + openRow: null, + creationUserData: {}, + } + }, + methods: { + rowToogleDetails(row, index) { + if (this.openRow) { + if (this.openRow.index === row.index) { + if (index === this.slotIndex) { + row.toggleDetails() + this.openRow = null + } else { + this.slotIndex = index + } + } else { + this.openRow.toggleDetails() + row.toggleDetails() + this.slotIndex = index + this.openRow = row + this.creationUserData = row.item + } + } else { + row.toggleDetails() + this.slotIndex = index + this.openRow = row + this.creationUserData = row.item + } + }, + }, +} diff --git a/admin/src/mixins/toggleRowDetails.test.js b/admin/src/mixins/toggleRowDetails.test.js new file mode 100644 index 000000000..b365bf613 --- /dev/null +++ b/admin/src/mixins/toggleRowDetails.test.js @@ -0,0 +1,141 @@ +import { toggleRowDetails } from './toggleRowDetails' +import { mount } from '@vue/test-utils' + +const localVue = global.localVue + +const Component = { + render() {}, + mixins: [toggleRowDetails], +} + +const toggleDetailsMock = jest.fn() +const secondToggleDetailsMock = jest.fn() + +const row = { + toggleDetails: toggleDetailsMock, + index: 0, + item: { + data: 'item-data', + }, +} + +let wrapper + +describe('toggleRowDetails', () => { + beforeEach(() => { + jest.clearAllMocks() + wrapper = mount(Component, { localVue }) + }) + + it('sets default data', () => { + expect(wrapper.vm.slotIndex).toBe(0) + expect(wrapper.vm.openRow).toBe(null) + expect(wrapper.vm.creationUserData).toEqual({}) + }) + + describe('no open row', () => { + beforeEach(() => { + wrapper.vm.rowToogleDetails(row, 2) + }) + + it('calls toggleDetails', () => { + expect(toggleDetailsMock).toBeCalled() + }) + + it('updates slot index', () => { + expect(wrapper.vm.slotIndex).toBe(2) + }) + + it('updates open row', () => { + expect(wrapper.vm.openRow).toEqual( + expect.objectContaining({ + index: 0, + item: { + data: 'item-data', + }, + }), + ) + }) + + it('updates creation user data', () => { + expect(wrapper.vm.creationUserData).toEqual({ data: 'item-data' }) + }) + }) + + describe('with open row', () => { + beforeEach(() => { + wrapper.setData({ openRow: row }) + }) + + describe('row index is open row index', () => { + describe('index is slot index', () => { + beforeEach(() => { + wrapper.vm.rowToogleDetails(row, 0) + }) + + it('calls toggleDetails', () => { + expect(toggleDetailsMock).toBeCalled() + }) + + it('sets open row to null', () => { + expect(wrapper.vm.openRow).toBe(null) + }) + }) + + describe('index is not slot index', () => { + beforeEach(() => { + wrapper.vm.rowToogleDetails(row, 2) + }) + + it('does not call toggleDetails', () => { + expect(toggleDetailsMock).not.toBeCalled() + }) + + it('updates slot index', () => { + expect(wrapper.vm.slotIndex).toBe(2) + }) + }) + }) + + describe('row index is not open row index', () => { + beforeEach(() => { + wrapper.vm.rowToogleDetails( + { + toggleDetails: secondToggleDetailsMock, + index: 2, + item: { + data: 'new-item-data', + }, + }, + 2, + ) + }) + + it('closes the open row', () => { + expect(toggleDetailsMock).toBeCalled() + }) + + it('opens the new row', () => { + expect(secondToggleDetailsMock).toBeCalled() + }) + + it('updates slot index', () => { + expect(wrapper.vm.slotIndex).toBe(2) + }) + + it('updates open row', () => { + expect(wrapper.vm.openRow).toEqual({ + toggleDetails: secondToggleDetailsMock, + index: 2, + item: { + data: 'new-item-data', + }, + }) + }) + + it('updates creation user data', () => { + expect(wrapper.vm.creationUserData).toEqual({ data: 'new-item-data' }) + }) + }) + }) +}) diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index 64efab997..16678cad8 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -17,11 +17,10 @@ - - @@ -65,7 +63,8 @@ + diff --git a/admin/src/pages/UserSearch.vue b/admin/src/pages/UserSearch.vue index 2efe9f8e8..de041282a 100644 --- a/admin/src/pages/UserSearch.vue +++ b/admin/src/pages/UserSearch.vue @@ -22,7 +22,7 @@ - +
- {{ overlayText.text2 }} -