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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fix: specs and the seller panel starter for the typed preferences contract
Damian Legawiecbd7c51ea7cff
diff --git a/packages/seller-dashboard-starter/package.json b/packages/seller-dashboard-starter/package.jsonindex 06c6cb2718..f68a04ebfb 100644--- a/packages/seller-dashboard-starter/package.json+++ b/packages/seller-dashboard-starter/package.json@@ -18,6 +18,7 @@"dependencies": {"@spree/admin-sdk": "workspace:^","@spree/seller-dashboard": "workspace:^",+ "@spree/admin-sdk": "workspace:^","@spree/dashboard-core": "workspace:^","@spree/dashboard-ui": "workspace:^","@spree/seller-sdk": "workspace:^",diff --git a/spree/core/spec/models/spree/delivery_method_rule_spec.rb b/spree/core/spec/models/spree/delivery_method_rule_spec.rbindex d55e5162f4..4104dca49d 100644--- a/spree/core/spec/models/spree/delivery_method_rule_spec.rb+++ b/spree/core/spec/models/spree/delivery_method_rule_spec.rb@@ -226,7 +226,7 @@ describe Spree::DeliveryMethodRule, type: :model dodescribe 'Spree::DeliveryMethod#rules=' doit 'creates rules alongside a new method in one save' domethod = Spree::DeliveryMethod.new(name: 'Express', store: store)- method.rules = [{ type: 'item_total_rule', preferences: { minimum_amount: 50 } }]+ method.rules = [{ type: 'item_total_rule', preferences: { minimum_amount: '50' } }]method.save!expect(method.delivery_method_rules.reload.sole.preferred_minimum_amount).to eq(50)@@ -238,8 +238,8 @@ describe Spree::DeliveryMethodRule, type: :model do)delivery_method.rules = [- { id: existing.prefixed_id, type: 'item_total_rule', preferences: { minimum_amount: 99 } },- { type: 'weight_rule', preferences: { maximum_weight: 5 } }+ { id: existing.prefixed_id, type: 'item_total_rule', preferences: { minimum_amount: '99' } },+ { type: 'weight_rule', preferences: { maximum_weight: '5' } }]delivery_method.save!diff --git a/spree/core/spec/models/spree/order_routing_rule_spec.rb b/spree/core/spec/models/spree/order_routing_rule_spec.rbindex 3dbec5f632..1072995ff6 100644--- a/spree/core/spec/models/spree/order_routing_rule_spec.rb+++ b/spree/core/spec/models/spree/order_routing_rule_spec.rb@@ -67,7 +67,7 @@ RSpec.describe Spree::OrderRoutingRule, type: :model doexpect(entry[:label]).to eq('Default location')expect(entry[:description]).to be_present- expect(entry[:preference_schema]).to eq([])+ expect(entry[:schema]).to include('type' => 'object', 'properties' => {})endenddiff --git a/spree/core/spec/models/spree/payment_method_spec.rb b/spree/core/spec/models/spree/payment_method_spec.rbindex 4e969fd500..90815606ac 100644--- a/spree/core/spec/models/spree/payment_method_spec.rb+++ b/spree/core/spec/models/spree/payment_method_spec.rb@@ -472,8 +472,9 @@ describe Spree::PaymentMethod, type: :model do# Describing a class needs a connection, so the schema can be asked for# before there is one — at boot, or in a rake task on an empty database.- # Settling on the empty answer would leave that class describing no- # preferences for the life of the process.+ # The preferences are still described, from the declarations alone, but+ # settling on that answer would leave out every default the database holds+ # for the life of the process.describe 'a schema asked for before the database was up' dolet(:gateway_class) doClass.new(Spree::Gateway) do@@ -485,11 +486,13 @@ describe Spree::PaymentMethod, type: :model doit 'is retried rather than settled on' doallow(gateway_class).to receive(:new).and_raise(ActiveRecord::ConnectionNotEstablished)- expect(gateway_class.preference_schema).to be_empty+ expect(gateway_class.preference_schema.map { |field| field[:key] }).to eq([:api_key])+ expect(gateway_class.instance_variable_get(:@preference_schema)).to be_nilallow(gateway_class).to receive(:new).and_call_originalexpect(gateway_class.preference_schema.map { |field| field[:key] }).to eq([:api_key])+ expect(gateway_class.instance_variable_get(:@preference_schema)).to be_presentend# These memoize off the schema, so caching what they derived from itsdiff --git a/spree/core/spec/models/spree/promotion_spec.rb b/spree/core/spec/models/spree/promotion_spec.rbindex 98ec93b352..1569c9d842 100644--- a/spree/core/spec/models/spree/promotion_spec.rb+++ b/spree/core/spec/models/spree/promotion_spec.rb@@ -953,7 +953,7 @@ describe Spree::Promotion, type: :model dolet(:category) { create(:category) }it 'builds a rule from a {type, preferences} hash' do- promotion.rules = [{ type: 'item_total', preferences: { amount_min: 50 } }]+ promotion.rules = [{ type: 'item_total', preferences: { amount_min: '50' } }]promotion.reloadexpect(promotion.rules.size).to eq(1)@@ -964,7 +964,7 @@ describe Spree::Promotion, type: :model doit 'updates an existing rule when matched by id' doexisting = promotion.rules.create!(type: 'Spree::Promotion::Rules::ItemTotal', preferences: { amount_min: 10 })- promotion.rules = [{ id: existing.id, type: 'item_total', preferences: { amount_min: 99 } }]+ promotion.rules = [{ id: existing.id, type: 'item_total', preferences: { amount_min: '99' } }]promotion.reloadexpect(promotion.rules.size).to eq(1)@@ -1059,7 +1059,7 @@ describe Spree::Promotion, type: :model doit 'defers application until after_save on a new promotion record' dopromotion = build(:promotion)- promotion.rules = [{ type: 'item_total', preferences: { amount_min: 25 } }]+ promotion.rules = [{ type: 'item_total', preferences: { amount_min: '25' } }]expect(promotion).to be_pending_rules_or_actionsexpect(promotion.rules).to be_empty@@ -1094,7 +1094,7 @@ describe Spree::Promotion, type: :model dotype: 'create_adjustment',calculator: {type: 'flat_rate',- preferences: { amount: 7.5, currency: 'USD' }+ preferences: { amount: '7.5', currency: 'USD' }}}]promotion.reload@@ -1115,7 +1115,7 @@ describe Spree::Promotion, type: :model dopromotion.actions = [{id: action.id,type: 'create_adjustment',- calculator: { type: 'flat_percent_item_total', preferences: { flat_percent: 15 } }+ calculator: { type: 'flat_percent_item_total', preferences: { flat_percent: '15' } }}]promotion.reloaddiff --git a/spree/core/spec/models/spree/stock/estimator_spec.rb b/spree/core/spec/models/spree/stock/estimator_spec.rbindex 69e9954f1c..5cb3d09491 100644--- a/spree/core/spec/models/spree/stock/estimator_spec.rb+++ b/spree/core/spec/models/spree/stock/estimator_spec.rb@@ -328,7 +328,7 @@ module Spreeretail = create(:channel, store: @default_store, name: "Retail #{SecureRandom.hex(3)}")wholesale_rate = create(:delivery_method, store: @default_store, name: 'Wholesale Rate')- wholesale_rate.rules = [{ type: 'channel_rule', preferences: { channel_ids: [wholesale.id] } }]+ wholesale_rate.rules = [{ type: 'channel_rule', preferences: { channel_ids: [wholesale.prefixed_id] } }]wholesale_rate.save!wholesale_order = create(:order_with_line_items, store: @default_store, channel: wholesale)