Skip to content

Commit

Permalink
fixed componen priview missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Dec 14, 2023
1 parent 9611968 commit 7632630
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 81 deletions.
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ group :development do
end

group :test do
gem 'capybara', '>= 2.15'
gem 'capybara', '~> 3.39.2'
gem 'cuprite'
# gem 'selenium-webdriver'
# gem 'selenium-webdriver', '4.10.0'
gem 'webdrivers'
gem 'simplecov', '~> 0.10', '< 0.18', require: false
gem 'spy'
gem 'webmock'
Expand Down
13 changes: 12 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,14 @@ GEM
faraday-multipart (>= 1)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
scenic (1.7.0)
activerecord (>= 4.0.0)
railties (>= 4.0.0)
selenium-webdriver (4.12.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
simplecov (0.17.1)
docile (~> 1.1)
json (>= 1.8, < 3)
Expand Down Expand Up @@ -440,6 +445,10 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webdrivers (5.2.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
webfinger (1.2.0)
activesupport
httpclient (>= 2.4)
Expand All @@ -451,6 +460,7 @@ GEM
hkdf (~> 0.2)
jwt (~> 2.0)
webrick (1.8.1)
websocket (1.2.10)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand All @@ -468,7 +478,7 @@ DEPENDENCIES
bullet
byebug
cancancan
capybara (>= 2.15)
capybara (~> 3.39.2)
chartkick
cssbundling-rails
cuprite
Expand Down Expand Up @@ -518,6 +528,7 @@ DEPENDENCIES
valvat
view_component
web-console (>= 3.3.0)
webdrivers
webmock
webpush

Expand Down
2 changes: 1 addition & 1 deletion app/assets/builds/application.js.map

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions app/components/application_view_component_preview.rb

This file was deleted.

8 changes: 4 additions & 4 deletions app/components/pages/auction/filter/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

<%= component 'common/form/radio_button', form: f, title: 'english', attribute: :type, data_attributes: { **form_filter_target }, options: { **radio_btn_style, id: 'filter_IO_button'} %>
<%= f.label :type_english, class: "c-table__filters__btn js-table-filter-btn", style: 'cursor: pointer;', for: 'filter_IO_button', data: { **form_filter_data_attrs } do %>
<span class="o-io-icon"></span><span class="u-hidden-m"><%= t('auction.english_auction') %></span>
<span class="o-io-icon"></span><span class="u-hidden-m"><%= t('auctions.english_auction') %></span>
<% end %>

<%= component 'common/form/radio_button', form: f, title: 'blind', attribute: :type,
data_attributes: { **form_filter_target }, options: { **radio_btn_style, id: 'filter_PO_button'} %>
<%= f.label :type_blind, class: "c-table__filters__btn js-table-filter-btn", style: 'cursor: pointer;', for: 'filter_PO_button', data: { **form_filter_data_attrs } do %>
<span class="o-po-icon"></span><span class="u-hidden-m"> <%= t('auction.blind_auction') %></span>
<span class="o-po-icon"></span><span class="u-hidden-m"> <%= t('auctions.blind_auction') %></span>
<% end %>
</div>

Expand All @@ -24,8 +24,8 @@
<%= component 'pages/auction/notification_subscribe', current_user: @current_user %>

<div class="c-auctions__legend">
<div><span class="o-io-icon o-icon--sm"></span><%= t('auction.english_auction') %></div>
<div><span class="o-po-icon o-icon--sm"></span><%= t('auction.blind_auction') %></div>
<div><span class="o-io-icon o-icon--sm"></span><%= t('auctions.english_auction') %></div>
<div><span class="o-po-icon o-icon--sm"></span><%= t('auctions.blind_auction') %></div>
</div>
</div>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="c-table__filters__more">
<% if @current_user&.daily_summary %>
<%= component 'common/links/link_button', link_title: t('auction.unsubscribe_for_notifications'), href: user_toggle_sub_path, color: 'ghost' %>
<%= component 'common/links/link_button', link_title: t('auctions.unsubscribe_for_notifications'), href: user_toggle_sub_path, color: 'ghost' %>
<% elsif @current_user %>
<%= component 'common/links/link_button', link_title: t('auction.subscribe_for_notifications'), href: user_toggle_sub_path(@current_user), color: 'ghost' %>
<%= component 'common/links/link_button', link_title: t('auctions.subscribe_for_notifications'), href: user_toggle_sub_path(@current_user), color: 'ghost' %>
<% end %>
</div>
7 changes: 7 additions & 0 deletions app/javascript/controllers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ const application = Application.start()
application.debug = document.documentElement.classList.contains("debug");
window.Stimulus = application

// if (process.env.RAILS_ENV === "test") {
// // propagate errors that happen inside Stimulus controllers
// application.handleError = (error, message, detail) => {
// throw error
// }
// }

export { application }
2 changes: 1 addition & 1 deletion test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
# Usually, especially when using Selenium, developers tend to increase the max wait time.
# With Cuprite, there is no need for that.
# We use a Capybara default value here explicitly.
Capybara.default_max_wait_time = 2
Capybara.default_max_wait_time = 10

# Normalize whitespaces when using `has_text?` and similar matchers,
# i.e., ignore newlines, trailing spaces, etc.
Expand Down
10 changes: 8 additions & 2 deletions test/support/cuprite_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ def pause
end

# Drop #debug anywhere in a test to open a Chrome inspector and pause the execution
def debug(*args)
page.driver.debug(*args)
def debug(binding = nil)
$stdout.puts '-------------------------------------------------'
$stdout.puts "🔎 Open Chrome inspector at http://localhost:3333"
$stdout.puts '-------------------------------------------------'
$stdout.puts ''
return binding.pry if binding

page.driver.pause
end
end
134 changes: 71 additions & 63 deletions test/system/auctions_test.rb
Original file line number Diff line number Diff line change
@@ -1,109 +1,117 @@
require 'application_system_test_case'
require "test_helper"

class AuctionsTest < ApplicationSystemTestCase
def setup
super

travel_to Time.parse('2010-07-05 10:40 +0000').in_time_zone

@blind_auction = auctions(:valid_with_offers)
@english_auction = auctions(:english)

@user = users(:participant)
end

def test_if_anonymous_click_to_offer_he_redirect_to_login_page
visit('/')

click_link_or_button(I18n.t('auctions.bid'), match: :first)

assert_current_path new_user_session_path
end

def test_if_user_click_to_offer_open_modal_window_for_blind_auction
sign_in @user

visit('/')

within("tr[data-platform='english']", match: :first) do
assert(page.has_content?(:visible, '0.0 €'))

click_link_or_button(I18n.t('auctions.bid'))
end

assert_selector('.c-modal', visible: true)
end

def test_if_user_click_to_offer_open_modal_window_for_english_auction
sign_in @user

end
visit('/')

def test_user_can_sort_auctions
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)
end

def test_user_can_filter_auctions

def test_subscribe_to_notifications
sign_in @user

visit('/')

assert(page.has_content?(:visible, I18n.t('auctions.subscribe_for_notifications')))
click_link_or_button(I18n.t('auctions.subscribe_for_notifications'))

assert(page.has_content?(:visible, I18n.t('auctions.unsubscribe_for_notifications')))
end

# include ActiveJob::TestHelper
def test_show_all
sign_in @user

# def setup
# super
visit('/')

# travel_to Time.parse('2010-07-05 10:30 +0000').in_time_zone
# @auction = auctions(:valid_with_offers)
# @other_auction = auctions(:valid_without_offers)
# @expired_auction = auctions(:expired)
# @orphaned_auction = auctions(:orphaned)
# @english_auction = auctions(:english)
# @english_nil_auction = auctions(:english_nil_starts)
# end
assert(page.has_content?(:visible, I18n.t('auctions.all_list')))
click_link_or_button(I18n.t('auctions.all_list'))

# def teardown
# super
assert_current_path auctions_path + '?show_all=true'
end

# travel_back
# end
def test_sort_table
# TODO: Stimulus actions not work in test mode
# --------------------------------------------

# def test_auctions_index_contains_a_list
# visit('/')
# sign_in @user

# assert(page.has_table?('auctions-table'))
# assert(page.has_link?('with-offers.test', href: auction_path(@auction.uuid)))
# assert(page.has_link?('no-offers.test', href: auction_path(@other_auction.uuid)))
# assert(page.has_link?('english_auction.test', href: auction_path(@english_auction.uuid)))
# assert(page.has_no_link?('english_nil_auction.test', href: auction_path(@english_nil_auction.uuid)))
# end
# visit('/')

# def test_numbers_have_a_span_class_in_index_list
# visit('/')
# list_of_domain = page.all('tbody#bids tr.contents td:first-child').map(&:text)

# assert(span_element = page.find('span.number-in-domain-name'))
# assert_equal('123', span_element.text)
# end
# puts list_of_domain
# puts '-----'

# def test_numbers_have_a_span_class_in_show_view
# visit(auction_path(@orphaned_auction.uuid))
# find('.sorting', text: I18n.t('auctions.domain_name', match: :first)).click

# assert(span_element = page.find('span.number-in-domain-name'))
# assert_equal('123', span_element.text)
# end
# list_of_domain = page.all('tbody#bids tr.contents td:first-child').map(&:text)

# def test_auctions_index_contains_a_link_to_terms_and_conditions
# visit('/')
# puts list_of_domain
end

# assert(
# page.has_link?('auctioning process',
# href: 'https://www.internet.ee/help-and-info/faq#III__ee_domain_auctions')
# )
def test_filter_auction_list
# TODO: Stimulus actions not work in test mode
# --------------------------------------------

# assert(page.has_link?('terms and conditions', href: Setting.find_by(code: 'terms_and_conditions_link').retrieve))
# end
# sign_in @user

# def test_auctions_index_does_not_contain_auctions_that_are_finished
# visit('/')

# assert_not(page.has_link?('expired.test'))
# end
# list_of_domain = page.all('tbody#bids tr.contents td:first-child').map(&:text)

# def test_show_page_for_finished_auctions_still_exists
# visit(auction_path(@expired_auction.uuid))
# assert(page.has_content?(:visible, 'This auction has finished'))
# assert(page.has_content?(:visible, 'expired.test'))
# end
# puts list_of_domain
# puts '-----'

# def test_show_page_contains_the_details_of_the_auction
# visit(auction_path(@auction.uuid))
# find('#domain_name').set('english_auction.test')
# sleep 1

# assert(page.has_content?(:visible, 'with-offers.test'))
# assert(page.has_content?(:visible, '2010-07-06 10:30'))
# end

# def test_for_english_auction_should_be_bid_button
# visit('/')
# list_of_domain = page.all('tbody#bids tr.contents td:first-child').map(&:text)

# assert(page.has_link?('english_auction.test', href: auction_path(@english_auction.uuid)))
# assert(page.has_link?('Bid!'))
# end
# puts list_of_domain
# puts '-----'

end
end
8 changes: 8 additions & 0 deletions test/system/autobider_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ class AutobiderControllerTest < ApplicationSystemTestCase
# travel_to Time.parse('2010-07-05 10:30 +0000').in_time_zone
# sign_in(@participant)
# end

def test_autobider_available_only_for_english_type_auctions

end

def test_autobider_not_available_for_blind_auctions

end
end

0 comments on commit 7632630

Please sign in to comment.