E frontend reconciliation (2/2): align consumers to generated bindings; svelte-check clean
Reconcile the ~50 frontend files that consumed the old hand-written types against
the stricter generated bindings (141 -> 0 svelte-check errors):
- Nullable strictness: null-coalesce/guard at consumer sites; widen shared helpers
(CachedImage.tag, ticksToSeconds, formatDuration, getSessionIcon, session store
send*/transferToRemote) to accept null.
- Field-name fixes exposed by codegen: userData.played -> isPlayed; remote
NowPlayingItem uses album (not albumName); ArtistItem id/name.
- player.ts: normalize remote NowPlayingItem -> MediaItem in mergedMedia.
- ArtistItem now serializes camelCase (PascalCase alias retained for Jellyfin
deserialize); update its serialize test.
- Update downloads.test.ts to the bundled { request } shape; complete the
sessions.test.ts NowPlayingItem mock.
Frontend: svelte-check 0 errors, vitest 448 passing. Backend: 387 passing.
This commit is contained in:
@@ -405,15 +405,21 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_artist_item_serialize() {
|
||||
// Test that ArtistItem serializes to PascalCase for consistency
|
||||
// ArtistItem serializes to camelCase for the frontend; it still accepts
|
||||
// Jellyfin's PascalCase on deserialize via #[serde(alias = ...)].
|
||||
let artist = ArtistItem {
|
||||
id: "test-id".to_string(),
|
||||
name: "Test Artist".to_string(),
|
||||
};
|
||||
|
||||
let json = serde_json::to_string(&artist).expect("Failed to serialize");
|
||||
assert!(json.contains(r#""Id":"test-id""#));
|
||||
assert!(json.contains(r#""Name":"Test Artist""#));
|
||||
assert!(json.contains(r#""id":"test-id""#));
|
||||
assert!(json.contains(r#""name":"Test Artist""#));
|
||||
|
||||
let from_pascal: ArtistItem =
|
||||
serde_json::from_str(r#"{"Id":"x","Name":"Y"}"#).expect("Failed to deserialize");
|
||||
assert_eq!(from_pascal.id, "x");
|
||||
assert_eq!(from_pascal.name, "Y");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user