From 5db2cdeca470b1d8fd526b45c93bf15f2e287ec0 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Wed, 24 Mar 2021 18:47:16 +0530 Subject: [PATCH] fixing test driver related errors in notification_highlighter_spec --- .../features/notification_highlighter_spec.rb | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/web/spec/features/notification_highlighter_spec.rb b/web/spec/features/notification_highlighter_spec.rb index 5f11beaf4..9da87c8dd 100644 --- a/web/spec/features/notification_highlighter_spec.rb +++ b/web/spec/features/notification_highlighter_spec.rb @@ -11,15 +11,17 @@ describe "Notification Highlighter", :js => true, :type => :feature, :capybara_f shared_examples_for :notification_badge do |options| it "in correct state" do - sign_in_poltergeist(user) unless page.has_selector?('h2', 'musicians') - badge = find("#{NOTIFICATION_PANEL} .badge", text:options[:count]) - badge['class'].include?('highlighted').should == options[:highlighted] + save_screenshot("notification_highlighter.png") + #sign_in_poltergeist(user) unless page.has_selector?('h2', 'musicians') + sign_in_poltergeist(user) unless page.has_selector?('h2', text: 'musicians') + badge = find("#{NOTIFICATION_PANEL} .badge", text: options[:count], visible: :all) + badge['class'].include?('highlighted').should == options[:highlighted] - if options[:action] == :click - badge.trigger(:click) - badge = find("#{NOTIFICATION_PANEL} .badge", text:0) - badge['class'].include?('highlighted').should == false - end + if options[:action] == :click + badge.click + badge = find("#{NOTIFICATION_PANEL} .badge", text:0, visible: :all) + badge['class'].include?('highlighted').should == false + end end end @@ -36,6 +38,7 @@ describe "Notification Highlighter", :js => true, :type => :feature, :capybara_f user.reload end + it_behaves_like :notification_badge, highlighted: false, count:0 describe "sees notification" do @@ -53,13 +56,13 @@ describe "Notification Highlighter", :js => true, :type => :feature, :capybara_f notification = Notification.send_text_message("text message", user2, user) notification.errors.any?.should be false end - + it_behaves_like :notification_badge, highlighted: true, count:1, action: :click end end - describe "and realtime notifications with sidebar open" do + describe "and realtime notifications with sidebar open" do before(:each) do # generate one message so that count = 1 to start notification = Notification.send_text_message("text message", user2, user) @@ -101,7 +104,7 @@ describe "Notification Highlighter", :js => true, :type => :feature, :capybara_f end end end - end + end end describe "user with new notifications" do @@ -154,7 +157,7 @@ describe "Notification Highlighter", :js => true, :type => :feature, :capybara_f in_client(user2) do sign_in_poltergeist(user2) find_musician(user) - find(".result-list-button-wrapper[data-musician-id='#{user.id}'] .search-m-friend").trigger(:click) + find(".result-list-button-wrapper[data-musician-id='#{user.id}'] .search-m-friend").click end in_client(user) do