merged with fixes
This commit is contained in:
parent
a9e758b712
commit
2f1818d656
176 changed files with 9000 additions and 907 deletions
|
|
@ -46,13 +46,14 @@ func TestUserVisibleTextRebrandsLocalizedProductNames(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestClientPresentationNames(t *testing.T) {
|
||||
cfg := Current()
|
||||
for platform, want := range map[string]string{
|
||||
"tdesktop": DesktopAppName,
|
||||
"android": AndroidAppName,
|
||||
"ios": IOSAppName,
|
||||
"macos": MacOSAppName,
|
||||
"telegram-tt": WebAAppName,
|
||||
"tweb": WebKAppName,
|
||||
"tdesktop": cfg.DesktopAppName,
|
||||
"android": cfg.AndroidAppName,
|
||||
"ios": cfg.IOSAppName,
|
||||
"macos": cfg.MacOSAppName,
|
||||
"telegram-tt": cfg.WebAAppName,
|
||||
"tweb": cfg.WebKAppName,
|
||||
} {
|
||||
if got := ClientAppName(platform); got != want {
|
||||
t.Fatalf("ClientAppName(%q) = %q, want %q", platform, got, want)
|
||||
|
|
@ -62,3 +63,55 @@ func TestClientPresentationNames(t *testing.T) {
|
|||
t.Fatalf("UserVisibleClientPlatform() = %q, want weba", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigureInstallsCompleteBrandSnapshot(t *testing.T) {
|
||||
previous := Current()
|
||||
t.Cleanup(func() {
|
||||
if err := Configure(previous); err != nil {
|
||||
t.Fatalf("restore branding: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
cfg := Config{
|
||||
ProductName: "Example Chat",
|
||||
ProductUsername: "@Example_Chat",
|
||||
DesktopAppName: "Example Workstation",
|
||||
AndroidAppName: "Example Droid",
|
||||
IOSAppName: "Example Phone",
|
||||
MacOSAppName: "Example Mac",
|
||||
WebAAppName: "Example Web Alpha",
|
||||
WebKAppName: "Example Web Kappa",
|
||||
PremiumName: "Example Plus",
|
||||
StarsName: "Example Credits",
|
||||
PublicBaseURL: "https://links.example.test/root/",
|
||||
}
|
||||
if err := Configure(cfg); err != nil {
|
||||
t.Fatalf("Configure: %v", err)
|
||||
}
|
||||
if got := Current(); got.ProductUsername != "example_chat" || got.PublicBaseURL != "https://links.example.test/root" {
|
||||
t.Fatalf("Current() = %+v", got)
|
||||
}
|
||||
if got := ClientAppName("android"); got != "Example Droid" {
|
||||
t.Fatalf("ClientAppName(android) = %q", got)
|
||||
}
|
||||
if got := UserVisibleText("Telegram at t.me/example", ""); got != "Example Chat at links.example.test/example" {
|
||||
t.Fatalf("UserVisibleText() = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateRejectsIncompleteOrUnsafeBranding(t *testing.T) {
|
||||
for name, mutate := range map[string]func(*Config){
|
||||
"blank product": func(cfg *Config) { cfg.ProductName = " " },
|
||||
"control": func(cfg *Config) { cfg.StarsName = "bad\nname" },
|
||||
"username": func(cfg *Config) { cfg.ProductUsername = "3bad" },
|
||||
"public URL": func(cfg *Config) { cfg.PublicBaseURL = "file:///tmp/brand" },
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
cfg := DefaultConfig()
|
||||
mutate(&cfg)
|
||||
if _, err := Validate(cfg); err == nil {
|
||||
t.Fatal("Validate accepted invalid branding")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue