diff --git a/platform_web/pages/ConsolePages.test.tsx b/platform_web/pages/ConsolePages.test.tsx index de9bb2b..945c829 100644 --- a/platform_web/pages/ConsolePages.test.tsx +++ b/platform_web/pages/ConsolePages.test.tsx @@ -6,7 +6,7 @@ import { MaintenancePage } from "./MaintenancePage"; import { PluginsPage } from "./PluginsPage"; import { ProfileSettingsPage } from "./ProfileSettingsPage"; import { ServerDetailPage } from "./ServerDetailPage"; -import { ServersPage } from "./ServersPage"; +import { runPlatformOptions, ServersPage } from "./ServersPage"; import { UsersPage } from "./UsersPage"; import runtimeTaskProgressSource from "../components/RuntimeTaskProgress.tsx?raw"; import serverDeploymentWorkflowSource from "../components/ServerDeploymentWorkflow.tsx?raw"; @@ -17,7 +17,7 @@ import serverDetailPageSource from "./ServerDetailPage.tsx?raw"; import type { PageComponentProps } from "../contracts/page"; import { capabilitiesForRoles, type CurrentUserView } from "../contracts/workspace"; import type { OperationTracker } from "../stores/operations"; -import type { UserResponse } from "../api/types"; +import type { GamePluginResponse, UserResponse } from "../api/types"; const adminUser: CurrentUserView = { id: "user-admin", @@ -62,6 +62,13 @@ function pageProps(params: PageComponentProps["params"] = {}): PageComponentProp } describe("first-party console pages", () => { + it("only offers plugin-declared run platforms", () => { + const plugin = { supportedOs: ["windows", "linux"] } as GamePluginResponse; + + expect(runPlatformOptions(plugin, "darwin")).toEqual(["windows", "linux"]); + expect(runPlatformOptions(undefined, "windows")).toEqual(["windows"]); + }); + it("renders the platform overview with first-screen health modules", () => { const html = renderToStaticMarkup(); diff --git a/platform_web/pages/ServersPage.tsx b/platform_web/pages/ServersPage.tsx index 843246b..2ecce92 100644 --- a/platform_web/pages/ServersPage.tsx +++ b/platform_web/pages/ServersPage.tsx @@ -981,7 +981,7 @@ function quickRuntimeDefaultsForPlugin(pluginId: string) { }; } -function runPlatformOptions(plugin: GamePluginResponse | undefined, fallback: string): string[] { +export function runPlatformOptions(plugin: GamePluginResponse | undefined, fallback: string): string[] { const options = new Set(); const add = (value: string | undefined) => { const normalized = value?.trim().toLowerCase(); @@ -989,10 +989,13 @@ function runPlatformOptions(plugin: GamePluginResponse | undefined, fallback: st options.add(normalized); } }; - add(fallback); plugin?.supportedOs?.forEach(add); - plugin?.runtimeProfiles?.lifecycleProfiles?.forEach((profile) => profile.platforms?.forEach(add)); - ["linux", "windows", "darwin"].forEach(add); + if (options.size === 0) { + plugin?.runtimeProfiles?.lifecycleProfiles?.forEach((profile) => profile.platforms?.forEach(add)); + } + if (options.size === 0) { + add(fallback); + } return [...options]; }