Files
openclaw/apps/ios/Tests/GatewayStatusBuilderTests.swift
Peter Steinberger f95ca90378 fix(ios): persist voice notes through offline delivery (#101236)
* fix(ios): persist voice note delivery state

* fix(ios): pin chats during attachment staging

* fix(ios): keep voice notes on captured chat

* fix(ios): keep voice notes durable through staging

* fix(ios): harden voice note lifecycle

* test(ios): satisfy strict concurrency in voice note proof

* fix(ios): keep legacy attachment sends live

* fix(ios): retain legacy drafts during outbox restore

* fix(ios): pin voice note recipient presentation

* fix(ios): preserve confirmed voice note duration

* chore(i18n): refresh voice note source inventory

* chore: leave release notes to release automation
2026-07-07 01:21:16 +01:00

76 lines
3.2 KiB
Swift

import OpenClawKit
import Testing
@testable import OpenClaw
struct GatewayStatusBuilderTests {
@Test func `paused problem keeps error status`() {
let state = GatewayStatusBuilder.build(
gatewayServerName: nil,
lastGatewayProblem: GatewayConnectionProblem(
kind: .pairingRequired,
owner: .gateway,
title: "Pairing required",
message: "Approve this device before reconnecting.",
requestId: "req-123",
retryable: false,
pauseReconnect: true),
gatewayStatusText: "Reconnecting…")
#expect(state == .error)
}
@Test func `transient problem allows connecting status`() {
let state = GatewayStatusBuilder.build(
gatewayServerName: nil,
lastGatewayProblem: GatewayConnectionProblem(
kind: .timeout,
owner: .network,
title: "Connection timed out",
message: "The gateway did not respond before the connection timed out.",
retryable: true,
pauseReconnect: false),
gatewayStatusText: "Reconnecting…")
#expect(state == .connecting)
}
@Test func `chat gateway pill labels match display state`() {
#expect(ChatProTab.gatewayPillTitle(state: .disconnected, isGatewayUsable: false) == "Offline")
#expect(ChatProTab.gatewayPillTitle(state: .connecting, isGatewayUsable: false) == "Connecting")
#expect(ChatProTab.gatewayPillTitle(state: .error, isGatewayUsable: false) == "Attention")
#expect(ChatProTab.gatewayPillTitle(state: .connected, isGatewayUsable: true) == "Connected")
#expect(ChatProTab.gatewayPillTitle(state: .connected, isGatewayUsable: false) == "Unavailable")
}
@Test func `chat agent badge rejects placeholder question mark`() {
#expect(ChatProTab.normalizedBadgeEmoji(" 🦞 ") == "🦞")
#expect(ChatProTab.normalizedBadgeEmoji("?") == nil)
#expect(ChatProTab.normalizedBadgeEmoji(" ") == nil)
#expect(ChatProTab.normalizedBadgeEmoji(nil) == nil)
#expect(ChatProTab.initialsBadge(for: "Agent Smith") == "AS")
}
@Test func `pinned attachment displays its captured gateway owner`() {
#expect(ChatProTab.presentationGatewayState(
current: .connected,
isAttachmentOwnerPinned: true,
capturedOwnerID: "gateway-a",
currentOwnerID: "gateway-b") == .disconnected)
#expect(ChatProTab.presentationGatewayState(
current: .connected,
isAttachmentOwnerPinned: true,
capturedOwnerID: "gateway-a",
currentOwnerID: "gateway-a") == .connected)
#expect(ChatProTab.presentationGatewayState(
current: .connected,
isAttachmentOwnerPinned: false,
capturedOwnerID: "gateway-a",
currentOwnerID: "gateway-b") == .connected)
}
@Test func `chat starter prompts stay stable and actionable`() {
#expect(ChatProTab.emptyAssistantPrompts.map(\.id) == ["summarize-status", "show-controls", "start-voice"])
#expect(ChatProTab.emptyAssistantPrompts.allSatisfy { !$0.title.isEmpty && !$0.prompt.isEmpty })
}
}