diff --git a/Packages/Features/Sources/Commanding/Commands/RecordingCommand.swift b/Packages/Features/Sources/Commanding/Commands/RecordingCommand.swift index 052320b..c19756c 100644 --- a/Packages/Features/Sources/Commanding/Commands/RecordingCommand.swift +++ b/Packages/Features/Sources/Commanding/Commands/RecordingCommand.swift @@ -4,4 +4,6 @@ public enum RecordingCommand: Equatable, Sendable { case toggle /// Discards the recording, like a press of the feature's discard button. case discard + /// Sends the paused recording for processing, like a press of the feature's send button. + case process } diff --git a/Packages/Features/Sources/Recording/View Models/RecordingViewModel.swift b/Packages/Features/Sources/Recording/View Models/RecordingViewModel.swift index 1b629bd..6e7fb22 100644 --- a/Packages/Features/Sources/Recording/View Models/RecordingViewModel.swift +++ b/Packages/Features/Sources/Recording/View Models/RecordingViewModel.swift @@ -436,6 +436,8 @@ private extension RecordingView.Model { pressedMain() case .discard: pressedDiscard() + case .process: + pressedSend() } } } diff --git a/Packages/Features/Tests/Recording/View Models/RecordingViewModelTests.swift b/Packages/Features/Tests/Recording/View Models/RecordingViewModelTests.swift index 74ae8c5..e1582ab 100644 --- a/Packages/Features/Tests/Recording/View Models/RecordingViewModelTests.swift +++ b/Packages/Features/Tests/Recording/View Models/RecordingViewModelTests.swift @@ -944,6 +944,25 @@ struct RecordingViewModelTests { #expect(model.elapsedSeconds == 0) } + @Test + func `a process command sends a paused recording for processing`() async throws { + let commander = RecordingCommander() + let model = Model( + transcribe: TranscribingMock(), + commander: commander + ) + + model.drive(to: .paused) + + try await Task.sleep(for: .seconds(0.1)) + + commander.send(.process) + + try await Task.sleep(for: .seconds(0.1)) + + #expect(model.state == .processing) + } + @Test func `commands are ignored before the first recording starts`() async throws { let commander = RecordingCommander()