diff --git a/frontend/package.json b/frontend/package.json index b5c7868b7..e50c5fe89 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -27,7 +27,6 @@ "babel-preset-vue": "^2.0.2", "bootstrap": "4.3.1", "bootstrap-vue": "^2.5.0", - "chart.js": "^2.9.3", "d3": "^5.7.0", "datamaps": "^0.5.9", "date-fns": "^1.30.1", @@ -64,7 +63,6 @@ "vue": "^2.6.11", "vue-apollo": "^3.0.7", "vue-bootstrap-typeahead": "^0.2.6", - "vue-chartjs": "^3.5.0", "vue-cli-plugin-i18n": "^1.0.1", "vue-clickaway": "^2.2.2", "vue-clipboard2": "^0.3.0", diff --git a/frontend/src/components/Status.spec.js b/frontend/src/components/Status.spec.js new file mode 100644 index 000000000..30dab4345 --- /dev/null +++ b/frontend/src/components/Status.spec.js @@ -0,0 +1,45 @@ +import { mount } from '@vue/test-utils' +import Status from './Status' + +const localVue = global.localVue + +describe('Status', () => { + let wrapper + + const mocks = { + $n: jest.fn((n) => n), + } + + const propsData = { + balance: 1234, + statusText: 'GDD', + } + + const Wrapper = () => { + return mount(Status, { localVue, mocks, propsData }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + describe('balance is pending', () => { + it('it displays an en-dash', () => { + expect(wrapper.find('div.gdd-status-div').text()).toEqual('— GDD') + }) + }) + + describe('balance is loaded', () => { + beforeEach(() => { + wrapper.setProps({ + pending: false, + }) + }) + + it('it displays the ammount of GDD', () => { + expect(wrapper.find('div.gdd-status-div').text()).toEqual('1234 GDD') + }) + }) + }) +}) diff --git a/frontend/src/components/Status.vue b/frontend/src/components/Status.vue new file mode 100644 index 000000000..7900763f7 --- /dev/null +++ b/frontend/src/components/Status.vue @@ -0,0 +1,24 @@ + + + diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 19a8f7c53..e46f9bb83 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -110,6 +110,7 @@ "logout": "Abmelden", "members_area": "Mitgliederbereich", "message": "hallo gradido !!", + "overview": "Übersicht", "privacy_policy": "Datenschutzerklärung", "send": "Senden", "settings": { diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index d74b8ec5b..23d551272 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -110,6 +110,7 @@ "logout": "Logout", "members_area": "Member's area", "message": "hello gradido !!", + "overview": "Overview", "privacy_policy": "Privacy policy", "send": "Send", "settings": { diff --git a/frontend/src/main.js b/frontend/src/main.js index ad5c6e1db..fd06bf9c0 100755 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -6,6 +6,7 @@ import { loadAllRules } from './validation-rules' import { ApolloClient, ApolloLink, InMemoryCache, HttpLink } from 'apollo-boost' import VueApollo from 'vue-apollo' import CONFIG from './config' + import addNavigationGuards from './routes/guards' import { store } from './store/store' diff --git a/frontend/src/routes/router.test.js b/frontend/src/routes/router.test.js index 23d2e71b6..df4f9c229 100644 --- a/frontend/src/routes/router.test.js +++ b/frontend/src/routes/router.test.js @@ -49,8 +49,8 @@ describe('router', () => { expect(routes.find((r) => r.path === '/').redirect()).toEqual({ path: '/login' }) }) - it('has twelve routes defined', () => { - expect(routes).toHaveLength(13) + it('has fourteen routes defined', () => { + expect(routes).toHaveLength(14) }) describe('overview', () => { @@ -64,6 +64,17 @@ describe('router', () => { }) }) + describe('send', () => { + it('requires authorization', () => { + expect(routes.find((r) => r.path === '/send').meta.requiresAuth).toBeTruthy() + }) + + it('loads the "Send" component', async () => { + const component = await routes.find((r) => r.path === '/send').component() + expect(component.default.name).toBe('SendOverview') + }) + }) + describe('profile', () => { it('requires authorization', () => { expect(routes.find((r) => r.path === '/profile').meta.requiresAuth).toBeTruthy() diff --git a/frontend/src/routes/routes.js b/frontend/src/routes/routes.js index 8cc4d313d..f4f0dfe04 100755 --- a/frontend/src/routes/routes.js +++ b/frontend/src/routes/routes.js @@ -14,6 +14,13 @@ const routes = [ requiresAuth: true, }, }, + { + path: '/send', + component: () => import('../views/Pages/SendOverview.vue'), + meta: { + requiresAuth: true, + }, + }, { path: '/profile', component: () => import('../views/Pages/UserProfileOverview.vue'), diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js index a753b9931..b25640e5c 100644 --- a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js +++ b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js @@ -89,33 +89,40 @@ describe('DashboardLayoutGdd', () => { navbar = wrapper.findAll('ul.navbar-nav').at(0) }) - it('has three items in the navbar', () => { - expect(navbar.findAll('ul > a')).toHaveLength(3) + it('has four items in the navbar', () => { + expect(navbar.findAll('ul > a')).toHaveLength(4) }) - it('has first item "send" in navbar', () => { - expect(navbar.findAll('ul > a').at(0).text()).toEqual('send') + it('has first item "overview" in navbar', () => { + expect(navbar.findAll('ul > a').at(0).text()).toEqual('overview') }) - it('has first item "send" linked to overview in navbar', () => { - navbar.findAll('ul > a').at(0).trigger('click') - expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/overview') + it('has first item "overview" linked to overview in navbar', () => { + expect(navbar.findAll('ul > a > a').at(0).attributes('href')).toBe('/overview') }) - it('has second item "transactions" in navbar', () => { - expect(navbar.findAll('ul > a').at(1).text()).toEqual('transactions') + it('has second item "send" in navbar', () => { + expect(navbar.findAll('ul > a').at(1).text()).toEqual('send') }) - it('has second item "transactions" linked to transactions in navbar', async () => { - expect(wrapper.findAll('a').at(3).attributes('href')).toBe('/transactions') + it('has second item "send" linked to /send in navbar', () => { + expect(wrapper.findAll('ul > a > a').at(1).attributes('href')).toBe('/send') }) - it('has three items in the navbar', () => { - expect(navbar.findAll('ul > a')).toHaveLength(3) + it('has third item "transactions" in navbar', () => { + expect(navbar.findAll('ul > a').at(2).text()).toEqual('transactions') }) - it('has third item "My profile" linked to profile in navbar', async () => { - expect(wrapper.findAll('a').at(5).attributes('href')).toBe('/profile') + it('has third item "transactions" linked to transactions in navbar', async () => { + expect(wrapper.findAll('ul > a > a').at(2).attributes('href')).toBe('/transactions') + }) + + it('has fourth item "My profile" in navbar', () => { + expect(navbar.findAll('ul > a').at(3).text()).toEqual('site.navbar.my-profil') + }) + + it('has fourth item "My profile" linked to profile in navbar', async () => { + expect(wrapper.findAll('ul > a > a').at(3).attributes('href')).toBe('/profile') }) it('has a link to the members area', () => { diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.vue b/frontend/src/views/Layout/DashboardLayout_gdd.vue index 2b63bf417..8273685bd 100755 --- a/frontend/src/views/Layout/DashboardLayout_gdd.vue +++ b/frontend/src/views/Layout/DashboardLayout_gdd.vue @@ -2,11 +2,16 @@