mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 03:25:56 +00:00
Merge master (0.6.6) into feat/portable-characters
Conflicts were additive only: the rusqlite and if-addrs dependencies sit side by side, and the portable.* and fr.lan.* translation blocks are both kept in en and ru. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
d05bfe8b09
89 files changed
+3444
-233
No files matched your search
@@ -67,3 +67,15 @@ for (const locale of ["en", "ru", "de", "fr", "es", "zh"]) {
|
||||
if (view.categories.some(c => !c.title)) throw new Error("SQUID categories must be translated");
|
||||
}
|
||||
console.log("SQUID Bots view: typed values, upstream defaults, categories and hidden managed settings verified");
|
||||
|
||||
const upstream = squidSettingsView([{ key: "AiPlayerbot.FutureOption", value: "2.5", default: "1", doc: "old description", field: {key:"AiPlayerbot.FutureOption",type:"float",title:"Future option",description:"From the release JSON",group:"new-group",group_title:"New activity",min:0,max:3} }], "ru");
|
||||
const future = upstream.settings[0];
|
||||
if (future.title !== "Future option" || future.description !== "From the release JSON" || future.type !== "float" || future.min !== 0 || future.max !== 3 || future.advanced || future.category !== "squid.new-group" || upstream.categories.find(c=>c.id===future.category)?.title !== "New activity") throw new Error("New upstream JSON options must appear without handwritten definitions");
|
||||
console.log("Upstream metadata: new fields, titles, ranges and arbitrary groups verified");
|
||||
|
||||
const localized = moduleField("AiPlayerbot.MaxRandomBots", "ru", { key:"AiPlayerbot.MaxRandomBots", type:"int", title:"Upstream English title", description:"Upstream English description", group:"population", min:10, max:1234 });
|
||||
const original = moduleField("AiPlayerbot.MaxRandomBots", "ru");
|
||||
if (localized.title !== original.title || localized.description !== original.description || localized.max !== 1234) throw new Error("Existing translations must survive upstream metadata while ranges stay current");
|
||||
const localizedGroup = squidSettingsView([{key:"AiPlayerbot.MaxRandomBots",value:"100",default:"500",doc:"",field:{key:"AiPlayerbot.MaxRandomBots",type:"int",title:"English",description:"English",group:"population",group_title:"English population"}}],"ru");
|
||||
if (localizedGroup.categories.find(c=>c.id==="squid.population")?.title !== "Население мира") throw new Error("Known groups must retain translated captions");
|
||||
console.log("Existing setting/group translations retained with upstream English fallback");
|
||||
@@ -0,0 +1,62 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { registerHooks } from "node:module";
|
||||
|
||||
let applyFailure = false;
|
||||
let stateFailure = false;
|
||||
let pending = null;
|
||||
const calls = [];
|
||||
globalThis.__hotfixApi = {
|
||||
applyUpdate: async () => { calls.push("apply"); if (applyFailure) throw new Error("SQL failure"); return { txn: { state: "committed", to_version: "2" } }; },
|
||||
pendingUpdate: async () => { calls.push("disk"); if (stateFailure) throw new Error("damaged journal"); return pending; },
|
||||
checkUpdate: async () => ({ from_version: "2", to_version: "2", items: [], conflicts: [], migrations: 1, pending_migrations: 0 }),
|
||||
};
|
||||
registerHooks({ resolve(specifier, context, next) {
|
||||
if (specifier === "react") return { shortCircuit: true, url: "data:text/javascript,export const useSyncExternalStore=(subscribe,getSnapshot)=>getSnapshot();" };
|
||||
if (specifier === "@/lib/api") return { shortCircuit: true, url: "data:text/javascript,export const api=globalThis.__hotfixApi;export const asUiError=e=>({human:{code:'unknown'},technical:e.message});" };
|
||||
if (specifier === "@tauri-apps/api/event") return { shortCircuit: true, url: "data:text/javascript,export const listen=async()=>()=>{};" };
|
||||
if (specifier === "./serverUpdateStatus" && context.parentURL?.endsWith("/serverUpdate.ts")) return { shortCircuit: true, url: new URL("../src/lib/serverUpdateStatus.ts", import.meta.url).href };
|
||||
return next(specifier, context);
|
||||
} });
|
||||
const { applyServerUpdate, refreshServerUpdateState, checkServerUpdate, useServerUpdate } = await import("../src/lib/serverUpdate.ts");
|
||||
|
||||
test("a failed update rereads its unfinished transaction from disk", async () => {
|
||||
calls.length = 0;
|
||||
applyFailure = true;
|
||||
pending = { id: "interrupted", state: "failed", message: "Recovery required" };
|
||||
assert.equal(await applyServerUpdate("failed-case", { choices: {} }), false);
|
||||
assert.deepEqual(calls, ["apply", "disk"]);
|
||||
assert.equal(await refreshServerUpdateState("failed-case"), pending);
|
||||
});
|
||||
test("unreadable state blocks another apply until a successful reread", async () => {
|
||||
calls.length = 0;
|
||||
applyFailure = false;
|
||||
stateFailure = true;
|
||||
await applyServerUpdate("corrupt-case", { choices: {} });
|
||||
assert.equal(await applyServerUpdate("corrupt-case", { choices: {} }), false);
|
||||
assert.deepEqual(calls, ["apply", "disk"]);
|
||||
stateFailure = false;
|
||||
pending = null;
|
||||
assert.equal(await refreshServerUpdateState("corrupt-case"), null);
|
||||
assert.equal(await applyServerUpdate("corrupt-case", { choices: {} }), true);
|
||||
assert.deepEqual(calls, ["apply", "disk", "disk", "apply", "disk"]);
|
||||
});
|
||||
test("refresh after recovery returns the latest disk state, then its absence", async () => {
|
||||
pending = { id: "recovery", state: "failed", message: "Restore failed at database verification" };
|
||||
assert.equal(await refreshServerUpdateState("recovery-case"), pending);
|
||||
pending = null;
|
||||
assert.equal(await refreshServerUpdateState("recovery-case"), null);
|
||||
});
|
||||
|
||||
test("a rejected recheck removes an earlier cached update offer", async () => {
|
||||
const original = globalThis.__hotfixApi.checkUpdate;
|
||||
try {
|
||||
globalThis.__hotfixApi.checkUpdate = async () => ({ from_version: "0.261005.22", to_version: "0.261005.24", items: [], migrations: 1, pending_migrations: 1 });
|
||||
await checkServerUpdate("stale-offer");
|
||||
assert.equal(useServerUpdate("stale-offer").available, true);
|
||||
globalThis.__hotfixApi.checkUpdate = async () => { throw new Error("Installed version is newer than package"); };
|
||||
await checkServerUpdate("stale-offer");
|
||||
assert.equal(useServerUpdate("stale-offer").available, false);
|
||||
assert.equal(useServerUpdate("stale-offer").preview, null);
|
||||
} finally { globalThis.__hotfixApi.checkUpdate = original; }
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { isUpdateCurrent } from "../src/lib/serverUpdateStatus.ts";
|
||||
|
||||
const same = { from_version: "1", to_version: "1", items: [{ action: "skip" }], migrations: 10 };
|
||||
|
||||
test("same files and version cannot hide pending database repairs", () => {
|
||||
assert.equal(isUpdateCurrent({ ...same, pending_migrations: 1 }), false);
|
||||
assert.equal(isUpdateCurrent({ ...same, pending_migrations: 0 }), true);
|
||||
});
|
||||
test("unknown history is not presented as up to date", () => {
|
||||
assert.equal(isUpdateCurrent(same), false);
|
||||
assert.equal(isUpdateCurrent({ ...same, migrations: 0 }), true);
|
||||
});
|
||||
test("file changes and new releases remain available with no pending SQL", () => {
|
||||
assert.equal(isUpdateCurrent({ ...same, pending_migrations: 0, items: [{ action: "replace" }] }), false);
|
||||
assert.equal(isUpdateCurrent({ ...same, pending_migrations: 0, to_version: "2" }), false);
|
||||
});
|
||||
Reference in new issue
Block a user