Implement full-text search for members closes #11 #163
3 changed files with 3 additions and 5 deletions
|
|
@ -8,7 +8,7 @@ defmodule MvWeb.Components.SearchBarComponent do
|
|||
use MvWeb, :live_component
|
||||
|
||||
@impl true
|
||||
def update(assigns, socket) do
|
||||
def update(_assigns, socket) do
|
||||
|
simon marked this conversation as resolved
Outdated
simon
commented
Outdated
```
mix test
Compiling 5 files (.ex)
warning: variable "assigns" is unused (if the variable is not meant to be used, prefix it with an underscore)
│
11 │ def update(assigns, socket) do
│ ~~~~~~~
│
└─ lib/mv_web/live/components/search_bar_component.ex:11:14: MvWeb.Components.SearchBarComponent.update/2
```
|
||||
socket =
|
||||
socket
|
||||
|> assign_new(:query, fn -> "" end)
|
||||
|
|
|
|||
|
|
@ -14,15 +14,14 @@ defmodule MvWeb.Components.SearchBarComponentTest do
|
|||
conn = conn_with_oidc_user(conn)
|
||||
{:ok, view, _html} = live(conn, "/members")
|
||||
|
||||
# simulate search input and check that correct user is listed
|
||||
# simulate search input and check that other members are not listed
|
||||
html =
|
||||
view
|
||||
|> element("form[role=search]")
|
||||
|> render_change(%{"query" => "Friedrich"})
|
||||
|
||||
assert html =~ "Friedrich"
|
||||
refute html =~ "Greta"
|
||||
|
simon marked this conversation as resolved
Outdated
simon
commented
Doesn't this just assert that "Friedrich" should occur anywhere in the html? Doesn't this just assert that "Friedrich" should occur anywhere in the html?
If I'm not wrong, this would also apply to the exact same search string "Friedrich" which is rendered in html, too, and therefore it doesn't matter for the test which result is presented?
carla
commented
Yes, you are right :) Changed that to checking if members are not present instead Yes, you are right :) Changed that to checking if members are not present instead
|
||||
|
||||
# simulate search input and check that not matching user is not shown
|
||||
html =
|
||||
view
|
||||
|> element("form[role=search]")
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ defmodule MvWeb.MemberLive.IndexTest do
|
|||
|
||||
send(view.pid, {:search_changed, "Friedrich"})
|
||||
|
||||
# State aus dem LiveView-Prozess holen
|
||||
state = :sys.get_state(view.pid)
|
||||
|
carla marked this conversation as resolved
simon
commented
a bit picky, but this comment should be in english :) a bit picky, but this comment should be in english :)
|
||||
|
||||
assert state.socket.assigns.query == "Friedrich"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue