improved specs

This commit is contained in:
Moriz Wahl 2020-01-07 15:35:04 +01:00
parent 57ab9128ea
commit 3f37b007d7
4 changed files with 22 additions and 53 deletions

View File

@ -8,11 +8,10 @@ export default {
// see http://lucene.apache.org/core/8_3_1/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package.description // see http://lucene.apache.org/core/8_3_1/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package.description
const myQuery = query const myQuery = query
.replace(/\s+/g, ' ') .replace(/\s+/g, ' ')
.replace(/[[@#:*~\\$|^\]?/"'(){}+?!,.-]/g, '') .replace(/[[@#:*~\\$|^\]?/"'(){}+?!,.-;]/g, '')
.split(' ') .split(' ')
.map(s => (s.toLowerCase().match(/^(not|and|or)$/) ? '"' + s + '"' : s + '*')) .map(s => (s.toLowerCase().match(/^(not|and|or)$/) ? '"' + s + '"' : s + '*'))
.join(' ') .join(' ')
// console.log(myQuery)
const postCypher = ` const postCypher = `
CALL db.index.fulltext.queryNodes('post_fulltext_search', $query) CALL db.index.fulltext.queryNodes('post_fulltext_search', $query)
YIELD node as resource, score YIELD node as resource, score
@ -73,36 +72,3 @@ export default {
}, },
}, },
} }
/* order users by closest geolocation could look like this
MATCH (u1:User { id: $thisUserId })-[:IS_IN]->(l1:Location)
MATCH (u2:User)-[:IS_IN]->(l2:Location)
WHERE NOT(u2.id = $thisUserId)
AND NOT (u2.deleted = true OR u2.disabled = true
OR (u1)-[:BLOCKED]-(u2))
WITH point({longitude: l1.lng, latitude: l1.lat}) AS P1,
point({longitude: l2.lng, latitude: l2.lat}) AS P2,
u2 AS otherUsers
WITH distance(P1, P2) AS Distance,
otherUsers AS users
ORDER BY Distance
RETURN users
*/
/* This query is to test if the calculation of distances works.
See:
https://github.com/Human-Connection/Human-Connection/issues/2587
MATCH (u1:User { name: 'Huey' })-[:IS_IN]->(l1:Location)
MATCH (u2:User)-[:IS_IN]->(l2:Location)
WHERE NOT(u2.name = 'Huey')
WITH point({longitude: l1.lng, latitude: l1.lat}) AS P1,
point({longitude: l2.lng, latitude: l2.lat}) AS P2,
l1.name AS Location1, l2.name AS Location2
WITH distance(P1, P2) AS Distance,
Location1 AS Location1, Location2 AS Location2
ORDER BY Distance
RETURN Location1, Location2, Distance
*/

View File

@ -52,7 +52,7 @@ describe('SearchResources.vue', () => {
}) })
it('clears searchResults', () => { it('clears searchResults', () => {
expect(wrapper.find('.is-open').exists()).toBe(false) expect(wrapper.vm.searchResults).toEqual([])
}) })
it('set pending to false', () => { it('set pending to false', () => {

View File

@ -37,26 +37,24 @@ describe('SearchPost.vue', () => {
wrapper wrapper
.find('.search-post-meta') .find('.search-post-meta')
.findAll('span') .findAll('span')
.at(0) .filter(item => item.text() === '3')
.text(), .exists(),
).toMatch('3') ).toBe(true)
}) })
it('renders post shoutedCount', () => { it('renders post shoutedCount', () => {
expect( expect(
wrapper wrapper
.find('.search-post-meta') .find('.search-post-meta')
.findAll('span') .findAll('span')
.at(1) .filter(item => item.text() === '6')
.text(), .exists(),
).toMatch('6') ).toBe(true)
}) })
it('renders post author', () => { it('renders post author', () => {
expect( expect(wrapper.find('.search-post-author').text()).toContain('Post Author')
wrapper })
.find('.search-post-author') it('renders post createdAt', () => {
.text() expect(wrapper.find('.search-post-author').text()).toContain('23.08.2019')
.replace(/\s+-\s+/, ' '),
).toMatch('Post Author 23.08.2019')
}) })
}) })
}) })

View File

@ -7,12 +7,12 @@
<ds-flex> <ds-flex>
<ds-flex-item> <ds-flex-item>
<ds-text size="small" color="softer" class="search-post-meta"> <ds-text size="small" color="softer" class="search-post-meta">
<span style="text-align: right;"> <span class="comments-count">
<b>{{ option.commentsCount }}</b> {{ option.commentsCount }}
<base-icon name="comments" /> <base-icon name="comments" />
</span> </span>
<span class="post-shouted"> <span class="shouted-count">
<b>{{ option.shoutedCount }}</b> {{ option.shoutedCount }}
<base-icon name="bullhorn" /> <base-icon name="bullhorn" />
</span> </span>
</ds-text> </ds-text>
@ -58,9 +58,14 @@ export default {
vertical-align: sub; vertical-align: sub;
} }
} }
.post-shouted { .shouted-count {
width: 36px; width: 36px;
display: inline-block; display: inline-block;
text-align: right; text-align: right;
font-weight: $font-weight-bold;
}
.comments-count {
text-align: right;
font-weight: $font-weight-bold;
} }
</style> </style>