mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Add example for report regression testing
I've done it only for a CSV file now but we can extend that to other formats and test the actual result including formatting.
This commit is contained in:
3
spec/fixtures/reports/orders_and_fulfillment/order_cycle_customer_totals_report.csv
vendored
Normal file
3
spec/fixtures/reports/orders_and_fulfillment/order_cycle_customer_totals_report.csv
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
Hub,Customer,Email,Phone,Producer,Product,Variant,Quantity,Item ($),Item + Fees ($),Admin & Handling ($),Ship ($),Pay fee ($),Total ($),Paid?,Shipping,Delivery?,Ship Street,Ship Street 2,Ship City,Ship Postcode,Ship State,Comments,SKU,Order Cycle,Payment Method,Customer Code,Tags,Billing Street,Billing Street 2,Billing City,Billing Postcode,Billing State,Order number,Date
|
||||
Apple Market,John Doe,john@example.net,123-456-7890,Apple Farmer,Apples,"1g, S",1,10.0,10.0,"","","","",No,UPS Ground,Yes,10 Lovely Street,Northwest,Herndon,20170,Victoria,"",APP,"","",JHN,"",10 Lovely Street,Northwest,Herndon,20170,Victoria,R644360121,2022-05-26 00:00:00
|
||||
Apple Market,John Doe,"","","","","",TOTAL,10.0,10.0,0,0.0,0,10.0,No,"","","","","","","","","","","","","","","","","","",R644360121,2022-05-26 00:00:00
|
||||
|
@@ -6,8 +6,9 @@ module Reporting
|
||||
module Reports
|
||||
module OrdersAndFulfillment
|
||||
describe OrderCycleCustomerTotals do
|
||||
let!(:distributor) { create(:distributor_enterprise) }
|
||||
let!(:customer) { create(:customer, enterprise: distributor) }
|
||||
let!(:distributor) { create(:distributor_enterprise, name: "Apple Market") }
|
||||
let!(:customer) { create(:customer, enterprise: distributor, user: user, code: "JHN") }
|
||||
let(:user) { create(:user, email: "john@example.net") }
|
||||
let(:current_user) { distributor.owner }
|
||||
let(:params) { { display_summary_row: true } }
|
||||
let(:report) { OrderCycleCustomerTotals.new(current_user, params) }
|
||||
@@ -18,12 +19,31 @@ module Reporting
|
||||
|
||||
context "viewing the report" do
|
||||
let!(:order) do
|
||||
create(:completed_order_with_totals, line_items_count: 1, user: customer.user,
|
||||
customer: customer, distributor: distributor)
|
||||
create(
|
||||
:completed_order_with_totals,
|
||||
number: "R644360121",
|
||||
line_items_count: 1,
|
||||
user: customer.user,
|
||||
customer: customer,
|
||||
distributor: distributor,
|
||||
completed_at: Date.parse("2022-05-26"),
|
||||
).tap do |order|
|
||||
order.line_items[0].product.supplier.update(name: "Apple Farmer")
|
||||
order.line_items[0].product.update(name: "Apples")
|
||||
order.line_items[0].variant.update(sku: "APP")
|
||||
end
|
||||
end
|
||||
let(:comparison_report) do
|
||||
File.read(Rails.root.join(report_file_name))
|
||||
end
|
||||
let(:report_file_name) do
|
||||
"spec/fixtures/reports/orders_and_fulfillment/order_cycle_customer_totals_report.csv"
|
||||
end
|
||||
|
||||
it "generates the report" do
|
||||
expect(report_table.length).to eq(2)
|
||||
|
||||
expect(report.render_as(:csv)).to eq comparison_report
|
||||
end
|
||||
|
||||
it "has a line item row" do
|
||||
|
||||
Reference in New Issue
Block a user