-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: wire chat search box to full-text search #27973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7fc93ab
2ee34e5
86445a0
026020b
3132d51
1fcef68
5a925b1
f0bd801
4a47b35
b1846b7
450d239
dbfde13
60a3a6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1265,6 +1265,55 @@ func TestSearchTasks(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| func TestSearchChatsFrontendEmitted(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| // These query shapes must match the emitters in | ||
| // site/src/pages/AgentsPage/components/ChatsSidebar/dialogs/searchQuery.ts | ||
| // and site/src/api/queries/chats.ts. | ||
| testCases := []struct { | ||
| name string | ||
| query string | ||
| }{ | ||
| {name: "SearchSingleWord", query: `search:"fix"`}, | ||
| {name: "SearchMultipleWords", query: `search:"fix auth"`}, | ||
| {name: "SearchColon", query: `search:"fix:lint"`}, | ||
| {name: "SearchURL", query: `search:"http://example.com"`}, | ||
| {name: "SearchUnicode", query: `search:"日本語"`}, | ||
| {name: "SearchOperators", query: `search:"fix race OR deadlock -timeout"`}, | ||
| {name: "SearchPunctuationOnly", query: `search:"!!!"`}, | ||
| {name: "SearchOperatorWord", query: `search:"or"`}, | ||
| {name: "HasUnread", query: "has_unread:true"}, | ||
| {name: "Archived", query: "archived:true"}, | ||
| {name: "PRStatuses", query: "pr_status:open,merged"}, | ||
| {name: "DiffURL", query: `diff_url:"https://github.com/coder/coder/pull/1"`}, | ||
| {name: "FilterAndSearch", query: `has_unread:true search:"fix auth"`}, | ||
| {name: "SidebarDefault", query: "archived:false"}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 [CRF-41] The cross-language contract table misses a live sidebar emitter shape:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. Added the archived:false has_unread:true shape to both the Go contract table and the chats.test.ts shape test, so the unread-sidebar emitter is now pinned on both sides.
|
||
| {name: "SidebarUnread", query: "archived:false has_unread:true"}, | ||
| { | ||
| name: "SidebarFiltered", | ||
| query: "archived:false pr_status:draft,closed source:created_by_me,shared_with_me", | ||
| }, | ||
| } | ||
|
|
||
| for _, testCase := range testCases { | ||
| t.Run(testCase.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| _, errs := searchquery.Chats(testCase.query) | ||
| require.Empty(t, errs) | ||
| }) | ||
| } | ||
|
|
||
| rejectedQueries := []string{"pr_status:banana", "has_unread:maybe"} | ||
| for _, query := range rejectedQueries { | ||
| t.Run("Rejects"+query, func(t *testing.T) { | ||
| t.Parallel() | ||
| _, errs := searchquery.Chats(query) | ||
| require.NotEmpty(t, errs) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSearchChats(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3 [CRF-44] The zero-lexeme backend test pins
!!!, the one input the frontend can never send, and skipsor, the one it can. (Chopper)The commit message for 026020b names "operator-only input like OR" as the motivating case, and the story types
or, but that story mocksgetChats, so the claim "the backend returns empty foror" is pinned nowhere.NoSearchableWordsReturnsEmptyusessearch:"!!!", which the frontend letter/number guard blocks from ever being emitted. The Go code path is identical for both inputs; the untested distinction iswebsearch_to_tsquery('simple', 'or')producing an empty tsquery, which is Postgres behavior, and this suite runs against real Postgres. One added case (Query: \search:"or"``) covers the scenario the commit message and the story both claim.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. The handler test now pins both search:"!!!" and search:"or" against real Postgres, covering the operator-only scenario the commit message and story reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. The handler test now pins both search:"!!!" and search:"or" against real Postgres, covering the operator-only scenario the commit message and story reference.