Skip to content

Commit 80ec14b

Browse files
committed
test(app): add tests for addWarning deduplication and edge cases
1 parent b59c891 commit 80ec14b

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

app/MeetingTranscriber/Tests/PipelineQueueTests.swift

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,4 +709,54 @@ final class PipelineQueueTests: XCTestCase {
709709
XCTAssertEqual(freshQueue.jobs.count, 1)
710710
XCTAssertEqual(freshQueue.jobs[0].state, .waiting)
711711
}
712+
713+
// MARK: - addWarning
714+
715+
func testAddWarningAppendsToJob() {
716+
let queue = PipelineQueue(logDir: tmpDir)
717+
let job = PipelineJob(
718+
meetingTitle: "Warn Test",
719+
appName: "Teams",
720+
mixPath: URL(fileURLWithPath: "/tmp/mix.wav"),
721+
appPath: nil, micPath: nil, micDelay: 0,
722+
)
723+
queue.enqueue(job)
724+
queue.addWarning(id: job.id, "Test warning")
725+
XCTAssertEqual(queue.jobs[0].warnings, ["Test warning"])
726+
}
727+
728+
func testAddWarningDeduplicates() {
729+
let queue = PipelineQueue(logDir: tmpDir)
730+
let job = PipelineJob(
731+
meetingTitle: "Dedup Test",
732+
appName: "Teams",
733+
mixPath: URL(fileURLWithPath: "/tmp/mix.wav"),
734+
appPath: nil, micPath: nil, micDelay: 0,
735+
)
736+
queue.enqueue(job)
737+
queue.addWarning(id: job.id, "Same warning")
738+
queue.addWarning(id: job.id, "Same warning")
739+
XCTAssertEqual(queue.jobs[0].warnings.count, 1)
740+
}
741+
742+
func testAddWarningIgnoresInvalidJobID() {
743+
let queue = PipelineQueue(logDir: tmpDir)
744+
// Should not crash with non-existent job ID
745+
queue.addWarning(id: UUID(), "Orphan warning")
746+
XCTAssertTrue(queue.jobs.isEmpty)
747+
}
748+
749+
func testAddWarningMultipleDistinct() {
750+
let queue = PipelineQueue(logDir: tmpDir)
751+
let job = PipelineJob(
752+
meetingTitle: "Multi Test",
753+
appName: "Teams",
754+
mixPath: URL(fileURLWithPath: "/tmp/mix.wav"),
755+
appPath: nil, micPath: nil, micDelay: 0,
756+
)
757+
queue.enqueue(job)
758+
queue.addWarning(id: job.id, "Warning A")
759+
queue.addWarning(id: job.id, "Warning B")
760+
XCTAssertEqual(queue.jobs[0].warnings, ["Warning A", "Warning B"])
761+
}
712762
}

0 commit comments

Comments
 (0)