From e812b715d310ed97b03e141a71322c7338b9453e Mon Sep 17 00:00:00 2001 From: Dwight Watson Date: Tue, 6 Feb 2024 08:19:31 +1100 Subject: [PATCH] First pass at a system test (#305) --- app/views/accounts/new.html.erb | 4 ++-- app/views/layouts/application.html.erb | 2 +- test/application_system_test_case.rb | 12 ++++++++++++ test/system/accounts_test.rb | 18 ++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 test/system/accounts_test.rb diff --git a/app/views/accounts/new.html.erb b/app/views/accounts/new.html.erb index a7556f27..2e6e7ddf 100644 --- a/app/views/accounts/new.html.erb +++ b/app/views/accounts/new.html.erb @@ -31,14 +31,14 @@ <%= render "accounts/#{permitted_accountable_partial(@account.accountable_type)}", f: f %>
- +
<%= f.number_field :balance, placeholder: "$0.00", in: 0.00..100000000.00, required: 'required', class: "p-0 mt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100" %>
-
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index f028840d..f8bd7290 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -57,7 +57,7 @@
Accounts - <%= link_to new_account_path, class: 'block hover:bg-gray-100 p-2 text-sm font-semibold text-gray-900 flex items-center rounded' do %> + <%= link_to new_account_path, class: 'block hover:bg-gray-100 p-2 text-sm font-semibold text-gray-900 flex items-center rounded', title: "New account" do %> <%= inline_svg_tag('icon-add.svg', class: 'text-gray-500 fill-current') %> <% end %>
diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index cee29fd2..42eb8460 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -2,4 +2,16 @@ require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ] + + private + + def sign_in(user) + visit new_session_path + within "form" do + fill_in "Email", with: user.email + fill_in "Password", with: "password" + click_button "Log in" + end + assert_text "Dashboard" + end end diff --git a/test/system/accounts_test.rb b/test/system/accounts_test.rb new file mode 100644 index 00000000..42cd1195 --- /dev/null +++ b/test/system/accounts_test.rb @@ -0,0 +1,18 @@ +require "application_system_test_case" + +class AccountsTest < ApplicationSystemTestCase + setup do + sign_in @user = users(:bob) + end + + test "should create account" do + click_on "New account" + click_on "Credit Card" + within "form" do + fill_in "Name", with: "VISA" + fill_in "Balance", with: "1000" + click_on "Submit" + end + assert_text "$1,000.00" + end +end