mirror of
https://github.com/discourse/discourse.git
synced 2025-07-13 09:21:27 +08:00

Introduces the viewport_based_mobile_mode experimental site setting. When enabled, user-agent-based mobile/desktop detection will be replaced with viewport-width logic. 'mobile mode' is enabled for any viewport less than our 'sm' breakpoint (40rem, or 640px at default font size). When this mode is enabled, mobile/desktop toggle buttons are hidden, since they are non-functional. Tests are also updated to use a consistent method for force-enabling the legacy mobile mode. All state is now stored in `lib/mobile`, and the `Site` model references that via a getter.
24 lines
818 B
Ruby
24 lines
818 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "Viewport-based mobile mode", type: :system do
|
|
before { SiteSetting.viewport_based_mobile_mode = true }
|
|
|
|
it "has both stylesheets, and updates classes at runtime" do
|
|
visit "/"
|
|
|
|
mobile_stylesheet = find("link[rel=stylesheet][href*='stylesheets/mobile']", visible: false)
|
|
desktop_stylesheet = find("link[rel=stylesheet][href*='stylesheets/desktop']", visible: false)
|
|
|
|
expect(mobile_stylesheet["media"]).to include("max-width")
|
|
expect(desktop_stylesheet["media"]).to include("min-width")
|
|
|
|
expect(page).to have_css("html.desktop-view")
|
|
expect(page).not_to have_css("html.mobile-view")
|
|
|
|
resize_window(width: 400) do
|
|
expect(page).to have_css("html.mobile-view")
|
|
expect(page).not_to have_css("html.desktop-view")
|
|
end
|
|
end
|
|
end
|