Skip to content

Commit

Permalink
Added missing integration/system tests for account_activities
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergei Tsõganov authored and Sergei Tsõganov committed Dec 28, 2021
1 parent a2c1b9c commit abf1da8
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
28 changes: 28 additions & 0 deletions test/fixtures/account_activities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,31 @@ one:
invoice: one
bank_transaction: one
created_at: <%= Time.zone.parse('2010-07-05 10:00') %>

renew_cash:
account: cash
activity_type: "renew"
description: "Description of activity renew_cash"
sum: "123.00"
created_at: <%= Time.zone.parse('2021-08-05 10:00') %>

renew_two:
account: two
activity_type: "renew"
description: "Description of activity renew_two"
sum: "123.00"
created_at: <%= Time.zone.parse('2021-12-05 10:00') %>

create_two:
account: two
activity_type: "create"
description: "Description of activity create_two"
sum: "123.00"
created_at: <%= Time.zone.parse('2021-09-05 10:00') %>

renew_two_previous:
account: two
activity_type: "renew"
description: "Description of activity renew_two_previous"
sum: "123.00"
created_at: <%= Time.zone.parse('2021-10-05 10:00') %>
24 changes: 24 additions & 0 deletions test/integration/admin_area/account_activities_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,28 @@ def test_download_account_activity
response.headers['Content-Disposition']
assert_not_empty response.body
end

def test_search_account_activity
account_activities(:one).update(description: "Description of activity one",
sum: "123.00",
activity_type: "create",
created_at: Time.zone.parse('2021-07-05 10:00'))

get admin_account_activities_path, params: { q: { account_registrar_id_in: [registrars(:bestnames).id, registrars(:goodnames).id],
activity_type_in: ['renew'],
created_at_gteq: '2021-09-25',
created_at_lteq: '2021-11-' },
results_per_page: 1,
page: 2 }

assert_response :success

parsed_data = Nokogiri::HTML.parse(response.body)
tr = parsed_data.xpath('//*/table/tbody/tr')

assert_equal tr.count, 1
assert_includes tr.xpath("//td").text, account_activities(:renew_two).description
assert_equal tr.xpath("//td").first.at('a').text, registrars(:goodnames).code
end
end

18 changes: 17 additions & 1 deletion test/system/registrar_area/account_activities_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,20 @@ def test_download_account_activity
response.headers['Content-Disposition']
assert_not_empty response.body
end
end

def test_search_account_activity_with_invalid_date
account_activities(:one).update(description: "Description of activity one",
sum: "123.00",
activity_type: "create",
created_at: Time.zone.parse('2021-07-05 10:00'))

visit registrar_account_activities_path

find('#q_activity_type_in').click
find(:option, "Renew").select_option
fill_in('q_created_at_lteq', with: '2021-12--')
find(:xpath, ".//button[./span[contains(@class, 'glyphicon-search')]]").click

assert_text 'Description of activity renew_cash'
end
end

0 comments on commit abf1da8

Please sign in to comment.