From 2b3a572987236a8eb67dad55d860d559357c528a Mon Sep 17 00:00:00 2001
From: Alan Guo Xiang Tan <gxtan1990@gmail.com>
Date: Fri, 29 Dec 2023 14:39:37 +0800
Subject: [PATCH] DEV: Attempt to fix flaky test by using `click_button`
 instead of `click` (#25070)

Why this change?

Some of the tests in `spec/system/table_builder_spec.rb` are flaky when
we are asserting that clicking the cancel button will close the modal.
This change attempts to fix it by using the `click_button` method
instead of `find` then `click` which is more reliable.
---
 spec/system/page_objects/modals/insert_table.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/spec/system/page_objects/modals/insert_table.rb b/spec/system/page_objects/modals/insert_table.rb
index 9e12d462d22..1badcd1dc09 100644
--- a/spec/system/page_objects/modals/insert_table.rb
+++ b/spec/system/page_objects/modals/insert_table.rb
@@ -11,7 +11,7 @@ module PageObjects
       end
 
       def cancel
-        find("#{MODAL_SELECTOR} .d-modal-cancel").click
+        click_button(I18n.t("js.cancel"))
       end
 
       def click_edit_reason