diff --git a/spec/system/comments/legislation_annotations_spec.rb b/spec/system/comments/legislation_annotations_spec.rb index dbbb41294..9d0de369d 100644 --- a/spec/system/comments/legislation_annotations_spec.rb +++ b/spec/system/comments/legislation_annotations_spec.rb @@ -618,6 +618,8 @@ describe "Commenting legislation questions" do create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{ "start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 10 }]) end + let!(:comment1) { annotation1.comments.first } + let!(:comment2) { annotation2.comments.first } before do login_as user @@ -648,15 +650,14 @@ describe "Commenting legislation questions" do first(:link, "0 replies").click end - comment = annotation1.comments.first click_link "Reply" - within "#js-comment-form-comment_#{comment.id}" do + within "#js-comment-form-comment_#{comment1.id}" do fill_in "Leave your comment", with: "replying in single annotation thread" click_button "Publish reply" end - within "#comment_#{comment.id}" do + within "#comment_#{comment1.id}" do expect(page).to have_content "replying in single annotation thread" end @@ -685,17 +686,16 @@ describe "Commenting legislation questions" do find(".icon-expand").click end - comment = annotation2.comments.first - within("#comment_#{comment.id}") do + within("#comment_#{comment2.id}") do click_link "Reply" end - within "#js-comment-form-comment_#{comment.id}" do + within "#js-comment-form-comment_#{comment2.id}" do fill_in "Leave your comment", with: "replying in multiple annotation thread" click_button "Publish reply" end - within "#comment_#{comment.id}" do + within "#comment_#{comment2.id}" do expect(page).to have_content "replying in multiple annotation thread" end diff --git a/spec/system/proposal_notifications_spec.rb b/spec/system/proposal_notifications_spec.rb index 2471198d1..7a9377962 100644 --- a/spec/system/proposal_notifications_spec.rb +++ b/spec/system/proposal_notifications_spec.rb @@ -200,10 +200,11 @@ describe "Proposal Notifications" do find(".icon-notification").click - notification_for_user1 = Notification.find_by(user: user1) expect(page).to have_css ".notification", count: 1 - expect(page).to have_content "There is one new notification on #{proposal.title}" - expect(page).to have_xpath "//a[@href='#{notification_path(notification_for_user1)}']" + + click_link text: "There is one new notification on #{proposal.title}" + + expect(page).to have_current_path(proposal_path(proposal)) logout login_as user2 @@ -211,10 +212,11 @@ describe "Proposal Notifications" do find(".icon-notification").click - notification_for_user2 = Notification.find_by(user: user2) expect(page).to have_css ".notification", count: 1 - expect(page).to have_content "There is one new notification on #{proposal.title}" - expect(page).to have_xpath "//a[@href='#{notification_path(notification_for_user2)}']" + + click_link text: "There is one new notification on #{proposal.title}" + + expect(page).to have_current_path(proposal_path(proposal)) logout login_as user3 @@ -251,10 +253,11 @@ describe "Proposal Notifications" do find(".icon-notification").click - notification_for_user1 = Notification.find_by(user: user1) expect(page).to have_css ".notification", count: 1 - expect(page).to have_content "There is one new notification on #{proposal.title}" - expect(page).to have_xpath "//a[@href='#{notification_path(notification_for_user1)}']" + + click_link text: "There is one new notification on #{proposal.title}" + + expect(page).to have_current_path(proposal_path(proposal)) logout login_as user2.reload @@ -262,10 +265,11 @@ describe "Proposal Notifications" do find(".icon-notification").click - notification_for_user2 = Notification.find_by(user: user2) expect(page).to have_css ".notification", count: 1 - expect(page).to have_content "There is one new notification on #{proposal.title}" - expect(page).to have_xpath "//a[@href='#{notification_path(notification_for_user2)}']" + + click_link text: "There is one new notification on #{proposal.title}" + + expect(page).to have_current_path(proposal_path(proposal)) logout login_as user3.reload @@ -301,10 +305,8 @@ describe "Proposal Notifications" do find(".icon-notification").click - notification_for_user = Notification.find_by(user: user) expect(page).to have_css ".notification", count: 1 expect(page).to have_content "This resource is not available anymore" - expect(page).not_to have_xpath "//a[@href='#{notification_path(notification_for_user)}']" end scenario "Proposal retired by author", :js do