Skip to content

Commit

Permalink
[BUG FIX] [MER-3401] Fixes instructor course search bug (#4925)
Browse files Browse the repository at this point in the history
* fixes instructor course search bug

* updates unit test

---------

Co-authored-by: Raphael Gachuhi <rgachuhi@cmu.edu>
  • Loading branch information
rgachuhi and Raphael Gachuhi authored Jun 28, 2024
1 parent 5c1321d commit 817433f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/oli_web/live/delivery/open_and_free_index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ defmodule OliWeb.Delivery.OpenAndFreeIndex do
<.form for={%{}} phx-change="search_section" class="w-[330px]">
<SearchInput.render
id="section_search_input"
name="search"
name="text_search"
placeholder="Search by course or instructor name"
text={@params.text_search}
/>
Expand Down Expand Up @@ -158,7 +158,7 @@ defmodule OliWeb.Delivery.OpenAndFreeIndex do
end

@impl Phoenix.LiveView
def handle_event("search_section", %{"search" => text_search}, socket) do
def handle_event("search_section", %{"text_search" => text_search}, socket) do
{:noreply, push_patch(socket, to: ~p"/sections?#{%{text_search: text_search}}")}
end

Expand Down
12 changes: 6 additions & 6 deletions test/oli_web/live/delivery/open_and_free_index_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,21 @@ defmodule OliWeb.Delivery.OpenAndFreeIndexTest do

view
|> form("form[phx-change=search_section]")
|> render_change(%{search: "best"})
|> render_change(%{text_search: "best"})

assert has_element?(view, "h5", "The best course ever!")
refute has_element?(view, "h5", "Maths")

view
|> form("form[phx-change=search_section]")
|> render_change(%{search: ""})
|> render_change(%{text_search: ""})

assert has_element?(view, "h5", "The best course ever!")
assert has_element?(view, "h5", "Maths")

view
|> form("form[phx-change=search_section]")
|> render_change(%{search: "a not existing course"})
|> render_change(%{text_search: "a not existing course"})

refute has_element?(view, "h5", "The best course ever!")
refute has_element?(view, "h5", "Maths")
Expand Down Expand Up @@ -222,23 +222,23 @@ defmodule OliWeb.Delivery.OpenAndFreeIndexTest do

view
|> form("form[phx-change=search_section]")
|> render_change(%{search: "messi"})
|> render_change(%{text_search: "messi"})

assert has_element?(view, "h5", "The best course ever!")
assert has_element?(view, "h5", "Maths")
refute has_element?(view, "h5", "Elixir")

view
|> form("form[phx-change=search_section]")
|> render_change(%{search: "maria"})
|> render_change(%{text_search: "maria"})

refute has_element?(view, "h5", "The best course ever!")
assert has_element?(view, "h5", "Maths")
assert has_element?(view, "h5", "Elixir")

view
|> form("form[phx-change=search_section]")
|> render_change(%{search: "a not existing instructor"})
|> render_change(%{text_search: "a not existing instructor"})

refute has_element?(view, "h5", "The best course ever!")
refute has_element?(view, "h5", "Maths")
Expand Down

0 comments on commit 817433f

Please sign in to comment.