This commit is contained in:
ponzischeme89
2026-08-22 18:40:50 +12:00
parent 9858e44710
commit 7d77700c7b
36 changed files with 480 additions and 119 deletions
+1
View File
@@ -62,6 +62,7 @@ var configurationCatalogue = []configurationDefinition{
{Key: "continueWatching.enabled", Name: "Continue Watching", Description: "Show the Continue Watching row.", Type: "boolean", Scopes: []string{"global", "user", "device"}, Default: true},
{Key: "continueWatching.showNextUp", Name: "Continue Watching: Next Up", Description: "Include an unstarted next episode in Continue Watching.", Type: "boolean", Scopes: []string{"global", "user", "device"}, Default: true},
{Key: "continueWatching.progressColour", Name: "Progress bar colour", Description: "Choose the progress bar treatment.", Type: "enum", Scopes: []string{"global", "user", "device"}, Default: "emby", Options: []string{"emby", "white"}},
{Key: "presentation.fontFamily", Name: "App font family", Description: "Choose the bundled font used in Membys typography trial areas.", Type: "enum", Scopes: []string{"global"}, Default: "system", Options: []string{"system", "inter"}},
{Key: "ratings.enabled", Name: "Ratings", Description: "Show ratings throughout the catalogue.", Type: "boolean", Scopes: []string{"global", "user", "device"}, Default: true},
{Key: "genres.enabled", Name: "Genres", Description: "Show genre browsing controls.", Type: "boolean", Scopes: []string{"global", "user", "device"}, Default: true},
{Key: "trailers.enabled", Name: "Trailers", Description: "Offer trailers where available.", Type: "boolean", Scopes: []string{"global", "device", "experimental"}, Default: true},
+14
View File
@@ -1,6 +1,7 @@
package api
import (
"encoding/json"
"net/http"
"net/http/httptest"
"strings"
@@ -75,6 +76,19 @@ func TestContinueWatchingIsServerControlledAndOnByDefault(t *testing.T) {
}
}
func TestAppFontFamilyIsAValidatedGlobalConfiguration(t *testing.T) {
definition, ok := configurationDefinitionFor("presentation.fontFamily")
if !ok || definition.Type != "enum" || len(definition.Scopes) != 1 || definition.Scopes[0] != "global" {
t.Fatalf("font family definition = %+v, found=%v", definition, ok)
}
if err := validateConfigurationValue(definition, json.RawMessage(`"inter"`)); err != nil {
t.Fatalf("Inter was rejected: %v", err)
}
if err := validateConfigurationValue(definition, json.RawMessage(`"unknown"`)); err == nil {
t.Fatal("unknown font family was accepted")
}
}
func TestClientCapabilitiesAreNormalizedAndBounded(t *testing.T) {
req := httptest.NewRequest(http.MethodGet, "/v1/status", nil)
req.Header.Set("X-Memby-Capabilities", " Sonarr_Preroll_V1,server_features_v1,sonarr_preroll_v1,"+
+4
View File
@@ -107,6 +107,10 @@ func applyGlobalConfiguration(document *config.RemoteConfig, policy store.Featur
if v, ok := value.(string); ok {
document.ContinueWatching.ProgressColour = v
}
case "presentation.fontFamily":
if v, ok := value.(string); ok && (v == "system" || v == "inter") {
document.Presentation.FontFamily = v
}
case "home.heroRefreshSeconds":
if v, ok := value.(float64); ok {
document.Home.HeroRefreshSeconds = int(v)
+14
View File
@@ -1,11 +1,13 @@
package api
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/ponzischeme89/memby/server/internal/config"
"github.com/ponzischeme89/memby/server/internal/store"
)
func TestRemoteConfigSupportsETagRevalidationWithoutAuthentication(t *testing.T) {
@@ -31,3 +33,15 @@ func TestRemoteConfigSupportsETagRevalidationWithoutAuthentication(t *testing.T)
t.Fatalf("revalidation status = %d", second.Code)
}
}
func TestGlobalFontFamilyConfigurationIsDelivered(t *testing.T) {
document := config.DefaultRemoteConfig()
policy := store.DefaultFeaturePolicy()
policy.Values["presentation.fontFamily"] = json.RawMessage(`"inter"`)
applyGlobalConfiguration(&document, policy)
if document.Presentation.FontFamily != "inter" {
t.Fatalf("font family = %q, want inter", document.Presentation.FontFamily)
}
}