2023-06-22 10:09:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe "Network Disconnected", type: :system do
|
|
|
|
def with_network_disconnected
|
2023-07-04 01:22:58 -04:00
|
|
|
begin
|
|
|
|
page.driver.browser.network_conditions = { offline: true }
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
page.driver.browser.network_conditions = { offline: false }
|
|
|
|
end
|
2023-06-22 10:09:28 -04:00
|
|
|
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
|