Merge pull request #1750 from gradido/frontend_community_info_bake_in

Refactor: Frontend bake in community info
This commit is contained in:
Ulf Gebhardt 2022-04-20 14:03:18 +02:00 committed by GitHub
commit daa07b780a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 163 additions and 345 deletions

View File

@ -17,6 +17,12 @@ NGINX_UPDATE_PAGE_ROOT=/home/gradido/gradido/deployment/bare_metal/nginx/update-
WEBHOOK_GITHUB_SECRET=secret WEBHOOK_GITHUB_SECRET=secret
WEBHOOK_GITHUB_BRANCH=master WEBHOOK_GITHUB_BRANCH=master
# community
COMMUNITY_NAME="Gradido Development Stage1"
COMMUNITY_URL=https://stage1.gradido.net/
COMMUNITY_REGISTER_URL=https://stage1.gradido.net/register
COMMUNITY_DESCRIPTION="Gradido Development Stage1 Test Community"
# backend # backend
BACKEND_CONFIG_VERSION=v5.2022-04-12 BACKEND_CONFIG_VERSION=v5.2022-04-12
@ -31,11 +37,6 @@ KLICKTIPP_PASSWORD=
KLICKTIPP_APIKEY_DE= KLICKTIPP_APIKEY_DE=
KLICKTIPP_APIKEY_EN= KLICKTIPP_APIKEY_EN=
COMMUNITY_NAME="Gradido Development Stage1"
COMMUNITY_URL=https://stage1.gradido.net/
COMMUNITY_REGISTER_URL=https://stage1.gradido.net/register
COMMUNITY_DESCRIPTION="Gradido Development Stage1 Test Community"
EMAIL=true EMAIL=true
EMAIL_USERNAME=peter@lustig.de EMAIL_USERNAME=peter@lustig.de
EMAIL_SENDER=peter@lustig.de EMAIL_SENDER=peter@lustig.de
@ -54,7 +55,7 @@ WEBHOOK_ELOPAGE_SECRET=secret
DATABASE_CONFIG_VERSION=v1.2022-03-18 DATABASE_CONFIG_VERSION=v1.2022-03-18
# frontend # frontend
FRONTEND_CONFIG_VERSION=v1.2022-03-18 FRONTEND_CONFIG_VERSION=v2.2022-04-07
GRAPHQL_URI=https://stage1.gradido.net/graphql GRAPHQL_URI=https://stage1.gradido.net/graphql
ADMIN_AUTH_URL=https://stage1.gradido.net/admin/authenticate?token={token} ADMIN_AUTH_URL=https://stage1.gradido.net/admin/authenticate?token={token}

View File

@ -1,5 +1,19 @@
CONFIG_VERSION=v1.2022-03-18 CONFIG_VERSION=v2.2022-04-07
# Environment
DEFAULT_PUBLISHER_ID=2896
# Endpoints
GRAPHQL_URI=http://localhost/graphql
ADMIN_AUTH_URL=http://localhost/admin/authenticate?token={token}
# Community
COMMUNITY_NAME=Gradido Entwicklung
COMMUNITY_URL=http://localhost/
COMMUNITY_REGISTER_URL=http://localhost/register
COMMUNITY_DESCRIPTION=Die lokale Entwicklungsumgebung von Gradido.
# Meta
META_URL=http://localhost META_URL=http://localhost
META_TITLE_DE="Gradido Dein Dankbarkeitskonto" META_TITLE_DE="Gradido Dein Dankbarkeitskonto"
META_TITLE_EN="Gradido - Your gratitude account" META_TITLE_EN="Gradido - Your gratitude account"
@ -8,6 +22,3 @@ META_DESCRIPTION_EN="Gratitude is the currency of the new age. More and more peo
META_KEYWORDS_DE="Grundeinkommen, Währung, Dankbarkeit, Schenk-Ökonomie, Natürliche Ökonomie des Lebens, Ökonomie, Ökologie, Potenzialentfaltung, Schenken und Danken, Kreislauf des Lebens, Geldsystem" META_KEYWORDS_DE="Grundeinkommen, Währung, Dankbarkeit, Schenk-Ökonomie, Natürliche Ökonomie des Lebens, Ökonomie, Ökologie, Potenzialentfaltung, Schenken und Danken, Kreislauf des Lebens, Geldsystem"
META_KEYWORDS_EN="Basic Income, Currency, Gratitude, Gift Economy, Natural Economy of Life, Economy, Ecology, Potential Development, Giving and Thanking, Cycle of Life, Monetary System" META_KEYWORDS_EN="Basic Income, Currency, Gratitude, Gift Economy, Natural Economy of Life, Economy, Ecology, Potential Development, Giving and Thanking, Cycle of Life, Monetary System"
META_AUTHOR="Bernd Hückstädt - Gradido-Akademie" META_AUTHOR="Bernd Hückstädt - Gradido-Akademie"
GRAPHQL_URI=http://localhost/graphql
DEFAULT_PUBLISHER_ID=2896
ADMIN_AUTH_URL=http://localhost/admin/authenticate?token={token}

View File

@ -1,5 +1,19 @@
CONFIG_VERSION=$FRONTEND_CONFIG_VERSION CONFIG_VERSION=$FRONTEND_CONFIG_VERSION
# Environment
DEFAULT_PUBLISHER_ID=$DEFAULT_PUBLISHER_ID
# Endpoints
GRAPHQL_URI=$GRAPHQL_URI
ADMIN_AUTH_URL=$ADMIN_AUTH_URL
# Community
COMMUNITY_NAME=$COMMUNITY_NAME
COMMUNITY_URL=$COMMUNITY_URL
COMMUNITY_REGISTER_URL=$COMMUNITY_REGISTER_URL
COMMUNITY_DESCRIPTION=$COMMUNITY_DESCRIPTION
# Meta
META_URL=$META_URL META_URL=$META_URL
META_TITLE_DE=$META_TITLE_DE META_TITLE_DE=$META_TITLE_DE
META_TITLE_EN=$META_TITLE_EN META_TITLE_EN=$META_TITLE_EN
@ -8,6 +22,3 @@ META_DESCRIPTION_EN=$META_DESCRIPTION_EN
META_KEYWORDS_DE=$META_KEYWORDS_DE META_KEYWORDS_DE=$META_KEYWORDS_DE
META_KEYWORDS_EN=$META_KEYWORDS_EN META_KEYWORDS_EN=$META_KEYWORDS_EN
META_AUTHOR=$META_AUTHOR META_AUTHOR=$META_AUTHOR
GRAPHQL_URI=$GRAPHQL_URI
DEFAULT_PUBLISHER_ID=$DEFAULT_PUBLISHER_ID
ADMIN_AUTH_URL=$ADMIN_AUTH_URL

View File

@ -8,7 +8,7 @@ const constants = {
DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
CONFIG_VERSION: { CONFIG_VERSION: {
DEFAULT: 'DEFAULT', DEFAULT: 'DEFAULT',
EXPECTED: 'v1.2022-03-18', EXPECTED: 'v2.2022-04-07',
CURRENT: '', CURRENT: '',
}, },
} }
@ -28,6 +28,19 @@ const environment = {
PORT: process.env.PORT || 3000, PORT: process.env.PORT || 3000,
} }
const endpoints = {
GRAPHQL_URI: process.env.GRAPHQL_URI || 'http://localhost/graphql',
ADMIN_AUTH_URL: process.env.ADMIN_AUTH_URL || 'http://localhost/admin/authenticate?token={token}',
}
const community = {
COMMUNITY_NAME: process.env.COMMUNITY_NAME || 'Gradido Entwicklung',
COMMUNITY_URL: process.env.COMMUNITY_URL || 'http://localhost/',
COMMUNITY_REGISTER_URL: process.env.COMMUNITY_REGISTER_URL || 'http://localhost/register',
COMMUNITY_DESCRIPTION:
process.env.COMMUNITY_DESCRIPTION || 'Die lokale Entwicklungsumgebung von Gradido.',
}
const meta = { const meta = {
META_URL: process.env.META_URL || 'http://localhost', META_URL: process.env.META_URL || 'http://localhost',
META_TITLE_DE: process.env.META_TITLE_DE || 'Gradido Dein Dankbarkeitskonto', META_TITLE_DE: process.env.META_TITLE_DE || 'Gradido Dein Dankbarkeitskonto',
@ -47,11 +60,6 @@ const meta = {
META_AUTHOR: process.env.META_AUTHOR || 'Bernd Hückstädt - Gradido-Akademie', META_AUTHOR: process.env.META_AUTHOR || 'Bernd Hückstädt - Gradido-Akademie',
} }
const endpoints = {
GRAPHQL_URI: process.env.GRAPHQL_URI || 'http://localhost/graphql',
ADMIN_AUTH_URL: process.env.ADMIN_AUTH_URL || 'http://localhost/admin/authenticate?token={token}',
}
// Check config version // Check config version
constants.CONFIG_VERSION.CURRENT = process.env.CONFIG_VERSION || constants.CONFIG_VERSION.DEFAULT constants.CONFIG_VERSION.CURRENT = process.env.CONFIG_VERSION || constants.CONFIG_VERSION.DEFAULT
if ( if (
@ -69,6 +77,7 @@ const CONFIG = {
...version, ...version,
...environment, ...environment,
...endpoints, ...endpoints,
...community,
...meta, ...meta,
} }

View File

@ -95,17 +95,6 @@ export const listGDTEntriesQuery = gql`
} }
` `
export const communityInfo = gql`
query {
getCommunityInfo {
name
description
registerUrl
url
}
}
`
export const communities = gql` export const communities = gql`
query { query {
communities { communities {

View File

@ -1,24 +0,0 @@
import { communityInfo } from '../graphql/queries'
export const getCommunityInfoMixin = {
methods: {
getCommunityInfo() {
if (this.$store.state.community.name === '') {
this.$apollo
.query({
query: communityInfo,
})
.then((result) => {
this.$store.commit('community', result.data.getCommunityInfo)
return result.data.getCommunityInfo
})
.catch((error) => {
this.toastError(error.message)
})
}
},
},
created() {
this.getCommunityInfo()
},
}

View File

@ -6,17 +6,7 @@ import { toastErrorSpy } from '@test/testSetup'
const localVue = global.localVue const localVue = global.localVue
const apolloQueryMock = jest.fn().mockResolvedValue({ const apolloQueryMock = jest.fn()
data: {
getCommunityInfo: {
name: 'test12',
description: 'test community 12',
url: 'http://test12.test12/',
registerUrl: 'http://test12.test12/register',
},
},
})
const mockStoreDispach = jest.fn() const mockStoreDispach = jest.fn()
const mockStoreCommit = jest.fn() const mockStoreCommit = jest.fn()
const mockRouterPush = jest.fn() const mockRouterPush = jest.fn()
@ -39,10 +29,6 @@ describe('Login', () => {
dispatch: mockStoreDispach, dispatch: mockStoreDispach,
commit: mockStoreCommit, commit: mockStoreCommit,
state: { state: {
community: {
name: '',
description: '',
},
publisherId: 12345, publisherId: 12345,
}, },
}, },
@ -73,50 +59,16 @@ describe('Login', () => {
wrapper = Wrapper() wrapper = Wrapper()
}) })
it('commits the community info to the store', () => {
expect(mockStoreCommit).toBeCalledWith('community', {
name: 'test12',
description: 'test community 12',
url: 'http://test12.test12/',
registerUrl: 'http://test12.test12/register',
})
})
it('renders the Login form', () => { it('renders the Login form', () => {
expect(wrapper.find('div.login-form').exists()).toBeTruthy() 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', () => { describe('Login header', () => {
it('has a welcome message', () => { it('has a welcome message', () => {
expect(wrapper.find('div.header').text()).toBe('site.login.heading site.login.community') expect(wrapper.find('div.header').text()).toBe('site.login.heading site.login.community')
}) })
}) })
describe('Community data already loaded', () => {
beforeEach(() => {
jest.clearAllMocks()
mocks.$store.state.community = {
name: 'Gradido Entwicklung',
url: 'http://localhost/',
registerUrl: 'http://localhost/register',
description: 'Die lokale Entwicklungsumgebung von Gradido.',
}
wrapper = Wrapper()
})
it('has a Community name', () => { it('has a Community name', () => {
expect(wrapper.find('.test-communitydata b').text()).toBe('Gradido Entwicklung') expect(wrapper.find('.test-communitydata b').text()).toBe('Gradido Entwicklung')
}) })
@ -127,11 +79,6 @@ describe('Login', () => {
) )
}) })
it('does not call community data update', () => {
expect(apolloQueryMock).not.toBeCalled()
})
})
describe('links', () => { describe('links', () => {
it('has a link "Forgot Password"', () => { it('has a link "Forgot Password"', () => {
expect(wrapper.findAllComponents(RouterLinkStub).at(0).text()).toEqual( expect(wrapper.findAllComponents(RouterLinkStub).at(0).text()).toEqual(
@ -197,13 +144,13 @@ describe('Login', () => {
await wrapper.find('input[placeholder="Email"]').setValue('user@example.org') await wrapper.find('input[placeholder="Email"]').setValue('user@example.org')
await wrapper.find('input[placeholder="form.password"]').setValue('1234') await wrapper.find('input[placeholder="form.password"]').setValue('1234')
await flushPromises() await flushPromises()
await wrapper.find('form').trigger('submit')
await flushPromises()
apolloQueryMock.mockResolvedValue({ apolloQueryMock.mockResolvedValue({
data: { data: {
login: 'token', login: 'token',
}, },
}) })
await wrapper.find('form').trigger('submit')
await flushPromises()
}) })
it('calls the API with the given data', () => { it('calls the API with the given data', () => {
@ -255,12 +202,19 @@ describe('Login', () => {
}) })
}) })
}) })
})
describe('login fails', () => { describe('login fails', () => {
beforeEach(() => { beforeEach(async () => {
jest.clearAllMocks()
await wrapper.find('input[placeholder="Email"]').setValue('user@example.org')
await wrapper.find('input[placeholder="form.password"]').setValue('1234')
await flushPromises()
apolloQueryMock.mockRejectedValue({ apolloQueryMock.mockRejectedValue({
message: '..No user with this credentials', message: '..No user with this credentials',
}) })
await wrapper.find('form').trigger('submit')
await flushPromises()
}) })
it('hides the spinner', () => { it('hides the spinner', () => {
@ -311,5 +265,4 @@ describe('Login', () => {
}) })
}) })
}) })
})
}) })

View File

@ -19,9 +19,9 @@
<b-card no-body class="border-0 mb-0 gradido-custom-background"> <b-card no-body class="border-0 mb-0 gradido-custom-background">
<b-card-body class="p-4"> <b-card-body class="p-4">
<div class="text-center text-muted mb-4 test-communitydata"> <div class="text-center text-muted mb-4 test-communitydata">
<b>{{ $store.state.community.name }}</b> <b>{{ CONFIG.COMMUNITY_NAME }}</b>
<p class="text-lead"> <p class="text-lead">
{{ $store.state.community.description }} {{ CONFIG.COMMUNITY_DESCRIPTION }}
</p> </p>
{{ $t('login') }} {{ $t('login') }}
</div> </div>
@ -63,7 +63,7 @@
import InputPassword from '@/components/Inputs/InputPassword' import InputPassword from '@/components/Inputs/InputPassword'
import InputEmail from '@/components/Inputs/InputEmail' import InputEmail from '@/components/Inputs/InputEmail'
import { login } from '@/graphql/queries' import { login } from '@/graphql/queries'
import { getCommunityInfoMixin } from '@/mixins/getCommunityInfo' import CONFIG from '@/config'
export default { export default {
name: 'Login', name: 'Login',
@ -71,7 +71,6 @@ export default {
InputPassword, InputPassword,
InputEmail, InputEmail,
}, },
mixins: [getCommunityInfoMixin],
data() { data() {
return { return {
form: { form: {
@ -79,6 +78,7 @@ export default {
password: '', password: '',
}, },
passwordVisible: false, passwordVisible: false,
CONFIG,
} }
}, },
methods: { methods: {

View File

@ -2,21 +2,8 @@ import { mount, RouterLinkStub } from '@vue/test-utils'
import flushPromises from 'flush-promises' import flushPromises from 'flush-promises'
import Register from './Register' import Register from './Register'
import { toastErrorSpy } from '@test/testSetup'
const localVue = global.localVue 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 mockStoreCommit = jest.fn()
const registerUserMutationMock = jest.fn() const registerUserMutationMock = jest.fn()
const routerPushMock = jest.fn() const routerPushMock = jest.fn()
@ -37,17 +24,12 @@ describe('Register', () => {
}, },
$apollo: { $apollo: {
mutate: registerUserMutationMock, mutate: registerUserMutationMock,
query: apolloQueryMock,
}, },
$store: { $store: {
commit: mockStoreCommit, commit: mockStoreCommit,
state: { state: {
email: 'peter@lustig.de', email: 'peter@lustig.de',
language: 'en', language: 'en',
community: {
name: '',
description: '',
},
publisherId: 12345, publisherId: 12345,
}, },
}, },
@ -66,15 +48,6 @@ describe('Register', () => {
wrapper = Wrapper() wrapper = Wrapper()
}) })
it('commits the community info to the store', () => {
expect(mockStoreCommit).toBeCalledWith('community', {
name: 'test12',
description: 'test community 12',
url: 'http://test12.test12/',
registerUrl: 'http://test12.test12/register',
})
})
it('renders the Register form', () => { it('renders the Register form', () => {
expect(wrapper.find('div#registerform').exists()).toBeTruthy() expect(wrapper.find('div#registerform').exists()).toBeTruthy()
}) })
@ -85,19 +58,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', () => { describe('Community data already loaded', () => {
beforeEach(() => { beforeEach(() => {
jest.clearAllMocks() jest.clearAllMocks()
@ -119,10 +79,6 @@ describe('Register', () => {
'Die lokale Entwicklungsumgebung von Gradido.', 'Die lokale Entwicklungsumgebung von Gradido.',
) )
}) })
it('does not call community data update', () => {
expect(apolloQueryMock).not.toBeCalled()
})
}) })
describe('links', () => { describe('links', () => {

View File

@ -23,9 +23,9 @@
<b-card no-body class="border-0 gradido-custom-background"> <b-card no-body class="border-0 gradido-custom-background">
<b-card-body class="p-4"> <b-card-body class="p-4">
<div class="text-center text-muted mb-4 test-communitydata"> <div class="text-center text-muted mb-4 test-communitydata">
<b>{{ $store.state.community.name }}</b> <b>{{ CONFIG.COMMUNITY_NAME }}</b>
<p class="text-lead"> <p class="text-lead">
{{ $store.state.community.description }} {{ CONFIG.COMMUNITY_DESCRIPTION }}
</p> </p>
<div>{{ $t('signup') }}</div> <div>{{ $t('signup') }}</div>
</div> </div>
@ -192,12 +192,11 @@
import InputEmail from '@/components/Inputs/InputEmail.vue' import InputEmail from '@/components/Inputs/InputEmail.vue'
import LanguageSwitchSelect from '@/components/LanguageSwitchSelect.vue' import LanguageSwitchSelect from '@/components/LanguageSwitchSelect.vue'
import { createUser } from '@/graphql/mutations' import { createUser } from '@/graphql/mutations'
import { getCommunityInfoMixin } from '@/mixins/getCommunityInfo' import CONFIG from '@/config'
export default { export default {
components: { InputEmail, LanguageSwitchSelect }, components: { InputEmail, LanguageSwitchSelect },
name: 'Register', name: 'Register',
mixins: [getCommunityInfoMixin],
data() { data() {
return { return {
form: { form: {
@ -213,6 +212,7 @@ export default {
register: true, register: true,
publisherId: this.$store.state.publisherId, publisherId: this.$store.state.publisherId,
redeemCode: this.$route.params.code, redeemCode: this.$route.params.code,
CONFIG,
} }
}, },
methods: { methods: {

View File

@ -1,21 +1,8 @@
import { mount, RouterLinkStub } from '@vue/test-utils' import { mount, RouterLinkStub } from '@vue/test-utils'
import RegisterCommunity from './RegisterCommunity' import RegisterCommunity from './RegisterCommunity'
import { toastErrorSpy } from '@test/testSetup'
const localVue = global.localVue 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 mockStoreCommit = jest.fn()
describe('RegisterCommunity', () => { describe('RegisterCommunity', () => {
@ -26,9 +13,6 @@ describe('RegisterCommunity', () => {
locale: 'en', locale: 'en',
}, },
$t: jest.fn((t) => t), $t: jest.fn((t) => t),
$apollo: {
query: apolloQueryMock,
},
$store: { $store: {
commit: mockStoreCommit, commit: mockStoreCommit,
state: { state: {
@ -53,32 +37,10 @@ describe('RegisterCommunity', () => {
wrapper = Wrapper() wrapper = Wrapper()
}) })
it('commits the community info to the store', () => {
expect(mockStoreCommit).toBeCalledWith('community', {
name: 'test12',
description: 'test community 12',
url: 'http://test12.test12/',
registerUrl: 'http://test12.test12/register',
})
})
it('renders the Div Element "#register-community"', () => { it('renders the Div Element "#register-community"', () => {
expect(wrapper.find('div#register-community').exists()).toBeTruthy() 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', () => { describe('Community data already loaded', () => {
beforeEach(() => { beforeEach(() => {
jest.clearAllMocks() jest.clearAllMocks()
@ -100,10 +62,6 @@ describe('RegisterCommunity', () => {
'Die lokale Entwicklungsumgebung von Gradido.', 'Die lokale Entwicklungsumgebung von Gradido.',
) )
}) })
it('does not call community data update', () => {
expect(apolloQueryMock).not.toBeCalled()
})
}) })
describe('buttons and links', () => { describe('buttons and links', () => {

View File

@ -6,12 +6,12 @@
<div class="text-center mb-7 header"> <div class="text-center mb-7 header">
<b-row class="justify-content-center"> <b-row class="justify-content-center">
<b-col xl="5" lg="6" md="8" class="px-2"> <b-col xl="5" lg="6" md="8" class="px-2">
<h1>{{ $store.state.community.name }}</h1> <h1>{{ CONFIG.COMMUNITY_NAME }}</h1>
<p class="text-lead"> <p class="text-lead">
{{ $store.state.community.description }} {{ CONFIG.COMMUNITY_DESCRIPTION }}
</p> </p>
<p class="text-lead community-location"> <p class="text-lead community-location">
{{ $store.state.community.url }} {{ CONFIG.COMMUNITY_URL }}
</p> </p>
</b-col> </b-col>
</b-row> </b-row>
@ -49,10 +49,14 @@
</div> </div>
</template> </template>
<script> <script>
import { getCommunityInfoMixin } from '@/mixins/getCommunityInfo' import CONFIG from '@/config'
export default { export default {
name: 'RegisterCommunity', name: 'RegisterCommunity',
mixins: [getCommunityInfoMixin], data() {
return {
CONFIG,
}
},
} }
</script> </script>

View File

@ -1,5 +1,5 @@
import { mount, RouterLinkStub } from '@vue/test-utils' import { mount, RouterLinkStub } from '@vue/test-utils'
import { communities, communityInfo } from '@/graphql/queries' import { communities } from '@/graphql/queries'
import SelectCommunity from './SelectCommunity' import SelectCommunity from './SelectCommunity'
import { toastErrorSpy } from '@test/testSetup' import { toastErrorSpy } from '@test/testSetup'
@ -14,19 +14,7 @@ const spinnerMock = jest.fn(() => {
} }
}) })
const apolloQueryMock = jest const apolloQueryMock = jest.fn().mockResolvedValue({
.fn()
.mockResolvedValueOnce({
data: {
getCommunityInfo: {
name: 'test12',
description: 'test community 12',
url: 'http://test12.test12/',
registerUrl: 'http://test12.test12/register',
},
},
})
.mockResolvedValue({
data: { data: {
communities: [ communities: [
{ {
@ -52,7 +40,7 @@ const apolloQueryMock = jest
}, },
], ],
}, },
}) })
const mockStoreCommit = jest.fn() const mockStoreCommit = jest.fn()
@ -95,12 +83,6 @@ describe('SelectCommunity', () => {
wrapper = Wrapper() 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', () => { it('calls the API to get the communities data', () => {
expect(apolloQueryMock).toBeCalledWith({ expect(apolloQueryMock).toBeCalledWith({
query: communities, query: communities,
@ -141,12 +123,6 @@ describe('SelectCommunity', () => {
wrapper = Wrapper() wrapper = Wrapper()
}) })
it('does not call community info data when already filled', () => {
expect(apolloQueryMock).not.toBeCalledWith({
query: communityInfo,
})
})
it('has a Community name', () => { it('has a Community name', () => {
expect(wrapper.find('.card-body b').text()).toBe('Gradido Entwicklung') expect(wrapper.find('.card-body b').text()).toBe('Gradido Entwicklung')
}) })

View File

@ -5,9 +5,9 @@
<div v-if="!pending"> <div v-if="!pending">
<b-card class="border-0 mb-0" bg-variant="primary"> <b-card class="border-0 mb-0" bg-variant="primary">
<b>{{ $store.state.community.name }}</b> <b>{{ CONFIG.COMMUNITY_NAME }}</b>
<br /> <br />
<p>{{ $store.state.community.description }}</p> <p>{{ CONFIG.COMMUNITY_DESCRIPTION }}</p>
<br /> <br />
<router-link to="/register"> <router-link to="/register">
<b-button variant="outline-secondary"> <b-button variant="outline-secondary">
@ -49,7 +49,7 @@
</template> </template>
<script> <script>
import { communities } from '@/graphql/queries' import { communities } from '@/graphql/queries'
import { getCommunityInfoMixin } from '@/mixins/getCommunityInfo' import CONFIG from '@/config'
export default { export default {
name: 'SelectCommunity', name: 'SelectCommunity',
@ -57,9 +57,9 @@ export default {
return { return {
communities: [], communities: [],
pending: true, pending: true,
CONFIG,
} }
}, },
mixins: [getCommunityInfoMixin],
methods: { methods: {
async getCommunities() { async getCommunities() {
const loader = this.$loading.show({ const loader = this.$loading.show({
@ -72,7 +72,7 @@ export default {
}) })
.then((response) => { .then((response) => {
this.communities = response.data.communities.filter( this.communities = response.data.communities.filter(
(c) => c.name !== this.$store.state.community.name, (c) => c.name !== CONFIG.COMMUNITY_NAME,
) )
}) })
.catch((error) => { .catch((error) => {

View File

@ -38,9 +38,6 @@ export const mutations = {
isAdmin: (state, isAdmin) => { isAdmin: (state, isAdmin) => {
state.isAdmin = !!isAdmin state.isAdmin = !!isAdmin
}, },
community: (state, community) => {
state.community = community
},
coinanimation: (state, coinanimation) => { coinanimation: (state, coinanimation) => {
state.coinanimation = coinanimation state.coinanimation = coinanimation
}, },
@ -96,10 +93,6 @@ try {
isAdmin: false, isAdmin: false,
coinanimation: true, coinanimation: true,
newsletterState: null, newsletterState: null,
community: {
name: '',
description: '',
},
hasElopage: false, hasElopage: false,
publisherId: null, publisherId: null,
}, },

View File

@ -24,7 +24,6 @@ const {
newsletterState, newsletterState,
publisherId, publisherId,
isAdmin, isAdmin,
community,
hasElopage, hasElopage,
} = mutations } = mutations
const { login, logout } = actions const { login, logout } = actions
@ -117,24 +116,6 @@ describe('Vuex store', () => {
}) })
}) })
describe('community', () => {
it('sets the state of community', () => {
const state = {}
community(state, {
name: 'test12',
description: 'test community 12',
url: 'http://test12.test12/',
registerUrl: 'http://test12.test12/register',
})
expect(state.community).toEqual({
name: 'test12',
description: 'test community 12',
url: 'http://test12.test12/',
registerUrl: 'http://test12.test12/register',
})
})
})
describe('hasElopage', () => { describe('hasElopage', () => {
it('sets the state of hasElopage', () => { it('sets the state of hasElopage', () => {
const state = { hasElopage: false } const state = { hasElopage: false }