fix: site scoped search not working for domain and hostname
* alter site_name_tsv to include hostname and domain * add test cases
This commit is contained in:
@ -338,7 +338,7 @@ const parseFieldFilter = (
|
||||
}
|
||||
}
|
||||
|
||||
const parseIds = (field: string, str?: string): string[] | undefined => {
|
||||
const parseIds = (str?: string): string[] | undefined => {
|
||||
if (str === undefined) {
|
||||
return undefined
|
||||
}
|
||||
@ -500,7 +500,7 @@ export const parseSearchQuery = (query: string | undefined): SearchFilter => {
|
||||
break
|
||||
}
|
||||
case 'includes': {
|
||||
const ids = parseIds(keyword.keyword, keyword.value)
|
||||
const ids = parseIds(keyword.value)
|
||||
ids && result.ids.push(...ids)
|
||||
break
|
||||
}
|
||||
|
||||
@ -1568,6 +1568,47 @@ describe('Article API', () => {
|
||||
).to.eq(group.name)
|
||||
})
|
||||
})
|
||||
|
||||
context('when site:youtube.com is in the query', () => {
|
||||
let items: LibraryItem[] = []
|
||||
|
||||
before(async () => {
|
||||
keyword = 'site:youtube.com'
|
||||
// Create some test items
|
||||
items = await createLibraryItems(
|
||||
[
|
||||
{
|
||||
user,
|
||||
title: 'test title 1',
|
||||
readableContent: '<p>test 1</p>',
|
||||
slug: 'test slug 1',
|
||||
originalUrl:
|
||||
'https://www.youtube.com/watch?v=Omnivore',
|
||||
itemType: PageType.Video,
|
||||
},
|
||||
{
|
||||
user,
|
||||
title: 'test title 2',
|
||||
readableContent: '<p>test 2</p>',
|
||||
slug: 'test slug 2',
|
||||
originalUrl: `${url}/test2`,
|
||||
},
|
||||
],
|
||||
user.id
|
||||
)
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await deleteLibraryItems(items, user.id)
|
||||
})
|
||||
|
||||
it('returns youtube videos', async () => {
|
||||
const res = await graphqlRequest(query, authToken).expect(200)
|
||||
|
||||
expect(res.body.data.search.pageInfo.totalCount).to.eq(1)
|
||||
expect(res.body.data.search.edges[0].node.id).to.eq(items[0].id)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('TypeaheadSearch API', () => {
|
||||
|
||||
Reference in New Issue
Block a user