Weak signal counts as no signal

With a signal so weak requests hang, the phone still says it's online, so
nothing fell back: Log Flight waited minutes with no feedback, and pages
never reached the offline page.

- Log Flight and Report Squawk say "Sending…" and, after 10 seconds
  without an answer (60 with photos), keep the entry on the device as
  with no signal. When the top bar is already red they keep it right
  away. If it got through after all, the copy sent later is dropped
  (same client_key).
- What's kept on the device isn't sent while the top bar is red, gives
  up after 15 seconds, and goes again as soon as the server answers.
- Every page of the app falls back to its kept copy or the offline page:
  after 10 seconds, then 3 while requests keep failing, and at once right
  after a failure. Downloads made while you wait (.sam.zip, records
  package, PDFs) have no time limit.

Checked on an Android 14 emulator with a connection that accepts
requests and never answers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-15 13:34:13 -05:00
1 parent d9de1be562
commit e4bc3a5b7b
8 files changed
+134 -24

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
require "test_helper"
# A signal so weak requests hang counts as none: pages fall back to the
# offline page within a time limit, and the Log Flight / Report Squawk forms
# are kept on the device instead of waiting.
class WeakSignalTest < ActionDispatch::IntegrationTest
setup do
@owner = create_user("owner@example.com")
@a = create_aircraft(owner: @owner)
end
test "the service worker gives up on pages after a time limit and sends every page to the offline page" do
get pwa_service_worker_path(format: :js)
js = response.body
assert_match(/const NETWORK_TIMEOUT = 10 \* 1000/, js)
assert_match(/const wait = since < STILL_OFFLINE \? OFFLINE_TIMEOUT : NETWORK_TIMEOUT/, js) # quick while offline
assert_match(/\} else if \(wantsHtml\) \{\s*\/\/[^\n]*\n\s*event\.respondWith\(page\(request\)\)/, js)
assert_match "if (request.mode !== \"navigate\") throw error\n return offlinePage()", js
# downloads built while you wait get no time limit
downloads = Regexp.new(js[%r{const DOWNLOADS = /(.+)/$}, 1])
%w[/aircraft/1/export /aircraft/1/records /aircraft/1/logbook/print.pdf].each { |path| assert_match downloads, path }
%w[/aircraft/1 /aircraft/1/flight_logs/new /aircraft/1/documents/2].each { |path| assert_no_match downloads, path }
end
test "the flight and squawk forms limit the wait and say they're sending" do
sign_in @owner
get new_aircraft_flight_log_path(@a)
assert_select "form[data-controller~=offline-form][data-action*='turbo:before-fetch-request->offline-form#limit']"
assert_select "input[type=submit][data-turbo-submits-with='Sending…']", 2
get new_aircraft_squawk_path(@a)
assert_select "form[data-controller~=offline-form][data-action*='turbo:before-fetch-request->offline-form#limit']"
assert_select "input[type=submit][data-turbo-submits-with='Sending…']", 1
end
end