Fix server create plugin filtering
This commit is contained in:
@@ -48,6 +48,70 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
describe("ServerDeploymentWorkflow", () => {
|
||||
it("merges plugin defaults into guided edit inputs", async () => {
|
||||
container = document.createElement("div");
|
||||
document.body.append(container);
|
||||
root = createRoot(container);
|
||||
const scumPlugin: GamePluginResponse = { ...plugin, id: "game.scum", name: "SCUM Server", serverType: "scum", serverDisplayName: "SCUM Dedicated Server", createFields: [{ key: "gamePort", label: "游戏端口", type: "port", required: true, defaultValue: "7779" }, { key: "queryPort", label: "查询端口", type: "port", required: true, defaultValue: "27015" }] };
|
||||
const initialForm = { ...defaultServerCreateForm([scumPlugin]), name: "Moon Base", createInputs: { gamePort: "28000" } };
|
||||
|
||||
await act(async () => {
|
||||
root?.render(
|
||||
<ServerDeploymentWorkflow
|
||||
open
|
||||
kind="edit"
|
||||
plugins={[scumPlugin]}
|
||||
initialForm={initialForm}
|
||||
deployment={{ serverInstanceId: "server-scum", mode: "guided-install", createInputs: { gamePort: "28000" }, serverRootConfigured: false, workingDirectoryConfigured: false, installCommandConfigured: false, startCommandConfigured: false, stopCommandConfigured: false, statusCommandConfigured: false, revision: 1 }}
|
||||
onClose={() => undefined}
|
||||
onSubmit={async () => undefined}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
expect(container.textContent).toContain("游戏端口");
|
||||
expect(container.textContent).toContain("查询端口");
|
||||
expect(Array.from(container.querySelectorAll<HTMLInputElement>('input[type="number"]')).map((input) => input.value)).toEqual(["28000", "27015"]);
|
||||
});
|
||||
|
||||
it("normalizes the create wizard to canonical plugins with visible guided inputs", async () => {
|
||||
container = document.createElement("div");
|
||||
document.body.append(container);
|
||||
root = createRoot(container);
|
||||
const examplePlugin: GamePluginResponse = { ...plugin, id: "game.example", name: "Example Server", serverType: "example", serverDisplayName: "Example Server", createFields: [], tags: ["development"] };
|
||||
const staleScumPlugin: GamePluginResponse = { ...plugin, id: "game.scum.codex.20260804095301", name: "SCUM Server", version: "0.1.4", serverType: "scum", serverDisplayName: "SCUM Dedicated Server", manifestRef: "plugins/examples/scum-server-plugin/game.scum.codex.20260804095301/manifest.json", tags: ["scum"], createFields: [{ key: "gamePort", label: "游戏端口", type: "port", required: true, defaultValue: "27000" }] };
|
||||
const scumPlugin: GamePluginResponse = { ...staleScumPlugin, id: "game.scum", version: "0.1.15", manifestRef: "artifact://manifests/game.scum/0.1.15", createFields: [{ key: "gamePort", label: "游戏端口", type: "port", required: true, defaultValue: "7779" }, { key: "queryPort", label: "查询端口", type: "port", required: true, defaultValue: "27015" }] };
|
||||
const initialForm = defaultServerCreateForm([examplePlugin, staleScumPlugin, scumPlugin]);
|
||||
|
||||
await act(async () => {
|
||||
root?.render(
|
||||
<ServerDeploymentWorkflow
|
||||
open
|
||||
kind="create"
|
||||
plugins={[examplePlugin, staleScumPlugin, scumPlugin]}
|
||||
initialForm={initialForm}
|
||||
onClose={() => undefined}
|
||||
onSubmit={async () => undefined}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
const pluginSelect = container.querySelector<HTMLSelectElement>('select[name="pluginId"]');
|
||||
expect(pluginSelect?.value).toBe("game.scum");
|
||||
expect(Array.from(pluginSelect?.options ?? []).map((option) => option.value)).toEqual(["game.scum", "game.example"]);
|
||||
|
||||
const nameInput = container.querySelector<HTMLInputElement>('input[name="name"]');
|
||||
if (!nameInput) throw new Error("server name input not found");
|
||||
await act(async () => {
|
||||
setInputValue(nameInput, "Moon Base");
|
||||
});
|
||||
|
||||
await submitWorkflow(container);
|
||||
await submitWorkflow(container);
|
||||
expect(container.querySelector<HTMLInputElement>('input[value="7779"]')).not.toBeNull();
|
||||
expect(container.querySelector<HTMLInputElement>('input[value="27015"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it("submits deployment mode and matching startup inputs from the create wizard", async () => {
|
||||
container = document.createElement("div");
|
||||
document.body.append(container);
|
||||
|
||||
Reference in New Issue
Block a user