From 3a5f983c5f21e9a8204ec32adc551eae6e56d678 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 31 Oct 2022 12:12:07 +0100 Subject: [PATCH 1/5] new Page ContributionLink,vue --- .../ContributionLink.spec.js | 0 .../ContributionLink.vue | 4 +- .../ContributionLinkForm.spec.js | 2 +- .../ContributionLinkForm.vue | 0 .../ContributionLinkList.spec.js | 2 +- .../ContributionLinkList.vue | 2 +- admin/src/components/NavBar.spec.js | 4 +- admin/src/components/NavBar.vue | 1 + admin/src/locales/de.json | 3 +- admin/src/locales/en.json | 3 +- admin/src/pages/ContributionLink.spec.js | 58 +++++++++++++++++++ admin/src/pages/ContributionLink.vue | 45 ++++++++++++++ admin/src/pages/Overview.spec.js | 30 ---------- admin/src/pages/Overview.vue | 25 -------- admin/src/router/router.test.js | 9 ++- admin/src/router/routes.js | 4 ++ 16 files changed, 127 insertions(+), 65 deletions(-) rename admin/src/components/{ => ContributionLink}/ContributionLink.spec.js (100%) rename admin/src/components/{ => ContributionLink}/ContributionLink.vue (91%) rename admin/src/components/{ => ContributionLink}/ContributionLinkForm.spec.js (98%) rename admin/src/components/{ => ContributionLink}/ContributionLinkForm.vue (100%) rename admin/src/components/{ => ContributionLink}/ContributionLinkList.spec.js (98%) rename admin/src/components/{ => ContributionLink}/ContributionLinkList.vue (98%) create mode 100644 admin/src/pages/ContributionLink.spec.js create mode 100644 admin/src/pages/ContributionLink.vue diff --git a/admin/src/components/ContributionLink.spec.js b/admin/src/components/ContributionLink/ContributionLink.spec.js similarity index 100% rename from admin/src/components/ContributionLink.spec.js rename to admin/src/components/ContributionLink/ContributionLink.spec.js diff --git a/admin/src/components/ContributionLink.vue b/admin/src/components/ContributionLink/ContributionLink.vue similarity index 91% rename from admin/src/components/ContributionLink.vue rename to admin/src/components/ContributionLink/ContributionLink.vue index 5621e4330..b21d82b55 100644 --- a/admin/src/components/ContributionLink.vue +++ b/admin/src/components/ContributionLink/ContributionLink.vue @@ -35,8 +35,8 @@ diff --git a/admin/src/pages/Overview.spec.js b/admin/src/pages/Overview.spec.js index 1861c5330..affd018a7 100644 --- a/admin/src/pages/Overview.spec.js +++ b/admin/src/pages/Overview.spec.js @@ -1,6 +1,5 @@ import { mount } from '@vue/test-utils' import Overview from './Overview.vue' -import { listContributionLinks } from '@/graphql/listContributionLinks.js' import { communityStatistics } from '@/graphql/communityStatistics.js' import { listUnconfirmedContributions } from '@/graphql/listUnconfirmedContributions.js' @@ -36,27 +35,6 @@ const apolloQueryMock = jest }, }, }) - .mockResolvedValueOnce({ - data: { - listContributionLinks: { - links: [ - { - id: 1, - name: 'Meditation', - memo: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut l', - amount: '200', - validFrom: '2022-04-01', - validTo: '2022-08-01', - cycle: 'täglich', - maxPerCycle: '3', - maxAmountPerMonth: 0, - link: 'https://localhost/redeem/CL-1a2345678', - }, - ], - count: 1, - }, - }, - }) .mockResolvedValue({ data: { listUnconfirmedContributions: [ @@ -118,14 +96,6 @@ describe('Overview', () => { ) }) - it('calls listContributionLinks', () => { - expect(apolloQueryMock).toBeCalledWith( - expect.objectContaining({ - query: listContributionLinks, - }), - ) - }) - it('commits three pending creations to store', () => { expect(storeCommitMock).toBeCalledWith('setOpenCreations', 3) }) diff --git a/admin/src/pages/Overview.vue b/admin/src/pages/Overview.vue index cfa247b8e..57bf7ff8c 100644 --- a/admin/src/pages/Overview.vue +++ b/admin/src/pages/Overview.vue @@ -28,31 +28,21 @@ - diff --git a/admin/src/router/router.test.js b/admin/src/router/router.test.js index eb9b646cb..bf2e724d2 100644 --- a/admin/src/router/router.test.js +++ b/admin/src/router/router.test.js @@ -45,7 +45,7 @@ describe('router', () => { describe('routes', () => { it('has seven routes defined', () => { - expect(routes).toHaveLength(7) + expect(routes).toHaveLength(8) }) it('has "/overview" as default', async () => { @@ -81,6 +81,13 @@ describe('router', () => { }) }) + describe('contribution-link', () => { + it('loads the "ContributionLink" component', async () => { + const component = await routes.find((r) => r.path === '/contribution-link').component() + expect(component.default.name).toBe('ContributionLinks') + }) + }) + describe('not found page', () => { it('renders the "NotFound" component', async () => { const component = await routes.find((r) => r.path === '*').component() diff --git a/admin/src/router/routes.js b/admin/src/router/routes.js index 72e7b1ac5..caf1030a1 100644 --- a/admin/src/router/routes.js +++ b/admin/src/router/routes.js @@ -23,6 +23,10 @@ const routes = [ path: '/creation-confirm', component: () => import('@/pages/CreationConfirm.vue'), }, + { + path: '/contribution-link', + component: () => import('@/pages/ContributionLink.vue'), + }, { path: '*', component: () => import('@/components/NotFoundPage.vue'), From 214378f683f5416ebd513950c37fd0ecb05d1679 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 31 Oct 2022 12:14:28 +0100 Subject: [PATCH 2/5] fix lint --- admin/src/locales/de.json | 2 +- admin/src/locales/en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index 2016f81a1..85f33660c 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -101,7 +101,7 @@ "open_creation": "Offene Schöpfungen", "overview": "Übersicht", "user_search": "Nutzersuche", - "automaticContributions":"automatische Beiträge" + "automaticContributions": "automatische Beiträge" }, "not_open_creations": "Keine offenen Schöpfungen", "open": "offen", diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index e79050b69..8146455d2 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -101,7 +101,7 @@ "open_creation": "Open creations", "overview": "Overview", "user_search": "User search", - "automaticContributions":"Automatic Contributions" + "automaticContributions": "Automatic Contributions" }, "not_open_creations": "No open creations", "open": "open", From f0e67930748df49a257f6d14082c2d508edf17e2 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 31 Oct 2022 12:14:49 +0100 Subject: [PATCH 3/5] fix locales --- admin/src/locales/de.json | 4 ++-- admin/src/locales/en.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index 85f33660c..ecd33045c 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -95,13 +95,13 @@ "multiple_creation_text": "Bitte wähle ein oder mehrere Mitglieder aus für die du Schöpfen möchtest.", "name": "Name", "navbar": { + "automaticContributions": "automatische Beiträge", "logout": "Abmelden", "multi_creation": "Mehrfachschöpfung", "my-account": "Mein Konto", "open_creation": "Offene Schöpfungen", "overview": "Übersicht", - "user_search": "Nutzersuche", - "automaticContributions": "automatische Beiträge" + "user_search": "Nutzersuche" }, "not_open_creations": "Keine offenen Schöpfungen", "open": "offen", diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index 8146455d2..91d7d406e 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -95,13 +95,13 @@ "multiple_creation_text": "Please select one or more members for which you would like to perform creations.", "name": "Name", "navbar": { + "automaticContributions": "Automatic Contributions", "logout": "Logout", "multi_creation": "Multiple creation", "my-account": "My Account", "open_creation": "Open creations", "overview": "Overview", - "user_search": "User search", - "automaticContributions": "Automatic Contributions" + "user_search": "User search" }, "not_open_creations": "No open creations", "open": "open", From c7c25f2077ebafb576b4ef2cd1301dc3f61fa833 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 1 Nov 2022 13:44:09 +0100 Subject: [PATCH 4/5] more tests for all nav-items --- admin/src/components/NavBar.spec.js | 34 +++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/admin/src/components/NavBar.spec.js b/admin/src/components/NavBar.spec.js index 0d9d22905..56e02fbac 100644 --- a/admin/src/components/NavBar.spec.js +++ b/admin/src/components/NavBar.spec.js @@ -7,6 +7,10 @@ const apolloMutateMock = jest.fn() const storeDispatchMock = jest.fn() const routerPushMock = jest.fn() +const stubs = { + RouterLink: true, +} + const mocks = { $t: jest.fn((t) => t), $apollo: { @@ -28,7 +32,7 @@ describe('NavBar', () => { let wrapper const Wrapper = () => { - return mount(NavBar, { mocks, localVue }) + return mount(NavBar, { mocks, localVue, stubs }) } describe('mount', () => { @@ -41,13 +45,35 @@ describe('NavBar', () => { }) }) + describe('Navbar Menu', () => { + it('has a link to overview', () => { + expect(wrapper.findAll('.nav-item').at(0).find('a').attributes('href')).toBe('/') + }) + it('has a link to /user', () => { + expect(wrapper.findAll('.nav-item').at(1).find('a').attributes('href')).toBe('/user') + }) + it('has a link to /creation', () => { + expect(wrapper.findAll('.nav-item').at(2).find('a').attributes('href')).toBe('/creation') + }) + it('has a link to /creation-confirm', () => { + expect(wrapper.findAll('.nav-item').at(3).find('a').attributes('href')).toBe( + '/creation-confirm', + ) + }) + it('has a link to /contribution-link', () => { + expect(wrapper.findAll('.nav-item').at(4).find('a').attributes('href')).toBe( + '/contribution-link', + ) + }) + }) + describe('wallet', () => { const assignLocationSpy = jest.fn() beforeEach(async () => { - await wrapper.findAll('a').at(6).trigger('click') + await wrapper.findAll('.nav-item').at(5).find('a').trigger('click') }) - it.skip('changes widnow location to wallet', () => { + it.skip('changes window location to wallet', () => { expect(assignLocationSpy).toBeCalledWith('valid-token') }) @@ -63,7 +89,7 @@ describe('NavBar', () => { window.location = { assign: windowLocationMock, } - await wrapper.findAll('a').at(7).trigger('click') + await wrapper.findAll('.nav-item').at(6).find('a').trigger('click') }) it('redirects to /logout', () => { From de1a305880f7f326cd94ef21b9344ee4d1596b10 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 1 Nov 2022 14:51:56 +0100 Subject: [PATCH 5/5] rename ContributionLink to ContributionLinks --- admin/src/components/NavBar.spec.js | 4 ++-- admin/src/components/NavBar.vue | 4 +++- .../{ContributionLink.spec.js => ContributionLinks.spec.js} | 6 +++--- .../pages/{ContributionLink.vue => ContributionLinks.vue} | 0 admin/src/router/router.test.js | 6 +++--- admin/src/router/routes.js | 4 ++-- 6 files changed, 13 insertions(+), 11 deletions(-) rename admin/src/pages/{ContributionLink.spec.js => ContributionLinks.spec.js} (89%) rename admin/src/pages/{ContributionLink.vue => ContributionLinks.vue} (100%) diff --git a/admin/src/components/NavBar.spec.js b/admin/src/components/NavBar.spec.js index 56e02fbac..8956564bd 100644 --- a/admin/src/components/NavBar.spec.js +++ b/admin/src/components/NavBar.spec.js @@ -60,9 +60,9 @@ describe('NavBar', () => { '/creation-confirm', ) }) - it('has a link to /contribution-link', () => { + it('has a link to /contribution-links', () => { expect(wrapper.findAll('.nav-item').at(4).find('a').attributes('href')).toBe( - '/contribution-link', + '/contribution-links', ) }) }) diff --git a/admin/src/components/NavBar.vue b/admin/src/components/NavBar.vue index 48833d15d..f8dd008d1 100644 --- a/admin/src/components/NavBar.vue +++ b/admin/src/components/NavBar.vue @@ -19,7 +19,9 @@ > {{ $store.state.openCreations }} {{ $t('navbar.open_creation') }} - {{ $t('navbar.automaticContributions') }} + + {{ $t('navbar.automaticContributions') }} + {{ $t('navbar.my-account') }} {{ $t('navbar.logout') }} diff --git a/admin/src/pages/ContributionLink.spec.js b/admin/src/pages/ContributionLinks.spec.js similarity index 89% rename from admin/src/pages/ContributionLink.spec.js rename to admin/src/pages/ContributionLinks.spec.js index 944c1d052..fb60a99cf 100644 --- a/admin/src/pages/ContributionLink.spec.js +++ b/admin/src/pages/ContributionLinks.spec.js @@ -1,5 +1,5 @@ import { mount } from '@vue/test-utils' -import ContributionLink from './ContributionLink.vue' +import ContributionLinks from './ContributionLinks.vue' import { listContributionLinks } from '@/graphql/listContributionLinks.js' const localVue = global.localVue @@ -34,12 +34,12 @@ const mocks = { }, } -describe('ContributionLink', () => { +describe('ContributionLinks', () => { // eslint-disable-next-line no-unused-vars let wrapper const Wrapper = () => { - return mount(ContributionLink, { localVue, mocks }) + return mount(ContributionLinks, { localVue, mocks }) } describe('mount', () => { diff --git a/admin/src/pages/ContributionLink.vue b/admin/src/pages/ContributionLinks.vue similarity index 100% rename from admin/src/pages/ContributionLink.vue rename to admin/src/pages/ContributionLinks.vue diff --git a/admin/src/router/router.test.js b/admin/src/router/router.test.js index bf2e724d2..22273c15b 100644 --- a/admin/src/router/router.test.js +++ b/admin/src/router/router.test.js @@ -81,9 +81,9 @@ describe('router', () => { }) }) - describe('contribution-link', () => { - it('loads the "ContributionLink" component', async () => { - const component = await routes.find((r) => r.path === '/contribution-link').component() + describe('contribution-links', () => { + it('loads the "ContributionLinks" component', async () => { + const component = await routes.find((r) => r.path === '/contribution-links').component() expect(component.default.name).toBe('ContributionLinks') }) }) diff --git a/admin/src/router/routes.js b/admin/src/router/routes.js index caf1030a1..ee82f128e 100644 --- a/admin/src/router/routes.js +++ b/admin/src/router/routes.js @@ -24,8 +24,8 @@ const routes = [ component: () => import('@/pages/CreationConfirm.vue'), }, { - path: '/contribution-link', - component: () => import('@/pages/ContributionLink.vue'), + path: '/contribution-links', + component: () => import('@/pages/ContributionLinks.vue'), }, { path: '*',