Skip to content

Commit 8947ff5

Browse files
manleyacmamhoff
authored andcommitted
Promotions: Pass product-picker to option-value-picker
This fixes an issue where the option-value-picker was not receiving the id for the selected product. Therefore the correct option values where not available and the params where malformed.
1 parent 36b8821 commit 8947ff5

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

promotions/app/javascript/backend/solidus_promotions/web_components/option_value_picker.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ $.fn.optionValueAutocomplete = function (options) {
4545

4646
class OptionValuePicker extends HTMLInputElement {
4747
connectedCallback() {
48-
$(this).optionValueAutocomplete();
48+
const container = this.closest(".promo-condition-option-value");
49+
const productPicker = container.querySelector('input[is="product-picker"]');
50+
51+
$(this).optionValueAutocomplete({
52+
productSelect: productPicker,
53+
});
4954
}
5055
}
5156

promotions/spec/system/solidus_promotions/backend/promotions_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,27 @@
161161
expect(page).to have_content("Benefit has been successfully removed!")
162162
end
163163
end
164+
165+
describe "Adding a benefit condition" do
166+
let!(:promotion_with_benefit) { create(:solidus_promotion, :with_adjustable_benefit) }
167+
let!(:product) { create(:product) }
168+
let!(:option_value) { create(:option_value) }
169+
let!(:variant) { create(:variant, product: product, option_values: [option_value]) }
170+
171+
it "allows adding a line_item_with_options condition", :js do
172+
visit solidus_promotions.edit_admin_promotion_path(promotion_with_benefit)
173+
click_link "Add Condition"
174+
select("Line Item Option Value(s)", from: "Condition Type")
175+
click_button "Add"
176+
expect(page).to have_content("Line Item Option Value(s)")
177+
click_link "Add product"
178+
within(".promo-condition-option-value") do
179+
# find('.select2-focusser').set(product.name)
180+
# find('.select2-input').set(option_value.name)
181+
end
182+
within("#benefits_adjust_line_item_#{promotion_with_benefit.benefits.first.id}_conditions") do
183+
find('input[type="submit"]', wait: 5).click
184+
end
185+
end
186+
end
164187
end

0 commit comments

Comments
 (0)