Files
openclaw/apps/ios/Tests/GatewayProblemPrimaryActionTests.swift
Lokimorty 4f933ccf7b fix(ios): gateway error shows twice on the Settings Gateway page (#98856)
* fix(ios): show gateway errors once as a swipeable animated toast

Gateway connection errors on the Settings > Gateway page appeared twice:
as the app-wide toast and again as an embedded banner section. Remove the
embedded banner (and its now-dead sheet/action helpers) so problems surface
only via the root toast, animate the toast in smoothly from the top, and
support swipe-up to dismiss with re-arm on new problems.

* fix(ios): re-surface gateway toast on repeated problem reports

A swiped-away toast stayed hidden when a retry failed with an identical
problem, because value equality alone produces no observable change. The
model now counts every problem report; a report while hidden re-shows the
toast, and a report while visible shakes it instead of stacking a new one.

* fix(ios): keep reset-onboarding action on the gateway toast and sync i18n inventory

The root toast is now the only gateway problem surface outside covers, so it
must keep the reset-onboarding primary action the removed settings banner had:
auth-token-mismatch problems now show Reset onboarding and run the full
GatewayOnboardingReset flow. Also refreshes the native i18n inventory for the
changed Swift strings.

* fix(ios): preserve gateway problem recovery state

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-02 04:50:12 -07:00

55 lines
1.8 KiB
Swift

import Foundation
import OpenClawKit
import Testing
@testable import OpenClaw
struct GatewayProblemPrimaryActionTests {
@Test func `protocol mismatch uses update action instead of retry`() {
let problem = GatewayConnectionProblem(
kind: .protocolMismatch,
owner: .iphone,
title: "App update required",
message: "This app is older than the gateway.",
actionLabel: "Update app",
retryable: false,
pauseReconnect: true)
let title = GatewayProblemPrimaryAction.title(for: problem, retryTitle: "Retry connection")
#expect(title == "Update app")
}
@Test func `reset-suggesting problem uses reset title when provided`() {
let problem = GatewayConnectionProblem(
kind: .gatewayAuthTokenMismatch,
owner: .iphone,
title: "Stored gateway token rejected",
message: "Reset onboarding to pair again.",
retryable: false,
pauseReconnect: true)
let title = GatewayProblemPrimaryAction.title(
for: problem,
retryTitle: "Retry",
resetTitle: "Reset onboarding",
nonRetryableTitle: "Open Settings")
#expect(title == "Reset onboarding")
}
@Test func `retryable problem uses mapped action label`() {
let problem = GatewayConnectionProblem(
kind: .timeout,
owner: .network,
title: "Connection timed out",
message: "Check the gateway network path.",
actionLabel: "Try again",
retryable: true,
pauseReconnect: false)
let title = GatewayProblemPrimaryAction.title(for: problem, retryTitle: "Retry connection")
#expect(title == "Try again")
}
}