From 6fb7e84ce1bb38b386a6f6effd1bb3b09d2b72e0 Mon Sep 17 00:00:00 2001 From: Pontus Jensen Karlsson Date: Thu, 8 Aug 2024 04:46:09 +0000 Subject: feat: API: Allow filtering entries on globally_hidden Currently there's no way through the API to mimic the Unread page of the client. This is now possible by filtering on globally_visible=true and status=unread. --- internal/api/api_integration_test.go | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'internal/api/api_integration_test.go') diff --git a/internal/api/api_integration_test.go b/internal/api/api_integration_test.go index 9259b590..df8d93a0 100644 --- a/internal/api/api_integration_test.go +++ b/internal/api/api_integration_test.go @@ -1986,6 +1986,54 @@ func TestGetAllEntriesEndpointWithFilter(t *testing.T) { } } +func TestGetGlobalEntriesEndpoint(t *testing.T) { + testConfig := newIntegrationTestConfig() + if !testConfig.isConfigured() { + t.Skip(skipIntegrationTestsMessage) + } + + adminClient := miniflux.NewClient(testConfig.testBaseURL, testConfig.testAdminUsername, testConfig.testAdminPassword) + + regularTestUser, err := adminClient.CreateUser(testConfig.genRandomUsername(), testConfig.testRegularPassword, false) + if err != nil { + t.Fatal(err) + } + defer adminClient.DeleteUser(regularTestUser.ID) + + regularUserClient := miniflux.NewClient(testConfig.testBaseURL, regularTestUser.Username, testConfig.testRegularPassword) + + feedID, err := regularUserClient.CreateFeed(&miniflux.FeedCreationRequest{ + FeedURL: testConfig.testFeedURL, + HideGlobally: true, + }) + + if err != nil { + t.Fatal(err) + } + + /* Not filtering on GloballyVisible should return all entries */ + feedEntries, err := regularUserClient.Entries(&miniflux.Filter{FeedID: feedID}) + + if err != nil { + t.Fatal(err) + } + + if len(feedEntries.Entries) == 0 { + t.Fatalf(`Expected entries but response contained none.`) + } + + /* Feed is hidden globally, so this should be empty */ + globallyVisibleEntries, err := regularUserClient.Entries(&miniflux.Filter{GloballyVisible: true}) + + if err != nil { + t.Fatal(err) + } + + if len(globallyVisibleEntries.Entries) != 0 { + t.Fatalf(`Expected no entries, got %d`, len(globallyVisibleEntries.Entries)) + } +} + func TestGetEntryEndpoints(t *testing.T) { testConfig := newIntegrationTestConfig() if !testConfig.isConfigured() { -- cgit v1.2.3