corrected correspondign pages

This commit is contained in:
Ulf Gebhardt 2022-04-07 12:56:01 +02:00
parent ab3ff9cf4a
commit 5361cc9eb9
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
8 changed files with 50 additions and 164 deletions

View File

@ -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', () => {

View File

@ -19,9 +19,9 @@
<b-card no-body class="border-0 mb-0 gradido-custom-background">
<b-card-body class="p-4">
<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">
{{ $store.state.community.description }}
{{ CONFIG.COMMUNITY_DESCRIPTION }}
</p>
{{ $t('login') }}
</div>
@ -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: {

View File

@ -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', () => {

View File

@ -23,9 +23,9 @@
<b-card no-body class="border-0 gradido-custom-background">
<b-card-body class="p-4">
<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">
{{ $store.state.community.description }}
{{ CONFIG.COMMUNITY_DESCRIPTION }}
</p>
<div>{{ $t('signup') }}</div>
</div>
@ -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: {

View File

@ -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', () => {

View File

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

View File

@ -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')
})

View File

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