ReviewOS

also looking at this

craft-native/craft

Bind the iOS fallback reset assertion to the recovery function

#322
Merged glennmichael123 wants to merge fix/ios-fallback-reset-assertion into main
1 file +15 -2
packages/ios/src/index.test.tsmodified+15-2
Changes to packages/ios/src/index.test.ts
@@ -337,9 +337,22 @@ describe('Craft iOS builder', () => {
337337 expect(failures).not.toContain('loadBundledFallback(in: webView)')
338338 expect(swift).toContain('guard CraftLoadFailure.isUnreachable(error) else { return }')
339339
340 // No longer one-way: two ways back to the remote origin.
340 // No longer one-way: two ways back to the remote origin. Bound the reset
341 // to the named recovery function, because `private var
342 // loadedBundledFallback = false` declares the field with the same text —
343 // an unbounded assertion passes on the declaration alone, and passed
344 // before this recovery existed at all.
341345 expect(swift).toContain('private func returnFromBundledFallback(because reason: String)')
342 expect(swift).toContain('loadedBundledFallback = false')
346 const recovery = swift.slice(
347 swift.indexOf('private func returnFromBundledFallback(because reason: String)'),
348 swift.indexOf('@objc private func appWillEnterForeground('),
349 )
350 // A renamed boundary must fail here rather than widen the slice back to
351 // the whole file and quietly restore the hole this replaces.
352 expect(recovery.length).toBeGreaterThan(0)
353 expect(recovery.length).toBeLessThan(swift.length / 2)
354 expect(recovery).toContain('loadedBundledFallback = false')
355 expect(recovery).toContain('webView.load(URLRequest(url: remote))')
343356 expect(swift).toContain('name: UIApplication.willEnterForegroundNotification')
344357
345358 // And the network trigger retries on a transition only. Retrying whenever