Watch: keep Recent past 10 behind an N more row with a full list, and settle all in one call
This commit is contained in:
1 parent
2a127327bf
commit
a5222e14e8
13 files changed
+384
-52
No files matched your search
@@ -58,6 +58,29 @@ private let feedItemJSON = """
|
||||
#expect(request.quickOptions?.allow.label == "Allow")
|
||||
#expect(request.quickOptions?.deny.decision == .decline)
|
||||
#expect(request.summary == "bun test --filter ocr")
|
||||
// An older gateway without `recentTotal` has nothing past `recent`.
|
||||
#expect(feed.recentTotal == 0)
|
||||
#expect(feed.moreRecent == 0)
|
||||
}
|
||||
|
||||
@Test func feedWithRecentTotal() throws {
|
||||
let item = feedItemJSON.replacingOccurrences(of: "waiting_for_approval", with: "completed")
|
||||
let feed = try decode(Feed.self, """
|
||||
{ "needsYou": [], "working": [], "recent": [\(item)], "recentTotal": 12, "hosts": [] }
|
||||
""")
|
||||
#expect(feed.recentTotal == 12)
|
||||
#expect(feed.moreRecent == 11)
|
||||
#expect(Feed(needsYou: [], working: [], recent: feed.recent, hosts: []).moreRecent == 0)
|
||||
}
|
||||
|
||||
@Test func recentResponses() throws {
|
||||
let item = feedItemJSON.replacingOccurrences(
|
||||
of: "\"Parser and tests are written. I want to run the suite.\"", with: "null")
|
||||
let recent = try decode(RecentResponse.self, "{ \"items\": [\(item)] }")
|
||||
#expect(recent.items.count == 1)
|
||||
#expect(recent.items.first?.lastMessage == nil)
|
||||
let settled = try decode(SettleRecentResponse.self, #"{ "settled": 11, "failed": 1 }"#)
|
||||
#expect(settled == SettleRecentResponse(settled: 11, failed: 1))
|
||||
}
|
||||
|
||||
@Test func subagentRequest() throws {
|
||||
@@ -277,7 +300,7 @@ private let feedItemJSON = """
|
||||
#expect(thread.url.absoluteString == "wristcode://thread/mac%20mini/t%2F1")
|
||||
#expect(Route(url: thread.url) == thread)
|
||||
#expect(Route(url: Route.newThread.url) == .newThread)
|
||||
for route in [Route.status, .host(id: "mac mini"), .notifications] {
|
||||
for route in [Route.recent, .status, .host(id: "mac mini"), .notifications] {
|
||||
#expect(Route(url: route.url) == route)
|
||||
}
|
||||
#expect(Route(url: URL(string: "wristcode://thread/only-host")!) == nil)
|
||||
@@ -444,6 +467,26 @@ private let feedItemJSON = """
|
||||
#expect(try await gateway.feed().working.contains { $0.id == item.id })
|
||||
}
|
||||
|
||||
@Test func feedShowsTenRecentAndCountsTheRest() async throws {
|
||||
let gateway = DemoGateway()
|
||||
let feed = try await gateway.feed()
|
||||
let all = try await gateway.recent().items
|
||||
#expect(feed.recent.count == 10)
|
||||
#expect(feed.recentTotal == all.count)
|
||||
#expect(feed.moreRecent == all.count - 10)
|
||||
#expect(feed.recent == Array(all.prefix(10)))
|
||||
}
|
||||
|
||||
@Test func settleRecentLeavesFailedThreads() async throws {
|
||||
let gateway = DemoGateway()
|
||||
let all = try await gateway.recent().items
|
||||
let result = try await gateway.settleRecent()
|
||||
#expect(result == SettleRecentResponse(settled: all.filter { $0.phase == .completed }.count, failed: 0))
|
||||
let left = try await gateway.recent().items
|
||||
#expect(!left.isEmpty && left.allSatisfy { $0.phase == .failed })
|
||||
#expect(try await gateway.feed().moreRecent == 0)
|
||||
}
|
||||
|
||||
@Test func multiSelectAnswerMovesThreadToWorking() async throws {
|
||||
let gateway = DemoGateway()
|
||||
let item = try #require(try await gateway.feed().needsYou.first { $0.request?.questions.first?.multiSelect == true })
|
||||
|
||||
Reference in new issue
Block a user