Merge pull request #2120 from gradido/2119-New-menu-item-GDT

2119 new menu item gdt
This commit is contained in:
Alexander Friedland 2022-08-16 11:46:58 +02:00 committed by GitHub
commit 8b3ebb807b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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()
})
})
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-col>
<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') }}
</b-button>
</b-col>

View File

@ -48,8 +48,8 @@ describe('Navbar', () => {
expect(wrapper.find('.navbar-toggler').exists()).toBeTruthy()
})
it('has ten b-nav-item in the navbar', () => {
expect(wrapper.findAll('.nav-item')).toHaveLength(11)
it('has twelve b-nav-item in the navbar', () => {
expect(wrapper.findAll('.nav-item')).toHaveLength(12)
})
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')
})
it('has first nav-item "navigation.transactions" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.community')
it('has first nav-item "gdt.gdt" in navbar', () => {
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', () => {
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)', () => {
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(8).find('a').attributes('href')).toBe(
expect(wrapper.findAll('.nav-item').at(9).text()).toContain('navigation.members_area')
expect(wrapper.findAll('.nav-item').at(9).find('a').attributes('href')).toBe(
'https://elopage.com',
)
})
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', () => {
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', () => {
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', () => {
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>
{{ $t('navigation.transactions') }}
</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-icon icon="people" aria-hidden="true"></b-icon>
{{ $t('navigation.community') }}

View File

@ -45,31 +45,35 @@ describe('Sidebar', () => {
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', () => {
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', () => {
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)', () => {
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', () => {
expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.members_area')
expect(wrapper.findAll('.nav-item').at(5).find('a').attributes('href')).toBe('#')
expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.members_area')
expect(wrapper.findAll('.nav-item').at(6).find('a').attributes('href')).toBe('#')
})
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', () => {
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', () => {
expect(wrapper.findAll('.nav-item')).toHaveLength(7)
expect(wrapper.findAll('.nav-item')).toHaveLength(8)
})
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', () => {
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>
{{ $t('navigation.transactions') }}
</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-icon icon="people" aria-hidden="true"></b-icon>
{{ $t('navigation.community') }}

View File

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

View File

@ -1,7 +1,11 @@
<template>
<div class="pb-4">
<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>
<gdd-transaction-list
@ -42,6 +46,7 @@ export default {
GdtTransactionList,
},
props: {
gdt: { type: Boolean, default: false },
balance: { type: Number, default: 0 },
GdtBalance: { type: Number, default: 0 },
transactions: {
@ -77,6 +82,8 @@ export default {
this.transactionsGdt = listGDTEntries.gdtEntries
this.transactionGdtCount = listGDTEntries.count
window.scrollTo(0, 0)
// eslint-disable-next-line no-unused-expressions
this.$route.path === '/transactions' ? this.$router.replace('/gdt') : ''
})
.catch((error) => {
this.transactionGdtCount = -1
@ -94,10 +101,26 @@ export default {
return this.$t('gdt.gdt')
},
},
created() {
if (this.gdt) {
this.tabIndex = 1
this.updateGdt()
} else {
this.tabIndex = 0
}
},
watch: {
currentPage() {
this.updateGdt()
},
gdt() {
if (this.gdt) {
this.tabIndex = 1
this.updateGdt()
} else {
this.tabIndex = 0
}
},
},
}
</script>

View File

@ -50,7 +50,7 @@ describe('router', () => {
})
it('has sixteen routes defined', () => {
expect(routes).toHaveLength(17)
expect(routes).toHaveLength(18)
})
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', () => {
it('loads the "Login" page', async () => {
const component = await routes.find((r) => r.path === '/login/:code?').component()

View File

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