-
-
Save shankardevy/48bc48252be3f1c11d08d3e7cf321aa2 to your computer and use it in GitHub Desktop.
Acceptance Test for Mango Homepage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MangoWeb.Acceptance.HomepageTest do | |
use ExUnit.Case | |
use Hound.Helpers | |
hound_session() | |
test "presence of seasonal products" do | |
## GIVEN ## | |
# There are two products Apple and Tomato price 100 and 50 respectively | |
# Where Apple being the only seasonal product | |
## WHEN ## | |
# I navigate to homepage | |
navigate_to("/") | |
## THEN ## | |
# I expect the page title to be "Seasonal products" | |
page_title = find_element(:css, ".page-title") |> visible_text() | |
assert page_title == "Seasonal Products" | |
# And I expect Apple in the product displayed | |
product = find_element(:css, ".product") | |
product_name = find_within_element(product, :css, ".product-name") |> visible_text() | |
product_price = find_within_element(product, :css, ".product-price") |> visible_text() | |
assert product_name == "Apple" | |
# And I expect its price to be displayed on screen | |
assert product_price == "100" | |
# And I expect that Tomato is not present on screen. | |
refute page_source() =~ "Tomato" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had to add
|> visible_test()
at the end of both line 23 and 24 or my tests would fail as below:To fix change lines 23 and 24 to the following: