From 635c8004817fb4b08acea3c7e0c229f8ab641087 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 14 Dec 2023 15:18:30 +0200 Subject: [PATCH] updated fixed values for modal windows for english auction bids, added autobider state rendering --- .../modals/change_offer/component.html.erb | 2 +- app/components/modals/change_offer/component.rb | 3 ++- .../number_form_field/component.html.erb | 2 +- app/controllers/autobider_controller.rb | 5 ++++- test/system/auctions_test.rb | 14 ++++++++++++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/components/modals/change_offer/component.html.erb b/app/components/modals/change_offer/component.html.erb index 4822aeb5c..fdbfc8d0a 100644 --- a/app/components/modals/change_offer/component.html.erb +++ b/app/components/modals/change_offer/component.html.erb @@ -50,7 +50,7 @@ <%= component 'common/form/checkboxes/rounded_checkbox', form: f, **autobider_checkbox_properties %> - <%= t('english_offers.form.autobider') %>: <%= t('english_offers.form.nope') %> + <%= t('english_offers.form.autobider') %>: <%= @autobider.enable ? t('english_offers.form.yep') : t('english_offers.form.nope') %> diff --git a/app/components/modals/change_offer/component.rb b/app/components/modals/change_offer/component.rb index 5419a9755..03e68ccdd 100644 --- a/app/components/modals/change_offer/component.rb +++ b/app/components/modals/change_offer/component.rb @@ -54,7 +54,8 @@ def number_field_properties options: { min: 0.0, step: 0.01, - value: number_with_precision(@autobider.price.to_f, precision: 2), + # value: number_with_precision(@autobider.price.to_f, precision: 2) || @auction.min_bids_step.to_f, + value: number_with_precision(@autobider.price.to_f, precision: 2, delimiter: '', separator: '.') || @auction.min_bids_step.to_f, disabled: is_number_field_disabled?, data: { action: 'keydown->form--autobider-submit#validatePrice input->form--autobider-submit#validatingInputPrice', diff --git a/app/components/modals/change_offer/number_form_field/component.html.erb b/app/components/modals/change_offer/number_form_field/component.html.erb index 50d2dae1f..3bb050d80 100644 --- a/app/components/modals/change_offer/number_form_field/component.html.erb +++ b/app/components/modals/change_offer/number_form_field/component.html.erb @@ -1 +1 @@ -<%= number_field_tag 'offer_price', number_with_precision(@offer_value, precision: 2), name: "offer[price]", class: "form-control", min: 0, step: "0.01", disabled: @offer_disabled, data: { action: 'autotax-counter#count' } %> +<%= number_field_tag 'offer_price', number_with_precision(@offer_value, precision: 2, separator: '.'), name: "offer[price]", class: "form-control", min: 0, step: "0.01", disabled: @offer_disabled, data: { action: 'autotax-counter#count' } %> diff --git a/app/controllers/autobider_controller.rb b/app/controllers/autobider_controller.rb index d82b13aa2..c3a2b5673 100644 --- a/app/controllers/autobider_controller.rb +++ b/app/controllers/autobider_controller.rb @@ -20,7 +20,10 @@ def update flash[:alert] = t('english_offers.form.captcha_verification') end - render turbo_stream: turbo_stream.replace('flash', partial: 'common/flash', locals: { flash: }) + render turbo_stream: [ + turbo_stream.replace('flash', partial: 'common/flash', locals: { flash: }), + turbo_stream.update('autobider-status', html: @autobider.enable ? I18n.t('english_offers.form.yep') : I18n.t('english_offers.form.nope')) + ] end def edit diff --git a/test/system/auctions_test.rb b/test/system/auctions_test.rb index 2de9e38b6..bd11df6bd 100644 --- a/test/system/auctions_test.rb +++ b/test/system/auctions_test.rb @@ -136,7 +136,21 @@ def test_autobider_available_only_for_english_type_auctions end def test_autobider_not_available_for_blind_auctions + sign_in @user + + visit('/') + + within("#auction_#{@blind_auction.id}", match: :first) do + assert(page.has_content?(:visible, @blind_auction.currently_winning_offer.price)) + + find('a.c-btn.c-btn--ghost.c-btn--icon', match: :first).click + end + + assert_selector '.c-modal', visible: true + assert_no_selector '#autobider_price', visible: true + assert_no_selector "input[name='autobider[enable]']" + refute(page.has_content?(:visible, "#{I18n.t('english_offers.form.autobider')}: #{I18n.t('english_offers.form.nope')}" )) end def test_autobidder_could_not_be_enable_if_price_is_less_than_minimum_required