Add From: Me to advanced search filters (#11126)
This commit is contained in:
@@ -73,12 +73,68 @@ describe(`AdvancedSearchDialog serialize/parse`, () => {
|
||||
expect(state.until).toBe('2024-02-01')
|
||||
})
|
||||
|
||||
it(`keeps from:me in the query box rather than lifting it into a row`, () => {
|
||||
const state = parseAdvancedSearch('from:me', {})
|
||||
expect(state.query).toBe('from:me')
|
||||
it(`lifts from:me typed into the query box into the "me" following filter`, () => {
|
||||
const state = parseAdvancedSearch('cats from:me', {})
|
||||
expect(state.query).toBe('cats')
|
||||
expect(state.following).toBe('me')
|
||||
expect(state.filters.find(f => f.field === 'authors')).toBeUndefined()
|
||||
})
|
||||
|
||||
it(`promotes the "me" filter from q to a structured filter`, () => {
|
||||
const out = serializeAdvancedSearch({
|
||||
...emptySerializeState,
|
||||
query: 'cats',
|
||||
following: 'me',
|
||||
})
|
||||
expect(out.q).toBe('cats')
|
||||
expect(out.filters.from).toBe('me')
|
||||
expect(out.filters.following).toBeUndefined()
|
||||
})
|
||||
|
||||
it(`strips from:me typed after selecting Me`, () => {
|
||||
const out = serializeAdvancedSearch({
|
||||
...emptySerializeState,
|
||||
query: 'cats from:me',
|
||||
following: 'me',
|
||||
})
|
||||
expect(out.q).toBe('cats')
|
||||
expect(out.filters.from).toBe('me')
|
||||
})
|
||||
|
||||
it(`promotes from:me typed after the dialog opens`, () => {
|
||||
const out = serializeAdvancedSearch({
|
||||
...emptySerializeState,
|
||||
query: 'cats from:me',
|
||||
})
|
||||
expect(out.q).toBe('cats')
|
||||
expect(out.filters.from).toBe('me')
|
||||
})
|
||||
|
||||
it(`keeps a quoted from:me as query text`, () => {
|
||||
const out = serializeAdvancedSearch({
|
||||
...emptySerializeState,
|
||||
query: 'cats "from:me"',
|
||||
})
|
||||
expect(out.q).toBe('cats "from:me"')
|
||||
expect(out.filters.from).toBeUndefined()
|
||||
})
|
||||
|
||||
it(`round-trips cats from:me through the "me" following filter`, () => {
|
||||
const state = parseAdvancedSearch('cats from:me', {})
|
||||
const out = serializeAdvancedSearch({
|
||||
...emptySerializeState,
|
||||
query: state.query,
|
||||
following: state.following,
|
||||
})
|
||||
expect(out.q).toBe('cats')
|
||||
expect(out.filters.from).toBe('me')
|
||||
expect(out.filters.following).toBeUndefined()
|
||||
})
|
||||
|
||||
it(`parses the structured Me filter into the From dropdown`, () => {
|
||||
expect(parseAdvancedSearch('cats', {from: 'me'}).following).toBe('me')
|
||||
})
|
||||
|
||||
it(`merges a query-box operator with the matching filter param`, () => {
|
||||
const state = parseAdvancedSearch('hi from:bob', {author: 'alice'})
|
||||
expect(state.query).toBe('hi')
|
||||
|
||||
Reference in New Issue
Block a user