have i18n as option for search groups, fix test

This commit is contained in:
Moriz Wahl 2022-10-23 13:02:04 +02:00
parent e27f9b00e6
commit 88b5fb9b46
3 changed files with 43 additions and 15 deletions

View File

@ -36,6 +36,7 @@ describe('SearchResults', () => {
}
propsData = {
pageSize: 12,
search: '',
}
wrapper = Wrapper()
})
@ -169,7 +170,7 @@ describe('SearchResults', () => {
await wrapper.vm.$nextTick()
await expect(
wrapper.vm.$options.apollo.searchPosts.variables.bind(wrapper.vm)(),
).toMatchObject({ query: undefined, firstPosts: 12, postsOffset: 12 })
).toMatchObject({ query: '', firstPosts: 12, postsOffset: 12 })
})
it('displays the next page button when next-button is clicked', async () => {
@ -199,7 +200,7 @@ describe('SearchResults', () => {
await wrapper.vm.$nextTick()
await expect(
wrapper.vm.$options.apollo.searchPosts.variables.bind(wrapper.vm)(),
).toMatchObject({ query: undefined, firstPosts: 12, postsOffset: 24 })
).toMatchObject({ query: '', firstPosts: 12, postsOffset: 24 })
})
it('deactivates next page button when next-button is clicked twice', async () => {
@ -234,7 +235,7 @@ describe('SearchResults', () => {
await wrapper.vm.$nextTick()
await expect(
wrapper.vm.$options.apollo.searchPosts.variables.bind(wrapper.vm)(),
).toMatchObject({ query: undefined, firstPosts: 12, postsOffset: 0 })
).toMatchObject({ query: '', firstPosts: 12, postsOffset: 0 })
})
})
})

View File

@ -120,6 +120,7 @@ import PaginationButtons from '~/components/_new/generic/PaginationButtons/Pagin
import HcHashtag from '~/components/Hashtag/Hashtag'
export default {
name: 'SearchResults',
components: {
TabNavigation,
HcEmpty,
@ -372,7 +373,7 @@ export default {
},
searchGroups: {
query() {
return searchGroups
return searchGroups(this.i18n)
},
variables() {
const { firstGroups, groupsOffset, search } = this

View File

@ -61,19 +61,45 @@ export const searchPosts = gql`
}
`
export const searchGroups = gql`
${groupFragment}
query ($query: String!, $firstGroups: Int, $groupsOffset: Int) {
searchGroups(query: $query, firstGroups: $firstGroups, groupsOffset: $groupsOffset) {
groupCount
groups {
__typename
...group
export const searchGroups = (i18n) => {
const lang = i18n ? i18n.locale().toUpperCase() : 'EN'
return gql`
query ($query: String!, $firstGroups: Int, $groupsOffset: Int) {
searchGroups(query: $query, firstGroups: $firstGroups, groupsOffset: $groupsOffset) {
groupCount
groups {
__typename
id
name
slug
createdAt
updatedAt
disabled
deleted
about
description
descriptionExcerpt
groupType
actionRadius
categories {
id
slug
name
icon
}
avatar {
url
}
locationName
location {
name: name${lang}
}
myRole
}
}
}
}
`
`
}
export const searchUsers = gql`
${userFragment}