1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00
chess/test/features/profile_test.exs
Dan Barber bc5c6c4f04
Add profile page to update name and email
* Also add ability to change password
2018-08-13 22:12:32 -04:00

69 lines
1.5 KiB
Elixir

defmodule Chess.Features.ProfileTest do
use ChessWeb.FeatureCase
import Wallaby.Query
import Chess.Factory
import Chess.AuthenticationHelpers
test "user can update their details", %{session: session} do
user = insert(:user, %{
name: "Link",
email: "link@hyrule.com",
password: "ilovezelda"
})
session
|> login(user.email, "ilovezelda")
session
|> click(link(user.name))
|> fill_in(text_field("Name"), with: "Not Zelda")
|> click(button("Update Profile"))
assert session |> has_text?("Not Zelda")
end
test "name cannot be blank", %{session: session} do
user = insert(:user, %{
name: "Link",
email: "link@hyrule.com",
password: "ilovezelda"
})
session
|> login(user.email, "ilovezelda")
session
|> click(link(user.name))
|> fill_in(text_field("Name"), with: "")
|> click(button("Update Profile"))
session
|> assert_has(
css("[data-role='name-error']", text: "can't be blank")
)
end
test "email cannot be blank", %{session: session} do
user = insert(:user, %{
name: "Link",
email: "link@hyrule.com",
password: "ilovezelda"
})
session
|> login(user.email, "ilovezelda")
session
|> click(link(user.name))
|> fill_in(text_field("Email"), with: "")
|> click(button("Update Profile"))
session
|> assert_has(
css("[data-role='email-error']", text: "can't be blank")
)
end
end