updated tests

This commit is contained in:
olegphenomenon 2022-02-10 15:03:27 +02:00
parent ef03166fee
commit d0236be063
21 changed files with 578 additions and 658 deletions

View file

@ -24,38 +24,30 @@ class AdminAreaInvoicesIntegrationTest < ApplicationIntegrationTest
end
def test_create_new_invoice
invoice_n = Invoice.order(number: :desc).last.number
if Feature.billing_system_integrated?
invoice_n = Invoice.order(number: :desc).last.number
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
with(
body: "{\"transaction_amount\":\"1200.0\",\"order_reference\":4,\"customer_name\":\"Best Names\",\"customer_email\":\"info@bestnames.test\",\"custom_field_1\":\"\",\"custom_field_2\":\"registry\",\"invoice_number\":4}",
headers: {
'Accept'=>'Bearer WA9UvDmzR9UcE5rLqpWravPQtdS8eDMAIynzGdSOTw==--9ZShwwij3qmLeuMJ--NE96w2PnfpfyIuuNzDJTGw==',
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'Authorization'=>'Bearer foobar',
'Content-Type'=>'application/json',
'User-Agent'=>'Ruby'
}).
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
with(
headers: {
'Accept'=>'Bearer WA9UvDmzR9UcE5rLqpWravPQtdS8eDMAIynzGdSOTw==--9ZShwwij3qmLeuMJ--NE96w2PnfpfyIuuNzDJTGw==',
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'Authorization'=>'Bearer foobar',
'Content-Type'=>'application/json',
'User-Agent'=>'Ruby'
}).
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
visit new_admin_invoice_path
stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
assert_text 'Create new invoice'
select 'Best Names', from: 'deposit_registrar_id', match: :first
fill_in 'Amount', with: '1000'
click_on 'Save'
stub_request(:put, "http://registry:3000/eis_billing/e_invoice_response").
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
assert_equal page.status_code, 200
stub_request(:post, "http://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
to_return(status: 200, body: "", headers: {})
visit new_admin_invoice_path
assert_text 'Create new invoice'
select 'Best Names', from: 'deposit_registrar_id', match: :first
fill_in 'Amount', with: '1000'
click_on 'Save'
assert_equal page.status_code, 200
end
end
def test_visit_list_of_invoices_pages