Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Prove every built-in report runs, not just validates

Damian Legawiec44ea953af394
diff --git a/spree/core/spec/services/spree/seeds/saved_reports_spec.rb b/spree/core/spec/services/spree/seeds/saved_reports_spec.rb
index 897c6ec7dc..2741611399 100644
--- a/spree/core/spec/services/spree/seeds/saved_reports_spec.rb
+++ b/spree/core/spec/services/spree/seeds/saved_reports_spec.rb
@@ -11,6 +11,17 @@ RSpec.describe Spree::Seeds::SavedReports do
expect(store.saved_reports.find_by(name: 'Top products').reporting_query.dimensions.first[:dimension].name).to eq(:product)
end
+ # Validation proves a seeded query names real members; only running it proves
+ # the compiler can express that combination against a database.
+ it 'seeds only queries that actually execute' do
+ create(:completed_order_with_totals, store: store, completed_at: 3.days.ago)
+
+ described_class::REPORTS.each do |report|
+ query = Spree::Reporting::Query.new(store: store, params: report[:query].deep_symbolize_keys)
+ expect { query.execute }.not_to raise_error, "#{report[:key]} failed"
+ end
+ end
+
it 'treats a merchant report differing only in case as already present' do
create(:saved_report, store: store, name: 'top products')