From fcedd37067ec7e5f6b7a1d35d2f68481622fa4b6 Mon Sep 17 00:00:00 2001 From: joshavant <830519+joshavant@users.noreply.github.com> Date: Tue, 23 Jun 2026 14:40:06 -0500 Subject: [PATCH] test(ios): guard local network permission trigger points --- apps/ios/Tests/RootTabsSourceGuardTests.swift | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/apps/ios/Tests/RootTabsSourceGuardTests.swift b/apps/ios/Tests/RootTabsSourceGuardTests.swift index f4adb6fd28ed..c12d072b3c10 100644 --- a/apps/ios/Tests/RootTabsSourceGuardTests.swift +++ b/apps/ios/Tests/RootTabsSourceGuardTests.swift @@ -594,6 +594,7 @@ struct RootTabsSourceGuardTests { #expect(actionsSource.contains("self.gatewayController.refreshActiveGatewayRegistrationFromSettings()")) #expect(actionsSource.contains("self.gatewayController.restartDiscovery()")) #expect(actionsSource.contains("await self.appModel.refreshGatewayOverviewIfConnected()")) + #expect(actionsSource.contains("self.gatewayController.requestLocalNetworkAccess(reason: \"settings_preflight\")")) #expect(actionsSource.contains("await TCPProbe.probe(host: trimmed, port: port")) #expect(actionsSource.contains("Check Tailscale or LAN.")) #expect(actionsSource.contains("Tailscale is off on this device. Turn it on, then try again.")) @@ -610,6 +611,32 @@ struct RootTabsSourceGuardTests { #expect(controllerSource.contains("trustRotatedGatewayCertificate(from problem: GatewayConnectionProblem)")) } + @Test func `local network access is requested from visible gateway flows`() throws { + let appSource = try String(contentsOf: Self.openClawAppSourceURL(), encoding: .utf8) + let rootSource = try String(contentsOf: Self.rootTabsSourceURL(), encoding: .utf8) + let onboardingSource = try String(contentsOf: Self.onboardingWizardSourceURL(), encoding: .utf8) + let actionsSource = try String(contentsOf: Self.settingsProTabActionsSourceURL(), encoding: .utf8) + let controllerSource = try String(contentsOf: Self.gatewayConnectionControllerSourceURL(), encoding: .utf8) + + #expect(appSource.contains("deferDiscoveryUntilLocalNetworkRequest: true")) + #expect(controllerSource.contains("func requestLocalNetworkAccess(reason: String)")) + #expect(controllerSource.contains("guard self.localNetworkAccessRequested else")) + #expect(controllerSource.contains("self.requestLocalNetworkAccess(reason: \"connect_manual\")")) + #expect(controllerSource.contains("self.requestLocalNetworkAccess(reason: \"connect_discovered_gateway\")")) + #expect(controllerSource.contains("self.requestLocalNetworkAccess(reason: \"connect_last_known\")")) + + #expect(rootSource.contains("self.maybeRequestLocalNetworkAccess(reason: \"root_appear\")")) + #expect(rootSource.contains("self.maybeRequestLocalNetworkAccess(reason: \"scene_active\")")) + #expect(rootSource.contains("self.maybeRequestLocalNetworkAccess(reason: \"onboarding_dismissed\")")) + #expect(rootSource.contains("self.requestLocalNetworkAccess(reason: \"gateway_setup_deeplink\")")) + #expect(rootSource.contains("guard self.didEvaluateOnboarding else { return }")) + #expect(rootSource.contains("onRequestLocalNetworkAccess: { reason in")) + + #expect(onboardingSource.contains("self.requestLocalNetworkAccess(reason: \"onboarding_continue\")")) + #expect(onboardingSource.contains("self.requestLocalNetworkAccessIfPastIntro(reason: \"onboarding_appear\")")) + #expect(actionsSource.contains("self.gatewayController.requestLocalNetworkAccess(reason: \"settings_preflight\")")) + } + @Test func `gateway settings preview matrix covers primary states`() throws { let supportSource = try String(contentsOf: Self.settingsProTabSupportSourceURL(), encoding: .utf8) @@ -800,6 +827,13 @@ struct RootTabsSourceGuardTests { .appendingPathComponent("Sources/Design/SettingsProTab.swift") } + private static func onboardingWizardSourceURL() -> URL { + URL(fileURLWithPath: #filePath) + .deletingLastPathComponent() + .deletingLastPathComponent() + .appendingPathComponent("Sources/Onboarding/OnboardingWizardView.swift") + } + private static func openClawAppSourceURL() -> URL { URL(fileURLWithPath: #filePath) .deletingLastPathComponent()