Skip to content

Commit

Permalink
test: ensure list_campaigns by ids works
Browse files Browse the repository at this point in the history
  • Loading branch information
teesloane committed Jun 19, 2024
1 parent 82afb45 commit a70e6c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/bike_brigade_web/live/campaign_signup_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ defmodule BikeBrigadeWeb.CampaignSignupLiveTest do
campaign = make_campaign_in_future(ctx.program.id)
task = fixture(:task, %{campaign: campaign, rider: nil})

{:ok, live, html} = live(ctx.conn, ~p"/campaigns/signup/#{campaign.id}/")
{:ok, live, _html} = live(ctx.conn, ~p"/campaigns/signup/#{campaign.id}/")

html = live |> element("#signup-btn-desktop-sign-up-task-#{task.id}") |> render_click()
assert html =~ "Unassign me"
Expand Down
19 changes: 17 additions & 2 deletions test/bike_brigade_web/live/rider_home_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ defmodule BikeBrigadeWeb.RiderHomeLiveTest do
program: program,
campaign: campaign,
campaign2: campaign2,
campaign3: campaign3
campaign3: campaign3,
campaign4: campaign4,
campaign_in_50_hours: campaign_in_50_hours
})
end

Expand All @@ -77,7 +79,20 @@ defmodule BikeBrigadeWeb.RiderHomeLiveTest do
expected_redirect =
~p"/campaigns/signup?campaign_ids[]=#{ctx.campaign.id}&campaign_ids[]=#{ctx.campaign2.id}&campaign_ids[]=#{ctx.campaign3.id}"

end
# the cta button should link to only the relevant campaigns.
assert html
|> Floki.parse_fragment!()
|> Floki.find("#urgent-campaigns-signup-btn")
|> Floki.attribute("href") == [expected_redirect]

# let's visit the campaigns and ensure that the right ones render.
{:ok, _live, html} = live(ctx.conn, expected_redirect)
assert html =~ "campaign-#{ctx.campaign.id}"
assert html =~ "campaign-#{ctx.campaign2.id}"
assert html =~ "campaign-#{ctx.campaign3.id}"
refute html =~ "campaign-#{ctx.campaign4.id}"
refute html =~ "campaign-#{ctx.campaign_in_50_hours.id}"
end

test "it shows rider's itinerary of deliveries for today, with a sign up button", ctx do
fixture(:task, %{campaign: ctx.campaign, rider: ctx.rider})
Expand Down

0 comments on commit a70e6c4

Please sign in to comment.