From 5361cc9eb9407dfb6b9596a44e2b3d494bec6b58 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 7 Apr 2022 12:56:01 +0200 Subject: [PATCH] corrected correspondign pages --- frontend/src/pages/Login.spec.js | 32 +------- frontend/src/pages/Login.vue | 8 +- frontend/src/pages/Register.spec.js | 31 -------- frontend/src/pages/Register.vue | 8 +- frontend/src/pages/RegisterCommunity.spec.js | 33 --------- frontend/src/pages/RegisterCommunity.vue | 14 ++-- frontend/src/pages/SelectCommunity.spec.js | 78 +++++++------------- frontend/src/pages/SelectCommunity.vue | 10 +-- 8 files changed, 50 insertions(+), 164 deletions(-) diff --git a/frontend/src/pages/Login.spec.js b/frontend/src/pages/Login.spec.js index e26888d49..e506794b3 100644 --- a/frontend/src/pages/Login.spec.js +++ b/frontend/src/pages/Login.spec.js @@ -6,17 +6,7 @@ import { toastErrorSpy } from '@test/testSetup' const localVue = global.localVue -const apolloQueryMock = jest.fn().mockResolvedValue({ - data: { - getCommunityInfo: { - name: 'test12', - description: 'test community 12', - url: 'http://test12.test12/', - registerUrl: 'http://test12.test12/register', - }, - }, -}) - +const apolloQueryMock = jest.fn() const mockStoreDispach = jest.fn() const mockStoreCommit = jest.fn() const mockRouterPush = jest.fn() @@ -55,9 +45,6 @@ describe('Login', () => { $route: { params: {}, }, - $apollo: { - query: apolloQueryMock, - }, } const stubs = { @@ -86,19 +73,6 @@ describe('Login', () => { expect(wrapper.find('div.login-form').exists()).toBeTruthy() }) - describe('communities gives back error', () => { - beforeEach(() => { - apolloQueryMock.mockRejectedValue({ - message: 'Failed to get communities', - }) - wrapper = Wrapper() - }) - - it('toasts an error message', () => { - expect(toastErrorSpy).toBeCalledWith('Failed to get communities') - }) - }) - describe('Login header', () => { it('has a welcome message', () => { expect(wrapper.find('div.header').text()).toBe('site.login.heading site.login.community') @@ -126,10 +100,6 @@ describe('Login', () => { 'Die lokale Entwicklungsumgebung von Gradido.', ) }) - - it('does not call community data update', () => { - expect(apolloQueryMock).not.toBeCalled() - }) }) describe('links', () => { diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue index 79532cb21..f01332202 100755 --- a/frontend/src/pages/Login.vue +++ b/frontend/src/pages/Login.vue @@ -19,9 +19,9 @@
- {{ $store.state.community.name }} + {{ CONFIG.COMMUNITY_NAME }}

- {{ $store.state.community.description }} + {{ CONFIG.COMMUNITY_DESCRIPTION }}

{{ $t('login') }}
@@ -63,7 +63,7 @@ import InputPassword from '@/components/Inputs/InputPassword' import InputEmail from '@/components/Inputs/InputEmail' import { login } from '@/graphql/queries' -import { getCommunityInfoMixin } from '@/mixins/getCommunityInfo' +import CONFIG from '@/config' export default { name: 'Login', @@ -71,7 +71,6 @@ export default { InputPassword, InputEmail, }, - mixins: [getCommunityInfoMixin], data() { return { form: { @@ -79,6 +78,7 @@ export default { password: '', }, passwordVisible: false, + CONFIG, } }, methods: { diff --git a/frontend/src/pages/Register.spec.js b/frontend/src/pages/Register.spec.js index 446c97928..b4f518d3c 100644 --- a/frontend/src/pages/Register.spec.js +++ b/frontend/src/pages/Register.spec.js @@ -2,21 +2,8 @@ import { mount, RouterLinkStub } from '@vue/test-utils' import flushPromises from 'flush-promises' import Register from './Register' -import { toastErrorSpy } from '@test/testSetup' - const localVue = global.localVue -const apolloQueryMock = jest.fn().mockResolvedValue({ - data: { - getCommunityInfo: { - name: 'test12', - description: 'test community 12', - url: 'http://test12.test12/', - registerUrl: 'http://test12.test12/register', - }, - }, -}) - const mockStoreCommit = jest.fn() const registerUserMutationMock = jest.fn() const routerPushMock = jest.fn() @@ -37,7 +24,6 @@ describe('Register', () => { }, $apollo: { mutate: registerUserMutationMock, - query: apolloQueryMock, }, $store: { commit: mockStoreCommit, @@ -85,19 +71,6 @@ describe('Register', () => { }) }) - describe('communities gives back error', () => { - beforeEach(() => { - apolloQueryMock.mockRejectedValue({ - message: 'Failed to get communities', - }) - wrapper = Wrapper() - }) - - it('toasts an error message', () => { - expect(toastErrorSpy).toBeCalledWith('Failed to get communities') - }) - }) - describe('Community data already loaded', () => { beforeEach(() => { jest.clearAllMocks() @@ -119,10 +92,6 @@ describe('Register', () => { 'Die lokale Entwicklungsumgebung von Gradido.', ) }) - - it('does not call community data update', () => { - expect(apolloQueryMock).not.toBeCalled() - }) }) describe('links', () => { diff --git a/frontend/src/pages/Register.vue b/frontend/src/pages/Register.vue index cadc0f34c..94441c636 100755 --- a/frontend/src/pages/Register.vue +++ b/frontend/src/pages/Register.vue @@ -23,9 +23,9 @@
- {{ $store.state.community.name }} + {{ CONFIG.COMMUNITY_NAME }}

- {{ $store.state.community.description }} + {{ CONFIG.COMMUNITY_DESCRIPTION }}

{{ $t('signup') }}
@@ -192,12 +192,11 @@ import InputEmail from '@/components/Inputs/InputEmail.vue' import LanguageSwitchSelect from '@/components/LanguageSwitchSelect.vue' import { createUser } from '@/graphql/mutations' -import { getCommunityInfoMixin } from '@/mixins/getCommunityInfo' +import CONFIG from '@/config' export default { components: { InputEmail, LanguageSwitchSelect }, name: 'Register', - mixins: [getCommunityInfoMixin], data() { return { form: { @@ -213,6 +212,7 @@ export default { register: true, publisherId: this.$store.state.publisherId, redeemCode: this.$route.params.code, + CONFIG, } }, methods: { diff --git a/frontend/src/pages/RegisterCommunity.spec.js b/frontend/src/pages/RegisterCommunity.spec.js index deb1d999d..76890f877 100644 --- a/frontend/src/pages/RegisterCommunity.spec.js +++ b/frontend/src/pages/RegisterCommunity.spec.js @@ -1,21 +1,8 @@ import { mount, RouterLinkStub } from '@vue/test-utils' import RegisterCommunity from './RegisterCommunity' -import { toastErrorSpy } from '@test/testSetup' - const localVue = global.localVue -const apolloQueryMock = jest.fn().mockResolvedValue({ - data: { - getCommunityInfo: { - name: 'test12', - description: 'test community 12', - url: 'http://test12.test12/', - registerUrl: 'http://test12.test12/register', - }, - }, -}) - const mockStoreCommit = jest.fn() describe('RegisterCommunity', () => { @@ -26,9 +13,6 @@ describe('RegisterCommunity', () => { locale: 'en', }, $t: jest.fn((t) => t), - $apollo: { - query: apolloQueryMock, - }, $store: { commit: mockStoreCommit, state: { @@ -66,19 +50,6 @@ describe('RegisterCommunity', () => { expect(wrapper.find('div#register-community').exists()).toBeTruthy() }) - describe('communities gives back error', () => { - beforeEach(() => { - apolloQueryMock.mockRejectedValue({ - message: 'Failed to get communities', - }) - wrapper = Wrapper() - }) - - it('toasts an error message', () => { - expect(toastErrorSpy).toBeCalledWith('Failed to get communities') - }) - }) - describe('Community data already loaded', () => { beforeEach(() => { jest.clearAllMocks() @@ -100,10 +71,6 @@ describe('RegisterCommunity', () => { 'Die lokale Entwicklungsumgebung von Gradido.', ) }) - - it('does not call community data update', () => { - expect(apolloQueryMock).not.toBeCalled() - }) }) describe('buttons and links', () => { diff --git a/frontend/src/pages/RegisterCommunity.vue b/frontend/src/pages/RegisterCommunity.vue index 736a4282f..1acc0827e 100644 --- a/frontend/src/pages/RegisterCommunity.vue +++ b/frontend/src/pages/RegisterCommunity.vue @@ -6,12 +6,12 @@
-

{{ $store.state.community.name }}

+

{{ CONFIG.COMMUNITY_NAME }}

- {{ $store.state.community.description }} + {{ CONFIG.COMMUNITY_DESCRIPTION }}

- {{ $store.state.community.url }} + {{ CONFIG.COMMUNITY_URL }}

@@ -49,10 +49,14 @@
diff --git a/frontend/src/pages/SelectCommunity.spec.js b/frontend/src/pages/SelectCommunity.spec.js index f8896ae15..25ec8db93 100644 --- a/frontend/src/pages/SelectCommunity.spec.js +++ b/frontend/src/pages/SelectCommunity.spec.js @@ -1,5 +1,5 @@ import { mount, RouterLinkStub } from '@vue/test-utils' -import { communities, communityInfo } from '@/graphql/queries' +import { communities } from '@/graphql/queries' import SelectCommunity from './SelectCommunity' import { toastErrorSpy } from '@test/testSetup' @@ -14,45 +14,33 @@ const spinnerMock = jest.fn(() => { } }) -const apolloQueryMock = jest - .fn() - .mockResolvedValueOnce({ - data: { - getCommunityInfo: { - name: 'test12', - description: 'test community 12', - url: 'http://test12.test12/', - registerUrl: 'http://test12.test12/register', +const apolloQueryMock = jest.fn().mockResolvedValue({ + data: { + communities: [ + { + id: 1, + name: 'Gradido Entwicklung', + description: 'Die lokale Entwicklungsumgebung von Gradido.', + url: 'http://localhost/', + registerUrl: 'http://localhost/register-community', }, - }, - }) - .mockResolvedValue({ - data: { - communities: [ - { - id: 1, - name: 'Gradido Entwicklung', - description: 'Die lokale Entwicklungsumgebung von Gradido.', - url: 'http://localhost/', - registerUrl: 'http://localhost/register-community', - }, - { - id: 2, - name: 'Gradido Staging', - description: 'Der Testserver der Gradido-Akademie.', - url: 'https://stage1.gradido.net/', - registerUrl: 'https://stage1.gradido.net/register-community', - }, - { - id: 3, - name: 'Gradido-Akademie', - description: 'Freies Institut für Wirtschaftsbionik.', - url: 'https://gradido.net', - registerUrl: 'https://gdd1.gradido.com/register-community', - }, - ], - }, - }) + { + id: 2, + name: 'Gradido Staging', + description: 'Der Testserver der Gradido-Akademie.', + url: 'https://stage1.gradido.net/', + registerUrl: 'https://stage1.gradido.net/register-community', + }, + { + id: 3, + name: 'Gradido-Akademie', + description: 'Freies Institut für Wirtschaftsbionik.', + url: 'https://gradido.net', + registerUrl: 'https://gdd1.gradido.com/register-community', + }, + ], + }, +}) const mockStoreCommit = jest.fn() @@ -95,12 +83,6 @@ describe('SelectCommunity', () => { wrapper = Wrapper() }) - it('calls the API to get the community info data', () => { - expect(apolloQueryMock).toBeCalledWith({ - query: communityInfo, - }) - }) - it('calls the API to get the communities data', () => { expect(apolloQueryMock).toBeCalledWith({ query: communities, @@ -141,12 +123,6 @@ describe('SelectCommunity', () => { wrapper = Wrapper() }) - it('does not call community info data when already filled', () => { - expect(apolloQueryMock).not.toBeCalledWith({ - query: communityInfo, - }) - }) - it('has a Community name', () => { expect(wrapper.find('.card-body b').text()).toBe('Gradido Entwicklung') }) diff --git a/frontend/src/pages/SelectCommunity.vue b/frontend/src/pages/SelectCommunity.vue index 0535e4fe7..8702d3e2e 100644 --- a/frontend/src/pages/SelectCommunity.vue +++ b/frontend/src/pages/SelectCommunity.vue @@ -5,9 +5,9 @@
- {{ $store.state.community.name }} + {{ CONFIG.COMMUNITY_NAME }}
-

{{ $store.state.community.description }}

+

{{ CONFIG.COMMUNITY_DESCRIPTION }}


@@ -49,7 +49,7 @@