Skip to content

Commit 6d61d2f

Browse files
committed
test(search): normalize Jira fake rows before filtering
1 parent fa94639 commit 6d61d2f

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎apps/sim/lib/sim-search/live/atlassian.test.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ describe('Confluence plain search ranking', () => {
334334

335335
describe('Jira plain search ranking', () => {
336336
const search = '/ex/jira/cloud/rest/api/3/search/jql'
337-
/** `outsideMatch` marks an issue whose text lacks a query term, so an all-terms clause excludes it. */
337+
/** `outsideMatch`: the issue lacks a query term, so a `text ~` all-terms clause drops it. */
338338
type Issue = string | { key: string; summary: string; outsideMatch?: boolean }
339339
/**
340340
* Answers the all-terms query with `exact`, the all-terms summary query with `titled`, and the
@@ -345,7 +345,8 @@ describe('Jira plain search ranking', () => {
345345
titled: Issue[] | (() => never),
346346
half: Issue[] | (() => never) = []
347347
) {
348-
const toRow = (row: Issue) => (typeof row === 'string' ? { key: row, summary: row } : row)
348+
const toRow = (row: Issue): Exclude<Issue, string> =>
349+
typeof row === 'string' ? { key: row, summary: row } : row
349350
const issues = (rows: Issue[]) =>
350351
rows.map(toRow).map(({ key, summary }) => ({ key, fields: { summary } }))
351352
const json = vi.fn(
@@ -355,9 +356,9 @@ describe('Jira plain search ranking', () => {
355356
const jql = options?.body?.jql ?? ''
356357
if (jql.includes('summary ~')) {
357358
const rows = jql.includes(' OR ') ? half : titled
358-
const picked = (typeof rows === 'function' ? rows() : rows).filter(
359-
(row) => !jql.includes('text ~') || typeof row === 'string' || !row.outsideMatch
360-
)
359+
const picked = (typeof rows === 'function' ? rows() : rows)
360+
.map(toRow)
361+
.filter((row) => !(row.outsideMatch && jql.includes('text ~')))
361362
return { issues: issues(picked).slice(0, options?.body?.maxResults) }
362363
}
363364
return { issues: issues(exact.ids), ...(exact.more ? { nextPageToken: 'page-2' } : {}) }

0 commit comments

Comments
 (0)