Show SCUM create inputs when adopting servers
This commit is contained in:
@@ -74,6 +74,34 @@ describe("ServerDeploymentWorkflow", () => {
|
||||
expect(Array.from(container.querySelectorAll<HTMLInputElement>('input[type="number"]')).map((input) => input.value)).toEqual(["28000", "27015"]);
|
||||
});
|
||||
|
||||
it("shows plugin startup inputs when editing an adopted SCUM server", 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" }, { key: "maxPlayers", label: "最大玩家数", type: "number", required: true, defaultValue: "128" }] };
|
||||
const initialForm = { ...defaultServerCreateForm([scumPlugin]), name: "Moon Base", deploymentMode: "existing-server" as const, createInputs: { gamePort: "28888" } };
|
||||
|
||||
await act(async () => {
|
||||
root?.render(
|
||||
<ServerDeploymentWorkflow
|
||||
open
|
||||
kind="edit"
|
||||
plugins={[scumPlugin]}
|
||||
initialForm={initialForm}
|
||||
deployment={{ serverInstanceId: "server-scum", mode: "existing-server", createInputs: { gamePort: "28888" }, serverRootConfigured: true, 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(container.textContent).toContain("最大玩家数");
|
||||
expect(container.textContent).toContain("接管流程不会把这些值写回或覆盖已有游戏配置");
|
||||
expect(Array.from(container.querySelectorAll<HTMLInputElement>('input[type="number"]')).map((input) => input.value)).toEqual(["28888", "27015", "128"]);
|
||||
});
|
||||
|
||||
it("normalizes the create wizard to canonical plugins with visible guided inputs", async () => {
|
||||
container = document.createElement("div");
|
||||
document.body.append(container);
|
||||
@@ -191,6 +219,74 @@ describe("ServerDeploymentWorkflow", () => {
|
||||
expect(submitted?.deployment && "profileKey" in submitted.deployment).toBe(false);
|
||||
expect(submitted?.deployment && "runtimeBindings" in submitted.deployment).toBe(false);
|
||||
});
|
||||
|
||||
it("submits SCUM port and max player inputs from the existing-server create wizard", 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" }, { key: "maxPlayers", label: "最大玩家数", type: "number", required: true, defaultValue: "128" }] };
|
||||
const initialForm = defaultServerCreateForm([scumPlugin]);
|
||||
let submitted: ReturnType<typeof serverCreateRequestFromForm> | undefined;
|
||||
const onSubmit = vi.fn(async (form: typeof initialForm) => {
|
||||
submitted = serverCreateRequestFromForm(form, 18);
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
root?.render(
|
||||
<ServerDeploymentWorkflow
|
||||
open
|
||||
kind="create"
|
||||
plugins={[scumPlugin]}
|
||||
initialForm={initialForm}
|
||||
onClose={() => undefined}
|
||||
onSubmit={onSubmit}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
const nameInput = container.querySelector<HTMLInputElement>('input[name="name"]');
|
||||
if (!nameInput) throw new Error("server name input not found");
|
||||
await act(async () => {
|
||||
setInputValue(nameInput, "SCUM Existing Server");
|
||||
});
|
||||
|
||||
await submitWorkflow(container);
|
||||
await clickButtonByText(container, "接管已有服务器");
|
||||
await submitWorkflow(container);
|
||||
|
||||
expect(container.textContent).toContain("已有服务器目录");
|
||||
expect(container.textContent).toContain("游戏端口");
|
||||
expect(container.textContent).toContain("查询端口");
|
||||
expect(container.textContent).toContain("最大玩家数");
|
||||
expect(Array.from(container.querySelectorAll<HTMLInputElement>('input[type="number"]')).map((input) => input.value)).toEqual(["7779", "27015", "128"]);
|
||||
|
||||
const rootInput = container.querySelector<HTMLInputElement>('input[name="serverRoot"]');
|
||||
const [gamePortInput, , maxPlayersInput] = Array.from(container.querySelectorAll<HTMLInputElement>('input[type="number"]'));
|
||||
if (!rootInput || !gamePortInput || !maxPlayersInput) throw new Error("SCUM existing-server inputs not found");
|
||||
await act(async () => {
|
||||
setInputValue(rootInput, "/srv/scum-existing");
|
||||
setInputValue(gamePortInput, "28001");
|
||||
setInputValue(maxPlayersInput, "64");
|
||||
});
|
||||
|
||||
await submitWorkflow(container);
|
||||
expect(container.textContent).toContain("本次保存创建向导配置");
|
||||
expect(container.textContent).toContain("游戏配置");
|
||||
expect(container.textContent).toContain("3 项已准备");
|
||||
|
||||
await submitWorkflow(container);
|
||||
expect(onSubmit).toHaveBeenCalledTimes(1);
|
||||
expect(submitted).toMatchObject({
|
||||
id: "server-scum-existing-server-18",
|
||||
pluginId: "game.scum",
|
||||
name: "SCUM Existing Server",
|
||||
deployment: {
|
||||
mode: "existing-server",
|
||||
serverRoot: "/srv/scum-existing",
|
||||
createInputs: { gamePort: "28001", queryPort: "27015", maxPlayers: "64" }
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
async function submitWorkflow(target: HTMLElement) {
|
||||
|
||||
Reference in New Issue
Block a user