Skip to content

Instantly share code, notes, and snippets.

@lucianghinda
Last active February 24, 2020 09:26
Show Gist options
  • Save lucianghinda/e49d2194512f42d5a92f92bcb9f92cde to your computer and use it in GitHub Desktop.
Save lucianghinda/e49d2194512f42d5a92f92bcb9f92cde to your computer and use it in GitHub Desktop.
Test Case for verifying Signup Form with valid data - written in Elixir
defmodule SignupTest do
use ExUnit.Case
use Hound.Helpers
alias Ecto.Adapters.SQL.Sandbox
hound_session()
setup do
:ok = Sandbox.checkout(App.Repo)
Sandbox.mode(App.Repo, {:shared, self()})
end
test "user is able to create account with valid data", _meta do
first_name = Faker.Name.first_name()
password = Faker.UUID.v4()
navigate_to("http://localhost:4002/registration/new")
find_element(:id, "user_first_name")
|> fill_field(first_name)
find_element(:id, "user_last_name")
|> fill_field(Faker.Name.last_name())
find_element(:id, "user_email")
|> fill_field(Faker.Internet.email())
find_element(:id, "user_password")
|> fill_field(password)
find_element(:id, "user_password_confirmation")
|> fill_field(password)
find_element(:id, "submit_button")
|> click()
assert(
visible_page_text()
|> String.contains?(String.upcase(first_name)),
"could not find firstname in the page"
)
assert(
current_url() == "http://localhost:4002/",
"after login was not redirected to homepage"
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment