@@ -146,6 +149,10 @@ export default {
quickSearchResults: 'search/quickResults',
quickSearchPending: 'search/quickPending'
}),
+ userName() {
+ const { name } = this.user || {}
+ return name || this.$t('profile.userAnonym')
+ },
routes() {
if (!this.user.slug) {
return []
diff --git a/webapp/locales/de.json b/webapp/locales/de.json
index efaf6f312..f4ea82e37 100644
--- a/webapp/locales/de.json
+++ b/webapp/locales/de.json
@@ -21,6 +21,7 @@
"following": "Folgt",
"shouted": "Empfohlen",
"commented": "Kommentiert",
+ "userAnonym": "Anonymus",
"socialMedia": "Wo sonst finde ich"
},
"notifications": {
@@ -38,8 +39,10 @@
"data": {
"name": "Deine Daten",
"labelName": "Dein Name",
+ "namePlaceholder": "Petra Lustig",
"labelCity": "Deine Stadt oder Region",
- "labelBio": "Über dich"
+ "labelBio": "Über dich",
+ "success": "Deine Daten wurden erfolgreich aktualisiert!"
},
"security": {
"name": "Sicherheit",
@@ -224,4 +227,4 @@
"shoutButton": {
"shouted": "empfohlen"
}
-}
+}
\ No newline at end of file
diff --git a/webapp/locales/en.json b/webapp/locales/en.json
index 023f0d362..0dc953666 100644
--- a/webapp/locales/en.json
+++ b/webapp/locales/en.json
@@ -21,6 +21,7 @@
"following": "Following",
"shouted": "Shouted",
"commented": "Commented",
+ "userAnonym": "Anonymous",
"socialMedia": "Where else can I find"
},
"notifications": {
@@ -38,8 +39,10 @@
"data": {
"name": "Your data",
"labelName": "Your Name",
+ "namePlaceholder": "Femanon Funny",
"labelCity": "Your City or Region",
- "labelBio": "About You"
+ "labelBio": "About You",
+ "success": "Your data was successfully updated!"
},
"security": {
"name": "Security",
@@ -224,4 +227,4 @@
"shoutButton": {
"shouted": "shouted"
}
-}
+}
\ No newline at end of file
diff --git a/webapp/locales/it.json b/webapp/locales/it.json
index 0225babad..25005a07a 100644
--- a/webapp/locales/it.json
+++ b/webapp/locales/it.json
@@ -15,13 +15,15 @@
"followers": "Seguenti",
"following": "Seguendo",
"shouted": "Gridato",
- "commented": "Commentato"
+ "commented": "Commentato",
+ "userAnonym": "Anonymous"
},
"settings": {
"name": "Impostazioni",
"data": {
"name": "I tuoi dati",
"labelName": "Nome",
+ "namePlaceholder": "Anonymous",
"labelCity": "La tua città o regione",
"labelBio": "Su di te"
},
diff --git a/webapp/locales/pl.json b/webapp/locales/pl.json
index 0f2147996..506a04f1b 100644
--- a/webapp/locales/pl.json
+++ b/webapp/locales/pl.json
@@ -15,13 +15,15 @@
"followers": "Obserwujący",
"following": "Obserwowani",
"shouted": "Krzyknij",
- "commented": "Skomentuj"
+ "commented": "Skomentuj",
+ "userAnonym": "Anonymous"
},
"settings": {
"name": "Ustawienia",
"data": {
"name": "Twoje dane",
"labelName": "Twoje dane",
+ "namePlaceholder": "Anonymous",
"labelCity": "Twoje miasto lub region",
"labelBio": "O Tobie"
},
diff --git a/webapp/locales/pt.json b/webapp/locales/pt.json
index 4151f49c7..0636ba6f9 100644
--- a/webapp/locales/pt.json
+++ b/webapp/locales/pt.json
@@ -15,13 +15,15 @@
"followers": "Seguidores",
"following": "Seguindo",
"shouted": "Aclamou",
- "commented": "Comentou"
+ "commented": "Comentou",
+ "userAnonym": "Anonymous"
},
"settings": {
"name": "Configurações",
"data": {
"name": "Seus dados",
"labelName": "Seu nome",
+ "namePlaceholder": "Anonymous",
"labelCity": "Sua cidade ou estado",
"labelBio": "Sobre você"
},
diff --git a/webapp/pages/profile/_id/_slug.vue b/webapp/pages/profile/_id/_slug.vue
index d577b79c8..ecb0baa9d 100644
--- a/webapp/pages/profile/_id/_slug.vue
+++ b/webapp/pages/profile/_id/_slug.vue
@@ -16,7 +16,7 @@
>
@@ -35,7 +35,7 @@
align="center"
no-margin
>
- {{ user.name }}
+ {{ userName }}
- Wem folgt {{ user.name | truncate(15) }}?
+ Wem folgt {{ userName | truncate(15) }}?
@@ -154,7 +154,7 @@
- {{ user.name }} folgt niemandem
+ {{ userName }} folgt niemandem
@@ -168,7 +168,7 @@
tag="h5"
color="soft"
>
- Wer folgt {{ user.name | truncate(15) }}?
+ Wer folgt {{ userName | truncate(15) }}?
@@ -199,18 +199,16 @@
- niemand folgt {{ user.name }}
+ niemand folgt {{ userName }}
-
-
+
-
+
{{ link.username }}
@@ -393,6 +389,10 @@ export default {
const username = url.split('/').pop()
return { url, username, favicon }
})
+ },
+ userName() {
+ const { name } = this.user || {}
+ return name || this.$t('profile.userAnonym')
}
},
watch: {
diff --git a/webapp/pages/settings/index.spec.js b/webapp/pages/settings/index.spec.js
new file mode 100644
index 000000000..8ee68172e
--- /dev/null
+++ b/webapp/pages/settings/index.spec.js
@@ -0,0 +1,73 @@
+import { mount, createLocalVue } from '@vue/test-utils'
+import index from './index.vue'
+import Vue from 'vue'
+import Vuex from 'vuex'
+import Styleguide from '@human-connection/styleguide'
+
+const localVue = createLocalVue()
+
+localVue.use(Vuex)
+localVue.use(Styleguide)
+
+describe('index.vue', () => {
+ let Wrapper
+ let store
+ let mocks
+ let getters
+
+ beforeEach(() => {
+ mocks = {
+ $t: jest.fn(),
+ $apollo: {
+ mutate: jest
+ .fn()
+ .mockRejectedValue({ message: 'Ouch!' })
+ .mockResolvedValueOnce({
+ data: {
+ UpdateUser: {
+ id: 'u1',
+ name: 'Peter',
+ locationName: 'Berlin',
+ about: 'Smth'
+ }
+ }
+ })
+ },
+ $toast: {
+ error: jest.fn(),
+ success: jest.fn()
+ }
+ }
+ getters = {
+ 'auth/user': () => {
+ return {}
+ }
+ }
+ })
+
+ describe('mount', () => {
+ const Wrapper = () => {
+ store = new Vuex.Store({
+ getters
+ })
+ return mount(index, { store, mocks, localVue })
+ }
+
+ it('renders', () => {
+ expect(Wrapper().contains('div')).toBe(true)
+ })
+
+ describe('given a new username and hitting submit', () => {
+ it('calls updateUser mutation', () => {
+ const wrapper = Wrapper()
+ const input = wrapper.find('#name')
+ const submitForm = wrapper.find('.ds-form')
+
+ input.setValue('Peter')
+ submitForm.trigger('submit')
+
+ expect(mocks.$apollo.mutate).toHaveBeenCalled()
+ })
+ })
+ })
+})
diff --git a/webapp/pages/settings/index.vue b/webapp/pages/settings/index.vue
index 5ff7c171e..a3b2298c3 100644
--- a/webapp/pages/settings/index.vue
+++ b/webapp/pages/settings/index.vue
@@ -9,7 +9,7 @@
model="name"
icon="user"
:label="$t('settings.data.labelName')"
- :placeholder="$t('settings.data.labelName')"
+ :placeholder="$t('settings.data.namePlaceholder')"
/>
@@ -36,7 +36,7 @@
style="float: right;"
icon="check"
type="submit"
- :loading="sending"
+ :loading="loadingData"
primary
>
{{ $t('actions.save') }}
@@ -88,8 +88,8 @@ export default {
return {
axiosSource: null,
cities: [],
- sending: false,
- loading: false,
+ loadingData: false,
+ loadingGeo: false,
formData: {}
}
},
@@ -111,13 +111,13 @@ export default {
...mapMutations({
setCurrentUser: 'auth/SET_USER'
}),
- submit() {
- this.sending = true
+ async submit() {
+ this.loadingData = true
const { name, about } = this.formData
let { locationName } = this.formData
locationName = locationName && (locationName['label'] || locationName)
- this.$apollo
- .mutate({
+ try {
+ const { data } = await this.$apollo.mutate({
mutation,
variables: {
id: this.currentUser.id,
@@ -135,15 +135,12 @@ export default {
})
}
})
- .then(data => {
- this.$toast.success('Updated user')
- })
- .catch(err => {
- this.$toast.error(err.message)
- })
- .finally(() => {
- this.sending = false
- })
+ this.$toast.success(this.$t('settings.data.success'))
+ } catch (err) {
+ this.$toast.error(err.message)
+ } finally {
+ this.loadingData = false
+ }
},
handleCityInput(value) {
clearTimeout(timeout)
@@ -181,7 +178,7 @@ export default {
return
}
- this.loading = true
+ this.loadingGeo = true
this.axiosSource = CancelToken.source()
const place = encodeURIComponent(value)
@@ -198,7 +195,7 @@ export default {
this.cities = this.processCityResults(res)
})
.finally(() => {
- this.loading = false
+ this.loadingGeo = false
})
}
}