From e9cf51e57fa7c9c8264f9a140d8c075249e5a6bb Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Sat, 3 Mar 2018 14:00:25 -0500 Subject: [PATCH] Add some tests for unsuccessful registration --- test/features/registration_test.exs | 44 ++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/test/features/registration_test.exs b/test/features/registration_test.exs index 57acf6b..0f1d081 100644 --- a/test/features/registration_test.exs +++ b/test/features/registration_test.exs @@ -1,7 +1,7 @@ defmodule Chess.RegistrationTest do use ChessWeb.FeatureCase - import Wallaby.Query, only: [text_field: 1, link: 1, button: 1] + import Wallaby.Query test "user can register", %{session: session} do session @@ -14,4 +14,46 @@ defmodule Chess.RegistrationTest do assert session |> has_text?("Registered successfully") end + + test "user cannot register without a name", %{session: session} do + session + |> visit("/") + |> click(link("Register")) + |> fill_in(text_field("Email"), with: "link@example.com") + |> fill_in(text_field("Password"), with: "ilovezelda") + |> click(button("Register")) + + session + |> assert_has( + css("[data-role='name-error']", text: "can't be blank") + ) + end + + test "user cannot register without an email", %{session: session} do + session + |> visit("/") + |> click(link("Register")) + |> fill_in(text_field("Name"), with: "Link") + |> fill_in(text_field("Password"), with: "ilovezelda") + |> click(button("Register")) + + session + |> assert_has( + css("[data-role='email-error']", text: "can't be blank") + ) + end + + test "user cannot register without a password", %{session: session} do + session + |> visit("/") + |> click(link("Register")) + |> fill_in(text_field("Name"), with: "Link") + |> fill_in(text_field("Email"), with: "link@example.com") + |> click(button("Register")) + + session + |> assert_has( + css("[data-role='password-error']", text: "can't be blank") + ) + end end