package validator import ( "strings" "testing" "browser.local/platform/domain" ) func TestValidateGamePluginRuntimeProfilesRejectsLegacySteamCMDAppStep(t *testing.T) { profiles := domain.GamePluginRuntimeProfiles{InstallPlans: []domain.RuntimeInstallPlan{{Key: "install-game", Title: "Install game", Steps: []domain.RuntimeInstallStep{{Type: "steamcmd-app", TargetKey: "server/install-root", PackageManager: "steamcmd", PackageName: "123456"}}}}} err := ValidateGamePluginRuntimeProfiles(profiles) if err == nil || !strings.Contains(err.Error(), "type is invalid") { t.Fatalf("expected legacy steamcmd-app step rejection, got %v", err) } } func TestValidateGamePluginRuntimeProfilesRejectsManualStepExecutionFields(t *testing.T) { profiles := domain.GamePluginRuntimeProfiles{InstallPlans: []domain.RuntimeInstallPlan{{Key: "manual-plan", Title: "Manual plan", Steps: []domain.RuntimeInstallStep{{Type: "manual", TargetKey: "operator/manual", PackageManager: "steamcmd"}}}}} err := ValidateGamePluginRuntimeProfiles(profiles) if err == nil || !strings.Contains(err.Error(), "manual step cannot contain machine execution fields") { t.Fatalf("expected manual execution field rejection, got %v", err) } } func TestValidateGamePluginRuntimeProfilesChecksSteamBuildProbeAppID(t *testing.T) { valid := domain.GamePluginRuntimeProfiles{DependencyProbes: []domain.RuntimeDependencyProbe{{Key: "game-build", Kind: "steam.update", TargetKey: "steamcmd", SteamAppID: "3792580"}}} if err := ValidateGamePluginRuntimeProfiles(valid); err != nil { t.Fatalf("expected declared steam build probe to validate, got %v", err) } missing := domain.GamePluginRuntimeProfiles{DependencyProbes: []domain.RuntimeDependencyProbe{{Key: "game-build", Kind: "steam.update", TargetKey: "steamcmd"}}} if err := ValidateGamePluginRuntimeProfiles(missing); err == nil || !strings.Contains(err.Error(), "steamAppId is invalid for a Steam build probe") { t.Fatalf("expected missing steam app id rejection, got %v", err) } misplaced := domain.GamePluginRuntimeProfiles{DependencyProbes: []domain.RuntimeDependencyProbe{{Key: "java-21", Kind: "java.version", TargetKey: "java", SteamAppID: "3792580"}}} if err := ValidateGamePluginRuntimeProfiles(misplaced); err == nil || !strings.Contains(err.Error(), "steamAppId is allowed only for steam.update probes") { t.Fatalf("expected misplaced steam app id rejection, got %v", err) } }