oficina / base Public

Steady two timing-bound tests

5f4c62d was committed with the gate red: ResendTests asserted at a fixed
1.7 s after a 1 s deadline, which a busy machine can miss, and
testSigningInSetsAskUp assumed the refresh, not Ask's own state change,
ran the set-up, which is a race between the two. The resend test now
waits up to six seconds for the button to come back by itself (still
with no typing or redraw), and the sign-in test waits for the set-up's
state read and checks it posted exactly once. Twelve full runs in a row
pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 0ff102157424425c6f23b0486e6f567e0f0855b5 parent 5f4c62d
2 files changed, +10 −6
  • native/apple/Tests/BaseKitTests/SessionTests.swift +6 −4
  • native/apple/Tests/BaseKitTests/StatusPanelTests.swift +4 −2
diff --git a/native/apple/Tests/BaseKitTests/SessionTests.swift b/native/apple/Tests/BaseKitTests/SessionTests.swift
index f805c51..b62a29d 100644
--- a/native/apple/Tests/BaseKitTests/SessionTests.swift
+++ b/native/apple/Tests/BaseKitTests/SessionTests.swift
@@ -88,7 +88,7 @@ extension SessionTests {
extension SessionTests {
/// Task 12: signing in sets Ask up when /ask/state says connect, with
/// an assertion addressed to Equipo, and reads the state again.
- func testSigningInSetsAskUp() async {
+ func testSigningInSetsAskUp() async throws {
let session = BaseSession(oficina: memoryOficina(), defaults: freshDefaults())
var audiences: [URL] = []
session.assertion = { audiences.append($0); return ("a", "v") }
@@ -98,9 +98,11 @@ extension SessionTests {
for path in ["/api/v1/me", "/api/v1/home", "/ask/state", "/api/v1/ask/oficina"] { t.release(path) }
session.begin(identity: "id-alice", origin: URL(string: "https://alice.example")!, transport: t)
await session.refreshing?.value
- XCTAssertEqual(audiences, [URL(string: "https://equipo.alice.example")!])
- XCTAssertTrue(t.calls.contains("/api/v1/ask/oficina"))
- XCTAssertGreaterThanOrEqual(t.calls.filter { $0 == "/ask/state" }.count, 2)
+ // The set-up runs from Ask's state change or the refresh, whichever
+ // comes first: wait for its state read rather than assume which.
+ try await waitUntil { t.calls.filter { $0 == "/ask/state" }.count >= 2 }
+ XCTAssertEqual(audiences, [URL(string: "https://equipo.alice.example")!], "set up once")
+ XCTAssertEqual(t.calls.filter { $0 == "/api/v1/ask/oficina" }.count, 1)
session.end()
}
}
diff --git a/native/apple/Tests/BaseKitTests/StatusPanelTests.swift b/native/apple/Tests/BaseKitTests/StatusPanelTests.swift
index ab9c08e..e891886 100644
--- a/native/apple/Tests/BaseKitTests/StatusPanelTests.swift
+++ b/native/apple/Tests/BaseKitTests/StatusPanelTests.swift
@@ -78,8 +78,10 @@ import XCTest
defer { window.orderOut(nil) }
try await Task.sleep(for: .milliseconds(300))
XCTAssertEqual(states.last, false, "disabled while the code is fresh")
- try await Task.sleep(for: .milliseconds(1400))
- XCTAssertEqual(states.last, true, "enabled on time, by waiting only")
+ // Only waiting: no typing, focus or other redraw. On time, give or
+ // take a busy machine's scheduling.
+ try await waitUntil(.seconds(6)) { states.last == true }
+ XCTAssertEqual(states.last, true, "enabled by waiting only")
}
}
#endif