mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 09:08:10 +08:00
DEV: Speed up core system tests (#21394)
What is the problem? We are relying on RSpec custom matchers in system tests by defining predicates in page objects. The problem is that this can result in a system test unnecessarily waiting up till the full duration of Capybara's default wait time when the RSpec custom matcher is used with `not_to`. Considering this topic page object where we have a `has_post?` predicate defined. ``` class Topic < PageObject def has_post? has_css?('something') end end ``` The assertion `expect(Topic.new).not_to have_post` will end up waiting the full Capybara's default wait time since the RSpec custom matcher is calling Capybara's `has_css?` method which will wait until the selector appear. If the selector has already disappeared by the time the assertion is called, we end up waiting for something that will never exists. This commit fixes such cases by introducing new predicates that uses the `has_no_*` versions of Capybara's node matchers. For future reference, `to have_css` and `not_to have_css` is safe to sue because the RSpec matcher defined by Capbyara is smart enough to call `has_css?` or `has_no_css?` based on the expectation of the assertion.
This commit is contained in:

committed by
GitHub

parent
f705e6d367
commit
e323628d8a
@ -91,7 +91,7 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||
expect(sidebar).to have_section("Edited section")
|
||||
expect(sidebar).to have_section_link("Edited Tag")
|
||||
|
||||
expect(sidebar).not_to have_section_link("Sidebar Categories")
|
||||
expect(sidebar).to have_no_section_link("Sidebar Categories")
|
||||
end
|
||||
|
||||
it "allows the user to reorder links in custom section" do
|
||||
@ -161,7 +161,7 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||
section_modal.delete
|
||||
section_modal.confirm_delete
|
||||
|
||||
expect(sidebar).not_to have_section("My section")
|
||||
expect(sidebar).to have_no_section("My section")
|
||||
end
|
||||
|
||||
it "allows admin to create, edit and delete public section" do
|
||||
@ -188,7 +188,7 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||
section_modal.delete
|
||||
section_modal.confirm_delete
|
||||
|
||||
expect(sidebar).not_to have_section("Edited public section")
|
||||
expect(sidebar).to have_no_section("Edited public section")
|
||||
end
|
||||
|
||||
it "shows anonymous public sections" do
|
||||
|
Reference in New Issue
Block a user