fix(servers): 主人可放弃服务器、管理员可删除服务器,由 reaper 归档世界后释放或移除

This commit is contained in:
Lemon-miaow committed 2026-09-27 03:49:49 +08:00
1 parent 4a26bf4ca0
commit 0e08fa7ced
55 files changed
+2774 -119

No files matched your search

+23
View File
@@ -273,6 +273,29 @@ describe("api access-control wire shapes", () => {
beforeEach(() => vi.restoreAllMocks());
afterEach(() => vi.unstubAllGlobals());
it("retireServer PUTs the typed name and the delete flag to the retirement path", async () => {
const requested_at = "2026-09-27T12:00:00Z";
const fetchSpy = fakeFetch({ name: "survival", retiring: { requested_at, delete: true } }, { status: 202 });
vi.stubGlobal("fetch", fetchSpy);
const res = await api.retireServer("survival", { confirm: "survival", delete: true });
expect(res.retiring).toEqual({ requested_at, delete: true });
const [url, opts] = (fetchSpy as unknown as ReturnType<typeof vi.fn>).mock.calls[0];
expect(String(url)).toBe("/servers/survival/retirement");
expect((opts as RequestInit).method).toBe("PUT");
expect(JSON.parse(String((opts as RequestInit).body))).toEqual({ confirm: "survival", delete: true });
});
it("cancelRetire DELETEs the retirement path", async () => {
const fetchSpy = vi.fn(async () => ({ ok: true, status: 204, statusText: "No Content", text: async () => "" })) as unknown as typeof fetch;
vi.stubGlobal("fetch", fetchSpy);
await api.cancelRetire("survival");
const [url, opts] = (fetchSpy as unknown as ReturnType<typeof vi.fn>).mock.calls[0];
expect(String(url)).toBe("/servers/survival/retirement");
expect((opts as RequestInit).method).toBe("DELETE");
});
it("accessWhitelistList GETs the whitelist path and returns players + raw output", async () => {
const fetchSpy = fakeFetch({
name: "survival",