Merge branch 'create-message-table' of https://github.com/gradido/gradido into create-message-table

This commit is contained in:
elweyn 2022-08-16 12:00:50 +02:00
commit 6e6d4c2b04
10 changed files with 104 additions and 24 deletions

View File

@ -46,5 +46,17 @@ describe('GddSend confirm', () => {
expect(wrapper.findAll('div.confirm-box-link').at(0).exists()).toBeTruthy() expect(wrapper.findAll('div.confirm-box-link').at(0).exists()).toBeTruthy()
}) })
}) })
describe('has total balance equal 0', () => {
beforeEach(async () => {
await wrapper.setProps({
balance: 0,
})
})
it('has send button disabled', () => {
expect(wrapper.find('.send-button').attributes('disabled')).toBe('disabled')
})
})
}) })
}) })

View File

@ -42,7 +42,12 @@
<b-button @click="$emit('on-reset')">{{ $t('back') }}</b-button> <b-button @click="$emit('on-reset')">{{ $t('back') }}</b-button>
</b-col> </b-col>
<b-col class="text-right"> <b-col class="text-right">
<b-button variant="primary" :disabled="disabled" @click="$emit('send-transaction')"> <b-button
class="send-button"
variant="primary"
:disabled="disabled"
@click="$emit('send-transaction')"
>
{{ $t('form.generate_now') }} {{ $t('form.generate_now') }}
</b-button> </b-button>
</b-col> </b-col>

View File

@ -48,8 +48,8 @@ describe('Navbar', () => {
expect(wrapper.find('.navbar-toggler').exists()).toBeTruthy() expect(wrapper.find('.navbar-toggler').exists()).toBeTruthy()
}) })
it('has ten b-nav-item in the navbar', () => { it('has twelve b-nav-item in the navbar', () => {
expect(wrapper.findAll('.nav-item')).toHaveLength(11) expect(wrapper.findAll('.nav-item')).toHaveLength(12)
}) })
it('has first nav-item "amount GDD" in navbar', () => { it('has first nav-item "amount GDD" in navbar', () => {
@ -68,29 +68,33 @@ describe('Navbar', () => {
expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.transactions') expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.transactions')
}) })
it('has first nav-item "navigation.transactions" in navbar', () => { it('has first nav-item "gdt.gdt" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.community') expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('gdt.gdt')
})
it('has first nav-item "navigation.community" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(7).text()).toEqual('navigation.community')
}) })
it('has first nav-item "navigation.profile" in navbar', () => { it('has first nav-item "navigation.profile" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(7).text()).toEqual('navigation.profile') expect(wrapper.findAll('.nav-item').at(8).text()).toEqual('navigation.profile')
}) })
}) })
describe('navigation Navbar (user has an elopage account)', () => { describe('navigation Navbar (user has an elopage account)', () => {
it('has a link to the members area', () => { it('has a link to the members area', () => {
expect(wrapper.findAll('.nav-item').at(8).text()).toContain('navigation.members_area') expect(wrapper.findAll('.nav-item').at(9).text()).toContain('navigation.members_area')
expect(wrapper.findAll('.nav-item').at(8).find('a').attributes('href')).toBe( expect(wrapper.findAll('.nav-item').at(9).find('a').attributes('href')).toBe(
'https://elopage.com', 'https://elopage.com',
) )
}) })
it('has first nav-item "navigation.admin_area" in navbar', () => { it('has first nav-item "navigation.admin_area" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(9).text()).toEqual('navigation.admin_area') expect(wrapper.findAll('.nav-item').at(10).text()).toEqual('navigation.admin_area')
}) })
it('has first nav-item "navigation.logout" in navbar', () => { it('has first nav-item "navigation.logout" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(10).text()).toEqual('navigation.logout') expect(wrapper.findAll('.nav-item').at(11).text()).toEqual('navigation.logout')
}) })
}) })
@ -101,11 +105,11 @@ describe('Navbar', () => {
}) })
it('has first nav-item "navigation.admin_area" in navbar', () => { it('has first nav-item "navigation.admin_area" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(8).text()).toEqual('navigation.admin_area') expect(wrapper.findAll('.nav-item').at(9).text()).toEqual('navigation.admin_area')
}) })
it('has first nav-item "navigation.logout" in navbar', () => { it('has first nav-item "navigation.logout" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(9).text()).toEqual('navigation.logout') expect(wrapper.findAll('.nav-item').at(10).text()).toEqual('navigation.logout')
}) })
}) })
}) })

View File

@ -52,6 +52,10 @@
<b-icon icon="layout-text-sidebar-reverse" aria-hidden="true"></b-icon> <b-icon icon="layout-text-sidebar-reverse" aria-hidden="true"></b-icon>
{{ $t('navigation.transactions') }} {{ $t('navigation.transactions') }}
</b-nav-item> </b-nav-item>
<b-nav-item to="/gdt" class="mb-3">
<b-icon icon="layout-text-sidebar-reverse" aria-hidden="true"></b-icon>
{{ $t('gdt.gdt') }}
</b-nav-item>
<b-nav-item to="/community" class="mb-3"> <b-nav-item to="/community" class="mb-3">
<b-icon icon="people" aria-hidden="true"></b-icon> <b-icon icon="people" aria-hidden="true"></b-icon>
{{ $t('navigation.community') }} {{ $t('navigation.community') }}

View File

@ -45,31 +45,35 @@ describe('Sidebar', () => {
expect(wrapper.findAll('.nav-item').at(2).text()).toEqual('navigation.transactions') expect(wrapper.findAll('.nav-item').at(2).text()).toEqual('navigation.transactions')
}) })
it('has first nav-item "gdt.gdt" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(3).text()).toEqual('gdt.gdt')
})
it('has first nav-item "navigation.community" in navbar', () => { it('has first nav-item "navigation.community" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(3).text()).toContain('navigation.community') expect(wrapper.findAll('.nav-item').at(4).text()).toContain('navigation.community')
}) })
it('has first nav-item "navigation.profile" in navbar', () => { it('has first nav-item "navigation.profile" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(4).text()).toEqual('navigation.profile') expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.profile')
}) })
}) })
describe('navigation Navbar (user has an elopage account)', () => { describe('navigation Navbar (user has an elopage account)', () => {
it('has eight b-nav-item in the navbar', () => { it('has eight b-nav-item in the navbar', () => {
expect(wrapper.findAll('.nav-item')).toHaveLength(8) expect(wrapper.findAll('.nav-item')).toHaveLength(9)
}) })
it('has a link to the members area', () => { it('has a link to the members area', () => {
expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.members_area') expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.members_area')
expect(wrapper.findAll('.nav-item').at(5).find('a').attributes('href')).toBe('#') expect(wrapper.findAll('.nav-item').at(6).find('a').attributes('href')).toBe('#')
}) })
it('has first nav-item "navigation.admin_area" in navbar', () => { it('has first nav-item "navigation.admin_area" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.admin_area') expect(wrapper.findAll('.nav-item').at(7).text()).toEqual('navigation.admin_area')
}) })
it('has first nav-item "navigation.logout" in navbar', () => { it('has first nav-item "navigation.logout" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(7).text()).toEqual('navigation.logout') expect(wrapper.findAll('.nav-item').at(8).text()).toEqual('navigation.logout')
}) })
}) })
@ -80,15 +84,15 @@ describe('Sidebar', () => {
}) })
it('has seven b-nav-item in the navbar', () => { it('has seven b-nav-item in the navbar', () => {
expect(wrapper.findAll('.nav-item')).toHaveLength(7) expect(wrapper.findAll('.nav-item')).toHaveLength(8)
}) })
it('has first nav-item "navigation.admin_area" in navbar', () => { it('has first nav-item "navigation.admin_area" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.admin_area') expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.admin_area')
}) })
it('has first nav-item "navigation.logout" in navbar', () => { it('has first nav-item "navigation.logout" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.logout') expect(wrapper.findAll('.nav-item').at(7).text()).toEqual('navigation.logout')
}) })
}) })
}) })

View File

@ -16,6 +16,10 @@
<b-icon icon="layout-text-sidebar-reverse" aria-hidden="true"></b-icon> <b-icon icon="layout-text-sidebar-reverse" aria-hidden="true"></b-icon>
{{ $t('navigation.transactions') }} {{ $t('navigation.transactions') }}
</b-nav-item> </b-nav-item>
<b-nav-item to="/gdt" class="mb-3">
<b-icon icon="layout-text-sidebar-reverse" aria-hidden="true"></b-icon>
{{ $t('gdt.gdt') }}
</b-nav-item>
<b-nav-item to="/community" class="mb-3"> <b-nav-item to="/community" class="mb-3">
<b-icon icon="people" aria-hidden="true"></b-icon> <b-icon icon="people" aria-hidden="true"></b-icon>
{{ $t('navigation.community') }} {{ $t('navigation.community') }}

View File

@ -6,6 +6,7 @@ import { toastErrorSpy } from '@test/testSetup'
const localVue = global.localVue const localVue = global.localVue
const mockRouterReplace = jest.fn()
const windowScrollToMock = jest.fn() const windowScrollToMock = jest.fn()
window.scrollTo = windowScrollToMock window.scrollTo = windowScrollToMock
@ -39,6 +40,9 @@ describe('Transactions', () => {
$apollo: { $apollo: {
query: apolloMock, query: apolloMock,
}, },
$router: {
replace: mockRouterReplace,
},
} }
const Wrapper = () => { const Wrapper = () => {

View File

@ -1,7 +1,11 @@
<template> <template>
<div class="pb-4"> <div class="pb-4">
<b-tabs v-model="tabIndex" content-class="" justified> <b-tabs v-model="tabIndex" content-class="" justified>
<b-tab :title="`Gradido (${$n(balance, 'decimal')} GDD)`" class="px-4"> <b-tab
:title="`Gradido (${$n(balance, 'decimal')} GDD)`"
class="px-4"
@click="$router.replace('/transactions')"
>
<p class="tab-tex">{{ $t('transaction.gdd-text') }}</p> <p class="tab-tex">{{ $t('transaction.gdd-text') }}</p>
<gdd-transaction-list <gdd-transaction-list
@ -42,6 +46,7 @@ export default {
GdtTransactionList, GdtTransactionList,
}, },
props: { props: {
gdt: { type: Boolean, default: false },
balance: { type: Number, default: 0 }, balance: { type: Number, default: 0 },
GdtBalance: { type: Number, default: 0 }, GdtBalance: { type: Number, default: 0 },
transactions: { transactions: {
@ -77,6 +82,8 @@ export default {
this.transactionsGdt = listGDTEntries.gdtEntries this.transactionsGdt = listGDTEntries.gdtEntries
this.transactionGdtCount = listGDTEntries.count this.transactionGdtCount = listGDTEntries.count
window.scrollTo(0, 0) window.scrollTo(0, 0)
// eslint-disable-next-line no-unused-expressions
this.$route.path === '/transactions' ? this.$router.replace('/gdt') : ''
}) })
.catch((error) => { .catch((error) => {
this.transactionGdtCount = -1 this.transactionGdtCount = -1
@ -94,10 +101,26 @@ export default {
return this.$t('gdt.gdt') return this.$t('gdt.gdt')
}, },
}, },
created() {
if (this.gdt) {
this.tabIndex = 1
this.updateGdt()
} else {
this.tabIndex = 0
}
},
watch: { watch: {
currentPage() { currentPage() {
this.updateGdt() this.updateGdt()
}, },
gdt() {
if (this.gdt) {
this.tabIndex = 1
this.updateGdt()
} else {
this.tabIndex = 0
}
},
}, },
} }
</script> </script>

View File

@ -50,7 +50,7 @@ describe('router', () => {
}) })
it('has sixteen routes defined', () => { it('has sixteen routes defined', () => {
expect(routes).toHaveLength(17) expect(routes).toHaveLength(18)
}) })
describe('overview', () => { describe('overview', () => {
@ -108,6 +108,17 @@ describe('router', () => {
}) })
}) })
describe('gdt', () => {
it('requires authorization', () => {
expect(routes.find((r) => r.path === '/gdt').meta.requiresAuth).toBeTruthy()
})
it('loads the "GDT" page', async () => {
const component = await routes.find((r) => r.path === '/gdt').component()
expect(component.default.name).toBe('Transactions')
})
})
describe('login', () => { describe('login', () => {
it('loads the "Login" page', async () => { it('loads the "Login" page', async () => {
const component = await routes.find((r) => r.path === '/login/:code?').component() const component = await routes.find((r) => r.path === '/login/:code?').component()

View File

@ -34,6 +34,15 @@ const routes = [
{ {
path: '/transactions', path: '/transactions',
component: () => import('@/pages/Transactions.vue'), component: () => import('@/pages/Transactions.vue'),
props: { gdt: false },
meta: {
requiresAuth: true,
},
},
{
path: '/gdt',
component: () => import('@/pages/Transactions.vue'),
props: { gdt: true },
meta: { meta: {
requiresAuth: true, requiresAuth: true,
}, },