From 52abffd4ea3d1bfb034e67d92b2c0948e95007d8 Mon Sep 17 00:00:00 2001 From: Andy Zhao <17884966+Zhao-Andy@users.noreply.github.com> Date: Fri, 29 Jan 2021 15:42:08 -0500 Subject: [PATCH] Verify link is available and wait for JS before testing (#12492) * Remove unused variables * Use find to ensure JS updates link and then test --- spec/system/articles/user_visits_an_article_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/system/articles/user_visits_an_article_spec.rb b/spec/system/articles/user_visits_an_article_spec.rb index 4fe821a81..c13f94657 100644 --- a/spec/system/articles/user_visits_an_article_spec.rb +++ b/spec/system/articles/user_visits_an_article_spec.rb @@ -142,8 +142,6 @@ RSpec.describe "Views an article", type: :system do describe "when an article is not published" do let(:article) { create(:article, user: article_user, published: false) } let(:article_path) { article.path + query_params } - let(:href) { "#{article.path}/edit" } - let(:link_text) { "Click to edit" } context "with the article password, and the logged-in user is authorized to update the article" do let(:query_params) { "?preview=#{article.password}" } @@ -151,7 +149,8 @@ RSpec.describe "Views an article", type: :system do it "shows the article edit link", js: true do visit article_path - expect(page.body).to include('display: inline-block;">Click to edit') + edit_link = find("a#author-click-to-edit") + expect(edit_link.matches_style?(display: "inline-block")).to be true end end