Skip to content

Commit

Permalink
Merge pull request #58 from launchscout/feature/upgrade-wallaby
Browse files Browse the repository at this point in the history
use shadow_root from updated wallaby fork
  • Loading branch information
superchris authored Mar 16, 2023
2 parents 49824da + aa0770b commit e79956f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 72 deletions.
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ defmodule LaunchCart.MixProject do
{:swoosh, "~> 1.3"},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},
{:wallaby, "~> 0.29.1",
git: "https://github.com/launchscout/wallaby.git", runtime: false, only: :test}
{:wallaby, "~> 0.30.2",
git: "https://github.com/launchscout/wallaby.git", branch: "shadow-dom", runtime: false, only: :test}
]
end

Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
"unsafe": {:hex, :unsafe, "1.0.1", "a27e1874f72ee49312e0a9ec2e0b27924214a05e3ddac90e91727bc76f8613d8", [:mix], [], "hexpm", "6c7729a2d214806450d29766abc2afaa7a2cbecf415be64f36a6691afebb50e5"},
"uri_query": {:hex, :uri_query, "0.1.2", "ae35b83b472f3568c2c159eee3f3ccf585375d8a94fb5382db1ea3589e75c3b4", [:mix], [], "hexpm", "e3bc81816c98502c36498b9b2f239b89c71ce5eadfff7ceb2d6c0a2e6ae2ea0c"},
"wallaby": {:git, "https://github.com/launchscout/wallaby.git", "46c729226007ce1715ad9688120622043650cf5f", []},
"wallaby": {:git, "https://github.com/launchscout/wallaby.git", "80f5959080b7dfd0f248124c7af9a2ed02402cb5", [branch: "shadow-dom"]},
"web_driver_client": {:hex, :web_driver_client, "0.2.0", "63b76cd9eb3b0716ec5467a0f8bead73d3d9612e63f7560d21357f03ad86e31a", [:mix], [{:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:tesla, "~> 1.3", [hex: :tesla, repo: "hexpm", optional: false]}], "hexpm", "83cc6092bc3e74926d1c8455f0ce927d5d1d36707b74d9a65e38c084aab0350f"},
}
129 changes: 60 additions & 69 deletions test/launch_cart_web/features/stripe_cart_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,99 +18,90 @@ defmodule LaunchCartWeb.Features.LaunchCartTest do
end

feature "add item", %{session: session, store: store} do
session =
session
|> visit("/fake_stores/#{store.id}")
|> assert_text("My Store")
|> click(css("button#add-price_123"))
|> within_shadow_dom("launch-cart", fn shadow_dom ->
shadow_dom
|> assert_has(css(".cart-count", text: "1"))
|> click(css(".cart-count"))
|> assert_has(css("dialog"))
|> assert_has(css("table", text: "Nifty onesie"))
end)
session
|> visit("/fake_stores/#{store.id}")
|> assert_text("My Store")
|> click(css("button#add-price_123"))
|> find(css("launch-cart"))
|> shadow_root()
|> assert_has(css(".cart-count", text: "1"))
|> click(css(".cart-count"))
|> assert_has(css("dialog"))
|> assert_has(css("table", text: "Nifty onesie"))

PallyTest.here(session)

assert Repo.get_by(Cart, store_id: store.id)
end

feature "alter quantity", %{session: session, store: store} do
session =
session
|> visit("/fake_stores/#{store.id}")
|> assert_text("My Store")
|> click(css("button#add-price_123"))
|> within_shadow_dom("launch-cart", fn shadow_dom ->
shadow_dom
|> assert_has(css(".cart-count", text: "1"))
|> click(css(".cart-count"))
|> assert_has(css("table", text: "Nifty onesie"))
|> assert_has(css("td[part='cart-summary-qty']", text: "1"))
|> click(css("button[part='cart-increase-qty-button']"))
|> assert_has(css("td[part='cart-summary-qty']", text: "2"))
|> click(css("button[part='cart-decrease-qty-button']"))
|> assert_has(css("td[part='cart-summary-qty']", text: "1"))
end)
session
|> visit("/fake_stores/#{store.id}")
|> assert_text("My Store")
|> click(css("button#add-price_123"))
|> find(css("launch-cart"))
|> shadow_root()
|> assert_has(css(".cart-count", text: "1"))
|> click(css(".cart-count"))
|> assert_has(css("table", text: "Nifty onesie"))
|> assert_has(css("td[part='cart-summary-qty']", text: "1"))
|> click(css("button[part='cart-increase-qty-button']"))
|> assert_has(css("td[part='cart-summary-qty']", text: "2"))
|> click(css("button[part='cart-decrease-qty-button']"))
|> assert_has(css("td[part='cart-summary-qty']", text: "1"))

PallyTest.here(session)
end

feature "add item and reload", %{session: session, store: store} do
session =
session
|> visit("/fake_stores/#{store.id}")
|> assert_text("My Store")
|> click(css("button#add-price_123"))
|> within_shadow_dom("launch-cart", fn shadow_dom ->
shadow_dom
|> assert_has(css(".cart-count", text: "1"))
end)
|> visit("/fake_stores/#{store.id}")
|> within_shadow_dom("launch-cart", fn shadow_dom ->
shadow_dom
|> assert_has(css(".cart-count", text: "1"))
end)
session
|> visit("/fake_stores/#{store.id}")
|> assert_text("My Store")
|> click(css("button#add-price_123"))
|> find(css("launch-cart"))
|> shadow_root()
|> assert_has(css(".cart-count", text: "1"))

session
|> visit("/fake_stores/#{store.id}")
|> find(css("launch-cart"))
|> shadow_root()
|> assert_has(css(".cart-count", text: "1"))

PallyTest.here(session)
end

feature "after checkout", %{session: session, store: store} do
cart = insert(:cart, store: store, status: :checkout_complete)

session =
session
|> visit("/fake_stores/#{store.id}")
|> execute_script("""
console.log('cart id: #{cart.id}');
window.localStorage.setItem('cart_id', '#{cart.id}');
""")
|> assert_text("My Store")
|> visit("/fake_stores/#{store.id}")
|> assert_text("My Store")
|> within_shadow_dom("launch-cart", fn shadow_dom ->
shadow_dom
|> assert_has(css("dialog"))
end)
session
|> visit("/fake_stores/#{store.id}")
|> execute_script("""
console.log('cart id: #{cart.id}');
window.localStorage.setItem('cart_id', '#{cart.id}');
""")
|> assert_text("My Store")
|> visit("/fake_stores/#{store.id}")
|> assert_text("My Store")
|> find(css("launch-cart"))
|> shadow_root()
|> assert_has(css("dialog"))

PallyTest.here(session)
end

feature "remove item from cart", %{session: session, store: store} do
session =
session
|> visit("/fake_stores/#{store.id}")
|> assert_text("My Store")
|> click(css("button#add-price_123"))
|> within_shadow_dom("launch-cart", fn shadow_dom ->
shadow_dom
|> assert_has(css(".cart-count", text: "1"))
|> click(css("button"))
|> assert_has(css("td", text: "Nifty onesie"))
|> click(css("button#remove-item"))
|> assert_has(css("td", text: "Nifty onesie", count: 0))
end)
session
|> visit("/fake_stores/#{store.id}")
|> assert_text("My Store")
|> click(css("button#add-price_123"))
|> find(css("launch-cart"))
|> shadow_root()
|> assert_has(css(".cart-count", text: "1"))
|> click(css("button"))
|> assert_has(css("td", text: "Nifty onesie"))
|> click(css("button#remove-item"))
|> assert_has(css("td", text: "Nifty onesie", count: 0))

PallyTest.here(session)

Expand Down

0 comments on commit e79956f

Please sign in to comment.