diff --git a/.gitignore b/.gitignore index 6cbbd99..5e2f246 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,12 @@ capybara-*.html .rspec /log /tmp +/test/dummy/log +/test/dummy/tmp /db/*.sqlite3 /db/*.sqlite3-journal +/test/dummy/db/*.sqlite3 +/test/dummy/db/*.sqlite3-journal /public/system /coverage/ /spec/tmp diff --git a/app/views/application/_abraham.html.erb b/app/views/application/_abraham.html.erb index 9b34c20..dea6365 100644 --- a/app/views/application/_abraham.html.erb +++ b/app/views/application/_abraham.html.erb @@ -32,6 +32,10 @@ text: "<%= step['text'] %>", <% if step.key?('attachTo') %> attachTo: { element: "<%= step['attachTo']['element'] %>", on: "<%= step['attachTo']['placement'] %>" }, + showOn: function() { + // Only display this step if its selector is present + return document.querySelector("<%= step['attachTo']['element'] %>") ? true : false + }, <% end %> buttons: [ <% if index == 0 %> diff --git a/lib/abraham/version.rb b/lib/abraham/version.rb index c05f56d..a5c6429 100644 --- a/lib/abraham/version.rb +++ b/lib/abraham/version.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true module Abraham - VERSION = '1.1.1' + VERSION = '1.2' end diff --git a/test/dummy/config/tours/dashboard/home.en.yml b/test/dummy/config/tours/dashboard/home.en.yml index 34c8cfc..0de045a 100644 --- a/test/dummy/config/tours/dashboard/home.en.yml +++ b/test/dummy/config/tours/dashboard/home.en.yml @@ -6,6 +6,12 @@ intro: title: "ENGLISH This step has a title" text: "ENGLISH This intermediate step has some text" 3: + title: "ENGLISH A missing step" + text: "ENGLISH Refers to an element that won't exist on the page, should skip to 4" + attachTo: + element: "#i-dont-exist" + position: "right" + 4: title: "ENGLISH The final step" text: "ENGLISH Some text here too, and it's attached to the right" attachTo: diff --git a/test/dummy/config/tours/dashboard/home.es.yml b/test/dummy/config/tours/dashboard/home.es.yml index ff645c0..7077862 100644 --- a/test/dummy/config/tours/dashboard/home.es.yml +++ b/test/dummy/config/tours/dashboard/home.es.yml @@ -6,6 +6,12 @@ intro: title: "SPANISH This step has a title" text: "This intermediate step has some text" 3: + title: "SPANISH A missing step" + text: "Refers to an element that won't exist on the page, should skip to 4" + attachTo: + element: "#i-dont-exist" + position: "right" + 4: title: "SPANISH The final step" text: "Some text here too, and it's attached to the right" attachTo: diff --git a/test/dummy/db/development.sqlite3 b/test/dummy/db/development.sqlite3 deleted file mode 100644 index 2b24f4f..0000000 Binary files a/test/dummy/db/development.sqlite3 and /dev/null differ diff --git a/test/dummy/db/test.sqlite3 b/test/dummy/db/test.sqlite3 deleted file mode 100644 index 2b032ab..0000000 Binary files a/test/dummy/db/test.sqlite3 and /dev/null differ diff --git a/test/dummy/test/controllers/dashboard_controller_test.rb b/test/dummy/test/controllers/dashboard_controller_test.rb index 183c6e5..c684713 100644 --- a/test/dummy/test/controllers/dashboard_controller_test.rb +++ b/test/dummy/test/controllers/dashboard_controller_test.rb @@ -31,6 +31,9 @@ class DashboardControllerTest < ActionDispatch::IntegrationTest assert element.text.include? 'step-1' assert element.text.include? 'step-2' assert element.text.include? 'step-3' + assert element.text.include? 'step-4' + # Generates a showOn option + assert element.text.include? 'showOn:' # it will post the right completion information assert element.text.include? "controller_name: 'dashboard'" assert element.text.include? "action_name: 'home'"