Unify category autocomplete fields
All checks were successful
Deploy Sokko G / deploy (push) Successful in 17s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 17s
This commit is contained in:
parent
e3d823d0b1
commit
055fb78d60
21 changed files with 739 additions and 168 deletions
|
|
@ -120,10 +120,15 @@ test("text exchange round trips simple toolbox modules and resets checklist prog
|
|||
["Mega potion", 5, 0]
|
||||
]);
|
||||
|
||||
const links = normalizeLinksData({ links: [{ id: "l1", title: "Build", url: "https://example.com/build" }] });
|
||||
const links = normalizeLinksData({
|
||||
categoryOrder: ["Builds", "Guides"],
|
||||
links: [{ id: "l1", title: "Build", url: "https://example.com/build", category: "Builds" }]
|
||||
});
|
||||
const linksImport = importModuleText("links", exportModuleText("links", links), context);
|
||||
assert.equal(linksImport.ok, true);
|
||||
assert.equal(linksImport.data.links[0].url, "https://example.com/build");
|
||||
assert.equal(linksImport.data.links[0].category, "Builds");
|
||||
assert.deepEqual(linksImport.data.categoryOrder, ["Builds", "Guides"]);
|
||||
|
||||
const counters = normalizeCountersData({ counters: [{ id: "c1", label: "Win", value: 12 }, { id: "c2", label: "Loss", value: -2 }] });
|
||||
const countersImport = importModuleText("counters", exportModuleText("counters", counters), context);
|
||||
|
|
@ -295,11 +300,11 @@ test("rng simulator preserves rate precision and compacts storage", () => {
|
|||
const normalized = normalizeRngSimulatorData({
|
||||
activeRateId: "rate2",
|
||||
rates: [
|
||||
{ id: "rate1", label: "Drop rare", rate: "2.500" },
|
||||
{ id: "rate2", label: "Ultra rare", rate: "0.000004" },
|
||||
{ id: "rate1", label: "Drop rare", rate: "2.500", multiplier: 25, perHour: 10 },
|
||||
{ id: "rate2", label: "Ultra rare", rate: "0.000004", multiplier: 50, perHour: 30, perDay: 120, perMonth: 3600 },
|
||||
{ id: "bad", label: "", rate: "4" }
|
||||
],
|
||||
settings: { multiplier: 50, simulationDraws: 2000, perHour: 30, perDay: 120, perMonth: 3600 },
|
||||
settings: { simulationDraws: 2000 },
|
||||
history: [
|
||||
{ id: "h1", at: "2026-08-30T12:00:00.000Z", label: "Drop rare", rate: "2.500", multiplier: 50, draws: 100, successes: 4, fails: 400, longestFailStreak: 40 }
|
||||
]
|
||||
|
|
@ -307,10 +312,12 @@ test("rng simulator preserves rate precision and compacts storage", () => {
|
|||
|
||||
assert.equal(normalized.activeRateId, "rate2");
|
||||
assert.deepEqual(normalized.rates.map((rate) => [rate.label, rate.rate]), [["Drop rare", "2.500"], ["Ultra rare", "0.000004"]]);
|
||||
assert.deepEqual(normalized.rates.map((rate) => [rate.multiplier, rate.perHour, rate.perDay, rate.perMonth]), [[25, 10, 0, 0], [50, 30, 120, 3600]]);
|
||||
assert.equal(normalized.history, undefined);
|
||||
assert.equal(compactModuleDataForStorage("rngSimulator", normalizeRngSimulatorData({})), null);
|
||||
assert.equal(compactModuleDataForStorage("rngSimulator", normalized).settings.multiplier, 50);
|
||||
assert.equal(compactModuleDataForStorage("rngSimulator", normalized).settings.perMonth, 3600);
|
||||
assert.equal(compactModuleDataForStorage("rngSimulator", normalized).rates[1].multiplier, 50);
|
||||
assert.equal(compactModuleDataForStorage("rngSimulator", normalized).rates[1].perMonth, 3600);
|
||||
assert.equal(compactModuleDataForStorage("rngSimulator", normalized).settings.simulationDraws, 2000);
|
||||
assert.equal(compactModuleDataForStorage("rngSimulator", normalized).history, undefined);
|
||||
});
|
||||
|
||||
|
|
@ -357,10 +364,10 @@ test("rng simulator text exchange round trips rates and settings", () => {
|
|||
const rngSimulator = normalizeRngSimulatorData({
|
||||
activeRateId: "rate2",
|
||||
rates: [
|
||||
{ id: "rate1", label: "Drop rare", rate: "2.500" },
|
||||
{ id: "rate2", label: "Ultra rare", rate: "0.000004" }
|
||||
{ id: "rate1", label: "Drop rare", rate: "2.500", multiplier: 25, perHour: 20 },
|
||||
{ id: "rate2", label: "Ultra rare", rate: "0.000004", multiplier: 50, perHour: 40, perDay: 120, perMonth: 3600 }
|
||||
],
|
||||
settings: { multiplier: 50, simulationDraws: 5000, perHour: 40, perDay: 120, perMonth: 3600 }
|
||||
settings: { simulationDraws: 5000 }
|
||||
});
|
||||
const exported = exportModuleText("rngSimulator", rngSimulator);
|
||||
assert.doesNotMatch(exported, /\[history\]/);
|
||||
|
|
@ -368,9 +375,11 @@ test("rng simulator text exchange round trips rates and settings", () => {
|
|||
assert.equal(imported.ok, true);
|
||||
assert.deepEqual(imported.data.rates.map((rate) => [rate.label, rate.rate]), [["Drop rare", "2.500"], ["Ultra rare", "0.000004"]]);
|
||||
assert.equal(imported.data.rates.find((rate) => rate.id === imported.data.activeRateId)?.label, "Ultra rare");
|
||||
assert.equal(imported.data.settings.multiplier, 50);
|
||||
assert.equal(imported.data.rates.find((rate) => rate.label === "Drop rare")?.multiplier, 25);
|
||||
assert.equal(imported.data.rates.find((rate) => rate.label === "Ultra rare")?.multiplier, 50);
|
||||
assert.equal(imported.data.rates.find((rate) => rate.label === "Ultra rare")?.perHour, 40);
|
||||
assert.equal(imported.data.rates.find((rate) => rate.label === "Ultra rare")?.perMonth, 3600);
|
||||
assert.equal(imported.data.settings.simulationDraws, 5000);
|
||||
assert.equal(imported.data.settings.perHour, 40);
|
||||
assert.equal(imported.data.history, undefined);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue