import Foundation import SprachmittlerEngines import SprachmittlerText import Testing @testable import SprachmittlerCore @Suite("Panel chunk progress") @MainActor struct PanelChunkingTests { private let longCaptured = CapturedText( text: String(repeating: "a", count: 9000), capturedAt: Date(timeIntervalSince1970: 0), source: .doubleCopy ) @Test func reportsPartsAndProgress() async { let limits = CaptureLimits(maximumParts: 3) let streaming = GatedMultiPartStreaming() let (panel, _, _) = makePanel(streaming: streaming, captureLimits: limits) await panel.begin(longCaptured) await waitFor { panel.currentChunk == 1 && panel.totalChunks == 3 && !panel.translation.isEmpty } #expect(panel.phase == .streaming) #expect(panel.chunkCount == 1) await streaming.release() await waitFor { panel.phase == .ready } #expect(panel.translation == "part1 part2 part3") #expect(panel.chunkCount == 3) #expect(panel.currentChunk == nil) #expect(panel.totalChunks == nil) #expect(await streaming.requests.first?.captureLimits == limits) } @Test func aSinglePartHasNoProgress() async { let captured = CapturedText( text: "Hallo.", capturedAt: Date(timeIntervalSince1970: 0), source: .doubleCopy ) let (panel, _, _) = makePanel(streaming: EchoStreaming()) await panel.begin(captured) await waitFor { panel.phase == .ready } #expect(panel.chunkCount == 1) #expect(panel.currentChunk == nil) #expect(panel.totalChunks == nil) } }