Adds coverage for CSV file download

This commit is contained in:
filipefurtad0
2023-02-28 19:13:47 +00:00
parent 890ab6796e
commit c1b60d88d6
2 changed files with 23 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
Distributor,Order Cycle,Order number,Tax Category,Tax Rate Name,Tax Rate,Total excl. tax ($),Tax,Total incl. tax ($),First Name,Last Name,Code,Email
Distributor,oc1,ORDER_NUMBER_1,tax_category,State,0.015,115.0,1.73,116.73,cfname,clname,ABC123,order1@example.com
Distributor,oc1,ORDER_NUMBER_1,tax_category,Country,0.025,115.0,2.88,117.88,cfname,clname,ABC123,order1@example.com
Distributor,oc1,ORDER_NUMBER_2,tax_category,State,0.015,215.0,3.23,218.23,c2fname,c2lname,DEF456,order2@example.com
Distributor,oc1,ORDER_NUMBER_2,tax_category,Country,0.025,215.0,5.38,220.38,c2fname,c2lname,DEF456,order2@example.com
1 Distributor Order Cycle Order number Tax Category Tax Rate Name Tax Rate Total excl. tax ($) Tax Total incl. tax ($) First Name Last Name Code Email
2 Distributor oc1 ORDER_NUMBER_1 tax_category State 0.015 115.0 1.73 116.73 cfname clname ABC123 order1@example.com
3 Distributor oc1 ORDER_NUMBER_1 tax_category Country 0.025 115.0 2.88 117.88 cfname clname ABC123 order1@example.com
4 Distributor oc1 ORDER_NUMBER_2 tax_category State 0.015 215.0 3.23 218.23 c2fname c2lname DEF456 order2@example.com
5 Distributor oc1 ORDER_NUMBER_2 tax_category Country 0.025 215.0 5.38 220.38 c2fname c2lname DEF456 order2@example.com

View File

@@ -105,7 +105,7 @@ describe "Sales Tax Totals By order" do
it "generates the report" do
login_as admin
visit admin_reports_path
click_on I18n.t("admin.reports.sales_tax_totals_by_order")
click_on "Sales Tax Totals By Order"
expect(page).to have_button("Go")
click_on "Go"
@@ -167,7 +167,7 @@ describe "Sales Tax Totals By order" do
it "generates the report" do
login_as admin
visit admin_reports_path
click_on I18n.t("admin.reports.sales_tax_totals_by_order")
click_on "Sales Tax Totals By Order"
expect(page).to have_button("Go")
click_on "Go"
@@ -335,7 +335,7 @@ describe "Sales Tax Totals By order" do
login_as admin
visit admin_reports_path
click_on I18n.t("admin.reports.sales_tax_totals_by_order")
click_on "Sales Tax Totals By Order"
end
it "should load all the orders" do
@@ -423,5 +423,20 @@ describe "Sales Tax Totals By order" do
expect(page.find("table.report__table tbody").text).to have_content(customer2_summary_row)
expect(page).to have_selector(table_raw_selector, count: 6)
end
context "downloads files" do
let(:report_file) do
CSV.read("spec/fixtures/reports/sales_tax_by_order/sales_tax_by_order.csv")
end
it 'as csv' do
expect(downloaded_filenames.length).to eq(0) # downloads folder should be empty
select "CSV", from: "report_format"
click_on "Go"
wait_for_download
expect(downloaded_filenames.length).to eq(1) # downloads folder should contain 1 file
expect(downloaded_filename).to match(/.*\.csv/)
expect(CSV.read(downloaded_filename)).to eq(report_file)
end
end
end
end