Skip to content

Commit

Permalink
First pass at a system test (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwightwatson authored Feb 5, 2024
1 parent 0922a7c commit e812b71
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/views/accounts/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
<%= render "accounts/#{permitted_accountable_partial(@account.accountable_type)}", f: f %>

<div class="relative p-4 border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
<label for="account_name" class="block text-sm font-medium opacity-50 focus-within:opacity-100">Balance</label>
<label for="account_balance" class="block text-sm font-medium opacity-50 focus-within:opacity-100">Balance</label>
<div class="flex">
<%= 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" %>
</div>
</div>

<div class="absolute right-5 bottom-5">
<button type="submit" class="flex items-center justify-center w-12 h-12 mb-2 bg-black rounded-full shrink-0 grow-0 hover:bg-gray-600">
<button type="submit" class="flex items-center justify-center w-12 h-12 mb-2 bg-black rounded-full shrink-0 grow-0 hover:bg-gray-600" title="Submit">
<%= inline_svg_tag('icn-check.svg', class: 'text-white fill-current') %>
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<div class="flex flex-col mt-6">
<div class="flex items-center justify-between">
<span class="text-xs">Accounts</span>
<%= 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 %>
</div>
Expand Down
12 changes: 12 additions & 0 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@

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
18 changes: 18 additions & 0 deletions test/system/accounts_test.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e812b71

Please sign in to comment.