Skip to content

Commit

Permalink
Add specs for admin sign in
Browse files Browse the repository at this point in the history
  • Loading branch information
aliciapaz committed Mar 29, 2024
1 parent b0d5542 commit d27e9da
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/views/admin_users/sessions/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
.c-form
.c-form--group
= f.label :email, "Email Address"
= f.email_field :email, autofocus: true, autocomplete: "email", class:"c-input rounded-md"
= f.email_field :email, autofocus: true, autocomplete: "email", class:"c-input rounded-md", data: { test_id: "admin_login_email_input"}
.c-form--group class="mb-3"
= f.label :password
= f.password_field :password, autocomplete: "current-password", class:"c-input rounded-md"
= f.password_field :password, autocomplete: "current-password", class:"c-input rounded-md", data: { test_id: "admin_login_password_input"}
- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations'
= link_to "Forgot your password?", new_password_path(resource_name), class:'font-bold flex self-end md:self-center'
.c-form--action class="mt-12"
= f.submit "Sign in", class:"c-button"
= f.submit "Sign in", class:"c-button", data: { test_id: "admin_login_submit_btn"}
21 changes: 21 additions & 0 deletions spec/system/administrate_system_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require "system_helper"

RSpec.describe "Administrate", type: :system do
before do
@admin = create(:admin_user)
end

it "can log in" do
visit admin_root_path

find(:test_id, "admin_login_email_input").fill_in with: @admin.email
find(:test_id, "admin_login_password_input").fill_in with: "wrong password"
click_button "admin_login_submit_btn"
expect(page).to have_content("Invalid Email or password.")

find(:test_id, "admin_login_password_input").fill_in with: @admin.password
click_button "admin_login_submit_btn"

expect(page).to have_content("Signed in successfully.")
end
end

0 comments on commit d27e9da

Please sign in to comment.