mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge pull request #1043 from gradido/1036-register-page-breaks-without-community
1036 register page breaks without community
This commit is contained in:
commit
eb033addaa
24
frontend/src/mixins/getCommunityInfo.js
Normal file
24
frontend/src/mixins/getCommunityInfo.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
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.$toasted.error(error.message)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getCommunityInfo()
|
||||||
|
},
|
||||||
|
}
|
||||||
@ -89,7 +89,10 @@ export const store = new Vuex.Store({
|
|||||||
token: null,
|
token: null,
|
||||||
coinanimation: true,
|
coinanimation: true,
|
||||||
newsletterState: null,
|
newsletterState: null,
|
||||||
community: null,
|
community: {
|
||||||
|
name: '',
|
||||||
|
description: '',
|
||||||
|
},
|
||||||
hasElopage: false,
|
hasElopage: false,
|
||||||
publisherId: null,
|
publisherId: null,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { mount, RouterLinkStub } from '@vue/test-utils'
|
import { RouterLinkStub, mount } from '@vue/test-utils'
|
||||||
import flushPromises from 'flush-promises'
|
import flushPromises from 'flush-promises'
|
||||||
import Login from './Login'
|
import Login from './Login'
|
||||||
|
|
||||||
@ -39,10 +39,8 @@ describe('Login', () => {
|
|||||||
commit: mockStoreCommit,
|
commit: mockStoreCommit,
|
||||||
state: {
|
state: {
|
||||||
community: {
|
community: {
|
||||||
name: 'Gradido Entwicklung',
|
name: '',
|
||||||
url: 'http://localhost/vue/',
|
description: '',
|
||||||
registerUrl: 'http://localhost/vue/register',
|
|
||||||
description: 'Die lokale Entwicklungsumgebung von Gradido.',
|
|
||||||
},
|
},
|
||||||
publisherId: 12345,
|
publisherId: 12345,
|
||||||
},
|
},
|
||||||
@ -74,10 +72,6 @@ describe('Login', () => {
|
|||||||
wrapper = Wrapper()
|
wrapper = Wrapper()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders the Login form', () => {
|
|
||||||
expect(wrapper.find('div.login-form').exists()).toBeTruthy()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('commits the community info to the store', () => {
|
it('commits the community info to the store', () => {
|
||||||
expect(mockStoreCommit).toBeCalledWith('community', {
|
expect(mockStoreCommit).toBeCalledWith('community', {
|
||||||
name: 'test12',
|
name: 'test12',
|
||||||
@ -87,6 +81,10 @@ describe('Login', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('renders the Login form', () => {
|
||||||
|
expect(wrapper.find('div.login-form').exists()).toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
describe('communities gives back error', () => {
|
describe('communities gives back error', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
apolloQueryMock.mockRejectedValue({
|
apolloQueryMock.mockRejectedValue({
|
||||||
@ -106,7 +104,18 @@ describe('Login', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Community Data', () => {
|
describe('Community data already loaded', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
mocks.$store.state.community = {
|
||||||
|
name: 'Gradido Entwicklung',
|
||||||
|
url: 'http://localhost/vue/',
|
||||||
|
registerUrl: 'http://localhost/vue/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')
|
||||||
})
|
})
|
||||||
@ -116,6 +125,10 @@ describe('Login', () => {
|
|||||||
'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', () => {
|
||||||
|
|||||||
@ -62,7 +62,8 @@
|
|||||||
<script>
|
<script>
|
||||||
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, communityInfo } from '../../graphql/queries'
|
import { login } from '../../graphql/queries'
|
||||||
|
import { getCommunityInfoMixin } from '../../mixins/getCommunityInfo'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'login',
|
name: 'login',
|
||||||
@ -70,6 +71,7 @@ export default {
|
|||||||
InputPassword,
|
InputPassword,
|
||||||
InputEmail,
|
InputEmail,
|
||||||
},
|
},
|
||||||
|
mixins: [getCommunityInfoMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
@ -107,21 +109,6 @@ export default {
|
|||||||
this.$toasted.error(this.$t('error.no-account'))
|
this.$toasted.error(this.$t('error.no-account'))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async onCreated() {
|
|
||||||
this.$apollo
|
|
||||||
.query({
|
|
||||||
query: communityInfo,
|
|
||||||
})
|
|
||||||
.then((result) => {
|
|
||||||
this.$store.commit('community', result.data.getCommunityInfo)
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
this.$toasted.error(error.message)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.onCreated()
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -5,6 +5,19 @@ import Register from './Register'
|
|||||||
|
|
||||||
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/vue/register',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const toastErrorMock = jest.fn()
|
||||||
|
const mockStoreCommit = jest.fn()
|
||||||
const registerUserMutationMock = jest.fn()
|
const registerUserMutationMock = jest.fn()
|
||||||
const routerPushMock = jest.fn()
|
const routerPushMock = jest.fn()
|
||||||
|
|
||||||
@ -21,20 +34,23 @@ describe('Register', () => {
|
|||||||
},
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
mutate: registerUserMutationMock,
|
mutate: registerUserMutationMock,
|
||||||
|
query: apolloQueryMock,
|
||||||
},
|
},
|
||||||
$store: {
|
$store: {
|
||||||
|
commit: mockStoreCommit,
|
||||||
state: {
|
state: {
|
||||||
email: 'peter@lustig.de',
|
email: 'peter@lustig.de',
|
||||||
language: 'en',
|
language: 'en',
|
||||||
community: {
|
community: {
|
||||||
name: 'Gradido Entwicklung',
|
name: '',
|
||||||
url: 'http://localhost/vue/',
|
description: '',
|
||||||
registerUrl: 'http://localhost/vue/register',
|
|
||||||
description: 'Die lokale Entwicklungsumgebung von Gradido.',
|
|
||||||
},
|
},
|
||||||
publisherId: 12345,
|
publisherId: 12345,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
$toasted: {
|
||||||
|
error: toastErrorMock,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const stubs = {
|
const stubs = {
|
||||||
@ -50,6 +66,15 @@ 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/vue/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()
|
||||||
})
|
})
|
||||||
@ -60,16 +85,44 @@ describe('Register', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Community Data', () => {
|
describe('communities gives back error', () => {
|
||||||
it('has a Community name?', () => {
|
beforeEach(() => {
|
||||||
|
apolloQueryMock.mockRejectedValue({
|
||||||
|
message: 'Failed to get communities',
|
||||||
|
})
|
||||||
|
wrapper = Wrapper()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('toasts an error message', () => {
|
||||||
|
expect(toastErrorMock).toBeCalledWith('Failed to get communities')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Community data already loaded', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
mocks.$store.state.community = {
|
||||||
|
name: 'Gradido Entwicklung',
|
||||||
|
url: 'http://localhost/vue/',
|
||||||
|
registerUrl: 'http://localhost/vue/register',
|
||||||
|
description: 'Die lokale Entwicklungsumgebung von Gradido.',
|
||||||
|
}
|
||||||
|
wrapper = Wrapper()
|
||||||
|
})
|
||||||
|
|
||||||
|
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')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has a Community description?', () => {
|
it('has a Community description', () => {
|
||||||
expect(wrapper.find('.test-communitydata p').text()).toBe(
|
expect(wrapper.find('.test-communitydata p').text()).toBe(
|
||||||
'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', () => {
|
||||||
|
|||||||
@ -161,10 +161,12 @@ import InputEmail from '../../components/Inputs/InputEmail.vue'
|
|||||||
import InputPasswordConfirmation from '../../components/Inputs/InputPasswordConfirmation.vue'
|
import InputPasswordConfirmation from '../../components/Inputs/InputPasswordConfirmation.vue'
|
||||||
import LanguageSwitchSelect from '../../components/LanguageSwitchSelect.vue'
|
import LanguageSwitchSelect from '../../components/LanguageSwitchSelect.vue'
|
||||||
import { registerUser } from '../../graphql/mutations'
|
import { registerUser } from '../../graphql/mutations'
|
||||||
|
import { getCommunityInfoMixin } from '../../mixins/getCommunityInfo'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { InputPasswordConfirmation, InputEmail, LanguageSwitchSelect },
|
components: { InputPasswordConfirmation, InputEmail, LanguageSwitchSelect },
|
||||||
name: 'register',
|
name: 'register',
|
||||||
|
mixins: [getCommunityInfoMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
|
|||||||
@ -3,6 +3,19 @@ import RegisterCommunity from './RegisterCommunity'
|
|||||||
|
|
||||||
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/vue/register',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const toastErrorMock = jest.fn()
|
||||||
|
const mockStoreCommit = jest.fn()
|
||||||
|
|
||||||
describe('RegisterCommunity', () => {
|
describe('RegisterCommunity', () => {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
@ -11,16 +24,21 @@ describe('RegisterCommunity', () => {
|
|||||||
locale: 'en',
|
locale: 'en',
|
||||||
},
|
},
|
||||||
$t: jest.fn((t) => t),
|
$t: jest.fn((t) => t),
|
||||||
|
$apollo: {
|
||||||
|
query: apolloQueryMock,
|
||||||
|
},
|
||||||
$store: {
|
$store: {
|
||||||
|
commit: mockStoreCommit,
|
||||||
state: {
|
state: {
|
||||||
community: {
|
community: {
|
||||||
name: 'Gradido Entwicklung',
|
name: '',
|
||||||
url: 'http://localhost/vue/',
|
description: '',
|
||||||
registerUrl: 'http://localhost/vue/register',
|
|
||||||
description: 'Die lokale Entwicklungsumgebung von Gradido.',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
$toasted: {
|
||||||
|
error: toastErrorMock,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const stubs = {
|
const stubs = {
|
||||||
@ -36,23 +54,56 @@ 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/vue/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('Displaying the current community info', () => {
|
describe('communities gives back error', () => {
|
||||||
it('has a current community name', () => {
|
beforeEach(() => {
|
||||||
expect(wrapper.find('.header h1').text()).toBe('Gradido Entwicklung')
|
apolloQueryMock.mockRejectedValue({
|
||||||
|
message: 'Failed to get communities',
|
||||||
|
})
|
||||||
|
wrapper = Wrapper()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has a current community description', () => {
|
it('toasts an error message', () => {
|
||||||
expect(wrapper.find('.header p').text()).toBe(
|
expect(toastErrorMock).toBeCalledWith('Failed to get communities')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Community data already loaded', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
mocks.$store.state.community = {
|
||||||
|
name: 'Gradido Entwicklung',
|
||||||
|
url: 'http://localhost/vue/',
|
||||||
|
registerUrl: 'http://localhost/vue/register',
|
||||||
|
description: 'Die lokale Entwicklungsumgebung von Gradido.',
|
||||||
|
}
|
||||||
|
wrapper = Wrapper()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('has a Community name', () => {
|
||||||
|
expect(wrapper.find('.justify-content-center h1').text()).toBe('Gradido Entwicklung')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('has a Community description', () => {
|
||||||
|
expect(wrapper.find('.justify-content-center p').text()).toBe(
|
||||||
'Die lokale Entwicklungsumgebung von Gradido.',
|
'Die lokale Entwicklungsumgebung von Gradido.',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has a current community location', () => {
|
it('does not call community data update', () => {
|
||||||
expect(wrapper.find('.header p.community-location').text()).toBe('http://localhost/vue/')
|
expect(apolloQueryMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -49,12 +49,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import { getCommunityInfoMixin } from '../../mixins/getCommunityInfo'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'registerCommunity',
|
name: 'registerCommunity',
|
||||||
data() {
|
mixins: [getCommunityInfoMixin],
|
||||||
return {}
|
|
||||||
},
|
|
||||||
methods: {},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style></style>
|
<style></style>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { mount, RouterLinkStub } from '@vue/test-utils'
|
import { mount, RouterLinkStub } from '@vue/test-utils'
|
||||||
|
import { communities, communityInfo } from '../../graphql/queries'
|
||||||
import RegisterSelectCommunity from './RegisterSelectCommunity'
|
import RegisterSelectCommunity from './RegisterSelectCommunity'
|
||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
@ -11,7 +12,19 @@ const spinnerMock = jest.fn(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const apolloQueryMock = jest.fn().mockResolvedValue({
|
const apolloQueryMock = jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValueOnce({
|
||||||
|
data: {
|
||||||
|
getCommunityInfo: {
|
||||||
|
name: 'test12',
|
||||||
|
description: 'test community 12',
|
||||||
|
url: 'http://test12.test12/',
|
||||||
|
registerUrl: 'http://test12.test12/vue/register',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
communities: [
|
communities: [
|
||||||
{
|
{
|
||||||
@ -40,6 +53,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const toasterMock = jest.fn()
|
const toasterMock = jest.fn()
|
||||||
|
const mockStoreCommit = jest.fn()
|
||||||
|
|
||||||
describe('RegisterSelectCommunity', () => {
|
describe('RegisterSelectCommunity', () => {
|
||||||
let wrapper
|
let wrapper
|
||||||
@ -50,12 +64,11 @@ describe('RegisterSelectCommunity', () => {
|
|||||||
},
|
},
|
||||||
$t: jest.fn((t) => t),
|
$t: jest.fn((t) => t),
|
||||||
$store: {
|
$store: {
|
||||||
|
commit: mockStoreCommit,
|
||||||
state: {
|
state: {
|
||||||
community: {
|
community: {
|
||||||
name: 'Gradido Entwicklung',
|
name: '',
|
||||||
url: 'http://localhost/vue/',
|
description: '',
|
||||||
registerUrl: 'http://localhost/vue/register',
|
|
||||||
description: 'Die lokale Entwicklungsumgebung von Gradido.',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -80,9 +93,23 @@ describe('RegisterSelectCommunity', () => {
|
|||||||
|
|
||||||
describe('mount', () => {
|
describe('mount', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks()
|
||||||
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', () => {
|
||||||
|
expect(apolloQueryMock).toBeCalledWith({
|
||||||
|
query: communities,
|
||||||
|
fetchPolicy: 'network-only',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('renders the Div Element "#register-select-community"', () => {
|
it('renders the Div Element "#register-select-community"', () => {
|
||||||
expect(wrapper.find('div#register-select-community').exists()).toBeTruthy()
|
expect(wrapper.find('div#register-select-community').exists()).toBeTruthy()
|
||||||
})
|
})
|
||||||
@ -91,8 +118,72 @@ describe('RegisterSelectCommunity', () => {
|
|||||||
expect(spinnerMock).toBeCalled()
|
expect(spinnerMock).toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('communities gives back error', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
apolloQueryMock.mockRejectedValue({
|
||||||
|
message: 'Failed to get communities',
|
||||||
|
})
|
||||||
|
wrapper = Wrapper()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('toasts an error message', () => {
|
||||||
|
expect(toasterMock).toBeCalledWith('Failed to get communities')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Community data already loaded', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
mocks.$store.state.community = {
|
||||||
|
name: 'Gradido Entwicklung',
|
||||||
|
description: 'Die lokale Entwicklungsumgebung von Gradido.',
|
||||||
|
url: 'http://localhost/vue/',
|
||||||
|
registerUrl: 'http://localhost/vue/register-community',
|
||||||
|
}
|
||||||
|
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')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('has a Community description', () => {
|
||||||
|
expect(wrapper.find('.card-body p').text()).toBe(
|
||||||
|
'Die lokale Entwicklungsumgebung von Gradido.',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('calls the apollo query', () => {
|
describe('calls the apollo query', () => {
|
||||||
describe('server returns data', () => {
|
describe('server returns data', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
wrapper = Wrapper()
|
||||||
|
await wrapper.setData({
|
||||||
|
communities: [
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: 'Gradido Staging',
|
||||||
|
description: 'Der Testserver der Gradido-Akademie.',
|
||||||
|
url: 'https://stage1.gradido.net/vue/',
|
||||||
|
registerUrl: 'https://stage1.gradido.net/vue/register-community',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
name: 'Gradido-Akademie',
|
||||||
|
description: 'Freies Institut für Wirtschaftsbionik.',
|
||||||
|
url: 'https://gradido.net',
|
||||||
|
registerUrl: 'https://gdd1.gradido.com/vue/register-community',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('calls the API to get the data', () => {
|
it('calls the API to get the data', () => {
|
||||||
expect(apolloQueryMock).toBeCalled()
|
expect(apolloQueryMock).toBeCalled()
|
||||||
})
|
})
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
<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>{{ $store.state.community.name }}</b>
|
||||||
<br />
|
<br />
|
||||||
{{ $store.state.community.description }}
|
<p>{{ $store.state.community.description }}</p>
|
||||||
<br />
|
<br />
|
||||||
<router-link to="/register">
|
<router-link to="/register">
|
||||||
<b-button variant="outline-secondary">
|
<b-button variant="outline-secondary">
|
||||||
@ -24,7 +24,7 @@
|
|||||||
<b-card bg-variant="secondary">
|
<b-card bg-variant="secondary">
|
||||||
<b>{{ community.name }}</b>
|
<b>{{ community.name }}</b>
|
||||||
<br />
|
<br />
|
||||||
{{ community.description }}
|
<p>{{ community.description }}</p>
|
||||||
<br />
|
<br />
|
||||||
<b>
|
<b>
|
||||||
<small>
|
<small>
|
||||||
@ -49,6 +49,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { communities } from '../../graphql/queries'
|
import { communities } from '../../graphql/queries'
|
||||||
|
import { getCommunityInfoMixin } from '../../mixins/getCommunityInfo'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'registerSelectCommunity',
|
name: 'registerSelectCommunity',
|
||||||
@ -58,6 +59,7 @@ export default {
|
|||||||
pending: true,
|
pending: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mixins: [getCommunityInfoMixin],
|
||||||
methods: {
|
methods: {
|
||||||
async getCommunities() {
|
async getCommunities() {
|
||||||
const loader = this.$loading.show({
|
const loader = this.$loading.show({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user