DEV: Temporary fix for flaky system test (#24598)

Why this change?

Asserting against records of the database in system tests can be flaky
because those assertions can run against the database before the server
has actually saved the necessary changes to the database.

What does this change do?

While the assertion is not ideal, we are working around this as a
temporary fix by using `try_until_success` which will retry the
assertion up till the default capybara timeout.
This commit is contained in:
Alan Guo Xiang Tan 2023-11-28 21:00:56 +08:00 committed by GitHub
parent 0cad82ef55
commit 91ec3323dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -19,10 +19,12 @@ describe "Flagging post", type: :system do
topic_page.click_post_action_button(post_to_flag, :flag) topic_page.click_post_action_button(post_to_flag, :flag)
flag_modal.choose_type(:off_topic) flag_modal.choose_type(:off_topic)
flag_modal.take_action(:agree_and_hide) flag_modal.take_action(:agree_and_hide)
expect( expect(
topic_page.post_by_number(post_to_flag).ancestor(".topic-post.post-hidden"), topic_page.post_by_number(post_to_flag).ancestor(".topic-post.post-hidden"),
).to be_present ).to be_present
expect(other_flag.reload.agreed_at).to be_present
try_until_success { expect(other_flag.reload.agreed_at).to be_present }
end end
end end
end end