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:
parent
5b7c67481c
commit
c080985fc4
@ -5,12 +5,24 @@ defmodule Chess.SessionTest do
|
|||||||
|
|
||||||
import Wallaby.Query, only: [text_field: 1, button: 1]
|
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()
|
create_user()
|
||||||
|
|
||||||
session
|
session
|
||||||
|> visit("/session/new")
|
|> visit("/session/new")
|
||||||
|> fill_in(text_field("Username"), with: "link@example.com")
|
|> 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")
|
|> fill_in(text_field("Password"), with: "calamityganon")
|
||||||
|> click(button("Sign in"))
|
|> click(button("Sign in"))
|
||||||
|
|
||||||
@ -22,7 +34,7 @@ defmodule Chess.SessionTest do
|
|||||||
|
|
||||||
session
|
session
|
||||||
|> visit("/session/new")
|
|> 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")
|
|> fill_in(text_field("Password"), with: "ilovezelda")
|
||||||
|> click(button("Sign in"))
|
|> click(button("Sign in"))
|
||||||
|
|
||||||
@ -32,7 +44,7 @@ defmodule Chess.SessionTest do
|
|||||||
defp create_user() do
|
defp create_user() do
|
||||||
changeset = User.changeset(
|
changeset = User.changeset(
|
||||||
%User{},
|
%User{},
|
||||||
%{username: "link@example.com", password: "ilovezelda"}
|
%{username: "link@hyrule.kingdom", password: "ilovezelda"}
|
||||||
)
|
)
|
||||||
Repo.insert!(changeset)
|
Repo.insert!(changeset)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user