Add From: Me to advanced search filters (#11126)

This commit is contained in:
DS Boyce
2026-07-22 15:01:24 -07:00
committed by GitHub
parent 850765bc8d
commit 77bbe8d8a0
12 changed files with 249 additions and 44 deletions
@@ -1,7 +1,9 @@
import {describe, expect, it} from '@jest/globals'
import {
appendFromMe,
buildSearchPostsV2Filters,
extractFromMe,
extractSearchPostsParams,
} from '#/state/queries/search-posts-params'
@@ -139,6 +141,39 @@ describe(`extractSearchPostsParams`, () => {
})
})
describe(`extractFromMe / appendFromMe`, () => {
it(`strips a bare from:me token and reports it`, () => {
expect(extractFromMe(`cats from:me`)).toEqual({q: `cats`, fromMe: true})
expect(extractFromMe(`from:me`)).toEqual({q: ``, fromMe: true})
})
it(`reports fromMe false when the token is absent`, () => {
expect(extractFromMe(`cats from:alice`)).toEqual({
q: `cats from:alice`,
fromMe: false,
})
})
it(`leaves a quoted from:me in the query text`, () => {
expect(extractFromMe(`"from:me"`)).toEqual({q: `"from:me"`, fromMe: false})
})
it(`re-appends the token only when the filter is active`, () => {
expect(appendFromMe(`cats`, true)).toBe(`cats from:me`)
expect(appendFromMe(`cats`, false)).toBe(`cats`)
expect(appendFromMe(``, true)).toBe(`from:me`)
})
it(`does not duplicate an existing from:me token`, () => {
expect(appendFromMe(`cats from:me`, true)).toBe(`cats from:me`)
})
it(`round-trips through extract and append`, () => {
const {q, fromMe} = extractFromMe(`cats from:me`)
expect(appendFromMe(q, fromMe)).toBe(`cats from:me`)
})
})
describe(`buildSearchPostsV2Filters`, () => {
it(`maps embedded operators alone into v2 plural params`, () => {
expect(