1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00

Add invalid username test

This commit is contained in:
Daniel Barber 2018-01-21 23:34:08 -05:00
parent 5b7c67481c
commit c080985fc4
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8

View File

@ -5,12 +5,24 @@ defmodule Chess.SessionTest do
import Wallaby.Query, only: [text_field: 1, button: 1]
test "user cannot sign in with incorrect password", %{session: session} do
test "user cannot sign in with incorrect username", %{session: session} do
create_user()
session
|> visit("/session/new")
|> fill_in(text_field("Username"), with: "link@example.com")
|> fill_in(text_field("Password"), with: "ilovezelda")
|> click(button("Sign in"))
assert session |> has_text?("Bad username or password")
end
test "user cannot sign in with incorrect password", %{session: session} do
create_user()
session
|> visit("/session/new")
|> fill_in(text_field("Username"), with: "link@hyrule.kingdom")
|> fill_in(text_field("Password"), with: "calamityganon")
|> click(button("Sign in"))
@ -22,7 +34,7 @@ defmodule Chess.SessionTest do
session
|> visit("/session/new")
|> fill_in(text_field("Username"), with: "link@example.com")
|> fill_in(text_field("Username"), with: "link@hyrule.kingdom")
|> fill_in(text_field("Password"), with: "ilovezelda")
|> click(button("Sign in"))
@ -32,7 +44,7 @@ defmodule Chess.SessionTest do
defp create_user() do
changeset = User.changeset(
%User{},
%{username: "link@example.com", password: "ilovezelda"}
%{username: "link@hyrule.kingdom", password: "ilovezelda"}
)
Repo.insert!(changeset)
end