diff --git a/spec/system/comment_anchoring_spec.rb b/spec/system/comment_anchoring_spec.rb index 706c53f..c7b4f47 100644 --- a/spec/system/comment_anchoring_spec.rb +++ b/spec/system/comment_anchoring_spec.rb @@ -34,6 +34,7 @@ visit sign_in_path fill_in "Email address", with: user.email click_button "Sign In" + expect(page).to have_current_path(root_path) expect(page).to have_content("Sign out") end diff --git a/spec/system/comment_ux_spec.rb b/spec/system/comment_ux_spec.rb index fff1cd5..aa492e3 100644 --- a/spec/system/comment_ux_spec.rb +++ b/spec/system/comment_ux_spec.rb @@ -34,6 +34,11 @@ def sign_in(user) visit sign_in_path fill_in "Email address", with: user.email click_button "Sign In" + # Wait for the Turbo-driven redirect to the plans index to complete before + # asserting page content; without this, Selenium can reference a stale DOM + # node from the sign-in page mid-navigation, causing "Node with given id + # does not belong to the document". + expect(page).to have_current_path(root_path) expect(page).to have_content("Sign out") end diff --git a/spec/system/tokens_spec.rb b/spec/system/tokens_spec.rb index 7104ede..45e686c 100644 --- a/spec/system/tokens_spec.rb +++ b/spec/system/tokens_spec.rb @@ -5,6 +5,7 @@ visit sign_in_path fill_in "Email address", with: "testuser@example.com" click_button "Sign In" + expect(page).to have_current_path(root_path) expect(page).to have_content("Sign out") end