mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Use online/offline window events to track network connectivity (#22243)
This commit is contained in:
committed by
GitHub
parent
dccdbd52a3
commit
fcaa9757f3
26
spec/system/network_disconnected_spec.rb
Normal file
26
spec/system/network_disconnected_spec.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
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 }
|
||||
end
|
||||
|
||||
it "NetworkConnectivity service adds class to DOM and displays offline indicator" do
|
||||
SiteSetting.enable_offline_indicator = true
|
||||
|
||||
visit("/c")
|
||||
|
||||
expect(page).to have_no_css("html.network-disconnected")
|
||||
expect(page).to have_no_css(".offline-indicator")
|
||||
|
||||
with_network_disconnected do
|
||||
# Message bus connectivity services adds the disconnected class to the DOM
|
||||
expect(page).to have_css("html.network-disconnected")
|
||||
|
||||
# Offline indicator is rendered
|
||||
expect(page).to have_css(".offline-indicator")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user