Merge remote-tracking branch 'origin/master' into 779-tags-of-contribution-in-text

# Conflicts:
#	webapp/components/Editor/index.vue
This commit is contained in:
Wolfgang Huß 2019-06-20 10:37:10 +02:00
commit 42942e4777
14 changed files with 192 additions and 36 deletions

View File

@ -44,7 +44,7 @@
"dependencies": {
"activitystrea.ms": "~2.1.3",
"apollo-cache-inmemory": "~1.6.2",
"apollo-client": "~2.6.2",
"apollo-client": "~2.6.3",
"apollo-link-context": "~1.0.18",
"apollo-link-http": "~1.5.15",
"apollo-server": "~2.6.3",
@ -89,7 +89,7 @@
"@babel/register": "~7.4.4",
"apollo-server-testing": "~2.6.3",
"babel-core": "~7.0.0-0",
"babel-eslint": "~10.0.1",
"babel-eslint": "~10.0.2",
"babel-jest": "~24.8.0",
"chai": "~4.2.0",
"cucumber": "~5.1.0",

View File

@ -1322,10 +1322,10 @@ apollo-cache@1.3.2, apollo-cache@^1.3.2:
apollo-utilities "^1.3.2"
tslib "^1.9.3"
apollo-client@~2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/apollo-client/-/apollo-client-2.6.2.tgz#03b6af651e09b6e413e486ddc87464c85bd6e514"
integrity sha512-oks1MaT5x7gHcPeC8vPC1UzzsKaEIC0tye+jg72eMDt5OKc7BobStTeS/o2Ib3e0ii40nKxGBnMdl/Xa/p56Yg==
apollo-client@~2.6.3:
version "2.6.3"
resolved "https://registry.yarnpkg.com/apollo-client/-/apollo-client-2.6.3.tgz#9bb2d42fb59f1572e51417f341c5f743798d22db"
integrity sha512-DS8pmF5CGiiJ658dG+mDn8pmCMMQIljKJSTeMNHnFuDLV0uAPZoeaAwVFiAmB408Ujqt92oIZ/8yJJAwSIhd4A==
dependencies:
"@types/zen-observable" "^0.8.0"
apollo-cache "1.3.2"
@ -1790,10 +1790,10 @@ babel-core@~7.0.0-0:
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece"
integrity sha512-poPX9mZH/5CSanm50Q+1toVci6pv5KSRv/5TWCwtzQS5XEwn40BcCrgIeMFWP9CKKIniKXNxoIOnOq4VVlGXhg==
babel-eslint@~10.0.1:
version "10.0.1"
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.1.tgz#919681dc099614cd7d31d45c8908695092a1faed"
integrity sha512-z7OT1iNV+TjOwHNLLyJk+HN+YVWX+CLE6fPD2SymJZOZQBs+QIexFjhm4keGTm8MW9xr4EC9Q0PbaLB24V5GoQ==
babel-eslint@~10.0.2:
version "10.0.2"
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.2.tgz#182d5ac204579ff0881684b040560fdcc1558456"
integrity sha512-UdsurWPtgiPgpJ06ryUnuaSXC2s0WoSZnQmEpbAH65XZSdwowgN5MvyP7e88nW07FYXv72erVtpBkxyDVKhH1Q==
dependencies:
"@babel/code-frame" "^7.0.0"
"@babel/parser" "^7.0.0"

View File

@ -1,9 +1,11 @@
import { config, mount, createLocalVue } from '@vue/test-utils'
import ContributionForm from './index.vue'
import Styleguide from '@human-connection/styleguide'
import Vuex from 'vuex'
const localVue = createLocalVue()
localVue.use(Vuex)
localVue.use(Styleguide)
config.stubs['no-ssr'] = '<span><slot /></span>'
@ -53,8 +55,16 @@ describe('ContributionForm.vue', () => {
})
describe('mount', () => {
const getters = {
'editor/placeholder': () => {
return 'some cool placeholder'
},
}
const store = new Vuex.Store({
getters,
})
const Wrapper = () => {
return mount(ContributionForm, { mocks, localVue, computed })
return mount(ContributionForm, { mocks, localVue, computed, store })
}
beforeEach(() => {

View File

@ -187,7 +187,11 @@ import {
History,
} from 'tiptap-extensions'
import Mention from './nodes/Mention.js'
<<<<<<< HEAD
import Tag from './nodes/Tag.js'
=======
import { mapGetters } from 'vuex'
>>>>>>> origin/master
let throttleInputEvent
@ -226,7 +230,7 @@ export default {
new ListItem(),
new Placeholder({
emptyNodeClass: 'is-empty',
emptyNodeText: this.$t('editor.placeholder'),
emptyNodeText: this.placeholder || this.$t('editor.placeholder'),
}),
new History(),
new Mention({
@ -382,11 +386,17 @@ export default {
}
},
computed: {
<<<<<<< HEAD
usersFilterHasResults() {
return this.filteredUsers.length > 0
},
tagsFilterHasResults() {
return this.filteredTags.length > 0
=======
...mapGetters({ placeholder: 'editor/placeholder' }),
hasResults() {
return this.filteredUsers.length
>>>>>>> origin/master
},
showSuggestions() {
return this.query || this.usersFilterHasResults || this.tagsFilterHasResults
@ -404,20 +414,20 @@ export default {
this.editor.setContent(content)
},
},
},
mounted() {
this.$root.$on('changeLanguage', () => {
this.changePlaceHolderText()
})
placeholder: {
immediate: true,
handler: function(val) {
if (!val) {
return
}
this.editor.extensions.options.placeholder.emptyNodeText = val
},
},
},
beforeDestroy() {
this.$root.$off('changeLanguage')
this.editor.destroy()
},
methods: {
changePlaceHolderText() {
this.editor.extensions.options.placeholder.emptyNodeText = this.$t('editor.placeholder')
},
// navigate to the previous item
// if it's the first item, navigate to the last one
upHandler(filteredArray) {

View File

@ -1,31 +1,43 @@
import { mount, createLocalVue } from '@vue/test-utils'
import Editor from './'
import Vuex from 'vuex'
import Styleguide from '@human-connection/styleguide'
const localVue = createLocalVue()
localVue.use(Vuex)
localVue.use(Styleguide)
describe('Editor.vue', () => {
let wrapper
let propsData
let mocks
let getters
beforeEach(() => {
propsData = {}
mocks = {
$t: () => {},
}
getters = {
'editor/placeholder': () => {
return 'some cool placeholder'
},
}
})
describe('mount', () => {
let Wrapper = () => {
const store = new Vuex.Store({
getters,
})
return (wrapper = mount(Editor, {
mocks,
propsData,
localVue,
sync: false,
stubs: { transition: false },
store,
}))
}
@ -43,5 +55,13 @@ describe('Editor.vue', () => {
expect(wrapper.find('.ProseMirror').text()).toContain('I am a piece of text')
})
})
describe('uses the placeholder', () => {
it('from the store', () => {
expect(wrapper.vm.editor.extensions.options.placeholder.emptyNodeText).toEqual(
'some cool placeholder',
)
})
})
})
})

View File

@ -0,0 +1,68 @@
import { mount, createLocalVue } from '@vue/test-utils'
import Styleguide from '@human-connection/styleguide'
import Vuex from 'vuex'
import VTooltip from 'v-tooltip'
import LocaleSwitch from './LocaleSwitch.vue'
import { mutations } from '~/store/editor'
const localVue = createLocalVue()
localVue.use(Vuex)
localVue.use(Styleguide)
localVue.use(VTooltip)
describe('LocaleSwitch.vue', () => {
let wrapper
let mocks
let computed
let deutschLanguageItem
beforeEach(() => {
mocks = {
$i18n: {
locale: () => 'de',
set: jest.fn(),
},
$t: jest.fn(),
setPlaceholderText: jest.fn(),
}
computed = {
current: () => {
return { code: 'en' }
},
routes: () => {
return [
{
name: 'English',
path: 'en',
},
{
name: 'Deutsch',
path: 'de',
},
]
},
}
})
describe('mount', () => {
const store = new Vuex.Store({
mutations: {
'editor/SET_PLACEHOLDER_TEXT': mutations.SET_PLACEHOLDER_TEXT,
},
})
const Wrapper = () => {
return mount(LocaleSwitch, { mocks, localVue, store, computed })
}
beforeEach(() => {
wrapper = Wrapper()
wrapper.find('.locale-menu').trigger('click')
deutschLanguageItem = wrapper.findAll('li').at(1)
deutschLanguageItem.trigger('click')
})
it("changes a user's locale", () => {
expect(mocks.$i18n.set).toHaveBeenCalledTimes(1)
})
})
})

View File

@ -36,6 +36,7 @@
import Dropdown from '~/components/Dropdown'
import find from 'lodash/find'
import orderBy from 'lodash/orderBy'
import { mapMutations } from 'vuex'
export default {
components: {
@ -65,10 +66,11 @@ export default {
},
},
methods: {
...mapMutations({ setPlaceholderText: 'editor/SET_PLACEHOLDER_TEXT' }),
changeLanguage(locale, toggleMenu) {
this.$i18n.set(locale)
toggleMenu()
this.$root.$emit('changeLanguage')
this.setPlaceholderText(this.$t('editor.placeholder'))
},
matcher(locale) {
return locale === this.$i18n.locale()

View File

@ -1,9 +1,10 @@
import { mount, createLocalVue, createWrapper } from '@vue/test-utils'
import CommentForm from './index.vue'
import Styleguide from '@human-connection/styleguide'
import Vuex from 'vuex'
const localVue = createLocalVue()
localVue.use(Vuex)
localVue.use(Styleguide)
describe('CommentForm.vue', () => {
@ -35,8 +36,16 @@ describe('CommentForm.vue', () => {
})
describe('mount', () => {
const getters = {
'editor/placeholder': () => {
return 'some cool placeholder'
},
}
const store = new Vuex.Store({
getters,
})
const Wrapper = () => {
return mount(CommentForm, { mocks, localVue, propsData })
return mount(CommentForm, { mocks, localVue, propsData, store })
}
beforeEach(() => {

View File

@ -92,7 +92,7 @@
<script>
import { mapGetters, mapActions } from 'vuex'
import LocaleSwitch from '~/components/LocaleSwitch'
import LocaleSwitch from '~/components/LocaleSwitch/LocaleSwitch'
import SearchInput from '~/components/SearchInput.vue'
import Modal from '~/components/Modal'
import NotificationMenu from '~/components/notifications/NotificationMenu'

View File

@ -56,7 +56,7 @@
"@nuxtjs/style-resources": "~0.1.2",
"accounting": "~0.4.1",
"apollo-cache-inmemory": "~1.5.1",
"apollo-client": "~2.6.2",
"apollo-client": "~2.6.3",
"cookie-universal-nuxt": "~2.0.16",
"cross-env": "~5.2.0",
"date-fns": "2.0.0-alpha.34",
@ -87,7 +87,7 @@
"@vue/server-test-utils": "~1.0.0-beta.29",
"@vue/test-utils": "~1.0.0-beta.29",
"babel-core": "~7.0.0-bridge.0",
"babel-eslint": "~10.0.1",
"babel-eslint": "~10.0.2",
"babel-jest": "~24.8.0",
"eslint": "~5.16.0",
"eslint-config-prettier": "~5.0.0",

View File

@ -73,7 +73,7 @@
</template>
<script>
import LocaleSwitch from '~/components/LocaleSwitch'
import LocaleSwitch from '~/components/LocaleSwitch/LocaleSwitch'
export default {
components: {

17
webapp/store/editor.js Normal file
View File

@ -0,0 +1,17 @@
export const state = () => {
return {
placeholder: null,
}
}
export const getters = {
placeholder(state) {
return state.placeholder
},
}
export const mutations = {
SET_PLACEHOLDER_TEXT(state, text) {
state.placeholder = text
},
}

View File

@ -0,0 +1,20 @@
import { getters, mutations } from './editor.js'
let state
describe('getters', () => {
describe('placeholder', () => {
it('return the value in state', () => {
state = { placeholder: null }
expect(getters.placeholder(state)).toBe(null)
})
})
})
describe('mutations', () => {
it('SET_PLACEHOLDER_TEXT', () => {
state = { placeholder: null }
mutations.SET_PLACEHOLDER_TEXT(state, 'new placeholder')
expect(getters.placeholder(state)).toBe('new placeholder')
})
})

View File

@ -1893,10 +1893,10 @@ apollo-cache@1.3.2, apollo-cache@^1.2.1:
apollo-utilities "^1.3.2"
tslib "^1.9.3"
apollo-client@^2.5.1, apollo-client@~2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/apollo-client/-/apollo-client-2.6.2.tgz#03b6af651e09b6e413e486ddc87464c85bd6e514"
integrity sha512-oks1MaT5x7gHcPeC8vPC1UzzsKaEIC0tye+jg72eMDt5OKc7BobStTeS/o2Ib3e0ii40nKxGBnMdl/Xa/p56Yg==
apollo-client@^2.5.1, apollo-client@~2.6.3:
version "2.6.3"
resolved "https://registry.yarnpkg.com/apollo-client/-/apollo-client-2.6.3.tgz#9bb2d42fb59f1572e51417f341c5f743798d22db"
integrity sha512-DS8pmF5CGiiJ658dG+mDn8pmCMMQIljKJSTeMNHnFuDLV0uAPZoeaAwVFiAmB408Ujqt92oIZ/8yJJAwSIhd4A==
dependencies:
"@types/zen-observable" "^0.8.0"
apollo-cache "1.3.2"
@ -2310,10 +2310,10 @@ babel-core@~7.0.0-bridge.0:
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece"
integrity sha512-poPX9mZH/5CSanm50Q+1toVci6pv5KSRv/5TWCwtzQS5XEwn40BcCrgIeMFWP9CKKIniKXNxoIOnOq4VVlGXhg==
babel-eslint@~10.0.1:
version "10.0.1"
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.1.tgz#919681dc099614cd7d31d45c8908695092a1faed"
integrity sha512-z7OT1iNV+TjOwHNLLyJk+HN+YVWX+CLE6fPD2SymJZOZQBs+QIexFjhm4keGTm8MW9xr4EC9Q0PbaLB24V5GoQ==
babel-eslint@~10.0.2:
version "10.0.2"
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.2.tgz#182d5ac204579ff0881684b040560fdcc1558456"
integrity sha512-UdsurWPtgiPgpJ06ryUnuaSXC2s0WoSZnQmEpbAH65XZSdwowgN5MvyP7e88nW07FYXv72erVtpBkxyDVKhH1Q==
dependencies:
"@babel/code-frame" "^7.0.0"
"@babel/parser" "^7.0.0"