Skip to content

Commit

Permalink
updated fixed values for modal windows for english auction bids, adde…
Browse files Browse the repository at this point in the history
…d autobider state rendering
  • Loading branch information
OlegPhenomenon committed Dec 18, 2023
1 parent 58067c9 commit 722cf8f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/components/modals/change_offer/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<%= component 'common/form/checkboxes/rounded_checkbox', form: f, **autobider_checkbox_properties %>

<span class="u-word-nowrap">
<%= t('english_offers.form.autobider') %>: <strong><%= t('english_offers.form.nope') %></strong>
<%= t('english_offers.form.autobider') %>: <strong id='autobider-status'><%= @autobider.enable ? t('english_offers.form.yep') : t('english_offers.form.nope') %></strong>
</span>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/components/modals/change_offer/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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' } %>
5 changes: 4 additions & 1 deletion app/controllers/autobider_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions test/system/auctions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 722cf8f

Please sign in to comment.