From 600dea6ce54989a792e666a0a26de0ee847e4562 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 5 Oct 2024 18:06:14 -0700 Subject: feat(client): add `custom_js` field to Go API client --- internal/api/api_integration_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 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 1d06fb8c..1a95cf08 100644 --- a/internal/api/api_integration_test.go +++ b/internal/api/api_integration_test.go @@ -592,6 +592,35 @@ func TestUpdateUserEndpointByChangingDefaultTheme(t *testing.T) { } } +func TestUpdateUserEndpointByChangingCustomJS(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) + + userUpdateRequest := &miniflux.UserModificationRequest{ + CustomJS: miniflux.SetOptionalField("alert('Hello, World!');"), + } + + updatedUser, err := regularUserClient.UpdateUser(regularTestUser.ID, userUpdateRequest) + if err != nil { + t.Fatal(err) + } + + if updatedUser.CustomJS != "alert('Hello, World!');" { + t.Fatalf(`Invalid custom JS, got %q`, updatedUser.CustomJS) + } +} + func TestUpdateUserEndpointByChangingDefaultThemeToInvalidValue(t *testing.T) { testConfig := newIntegrationTestConfig() if !testConfig.isConfigured() { -- cgit v1.2.3