Skip to content

A platform for community discussion. Free, open, simple.

DEV: Ensure browser network conditions is reset in system tests (#22404)

Alan Guo Xiang Tan454a4af0bf30
diff --git a/plugins/chat/spec/system/chat_composer_spec.rb b/plugins/chat/spec/system/chat_composer_spec.rb
index 59ff02a802b..d0eb36235e1 100644
--- a/plugins/chat/spec/system/chat_composer_spec.rb
+++ b/plugins/chat/spec/system/chat_composer_spec.rb
@@ -142,7 +142,7 @@ RSpec.describe "Chat composer", type: :system do
expect(page).to have_css(".chat-composer-upload--in-progress")
expect(page).to have_css(".chat-composer.is-send-disabled")
-
+ ensure
page.driver.browser.network_conditions = { latency: 0 }
end
end
diff --git a/spec/system/network_disconnected_spec.rb b/spec/system/network_disconnected_spec.rb
index 08a14b5c46c..288babbcbd0 100644
--- a/spec/system/network_disconnected_spec.rb
+++ b/spec/system/network_disconnected_spec.rb
@@ -2,9 +2,12 @@
RSpec.describe "Network Disconnected", type: :system do
def with_network_disconnected
- page.driver.browser.network_conditions = { offline: true }
- yield
- page.driver.browser.network_conditions = { offline: false }
+ begin
+ page.driver.browser.network_conditions = { offline: true }
+ yield
+ ensure
+ page.driver.browser.network_conditions = { offline: false }
+ end
end
it "NetworkConnectivity service adds class to DOM and displays offline indicator" do