mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
add tests, fix bugs
This commit is contained in:
parent
2893c23d2e
commit
c7c569e1ca
@ -609,16 +609,16 @@ export class UserResolver {
|
||||
user.hideAmountGDT = hideAmountGDT
|
||||
}
|
||||
|
||||
if (gmsAllowed) {
|
||||
if (gmsAllowed !== undefined) {
|
||||
user.gmsAllowed = gmsAllowed
|
||||
}
|
||||
if (gmsPublishName) {
|
||||
if (gmsPublishName !== null && gmsPublishName !== undefined) {
|
||||
user.gmsPublishName = gmsPublishName
|
||||
}
|
||||
if (gmsLocation) {
|
||||
user.location = Location2Point(gmsLocation)
|
||||
}
|
||||
if (gmsPublishLocation) {
|
||||
if (gmsPublishLocation !== null && gmsPublishLocation !== undefined) {
|
||||
user.gmsPublishLocation = gmsPublishLocation
|
||||
}
|
||||
// } catch (err) {
|
||||
|
||||
@ -71,4 +71,16 @@ export default {
|
||||
.text-color-gdd-yellow {
|
||||
color: rgb(197 141 56);
|
||||
}
|
||||
|
||||
.dropdown > .dropdown-toggle {
|
||||
border-radius: 17px;
|
||||
height: 50px;
|
||||
text-align: left;
|
||||
}
|
||||
.dropdown-toggle::after {
|
||||
float: right;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -90,20 +90,3 @@ export default {
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.community-switch > div,
|
||||
.community-switch ul.dropdown-menu {
|
||||
width: 100%;
|
||||
}
|
||||
.community-switch > div > button {
|
||||
border-radius: 17px;
|
||||
height: 50px;
|
||||
text-align: left;
|
||||
}
|
||||
.community-switch .dropdown-toggle::after {
|
||||
float: right;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import UserGMSLocationFormat from './UserGMSLocationFormat.vue'
|
||||
import { toastErrorSpy } from '@test/testSetup'
|
||||
|
||||
const mockAPIcall = jest.fn()
|
||||
|
||||
const storeCommitMock = jest.fn()
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
describe('UserGMSLocationFormat', () => {
|
||||
let wrapper
|
||||
beforeEach(() => {
|
||||
wrapper = mount(UserGMSLocationFormat, {
|
||||
mocks: {
|
||||
$t: (key) => key, // Mocking the translation function
|
||||
$store: {
|
||||
state: {
|
||||
gmsPublishLocation: null,
|
||||
},
|
||||
commit: storeCommitMock,
|
||||
},
|
||||
$apollo: {
|
||||
mutate: mockAPIcall,
|
||||
},
|
||||
},
|
||||
localVue,
|
||||
propsData: {
|
||||
selectedOption: 'GMS_LOCATION_TYPE_RANDOM',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.destroy()
|
||||
})
|
||||
|
||||
it('renders the correct dropdown options', () => {
|
||||
const dropdownItems = wrapper.findAll('.dropdown-item')
|
||||
expect(dropdownItems.length).toBe(3)
|
||||
|
||||
const labels = dropdownItems.wrappers.map((item) => item.text())
|
||||
expect(labels).toEqual([
|
||||
'settings.GMS.publish-location.exact',
|
||||
'settings.GMS.publish-location.approximate',
|
||||
'settings.GMS.publish-location.random',
|
||||
])
|
||||
})
|
||||
|
||||
it('updates selected option on click', async () => {
|
||||
const dropdownItem = wrapper.findAll('.dropdown-item').at(1) // Click the second item
|
||||
await dropdownItem.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().gmsPublishLocation).toBeTruthy()
|
||||
expect(wrapper.emitted().gmsPublishLocation.length).toBe(1)
|
||||
expect(wrapper.emitted().gmsPublishLocation[0]).toEqual(['GMS_LOCATION_TYPE_APPROXIMATE'])
|
||||
})
|
||||
|
||||
it('does not update when clicking on already selected option', async () => {
|
||||
const dropdownItem = wrapper.findAll('.dropdown-item').at(2) // Click the third item (which is already selected)
|
||||
await dropdownItem.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().gmsPublishLocation).toBeFalsy()
|
||||
})
|
||||
|
||||
describe('update with error', () => {
|
||||
beforeEach(async () => {
|
||||
mockAPIcall.mockRejectedValue({
|
||||
message: 'Ouch',
|
||||
})
|
||||
const dropdownItem = wrapper.findAll('.dropdown-item').at(1) // Click the second item
|
||||
await dropdownItem.trigger('click')
|
||||
})
|
||||
|
||||
it('toasts an error message', () => {
|
||||
expect(toastErrorSpy).toBeCalledWith('Ouch')
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -39,13 +39,12 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
selectedOptionLabel() {
|
||||
const selected = this.dropdownOptions.find((option) => option.value === this.selectedOption)
|
||||
return selected ? selected.label : this.selectedOption
|
||||
return this.dropdownOptions.find((option) => option.value === this.selectedOption).label
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async update(option) {
|
||||
if (option === this.selectedOption) {
|
||||
if (option.value === this.selectedOption) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
@ -67,19 +66,8 @@ export default {
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.user-gms-location-format > div,
|
||||
.user-gms-location-format ul.dropdown-menu {
|
||||
.user-gms-location-format > .dropdown,
|
||||
.user-gms-location-format > .dropdown > .dropdown-toggle > ul.dropdown-menu {
|
||||
width: 100%;
|
||||
}
|
||||
.user-gms-location-format > div > button {
|
||||
border-radius: 17px;
|
||||
height: 50px;
|
||||
text-align: left;
|
||||
}
|
||||
.user-gms-location-format .dropdown-toggle::after {
|
||||
float: right;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -0,0 +1,81 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import UserGMSNamingFormat from './UserGMSNamingFormat.vue'
|
||||
import { toastErrorSpy } from '@test/testSetup'
|
||||
|
||||
const mockAPIcall = jest.fn()
|
||||
|
||||
const storeCommitMock = jest.fn()
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
describe('UserGMSNamingFormat', () => {
|
||||
let wrapper
|
||||
beforeEach(() => {
|
||||
wrapper = mount(UserGMSNamingFormat, {
|
||||
mocks: {
|
||||
$t: (key) => key, // Mocking the translation function
|
||||
$store: {
|
||||
state: {
|
||||
gmsPublishName: null,
|
||||
},
|
||||
commit: storeCommitMock,
|
||||
},
|
||||
$apollo: {
|
||||
mutate: mockAPIcall,
|
||||
},
|
||||
},
|
||||
localVue,
|
||||
propsData: {
|
||||
selectedOption: 'GMS_PUBLISH_NAME_ALIAS_OR_INITALS',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.destroy()
|
||||
})
|
||||
|
||||
it('renders the correct dropdown options', () => {
|
||||
const dropdownItems = wrapper.findAll('.dropdown-item')
|
||||
expect(dropdownItems.length).toBe(5)
|
||||
|
||||
const labels = dropdownItems.wrappers.map((item) => item.text())
|
||||
expect(labels).toEqual([
|
||||
'settings.GMS.publish-name.alias-or-initials',
|
||||
'settings.GMS.publish-name.initials',
|
||||
'settings.GMS.publish-name.first',
|
||||
'settings.GMS.publish-name.first-initial',
|
||||
'settings.GMS.publish-name.name-full',
|
||||
])
|
||||
})
|
||||
|
||||
it('updates selected option on click', async () => {
|
||||
const dropdownItem = wrapper.findAll('.dropdown-item').at(3) // Click the fourth item
|
||||
await dropdownItem.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().gmsPublishName).toBeTruthy()
|
||||
expect(wrapper.emitted().gmsPublishName.length).toBe(1)
|
||||
expect(wrapper.emitted().gmsPublishName[0]).toEqual(['GMS_PUBLISH_NAME_FIRST_INITIAL'])
|
||||
})
|
||||
|
||||
it('does not update when clicking on already selected option', async () => {
|
||||
const dropdownItem = wrapper.findAll('.dropdown-item').at(0) // Click the first item (which is already selected)
|
||||
await dropdownItem.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().gmsPublishName).toBeFalsy()
|
||||
})
|
||||
|
||||
describe('update with error', () => {
|
||||
beforeEach(async () => {
|
||||
mockAPIcall.mockRejectedValue({
|
||||
message: 'Ouch',
|
||||
})
|
||||
const dropdownItem = wrapper.findAll('.dropdown-item').at(2) // Click the third item
|
||||
await dropdownItem.trigger('click')
|
||||
})
|
||||
|
||||
it('toasts an error message', () => {
|
||||
expect(toastErrorSpy).toBeCalledWith('Ouch')
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -53,13 +53,12 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
selectedOptionLabel() {
|
||||
const selected = this.dropdownOptions.find((option) => option.value === this.selectedOption)
|
||||
return selected ? selected.label : this.selectedOption
|
||||
return this.dropdownOptions.find((option) => option.value === this.selectedOption).label
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async update(option) {
|
||||
if (option === this.selectedOption) {
|
||||
if (option.value === this.selectedOption) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
@ -81,19 +80,8 @@ export default {
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.user-gms-naming-format > div,
|
||||
.user-gms-naming-format ul.dropdown-menu {
|
||||
.user-gms-naming-format > .dropdown,
|
||||
.user-gms-naming-format > .dropdown > .dropdown-toggle > ul.dropdown-menu {
|
||||
width: 100%;
|
||||
}
|
||||
.user-gms-naming-format > div > button {
|
||||
border-radius: 17px;
|
||||
height: 50px;
|
||||
text-align: left;
|
||||
}
|
||||
.user-gms-naming-format .dropdown-toggle::after {
|
||||
float: right;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -29,8 +29,8 @@ export default {
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
this.$store.commit('gmsState', this.gmsAllowed)
|
||||
this.$emit('gmsStateSwitch', this.gmsAllowed)
|
||||
this.$store.commit('gmsAllowed', this.gmsAllowed)
|
||||
this.$emit('gmsAllowed', this.gmsAllowed)
|
||||
this.toastSuccess(
|
||||
this.gmsAllowed ? this.$t('settings.GMS.enabled') : this.$t('settings.GMS.disabled'),
|
||||
)
|
||||
|
||||
@ -294,7 +294,7 @@
|
||||
"emailInfo": "Kann aktuell noch nicht geändert werden.",
|
||||
"GMS": {
|
||||
"disabled": "Daten werden nicht nach GMS exportiert",
|
||||
"enabled": "Daten werden nach GMS exportiert",
|
||||
"enabled": "Daten werden nach GMS exportiert",
|
||||
"location": {
|
||||
"label": "Positionsbestimmung",
|
||||
"button": "Klick mich!"
|
||||
@ -305,7 +305,7 @@
|
||||
"exact": "Genaue Position",
|
||||
"approximate": "Ungefähre Position",
|
||||
"random": "Zufallsposition",
|
||||
"updated":"Positionstyp für GMS aktualisiert"
|
||||
"updated": "Positionstyp für GMS aktualisiert"
|
||||
},
|
||||
"publish-name": {
|
||||
"alias-or-initials": "Benutzername oder Initialen",
|
||||
|
||||
@ -304,7 +304,8 @@
|
||||
"publish-location": {
|
||||
"exact": "exact position",
|
||||
"approximate": "approximate position",
|
||||
"random": "random position"
|
||||
"random": "random position",
|
||||
"updated": "format of location for GMS updated"
|
||||
},
|
||||
"publish-name": {
|
||||
"alias-or-initials": "Username or initials",
|
||||
@ -319,7 +320,7 @@
|
||||
"name-full-tooltip": "fullname: firstname plus lastname",
|
||||
"updated": "format of name for GMS updated"
|
||||
},
|
||||
"switch": "Allow data export to GMS"
|
||||
"switch": "Allow data export to GMS"
|
||||
},
|
||||
"hideAmountGDD": "Your GDD amount is hidden.",
|
||||
"hideAmountGDT": "Your GDT amount is hidden.",
|
||||
|
||||
@ -90,7 +90,7 @@
|
||||
</div>
|
||||
</b-col>
|
||||
<b-col cols="12" md="6" lg="6" class="text-right">
|
||||
<user-g-m-s-switch @gmsStateSwitch="gmsStateSwitch" />
|
||||
<user-g-m-s-switch @gmsAllowed="gmsStateSwitch" />
|
||||
</b-col>
|
||||
</b-row>
|
||||
<div v-if="gmsAllowed">
|
||||
@ -206,7 +206,7 @@ export default {
|
||||
} catch (error) {}
|
||||
},
|
||||
gmsStateSwitch(eventData) {
|
||||
this.gmsState = eventData
|
||||
this.gmsAllowed = eventData
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user