mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Made the community resolver work again & changes in frontend merged with 803-community-selection-page-of-registration-process
This commit is contained in:
parent
5462e8b606
commit
06b7778f11
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"community": [
|
|
||||||
{"id": 1, "name": "Gradido Entwicklung", "url": "http://localhost:3000/vue/", "description":"Die lokale Entwicklungsumgebung von Gradido.", "registerUrl": "http://localhost:3000/vue/register"},
|
|
||||||
{"id": 2, "name": "Gradido Staging", "url": "https://stage1.gradido.net/vue/", "description":"Der Testserver der Gradido Akademie.", "registerUrl": "https://stage1.gradido.net/vue/register"},
|
|
||||||
{"id": 3, "name": "Gradido-Akademie", "url": "https://gdd1.gradido.com/vue/", "description":"Freies Institut für Wirtschaftsbionik.", "registerUrl": "https://gdd1.gradido.com/vue/register"}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -106,13 +106,13 @@ export const checkEmailQuery = gql`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
export const serverInformation = gql`
|
export const communityInfo = gql`
|
||||||
query {
|
query {
|
||||||
serverInformation {
|
getCommunityInfo {
|
||||||
community {
|
name
|
||||||
name
|
description
|
||||||
description
|
registerUrl
|
||||||
}
|
url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|||||||
@ -43,7 +43,6 @@ export const actions = {
|
|||||||
commit('lastName', data.lastName)
|
commit('lastName', data.lastName)
|
||||||
commit('description', data.description)
|
commit('description', data.description)
|
||||||
commit('newsletterState', data.klickTipp.newsletterState)
|
commit('newsletterState', data.klickTipp.newsletterState)
|
||||||
commit('community', data.community)
|
|
||||||
},
|
},
|
||||||
logout: ({ commit, state }) => {
|
logout: ({ commit, state }) => {
|
||||||
commit('token', null)
|
commit('token', null)
|
||||||
@ -53,7 +52,6 @@ export const actions = {
|
|||||||
commit('lastName', '')
|
commit('lastName', '')
|
||||||
commit('description', '')
|
commit('description', '')
|
||||||
commit('newsletterState', null)
|
commit('newsletterState', null)
|
||||||
commit('community', null)
|
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,20 @@ import Login from './Login'
|
|||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
const loginQueryMock = jest.fn().mockResolvedValue({
|
const apolloQueryMock = jest.fn().mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
login: 'token',
|
getCommunityInfo: {
|
||||||
|
name: 'test12',
|
||||||
|
description: 'test community 12',
|
||||||
|
url: 'http://test12.test12/',
|
||||||
|
registerUrl: 'http://test12.test12/vue/register',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const toastErrorMock = jest.fn()
|
const toastErrorMock = jest.fn()
|
||||||
const mockStoreDispach = jest.fn()
|
const mockStoreDispach = jest.fn()
|
||||||
|
const mockStoreCommit = jest.fn()
|
||||||
const mockRouterPush = jest.fn()
|
const mockRouterPush = jest.fn()
|
||||||
const spinnerHideMock = jest.fn()
|
const spinnerHideMock = jest.fn()
|
||||||
const spinnerMock = jest.fn(() => {
|
const spinnerMock = jest.fn(() => {
|
||||||
@ -30,6 +36,7 @@ describe('Login', () => {
|
|||||||
$t: jest.fn((t) => t),
|
$t: jest.fn((t) => t),
|
||||||
$store: {
|
$store: {
|
||||||
dispatch: mockStoreDispach,
|
dispatch: mockStoreDispach,
|
||||||
|
commit: mockStoreCommit,
|
||||||
state: {
|
state: {
|
||||||
community: {
|
community: {
|
||||||
name: 'Gradido Entwicklung',
|
name: 'Gradido Entwicklung',
|
||||||
@ -49,7 +56,7 @@ describe('Login', () => {
|
|||||||
error: toastErrorMock,
|
error: toastErrorMock,
|
||||||
},
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
query: loginQueryMock,
|
query: apolloQueryMock,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +77,15 @@ describe('Login', () => {
|
|||||||
expect(wrapper.find('div.login-form').exists()).toBeTruthy()
|
expect(wrapper.find('div.login-form').exists()).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('calls the communityInfo', () => {
|
||||||
|
expect(mockStoreCommit).toBeCalledWith('community', {
|
||||||
|
name: 'test12',
|
||||||
|
description: 'test community 12',
|
||||||
|
url: 'http://test12.test12/',
|
||||||
|
registerUrl: 'http://test12.test12/vue/register',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('Login header', () => {
|
describe('Login header', () => {
|
||||||
it('has a welcome message', () => {
|
it('has a welcome message', () => {
|
||||||
expect(wrapper.find('div.header').text()).toBe('Gradido site.login.community')
|
expect(wrapper.find('div.header').text()).toBe('Gradido site.login.community')
|
||||||
@ -157,10 +173,15 @@ describe('Login', () => {
|
|||||||
await flushPromises()
|
await flushPromises()
|
||||||
await wrapper.find('form').trigger('submit')
|
await wrapper.find('form').trigger('submit')
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
|
apolloQueryMock.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
login: 'token',
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls the API with the given data', () => {
|
it('calls the API with the given data', () => {
|
||||||
expect(loginQueryMock).toBeCalledWith(
|
expect(apolloQueryMock).toBeCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
variables: {
|
variables: {
|
||||||
email: 'user@example.org',
|
email: 'user@example.org',
|
||||||
@ -190,7 +211,7 @@ describe('Login', () => {
|
|||||||
|
|
||||||
describe('login fails', () => {
|
describe('login fails', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
loginQueryMock.mockRejectedValue({
|
apolloQueryMock.mockRejectedValue({
|
||||||
message: 'Ouch!',
|
message: 'Ouch!',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -67,7 +67,7 @@
|
|||||||
import CONFIG from '../../config'
|
import CONFIG from '../../config'
|
||||||
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, communityInfo } from '../../graphql/queries'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'login',
|
name: 'login',
|
||||||
@ -112,6 +112,21 @@ 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)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.onCreated()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
</small>
|
</small>
|
||||||
</b>
|
</b>
|
||||||
<br />
|
<br />
|
||||||
<b-button variant="outline-secondary" :href="community.url">
|
<b-button variant="outline-secondary" :href="community.registerUrl">
|
||||||
{{ $t('community.switch-to-this-community') }}
|
{{ $t('community.switch-to-this-community') }}
|
||||||
</b-button>
|
</b-button>
|
||||||
</b-card>
|
</b-card>
|
||||||
@ -51,7 +51,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import communities from '../../graphql/queries'
|
import { communities } from '../../graphql/queries'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'registerSelectCommunity',
|
name: 'registerSelectCommunity',
|
||||||
@ -69,11 +69,14 @@ export default {
|
|||||||
this.$apollo
|
this.$apollo
|
||||||
.query({
|
.query({
|
||||||
query: communities,
|
query: communities,
|
||||||
|
fetchPolicy: 'network-only',
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
console.log('got communities:', response.data.communities)
|
||||||
this.communities = response.data.communities
|
this.communities = response.data.communities
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
console.log('Huston got a problem', error.message)
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.error(error.message)
|
||||||
})
|
})
|
||||||
loader.hide()
|
loader.hide()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user