mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
- The top bar (and the phone's status bar) turns red when the server can't be reached: the device is offline, or a request failed (signal but no internet, or the proxy answering for the app). While red it checks /up every 15 seconds and turns back on its own. - A ring fills while pages are saved for offline use or flights and squawks logged offline are sent, with the percentage in its middle, and hides when done. While some wait to send, it's amber with how many. Checked on an Android 14 emulator: airplane mode on and off, saving for offline, and a flight logged offline then sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.3 KiB
Ruby
32 lines
1.3 KiB
Ruby
require "test_helper"
|
|
|
|
# The top bar turns red when the server can't be reached and has a ring for
|
|
# saving for offline / sending (connection_controller.js); here, its markup,
|
|
# styles and strings.
|
|
class ConnectionStatusTest < ActionDispatch::IntegrationTest
|
|
test "the top bar carries the connection status, hidden ring and announcer" do
|
|
sign_in create_user
|
|
get root_path
|
|
assert_select "header[data-controller=connection]" do
|
|
assert_select ".sync-ring[hidden][role=img][data-connection-target=ring] [data-connection-target=label]"
|
|
assert_select "[role=status][data-connection-target=announce]"
|
|
end
|
|
strings = JSON.parse(css_select("script#i18n").first.text)
|
|
assert_equal %w[back_online offline saving sending waiting], strings["connection"].keys.sort
|
|
assert_match "%{percent}", strings["connection"]["saving"]
|
|
end
|
|
|
|
test "signed out pages have it too, for the sign-in page offline" do
|
|
create_user
|
|
get new_session_path
|
|
assert_response :success
|
|
assert_select "header[data-controller=connection] .sync-ring[hidden]"
|
|
end
|
|
|
|
test "the red top bar and the ring are styled" do
|
|
css = Rails.root.join("app/assets/tailwind/application.css").read
|
|
assert_match(/header\.is-offline \{ --color-header: var\(--color-header-offline\); \}/, css)
|
|
assert_match "conic-gradient", css
|
|
end
|
|
end
|