diff options
author | 2024-10-05 18:06:14 -0700 | |
---|---|---|
committer | 2024-10-05 18:37:34 -0700 | |
commit | 600dea6ce54989a792e666a0a26de0ee847e4562 (patch) | |
tree | cc113950f4c3695a8d592d7317002ade30377077 /internal/api/api_integration_test.go | |
parent | e07203ad46d91551f87e0d50009181e2a1363209 (diff) | |
download | v2-600dea6ce54989a792e666a0a26de0ee847e4562.tar.gz v2-600dea6ce54989a792e666a0a26de0ee847e4562.tar.zst v2-600dea6ce54989a792e666a0a26de0ee847e4562.zip |
feat(client): add `custom_js` field to Go API client
Diffstat (limited to '')
-rw-r--r-- | internal/api/api_integration_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
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() { |