diff --git a/internal/handlers/dashboard_test.go b/internal/handlers/dashboard_test.go index 65b6e69..aae45e9 100644 --- a/internal/handlers/dashboard_test.go +++ b/internal/handlers/dashboard_test.go @@ -46,7 +46,7 @@ func TestBuildSections_ConvertsServiceTypesToHandlerTypes(t *testing.T) { }, } - result := BuildSections(serviceSections) + result := BuildSections(serviceSections, "") assert.Equal(t, 2, len(result), "should have 2 sections") @@ -57,13 +57,13 @@ func TestBuildSections_ConvertsServiceTypesToHandlerTypes(t *testing.T) { assert.Equal(t, "Books you're currently reading", section1.Description, "Description should be string") assert.Equal(t, "📖", section1.Icon, "Icon should be string") assert.Equal(t, 1, section1.Priority, "Priority should be number") - assert.Equal(t, "/section/continue-reading", section1.ViewAllURL, "ViewAllURL should match system collection") + assert.Equal(t, "/collections/00000000-0000-0000-0000-000000000000", section1.ViewAllURL, "ViewAllURL should match collection URL") section2 := result[1] assert.Equal(t, "my-favorites", section2.ID) assert.False(t, section2.IsSystem, "IsSystem should be boolean false") assert.Equal(t, "My Favorites", section2.Title) - assert.Equal(t, "", section2.ViewAllURL, "ViewAllURL should be empty for user collections") + assert.Equal(t, "/collections/00000000-0000-0000-0000-000000000000", section2.ViewAllURL, "ViewAllURL should be set for user collections") } func TestBuildSections_ConvertsItemsCorrectly(t *testing.T) { @@ -90,7 +90,7 @@ func TestBuildSections_ConvertsItemsCorrectly(t *testing.T) { }, } - result := BuildSections(serviceSections) + result := BuildSections(serviceSections, "") assert.Equal(t, 1, len(result), "should have 1 section") section := result[0] @@ -136,46 +136,58 @@ func TestTextToString_Valid(t *testing.T) { func TestGetViewAllURL_SystemCollections(t *testing.T) { tests := []struct { - name string - collectionName string - queryType string - expected string + name string + collectionID string + libraryID string + expected string }{ { - name: "continue-reading", - collectionName: "continue-reading", - queryType: "continue-reading", - expected: "/section/continue-reading", + name: "continue-reading with no library", + collectionID: "continue-reading", + libraryID: "", + expected: "/collections/continue-reading", }, { - name: "recently-added", - collectionName: "recently-added", - queryType: "recently-added", - expected: "/section/recently-added", + name: "continue-reading with library", + collectionID: "continue-reading", + libraryID: "lib-123", + expected: "/collections/continue-reading?library_id=lib-123", }, { - name: "recently-read", - collectionName: "recently-read", - queryType: "recently-read", - expected: "/history", + name: "recently-added with no library", + collectionID: "recently-added", + libraryID: "", + expected: "/collections/recently-added", }, { - name: "not-started", - collectionName: "not-started", - queryType: "not-started", - expected: "/section/not-started", + name: "recently-read with library", + collectionID: "recently-read", + libraryID: "lib-456", + expected: "/collections/recently-read?library_id=lib-456", }, { - name: "user collection", - collectionName: "my-favorites", - queryType: "filter", - expected: "", + name: "not-started with no library", + collectionID: "not-started", + libraryID: "", + expected: "/collections/not-started", + }, + { + name: "user collection with library", + collectionID: "my-favorites", + libraryID: "lib-789", + expected: "/collections/my-favorites?library_id=lib-789", + }, + { + name: "empty collection ID", + collectionID: "", + libraryID: "lib-123", + expected: "", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - result := getViewAllURL(tt.collectionName) + result := getViewAllURL(tt.collectionID, tt.libraryID) assert.Equal(t, tt.expected, result, "getViewAllURL mismatch") }) }