From 4a775d2d493e29a222e1866c3a03566107585612 Mon Sep 17 00:00:00 2001 From: Kirill Platonov Date: Mon, 18 Apr 2022 18:40:38 +0300 Subject: [PATCH] Add system tests Closes #42 --- Gemfile | 7 +- Gemfile.lock | 36 ++++++-- Rakefile | 2 - .../stylesheets/polaris_view_components.css | 7 ++ .../polaris_view_components/custom.css | 9 ++ .../polaris/dropzone_component.html.erb | 13 ++- demo/Gemfile | 5 +- demo/Gemfile.lock | 11 --- demo/config/boot.rb | 1 - ....keep => apple-touch-icon-precomposed.png} | 0 demo/public/apple-touch-icon.png | 0 demo/public/favicon.ico | 0 .../preselected.html.erb | 9 +- polaris_view_components.gemspec | 12 ++- test/application_system_test_case.rb | 17 ++++ test/fixtures/file.txt | 1 + test/fixtures/image.png | Bin 0 -> 11646 bytes test/fixtures/image.svg | 13 +++ test/system/autocomplete_component_test.rb | 74 +++++++++++++++ test/system/button_component_test.rb | 25 +++++ test/system/collapsible_component_test.rb | 13 +++ test/system/dropzone_component_test.rb | 86 ++++++++++++++++++ test/system/modal_component_test.rb | 29 ++++++ test/system/select_component_test.rb | 18 ++++ 24 files changed, 351 insertions(+), 37 deletions(-) rename demo/public/{.keep => apple-touch-icon-precomposed.png} (100%) create mode 100644 demo/public/apple-touch-icon.png create mode 100644 demo/public/favicon.ico create mode 100644 test/application_system_test_case.rb create mode 100644 test/fixtures/file.txt create mode 100644 test/fixtures/image.png create mode 100644 test/fixtures/image.svg create mode 100644 test/system/autocomplete_component_test.rb create mode 100644 test/system/button_component_test.rb create mode 100644 test/system/collapsible_component_test.rb create mode 100644 test/system/dropzone_component_test.rb create mode 100644 test/system/modal_component_test.rb create mode 100644 test/system/select_component_test.rb diff --git a/Gemfile b/Gemfile index d9c4d32b..6c963213 100644 --- a/Gemfile +++ b/Gemfile @@ -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" diff --git a/Gemfile.lock b/Gemfile.lock index 7c5844d2..b75e4f11 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 @@ -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) @@ -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) @@ -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 @@ -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) @@ -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) @@ -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) @@ -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 diff --git a/Rakefile b/Rakefile index edd0cb08..3a498c49 100644 --- a/Rakefile +++ b/Rakefile @@ -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| diff --git a/app/assets/stylesheets/polaris_view_components.css b/app/assets/stylesheets/polaris_view_components.css index f06802dd..3c5d9a22 100644 --- a/app/assets/stylesheets/polaris_view_components.css +++ b/app/assets/stylesheets/polaris_view_components.css @@ -2325,6 +2325,13 @@ a.Polaris-Tag__Button { text-align: center; justify-content: center; } +.Polaris-DropZone__Preview--sizeMedium { + justify-content: center; + text-align: center; + } +.Polaris-DropZone__Preview--sizeMedium .Polaris-Stack.Polaris-Stack--alignmentCenter { + justify-content: center; + } .Polaris-DropZone__Preview--sizeSmall { padding: 0; justify-content: center; diff --git a/app/assets/stylesheets/polaris_view_components/custom.css b/app/assets/stylesheets/polaris_view_components/custom.css index de0c26d5..b7ba577d 100644 --- a/app/assets/stylesheets/polaris_view_components/custom.css +++ b/app/assets/stylesheets/polaris_view_components/custom.css @@ -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; diff --git a/app/components/polaris/dropzone_component.html.erb b/app/components/polaris/dropzone_component.html.erb index e0496d12..3792c79b 100644 --- a/app/components/polaris/dropzone_component.html.erb +++ b/app/components/polaris/dropzone_component.html.erb @@ -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 %> @@ -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]) %> diff --git a/demo/Gemfile b/demo/Gemfile index bf46a846..60a797b7 100644 --- a/demo/Gemfile +++ b/demo/Gemfile @@ -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 diff --git a/demo/Gemfile.lock b/demo/Gemfile.lock index 8fd60a8c..a1c1d77d 100644 --- a/demo/Gemfile.lock +++ b/demo/Gemfile.lock @@ -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) @@ -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 @@ -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) @@ -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 diff --git a/demo/config/boot.rb b/demo/config/boot.rb index 988a5ddc..28201161 100644 --- a/demo/config/boot.rb +++ b/demo/config/boot.rb @@ -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. diff --git a/demo/public/.keep b/demo/public/apple-touch-icon-precomposed.png similarity index 100% rename from demo/public/.keep rename to demo/public/apple-touch-icon-precomposed.png diff --git a/demo/public/apple-touch-icon.png b/demo/public/apple-touch-icon.png new file mode 100644 index 00000000..e69de29b diff --git a/demo/public/favicon.ico b/demo/public/favicon.ico new file mode 100644 index 00000000..e69de29b diff --git a/demo/test/components/previews/forms/autocomplete_component_preview/preselected.html.erb b/demo/test/components/previews/forms/autocomplete_component_preview/preselected.html.erb index e52d44f6..4839850e 100644 --- a/demo/test/components/previews/forms/autocomplete_component_preview/preselected.html.erb +++ b/demo/test/components/previews/forms/autocomplete_component_preview/preselected.html.erb @@ -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") %> @@ -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 %> diff --git a/polaris_view_components.gemspec b/polaris_view_components.gemspec index 9c4d58f7..55cbd113 100644 --- a/polaris_view_components.gemspec +++ b/polaris_view_components.gemspec @@ -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 diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb new file mode 100644 index 00000000..0b307469 --- /dev/null +++ b/test/application_system_test_case.rb @@ -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 diff --git a/test/fixtures/file.txt b/test/fixtures/file.txt new file mode 100644 index 00000000..524acfff --- /dev/null +++ b/test/fixtures/file.txt @@ -0,0 +1 @@ +Test file diff --git a/test/fixtures/image.png b/test/fixtures/image.png new file mode 100644 index 0000000000000000000000000000000000000000..509cd8e76beb7c90c6a7870778f699af97b053fc GIT binary patch literal 11646 zcmZ{KWl$YW6E5zS;O_2{;O@cQ4(=A*-QDHjc7lcAc5sK_5Q4k=!Ghc6{i^Pd`{UNu z?yO9APftJlRPSuZs4B~%qY$A$K|!I*%Sow2K|$Aiockgnd>jv1Tk$^{IBRhwaVV(z zB-9sE_>XG}b2)XTk3MuzP{H9)P){GXf{&n}JUF1BPE4Sn1hSx@@SXG8)r3ACAebr0 zN69fD0nkx{@xwIAgB5D@4ADF#C7jU-5~>`r(Pv0JGwz%Fe=m{* z9NTmKoHjK)rVMkQgj7UlS}&GQ@-#Mmt2U%nDOdo)-38{# zy(n-h0G;L^2ysJZ^-Ts+-Gy5(IX_Vt-UOnFL*5(%j8W;Ncj5y2fjvMdr3|R2uaBF(?nryVMAY>jlSpHv{Eu}T(?n=r~ z<5K-gKV{LE#-sGnC!%#38UZ>_#?uN!Y@9ki4C`)RCv*VwSF88{|G-kpLQf7u&wQ?w z+k@O4_HIFHlz%!RkC9AKgL~6v2>8FVnXf*%p2^U)#>HV<$%h~5( zBZHf10J$82VE#nq3s(1a`)Hh3(}vY-iQcxb@ChU>)X9eIu3m0LSjW)sgqZW0L6-$j z!4zvODoyvpR~No*A(tkb(TEP)yd1?Qh@lY3LdS9)#3;o)`>jw1b&%OP-Qx?hXT^x5 z`azFZ>3{xS%YpAS7bX$unx7sD__Y*zQXK5++RK>+83wc)Q}YVzd0L={&38YdYidgB+y-XJ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z5zIZ=;jR@N*|U$dV^w^o;aCehV;_0GGUCT@NQwoOD$-2*Q>#UcaaRC|_gGm6ok|#G zNV$gLb^RG5G&|83>^UM6E#b6?@$+lnVK=xHbwjObm?F>dj}BGfw2rr2SCseh2tH8` zEt2fnP!jCsBn+UjkL_^JMn;ZSfEnXTu~`1|#z(r;-f}%WcAUo&<5HQ8oq@}G%uNL} zRtc;6U!h2LG+J`X411+coy<9?EK$Sq{Ld`(MZzBKF4tb_oy zWwe?c=O4$qZ_h6el0uY-E82Ay+4Tsk-Hy5JYqW?>;F9lYH}YlW96 z_uS!sHBqtiw|ty9pQ%eNG`so3M4^zDiuEwY)QFm+P)#K-u5fAqtjKEh#CLd%F&D-;N?u&W7Z@F5dV|57huIchEg z>QTOZJP1=)m?AK@dHpUiAF-OAginuhmB`|K++V|0Krp|DMP*^rDU}GliOT-5C^#AM zvqDbfa*o;FsOch;RwX;(r&aX;a>Y(c=33*YuH;Cds>jmZ!D&RyojWi`FdV7!aC27_P-q4aw?87r{5J6`ye2PyIMSXsZ;`L_si*vZZZMI=u8Dfx{n5G; zu5ZG=gIVWk$wdS><+9g4-D3v3yA+}KuJ;DP+(x*YW?Bhdt~Gr}mv-ebl|g14h5`|R zrn1m;iN?pq`Y&+tUd&)j zM{d3Us=17_qV+rMo|X~UU`ecVhySZre3V1l$9tz>iZa#n16RCbUM?cF#m1V)ev~ZJ zx=ZW2TbR0A3YfcEel$>A99$f%9K5U?Uo<(m1h_c_xcQkmI0QI2Hq?vf{~rNICktCE YpZ~u=EheGuhX9nkw6au + + + + + + + + + + + + \ No newline at end of file diff --git a/test/system/autocomplete_component_test.rb b/test/system/autocomplete_component_test.rb new file mode 100644 index 00000000..ece2abdc --- /dev/null +++ b/test/system/autocomplete_component_test.rb @@ -0,0 +1,74 @@ +require "application_system_test_case" + +class AutocompleteComponentSystemTest < ApplicationSystemTestCase + def test_basic_autocomplete + with_preview("forms/autocomplete_component/basic") + + # Open autocomplete + find(".Polaris-TextField__Input").click + assert_selector ".Polaris-OptionList-Option", text: "Rustic" + assert_selector ".Polaris-OptionList-Option", text: "Vintage" + + # Enter query + find(".Polaris-TextField__Input").set "Vint" + assert_no_selector ".Polaris-OptionList-Option", text: "Rustic" + assert_selector ".Polaris-OptionList-Option", text: "Vintage" + end + + def test_preselected_autocomplete + with_preview("forms/autocomplete_component/preselected") + + # Open autocomplete + find(".Polaris-TextField__Input").click + assert_no_selector ".Polaris-OptionList-Checkbox__Input:checked[value=rustic]" + assert_selector ".Polaris-OptionList-Checkbox__Input:checked[value=antique]" + assert_selector ".Polaris-OptionList-Checkbox__Input:checked[value=vintage]" + + # Enter query + find(".Polaris-TextField__Input").set "Vin" + assert_no_selector ".Polaris-OptionList-Checkbox__Input:checked[value=vinyl]" + assert_selector ".Polaris-OptionList-Checkbox__Input:checked[value=vintage]" + end + + def test_remote_autocomplete + with_preview("forms/autocomplete_component/remote") + + # Local default suggestions + within all('[data-controller="polaris-autocomplete"]')[0] do + assert_selector ".Polaris-Label", text: "Tags with local suggestions" + + # Check default suggestions + find(".Polaris-TextField__Input").click + assert_selector ".Polaris-OptionList-Option", text: "Rustic" + assert_selector ".Polaris-OptionList-Option", text: "Vintage" + + # Enter query + find(".Polaris-TextField__Input").set "Vint" + assert_no_selector ".Polaris-OptionList-Option", text: "Rustic" + assert_selector ".Polaris-OptionList-Option", text: "Vintage" + end + + # Remote default suggestions + within all('[data-controller="polaris-autocomplete"]')[1] do + assert_selector ".Polaris-Label", text: "Tags with remote suggestions" + + # Check default suggestions + find(".Polaris-TextField__Input").click + assert_selector ".Polaris-OptionList-Option", text: "Rustic" + assert_selector ".Polaris-OptionList-Option", text: "Vintage" + + # Enter query + find(".Polaris-TextField__Input").set "Vint" + assert_no_selector ".Polaris-OptionList-Option", text: "Rustic" + assert_selector ".Polaris-OptionList-Option", text: "Vintage" + end + end + + def test_empty_state + with_preview("forms/autocomplete_component/empty_state") + + find(".Polaris-TextField__Input").click + find(".Polaris-TextField__Input").set "Unknown" + assert_selector ".Polaris-Autocomplete__EmptyState", text: "Could not find any results" + end +end diff --git a/test/system/button_component_test.rb b/test/system/button_component_test.rb new file mode 100644 index 00000000..b648b1ba --- /dev/null +++ b/test/system/button_component_test.rb @@ -0,0 +1,25 @@ +require "application_system_test_case" + +class ButtonComponentSystemTest < ApplicationSystemTestCase + def test_disable_with_actions + with_preview("actions/button_component/disable_with_actions") + + assert_no_selector ".Polaris-Button--loading" + + # Disable + click_on "Disable" + assert_selector ".Polaris-Button--loading > .Polaris-Button__Content > .Polaris-Button__Spinner" + + # Enable + click_on "Enable" + assert_no_selector ".Polaris-Button--loading" + end + + def test_disable_with_loader + with_preview("actions/button_component/disable_with_loader") + + assert_no_selector ".Polaris-Button--loading" + click_on "Disable on click" + assert_selector ".Polaris-Button--loading > .Polaris-Button__Content > .Polaris-Button__Spinner" + end +end diff --git a/test/system/collapsible_component_test.rb b/test/system/collapsible_component_test.rb new file mode 100644 index 00000000..798d2fd6 --- /dev/null +++ b/test/system/collapsible_component_test.rb @@ -0,0 +1,13 @@ +require "application_system_test_case" + +class CollapsibleComponentSystemTest < ApplicationSystemTestCase + def test_integration + with_preview("behavior/collapsible_component/default") + + assert_no_text "Your mailing list lets you contact" + click_on "Toggle" + assert_text "Your mailing list lets you contact" + click_on "Toggle" + assert_no_text "Your mailing list lets you contact" + end +end diff --git a/test/system/dropzone_component_test.rb b/test/system/dropzone_component_test.rb new file mode 100644 index 00000000..99ee0431 --- /dev/null +++ b/test/system/dropzone_component_test.rb @@ -0,0 +1,86 @@ +require "application_system_test_case" + +class DropzoneComponentSystemTest < ApplicationSystemTestCase + def test_file_upload + with_preview("forms/dropzone_component/with_file_upload") + + find(".Polaris-DropZone").drop(fixture_file("file.txt"), fixture_file("image.png")) + assert_selector ".Polaris-DropZone__Preview > .Polaris-Stack > .Polaris-Stack__Item", count: 2 + within ".Polaris-DropZone__Preview > .Polaris-Stack" do + assert_selector ".Polaris-Stack__Item:nth-child(1)" do + assert_text "file.txt" + assert_text "10 Bytes" + end + assert_selector ".Polaris-Stack__Item:nth-child(2)" do + assert_text "image.png" + assert_text "11.37 KB" + end + end + end + + def test_image_upload + with_preview("forms/dropzone_component/with_image_upload") + + find(".Polaris-DropZone").drop(fixture_file("file.txt")) + assert_selector ".Polaris-DropZone__Overlay", text: "This file type isn't accepted" + + with_preview("forms/dropzone_component/with_image_upload") + + find(".Polaris-DropZone").drop(fixture_file("image.png")) + within ".Polaris-DropZone__Preview" do + assert_text "image.png" + assert_text "11.37 KB" + end + end + + def test_single_file_upload + with_preview("forms/dropzone_component/with_single_file_upload") + + find(".Polaris-DropZone").drop(fixture_file("file.txt"), fixture_file("image.png")) + assert_selector ".Polaris-DropZone__Preview > .Polaris-Stack > .Polaris-Stack__Item", count: 1 + within ".Polaris-DropZone__Preview" do + assert_text "file.txt" + assert_text "10 Bytes" + end + end + + def test_drop_on_page + with_preview("forms/dropzone_component/with_drop_on_page") + + first(".Polaris-Page").drop(fixture_file("file.txt")) + within ".Polaris-DropZone__Preview" do + assert_text "file.txt" + assert_text "10 Bytes" + end + end + + def test_accepts_only_svg + with_preview("forms/dropzone_component/accepts_only_svg_files") + + find(".Polaris-DropZone").drop(fixture_file("file.txt")) + assert_selector ".Polaris-DropZone__Overlay", text: "File type must be .svg" + + with_preview("forms/dropzone_component/with_image_upload") + + find(".Polaris-DropZone").drop(fixture_file("image.svg")) + within ".Polaris-DropZone__Preview" do + assert_text "image.svg" + assert_text "5.63 KB" + end + end + + def test_small_dropzone + with_preview("forms/dropzone_component/small_sized") + + find(".Polaris-DropZone").drop(fixture_file("image.png")) + within ".Polaris-DropZone__Preview" do + assert_no_text "image.png" + assert_no_text "11.37 KB" + assert_selector ".Polaris-Thumbnail > img[alt='image.png']" + end + end + + def fixture_file(name) + Rails.root.join("../test/fixtures/#{name}") + end +end diff --git a/test/system/modal_component_test.rb b/test/system/modal_component_test.rb new file mode 100644 index 00000000..4df9b590 --- /dev/null +++ b/test/system/modal_component_test.rb @@ -0,0 +1,29 @@ +require "application_system_test_case" + +class ModalComponentSystemTest < ApplicationSystemTestCase + def test_basic_modal + with_preview("overlays/modal_component/basic") + + # Close modal + find(".Polaris-Modal-CloseButton").click + assert_no_selector ".Polaris-Modal-Dialog" + + # Open modal + click_on "Open" + within ".Polaris-Modal-Dialog" do + assert_selector ".Polaris-Modal-Header__Title", text: "Reach more shoppers" + assert_selector ".Polaris-Modal-Section", text: "Use Instagram posts to share your products" + assert_selector ".Polaris-Button", text: "Add instagram" + end + end + + def test_custom_close_button + with_preview("overlays/modal_component/custom_close_button") + + assert_selector ".Polaris-Modal-Dialog" + accept_alert "Close modal" do + find(".Polaris-Modal-CloseButton").click + end + assert_selector ".Polaris-Modal-Dialog" + end +end diff --git a/test/system/select_component_test.rb b/test/system/select_component_test.rb new file mode 100644 index 00000000..c16c07db --- /dev/null +++ b/test/system/select_component_test.rb @@ -0,0 +1,18 @@ +require "application_system_test_case" + +class SelectComponentSystemTest < ApplicationSystemTestCase + def test_default_select + with_preview("forms/select_component/default") + + within first(".Polaris-Select") do + # Default option + assert_selector ".Polaris-Select__Content", text: "Yesterday" + + # Select new option + within "select#date_range", visible: false do + find("option[value='today']").click + end + assert_selector ".Polaris-Select__Content", text: "Today" + end + end +end