feat: add insta snapshot testing for TUI components

- Add insta dev-dependency for visual regression testing
- Create lib.rs to expose modules for integration tests
- Add snapshot tests for progress_bar, topbar, library, help modal
- Add unit tests for LibraryState navigation
- Move all tests to tests/ directory (proper Rust convention)
- Make build.rs skip proto compilation when protoc unavailable
- Add docs/testing-possible-solutions.md with testing strategies
This commit is contained in:
Alexander
2026-05-09 11:35:10 +02:00
parent f7660436c2
commit 5bee7092d3
25 changed files with 799 additions and 115 deletions
+9 -9
View File
@@ -17,7 +17,10 @@ pub enum GrpcRequest {
#[allow(dead_code, clippy::large_enum_variant)]
pub enum GrpcResponse {
Artists(Vec<ArtistSummary>),
Album { album: AlbumDetail, tracks: Vec<TrackDetail> },
Album {
album: AlbumDetail,
tracks: Vec<TrackDetail>,
},
Error(String),
}
@@ -46,14 +49,11 @@ impl GrpcClient {
&mut self,
album_id: String,
) -> Result<(AlbumDetail, Vec<TrackDetail>), tonic::Status> {
let response = self
.music
.get_album(GetAlbumRequest { album_id })
.await?;
let response = self.music.get_album(GetAlbumRequest { album_id }).await?;
let inner = response.into_inner();
let album = inner.album.ok_or_else(|| {
tonic::Status::not_found("Album not found in response")
})?;
let album = inner
.album
.ok_or_else(|| tonic::Status::not_found("Album not found in response"))?;
Ok((album, inner.tracks))
}
}
@@ -84,7 +84,7 @@ pub fn spawn_grpc_worker(
GrpcRequest::GetAlbum { album_id } => match client.get_album(album_id).await {
Ok((album, tracks)) => GrpcResponse::Album { album, tracks },
Err(e) => GrpcResponse::Error(e.to_string()),
}
},
};
if resp_tx.send(response).await.is_err() {