diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 15a736630..51f8e49b0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -470,7 +470,7 @@ jobs: report_name: Coverage Admin Interface type: lcov result_path: ./coverage/lcov.info - min_coverage: 76 + min_coverage: 77 token: ${{ github.token }} ############################################################################## diff --git a/admin/.env.dist b/admin/.env.dist index 6d78e6782..7e81ca9ab 100644 --- a/admin/.env.dist +++ b/admin/.env.dist @@ -1,3 +1,4 @@ GRAPHQL_URI=http://localhost:4000/graphql WALLET_AUTH_URL=http://localhost/vue/authenticate?token=$1 +WALLET_URL=http://localhost/vue/login DEBUG_DISABLE_AUTH=false \ No newline at end of file diff --git a/admin/src/components/ConfirmRegisterMailFormular.spec.js b/admin/src/components/ConfirmRegisterMailFormular.spec.js index 705a185a3..78f5791dc 100644 --- a/admin/src/components/ConfirmRegisterMailFormular.spec.js +++ b/admin/src/components/ConfirmRegisterMailFormular.spec.js @@ -19,6 +19,7 @@ const mocks = { } const propsData = { + checked: false, email: 'bob@baumeister.de', dateLastSend: '', } diff --git a/admin/src/components/ConfirmRegisterMailFormular.vue b/admin/src/components/ConfirmRegisterMailFormular.vue index 5052a8a3e..635b80939 100644 --- a/admin/src/components/ConfirmRegisterMailFormular.vue +++ b/admin/src/components/ConfirmRegisterMailFormular.vue @@ -1,19 +1,20 @@ @@ -23,6 +24,9 @@ import { sendActivationEmail } from '../graphql/sendActivationEmail' export default { name: 'ConfirmRegisterMail', props: { + checked: { + type: Boolean, + }, email: { type: String, }, diff --git a/admin/src/components/CreationTransactionListFormular.spec.js b/admin/src/components/CreationTransactionListFormular.spec.js index 9817d6b8f..32dcb6c9d 100644 --- a/admin/src/components/CreationTransactionListFormular.spec.js +++ b/admin/src/components/CreationTransactionListFormular.spec.js @@ -8,7 +8,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({ transactionList: { transactions: [ { - type: 'created', + type: 'creation', balance: 100, decayStart: 0, decayEnd: 0, @@ -27,7 +27,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({ }, }, { - type: 'created', + type: 'creation', balance: 200, decayStart: 0, decayEnd: 0, @@ -58,9 +58,7 @@ const mocks = { query: apolloQueryMock, }, $toasted: { - global: { - error: toastedErrorMock, - }, + error: toastedErrorMock, }, } diff --git a/admin/src/components/CreationTransactionListFormular.vue b/admin/src/components/CreationTransactionListFormular.vue index 09e1fa92a..7fed4adcc 100644 --- a/admin/src/components/CreationTransactionListFormular.vue +++ b/admin/src/components/CreationTransactionListFormular.vue @@ -30,10 +30,10 @@ export default { }, }) .then((result) => { - this.items = result.data.transactionList.transactions + this.items = result.data.transactionList.transactions.filter((t) => t.type === 'creation') }) .catch((error) => { - this.$toasted.global.error(error.message) + this.$toasted.error(error.message) }) }, }, diff --git a/admin/src/components/NavBar.spec.js b/admin/src/components/NavBar.spec.js index 6871cb4f7..621ba0eb9 100644 --- a/admin/src/components/NavBar.spec.js +++ b/admin/src/components/NavBar.spec.js @@ -53,13 +53,17 @@ describe('NavBar', () => { }) describe('logout', () => { - // const assignLocationSpy = jest.fn() + const windowLocationMock = jest.fn() beforeEach(async () => { + delete window.location + window.location = { + assign: windowLocationMock, + } await wrapper.findAll('a').at(6).trigger('click') }) it('redirects to /logout', () => { - expect(routerPushMock).toBeCalledWith('/logout') + expect(windowLocationMock).toBeCalledWith('http://localhost/vue/login') }) it('dispatches logout to store', () => { diff --git a/admin/src/components/NavBar.vue b/admin/src/components/NavBar.vue index 03ace0335..c1c315755 100644 --- a/admin/src/components/NavBar.vue +++ b/admin/src/components/NavBar.vue @@ -33,8 +33,9 @@ export default { name: 'navbar', methods: { logout() { + window.location.assign(CONFIG.WALLET_URL) + // window.location = CONFIG.WALLET_URL this.$store.dispatch('logout') - this.$router.push('/logout') }, wallet() { window.location = CONFIG.WALLET_AUTH_URL.replace('$1', this.$store.state.token) diff --git a/admin/src/components/UserTable.spec.js b/admin/src/components/UserTable.spec.js index e25f53015..e26a548cc 100644 --- a/admin/src/components/UserTable.spec.js +++ b/admin/src/components/UserTable.spec.js @@ -3,31 +3,287 @@ import UserTable from './UserTable.vue' const localVue = global.localVue +const apolloQueryMock = jest.fn() +apolloQueryMock.mockResolvedValue() + describe('UserTable', () => { let wrapper - const propsData = { - type: 'Type', - itemsUser: [], - fieldsTable: [], - creation: [], + const defaultItemsUser = [ + { + email: 'bibi@bloxberg.de', + firstName: 'Bibi', + lastName: 'Bloxberg', + creation: [1000, 1000, 1000], + }, + { + email: 'bibi@bloxberg.de', + firstName: 'Bibi', + lastName: 'Bloxberg', + creation: [1000, 1000, 1000], + }, + { + email: 'bibi@bloxberg.de', + firstName: 'Bibi', + lastName: 'Bloxberg', + creation: [1000, 1000, 1000], + }, + ] + + 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), + $moment: jest.fn(() => { + return { + format: jest.fn((m) => m), + subtract: jest.fn(() => { + return { + format: jest.fn((m) => m), + } + }), + } + }), + $apollo: { + query: apolloQueryMock, + }, + $store: { + commit: jest.fn(), + }, } - const Wrapper = () => { + const Wrapper = (propsData) => { return mount(UserTable, { localVue, propsData, mocks }) } describe('mount', () => { - beforeEach(() => { - wrapper = Wrapper() + describe('type PageUserSearch', () => { + beforeEach(() => { + 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 3 rows', () => { + expect(wrapper.findAll('tbody tr').length).toBe(3) + }) + + it('has 7 columns', () => { + expect(wrapper.findAll('tr:nth-child(1) > td').length).toBe(7) + }) + + it('click button on fifth column', () => { + wrapper.find('tbody tr td[aria-colindex="5"] button').trigger('click') + }) + }) + }) + + // it('expect(wrapper.html()).', () => { + // // eslint-disable-next-line no-console + // console.log(wrapper.html()) + // }) }) - it('has a DIV element with the class.component-user-table', () => { - expect(wrapper.find('.component-user-table').exists()).toBeTruthy() + 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() + }) + + // it('expect(wrapper.html()).', () => { + // // eslint-disable-next-line no-console + // console.log(wrapper.html()) + // }) }) + + 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() + }) + + // it('expect(wrapper.html()).', () => { + // // eslint-disable-next-line no-console + // console.log(wrapper.html()) + // }) + }) + + 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() + }) + + // it('expect(wrapper.html()).', () => { + // // eslint-disable-next-line no-console + // console.log(wrapper.html()) + // }) + }) + /** + + + + + + + + */ }) }) diff --git a/admin/src/components/UserTable.vue b/admin/src/components/UserTable.vue index 3f5393412..3f8dface3 100644 --- a/admin/src/components/UserTable.vue +++ b/admin/src/components/UserTable.vue @@ -74,6 +74,7 @@