From 51e8fc0ef22d28a9117c541fe912ee4a579f6be0 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 3 Feb 2016 15:21:59 +0100 Subject: [PATCH] So only show dashboard clues if dashboard is visible. --- .../app/controllers/dashboard.coffee | 13 ++++-- test/browser_test_helper.rb | 44 ++++++++++++++----- test/integration/auto_wizard_test.rb | 2 + 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/app/controllers/dashboard.coffee b/app/assets/javascripts/app/controllers/dashboard.coffee index aaa241397..701519dec 100644 --- a/app/assets/javascripts/app/controllers/dashboard.coffee +++ b/app/assets/javascripts/app/controllers/dashboard.coffee @@ -18,10 +18,7 @@ class App.Dashboard extends App.Controller return if !@authenticate(true) @render() - # start intro - preferences = @Session.get('preferences') - if !preferences['intro'] - @clues() + @mayBeClues() render: -> @@ -39,6 +36,12 @@ class App.Dashboard extends App.Controller limit: 25 ) + mayBeClues: => + preferences = @Session.get('preferences') + return if preferences['intro'] + return if !@el.is(':visible') + @clues() + clues: (e) => if e e.preventDefault() @@ -56,6 +59,8 @@ class App.Dashboard extends App.Controller active: (state) => @activeState = state + if state + @mayBeClues() isActive: => @activeState diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 5393362b3..63a03fd34 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -157,11 +157,10 @@ class TestCase < Test::Unit::TestCase end assert(true, 'auto wizard login ok') - # remove clues - clues = instance.find_elements({ css: '.js-modal--clue .js-close' })[0] - if clues - clues.click - end + clues_close( + browser: instance, + optional: true, + ) return end @@ -190,11 +189,10 @@ class TestCase < Test::Unit::TestCase fail 'login failed' end - # remove clues - clues = instance.find_elements({ css: '.js-modal--clue .js-close' })[0] - if clues - clues.click - end + clues_close( + browser: instance, + optional: true, + ) screenshot(browser: instance, comment: 'login_ok') assert(true, 'login ok') @@ -231,6 +229,32 @@ class TestCase < Test::Unit::TestCase fail 'no login box found, seems logout was not successfully!' end +=begin + + clues_close( + browser: browser1, + optional: false, + ) + +=end + + def clues_close(params) + switch_window_focus(params) + log('clues_close', params) + + instance = params[:browser] || @browser + + clues = instance.find_elements({ css: '.js-modal--clue .js-close' })[0] + if !params[:optional] && !clues + screenshot(browser: instance, comment: 'no_clues') + fail 'Unable to closes clues, no clues found!' + end + return if !clues + instance.execute_script("$('.js-modal--clue .js-close').click()") + assert(true, 'clues closed') + sleep 4 + end + =begin location( diff --git a/test/integration/auto_wizard_test.rb b/test/integration/auto_wizard_test.rb index bd37864ac..9ccf5d9a2 100644 --- a/test/integration/auto_wizard_test.rb +++ b/test/integration/auto_wizard_test.rb @@ -29,6 +29,8 @@ class AutoWizardTest < TestCase timeout: 20, ) + clues_close + organization_open_by_search( value: 'Demo Organization', )