1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00
chess/test/features/session_test.exs
Dan Barber bedd6605ef
Redesign whole site in B&W
* Forms and board tweaks for small screen sizes
* Re-style game status indicators
* Re-style viewing/offline indicator
* Better eyecons 👁
* Re-organise CSS according to ITCSS principles
* Pick new font from Google Fonts
* Fix up tests
* Move some things into partials
2018-09-16 14:02:52 -04:00

65 lines
2.0 KiB
Elixir

defmodule Chess.Features.SessionTest do
use ChessWeb.FeatureCase
import Wallaby.Query
import Chess.Factory
test "user cannot log in with incorrect email", %{session: session} do
insert(:user, %{email: "link@hyrule.kingdom", password: "ilovezelda"})
session
|> visit("/")
|> click(css(".header__user-nav a", text: "Log in"))
|> fill_in(text_field("Email"), with: "link@example.com")
|> fill_in(text_field("Password"), with: "ilovezelda")
|> click(button("Log in"))
assert session |> has_text?("Bad email or password")
end
test "user cannot log in with incorrect password", %{session: session} do
insert(:user, %{email: "link@hyrule.kingdom", password: "ilovezelda"})
session
|> visit("/")
|> click(css(".header__user-nav a", text: "Log in"))
|> fill_in(text_field("Email"), with: "link@hyrule.kingdom")
|> fill_in(text_field("Password"), with: "calamityganon")
|> click(button("Log in"))
assert session |> has_text?("Bad email or password")
end
test "user can log in with correct details", %{session: session} do
insert(:user, %{email: "link@hyrule.kingdom", password: "ilovezelda"})
session
|> visit("/")
|> click(css(".header__user-nav a", text: "Log in"))
|> fill_in(text_field("Email"), with: "link@hyrule.kingdom")
|> fill_in(text_field("Password"), with: "ilovezelda")
|> click(button("Log in"))
assert session |> has_text?("You are logged in")
assert session |> has_text?("Listing games")
assert session |> has_text?("link@hyrule.kingdom")
end
test "user can log out", %{session: session} do
insert(:user, %{email: "link@hyrule.kingdom", password: "ilovezelda"})
session
|> visit("/")
|> click(css(".header__user-nav a", text: "Log in"))
|> fill_in(text_field("Email"), with: "link@hyrule.kingdom")
|> fill_in(text_field("Password"), with: "ilovezelda")
|> click(button("Log in"))
session
|> visit("/")
|> click(link("Log out"))
assert session |> has_text?("You are logged out")
end
end