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 Jul 4, 2024
1 parent 6fc8119 commit 6fddf2d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 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 @@ -205,7 +205,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
18 changes: 17 additions & 1 deletion 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 @@ -76,6 +78,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}"

# 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
Expand Down

0 comments on commit 6fddf2d

Please sign in to comment.