Skip to content

Commit

Permalink
Add system tests
Browse files Browse the repository at this point in the history
Closes #42
  • Loading branch information
kirillplatonov committed Apr 18, 2022
1 parent 38052b8 commit 4a775d2
Show file tree
Hide file tree
Showing 24 changed files with 351 additions and 37 deletions.
7 changes: 5 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ source "https://rubygems.org"

gemspec

gem "rake", "~> 13.0"
gem "rails", "~> 7.0.2"
gem "bootsnap", ">= 1.4.4", require: false
gem "puma", "~> 5.0"
gem "sprockets-rails"
gem "importmap-rails"
gem "turbo-rails"
gem "stimulus-rails"
gem "lookbook"

gem "pry-rails"
gem "foreman"
gem "capybara"
gem "sqlite3"
Expand Down
36 changes: 29 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ GEM
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
bootsnap (1.11.1)
msgpack (~> 1.2)
builder (3.2.4)
capybara (3.36.0)
addressable
Expand All @@ -88,6 +86,7 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
childprocess (4.1.0)
coderay (1.1.3)
concurrent-ruby (1.1.10)
crass (1.0.6)
Expand All @@ -100,6 +99,9 @@ GEM
htmlbeautifier (1.4.2)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
importmap-rails (1.0.3)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand All @@ -122,7 +124,6 @@ GEM
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.15.0)
msgpack (1.5.1)
net-imap (0.2.3)
digest
net-protocol
Expand Down Expand Up @@ -150,9 +151,9 @@ GEM
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-rails (0.3.9)
pry (>= 0.10.4)
public_suffix (4.0.7)
puma (5.6.4)
nio4r (~> 2.0)
racc (1.6.0)
rack (2.2.3)
rack-test (1.1.0)
Expand Down Expand Up @@ -207,6 +208,11 @@ GEM
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.11.0)
rubyzip (2.3.2)
selenium-webdriver (4.1.0)
childprocess (>= 0.5, < 5.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2)
sprockets (4.0.3)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -218,15 +224,24 @@ GEM
standard (1.10.0)
rubocop (= 1.27.0)
rubocop-performance (= 1.13.3)
stimulus-rails (1.0.4)
railties (>= 6.0.0)
strscan (3.0.1)
thor (1.2.1)
timeout (0.2.0)
turbo-rails (1.0.1)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (2.1.0)
view_component (2.52.0)
activesupport (>= 5.0.0, < 8.0)
method_source (~> 1.0)
webdrivers (5.0.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
webrick (1.7.0)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
Expand All @@ -245,16 +260,23 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
bootsnap (>= 1.4.4)
capybara
foreman
importmap-rails
lookbook
minitest (~> 5.0)
polaris_view_components!
pry-rails
pry
puma (~> 5.0)
rails (~> 7.0.2)
rake (~> 13.0)
selenium-webdriver (~> 4.1)
sprockets-rails
sqlite3
standard
stimulus-rails
turbo-rails
webdrivers (~> 5.0)

BUNDLED WITH
2.3.11
2 changes: 0 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ require "bundler/setup"

APP_RAKEFILE = File.expand_path("demo/Rakefile", __dir__)
load "rails/tasks/engine.rake"

load "rails/tasks/statistics.rake"

require "bundler/gem_tasks"

require "rake/testtask"

Rake::TestTask.new(:test) do |t|
Expand Down
7 changes: 7 additions & 0 deletions app/assets/stylesheets/polaris_view_components.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions app/assets/stylesheets/polaris_view_components/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ a.Polaris-Tag__Button {
justify-content: center;
}

&--sizeMedium {
justify-content: center;
text-align: center;

.Polaris-Stack.Polaris-Stack--alignmentCenter {
justify-content: center;
}
}

&--sizeSmall {
padding: 0;
justify-content: center;
Expand Down
13 changes: 8 additions & 5 deletions app/components/polaris/dropzone_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
class="Polaris-DropZone__Overlay Polaris-VisuallyHidden"
data-polaris-dropzone-target="overlay"
>
<%= render Polaris::StackComponent.new(vertical: true, spacing: :tight) do |stack| %>
<% stack.item do %>
<%= render Polaris::DisplayTextComponent.new(size: :small) do %>
<%= @overlay_text %>
<% unless @size == :small %>
<%= render Polaris::StackComponent.new(vertical: true, spacing: :tight) do |stack| %>
<% stack.item do %>
<%= render Polaris::DisplayTextComponent.new(size: :small) do %>
<%= @overlay_text %>
<% end %>
<% end %>
<% end %>
<% end %>
Expand Down Expand Up @@ -86,7 +88,8 @@
class: [
"Polaris-DropZone__Preview",
"Polaris-DropZone__Preview--singleFile": !@multiple,
"Polaris-DropZone__Preview--sizeSmall": @size == :small
"Polaris-DropZone__Preview--sizeMedium": @size == :medium,
"Polaris-DropZone__Preview--sizeSmall": @size == :small,
]
) do %>
<% if @size.in?(%i[small]) %>
Expand Down
5 changes: 1 addition & 4 deletions demo/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ ruby File.read(".ruby-version").chomp

gem "rails", "~> 7.0.2"
gem "puma", "~> 5.0"
gem "bootsnap", ">= 1.4.4", require: false

gem "sprockets-rails"
gem "importmap-rails"
gem "turbo-rails"
gem "stimulus-rails"
gem "lookbook"

gem "polaris_view_components", path: "../"
gem "lookbook"

group :development, :test do
gem "foreman"
gem "pry-rails"
end

group :development do
Expand Down
11 changes: 0 additions & 11 deletions demo/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
bindex (0.8.1)
bootsnap (1.11.1)
msgpack (~> 1.2)
builder (3.2.4)
coderay (1.1.3)
concurrent-ruby (1.1.10)
crass (1.0.6)
digest (3.1.0)
Expand Down Expand Up @@ -113,7 +110,6 @@ GEM
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.15.0)
msgpack (1.5.1)
net-imap (0.2.3)
digest
net-protocol
Expand All @@ -135,11 +131,6 @@ GEM
racc (~> 1.4)
nokogiri (1.13.4-x86_64-linux)
racc (~> 1.4)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-rails (0.3.9)
pry (>= 0.10.4)
puma (5.6.4)
nio4r (~> 2.0)
racc (1.6.0)
Expand Down Expand Up @@ -218,12 +209,10 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
bootsnap (>= 1.4.4)
foreman
importmap-rails
lookbook
polaris_view_components!
pry-rails
puma (~> 5.0)
rails (~> 7.0.2)
sprockets-rails
Expand Down
1 change: 0 additions & 1 deletion demo/config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

require "bundler/setup" # Set up gems listed in the Gemfile.
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added demo/public/favicon.ico
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<%= polaris_autocomplete(multiple: true) do |autocomplete| %>
<%= polaris_autocomplete(
multiple: true,
selected: ["antique", "vintage"],
) do |autocomplete| %>
<% autocomplete.text_field(label: "Tags", placeholder: "Search") do |c| %>
<% c.prefix do %>
<%= polaris_icon(name: "SearchMinor") %>
Expand All @@ -7,9 +10,9 @@
<% autocomplete.section(title: "Suggested tags") do |section| %>
<% section.option(label: "Rustic", value: "rustic") %>
<% section.option(label: "Antique", value: "antique", checked: true) %>
<% section.option(label: "Antique", value: "antique") %>
<% section.option(label: "Vinyl", value: "vinyl") %>
<% section.option(label: "Vintage", value: "vintage", checked: true) %>
<% section.option(label: "Vintage", value: "vintage") %>
<% section.option(label: "Refurbished", value: "refurbished") %>
<% end %>
<% end %>
12 changes: 10 additions & 2 deletions polaris_view_components.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ Gem::Specification.new do |spec|
spec.files = Dir["lib/**/*", "app/**/*", "config/**/*", "LICENSE.txt", "README.md"]

spec.required_ruby_version = ">= 2.7.0"
spec.add_dependency "rails", ">= 5.0.0"
spec.add_dependency "view_component", ">= 2.0.0"

spec.add_runtime_dependency "rails", ">= 5.0.0"
spec.add_runtime_dependency "view_component", ">= 2.0.0"

spec.add_development_dependency "capybara", "~> 3"
spec.add_development_dependency "webdrivers", "~> 5.0"
spec.add_development_dependency "selenium-webdriver", "~> 4.1"
spec.add_development_dependency "minitest", "~> 5.0"
spec.add_development_dependency "pry"
spec.add_development_dependency "sprockets-rails"
end
17 changes: 17 additions & 0 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require "test_helper"
require "webdrivers/geckodriver"

Capybara.server = :puma, {Silent: true}
Capybara.default_max_wait_time = 15
Capybara.default_set_options = {clear: :backspace}

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
DRIVER = ENV["HEADLESS"] == "false" ? :firefox : :headless_firefox

driven_by :selenium, using: DRIVER, screen_size: [1400, 1400]

def with_preview(path)
visit "/rails/view_components/#{path}"
sleep 0.5
end
end
1 change: 1 addition & 0 deletions test/fixtures/file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test file
Binary file added test/fixtures/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions test/fixtures/image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4a775d2

Please sign in to comment.