diff --git a/frontend/src/components/GddSend/TransactionConfirmationLink.spec.js b/frontend/src/components/GddSend/TransactionConfirmationLink.spec.js index a28c2d185..56694296a 100644 --- a/frontend/src/components/GddSend/TransactionConfirmationLink.spec.js +++ b/frontend/src/components/GddSend/TransactionConfirmationLink.spec.js @@ -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') + }) + }) }) }) diff --git a/frontend/src/components/GddSend/TransactionConfirmationLink.vue b/frontend/src/components/GddSend/TransactionConfirmationLink.vue index c23ed35d2..2620753ee 100644 --- a/frontend/src/components/GddSend/TransactionConfirmationLink.vue +++ b/frontend/src/components/GddSend/TransactionConfirmationLink.vue @@ -42,7 +42,12 @@ {{ $t('back') }} - + {{ $t('form.generate_now') }} diff --git a/frontend/src/components/Menu/Navbar.spec.js b/frontend/src/components/Menu/Navbar.spec.js index 3f12682c0..e7a0f4784 100644 --- a/frontend/src/components/Menu/Navbar.spec.js +++ b/frontend/src/components/Menu/Navbar.spec.js @@ -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') }) }) }) diff --git a/frontend/src/components/Menu/Navbar.vue b/frontend/src/components/Menu/Navbar.vue index ef222fdb4..a0f6e5a9d 100644 --- a/frontend/src/components/Menu/Navbar.vue +++ b/frontend/src/components/Menu/Navbar.vue @@ -52,6 +52,10 @@ {{ $t('navigation.transactions') }} + + + {{ $t('gdt.gdt') }} + {{ $t('navigation.community') }} diff --git a/frontend/src/components/Menu/Sidebar.spec.js b/frontend/src/components/Menu/Sidebar.spec.js index 1593a79a8..1ffa8bf15 100644 --- a/frontend/src/components/Menu/Sidebar.spec.js +++ b/frontend/src/components/Menu/Sidebar.spec.js @@ -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') }) }) }) diff --git a/frontend/src/components/Menu/Sidebar.vue b/frontend/src/components/Menu/Sidebar.vue index 00243fa49..fc3ecc21d 100644 --- a/frontend/src/components/Menu/Sidebar.vue +++ b/frontend/src/components/Menu/Sidebar.vue @@ -16,6 +16,10 @@ {{ $t('navigation.transactions') }} + + + {{ $t('gdt.gdt') }} + {{ $t('navigation.community') }} diff --git a/frontend/src/pages/Transactions.spec.js b/frontend/src/pages/Transactions.spec.js index 94e0f51c1..171a089ca 100644 --- a/frontend/src/pages/Transactions.spec.js +++ b/frontend/src/pages/Transactions.spec.js @@ -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 = () => { diff --git a/frontend/src/pages/Transactions.vue b/frontend/src/pages/Transactions.vue index 109e3f19c..d0f4ac8b8 100644 --- a/frontend/src/pages/Transactions.vue +++ b/frontend/src/pages/Transactions.vue @@ -1,7 +1,11 @@ - + {{ $t('transaction.gdd-text') }} { 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 + } + }, }, } diff --git a/frontend/src/routes/router.test.js b/frontend/src/routes/router.test.js index 2eefaeb36..d3f9cf992 100644 --- a/frontend/src/routes/router.test.js +++ b/frontend/src/routes/router.test.js @@ -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() diff --git a/frontend/src/routes/routes.js b/frontend/src/routes/routes.js index 540ef9d69..2c727304b 100755 --- a/frontend/src/routes/routes.js +++ b/frontend/src/routes/routes.js @@ -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, },
{{ $t('transaction.gdd-text') }}