From c080985fc4ff66c619b404d1582021e596281b1b Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Sun, 21 Jan 2018 23:34:08 -0500 Subject: [PATCH] Add invalid username test --- test/features/session_test.exs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test/features/session_test.exs b/test/features/session_test.exs index a9cef22..552eda6 100644 --- a/test/features/session_test.exs +++ b/test/features/session_test.exs @@ -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