diff --git a/test/functional/kaui/accounts_controller_test.rb b/test/functional/kaui/accounts_controller_test.rb index 59eadc66..0e67bd41 100644 --- a/test/functional/kaui/accounts_controller_test.rb +++ b/test/functional/kaui/accounts_controller_test.rb @@ -294,6 +294,22 @@ class AccountsControllerTest < Kaui::FunctionalTestHelper assert_equal 'text/plain', @response.header['Content-Type'] end + test 'should download accounts data' do + start_date = Date.today.strftime('%Y-%m-%d') + end_date = Date.today.strftime('%Y-%m-%d') + columns = %w[account_id name email bcd cba] + account = create_account(@tenant) + + get :download, params: { startDate: start_date, endDate: end_date, allFieldsChecked: 'false', columnsString: columns.join(',') } + assert_response :success + assert_equal 'text/csv', @response.header['Content-Type'] + assert_includes @response.header['Content-Disposition'], "filename=\"accounts-#{Date.today}.csv\"" + assert_includes @response.body, account.account_id + + csv = CSV.parse(@response.body, headers: true) + assert_equal %w[account_id name email bill_cycle_day_local account_cba], csv.headers + end + private def redirected_account_id diff --git a/test/functional/kaui/audit_logs_controller_test.rb b/test/functional/kaui/audit_logs_controller_test.rb index 42ef1039..92ae4e89 100644 --- a/test/functional/kaui/audit_logs_controller_test.rb +++ b/test/functional/kaui/audit_logs_controller_test.rb @@ -61,6 +61,15 @@ class AuditLogsControllerTest < Kaui::FunctionalTestHelper end end + test 'should download audit logs data' do + get :download, params: { account_id: @account.account_id } + assert_response :success + assert_equal 'text/csv', @response.header['Content-Type'] + assert_includes @response.header['Content-Disposition'], "filename=\"audit-logs-#{Date.today}.csv\"" + assert_includes @response.body, @payment.payment_id + assert_includes @response.body, @account.account_id + end + private def add_a_note(account) diff --git a/test/functional/kaui/invoices_controller_test.rb b/test/functional/kaui/invoices_controller_test.rb index cd629615..fc3f19a0 100644 --- a/test/functional/kaui/invoices_controller_test.rb +++ b/test/functional/kaui/invoices_controller_test.rb @@ -92,5 +92,21 @@ class InvoicesControllerTest < Kaui::FunctionalTestHelper assert_redirected_to account_invoice_path(@account.account_id, invoice_id) assert_equal 'Invoice successfully committed', flash[:notice] end + + test 'should download invoices data' do + start_date = Date.today.strftime('%Y-%m-%d') + end_date = Date.today.strftime('%Y-%m-%d') + columns = %w[invoice_id currency status] + invoice = create_charge(@account, @tenant) + + get :download, params: { startDate: start_date, endDate: end_date, allFieldsChecked: 'false', columnsString: columns.join(',') } + assert_response :success + assert_equal 'text/csv', @response.header['Content-Type'] + assert_includes @response.header['Content-Disposition'], "filename=\"invoices-#{Date.today}.csv\"" + assert_includes @response.body, invoice.invoice_id + + csv = CSV.parse(@response.body, headers: true) + assert_equal columns, csv.headers + end end end diff --git a/test/functional/kaui/payments_controller_test.rb b/test/functional/kaui/payments_controller_test.rb index 36411fb8..61ab828f 100644 --- a/test/functional/kaui/payments_controller_test.rb +++ b/test/functional/kaui/payments_controller_test.rb @@ -60,5 +60,20 @@ class PaymentsControllerTest < Kaui::FunctionalTestHelper expected_response_path = "/accounts/#{@payment.account_id}/payments/#{@payment.payment_id}" assert response_path.include?(expected_response_path), "#{response_path} is expected to contain #{expected_response_path}" end + + test 'should download payments data' do + start_date = Date.today.strftime('%Y-%m-%d') + end_date = Date.today.strftime('%Y-%m-%d') + columns = %w[payment_id auth currency capture purchase refund credit] + + get :download, params: { startDate: start_date, endDate: end_date, allFieldsChecked: 'false', columnsString: columns.join(',') } + assert_response :success + assert_equal 'text/csv', @response.header['Content-Type'] + assert_includes @response.header['Content-Disposition'], "filename=\"payments-#{Date.today}.csv\"" + assert_includes @response.body, @payment.payment_id + + csv = CSV.parse(@response.body, headers: true) + assert_equal %w[payment_id auth_amount currency captured_amount purchased_amount refunded_amount credited_amount], csv.headers + end end end