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:
+9
-9
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user