check bonxes

This commit is contained in:
bryanthaboi
2026-08-13 13:22:18 -04:00
parent 9ceb1a8940
commit 941181d31c
12 changed files with 258 additions and 87 deletions
+18 -6
View File
@@ -56,10 +56,24 @@ do
local m = byId(LauncherMods.deriveList(manifests, { mods = { bbb = false } }))
check(m.aaa.enabled, "a mod with no options entry defaults to enabled")
check(not m.bbb.enabled, "an explicit false disables the mod")
check(m.aaa.enabledByVersion.red and m.aaa.enabledByVersion.gold,
"every row exposes its enabled answer for each game")
eq(m.aaa.status, "ok", "a healthy enabled mod is ok")
eq(m.aaa.statusDetail, "Ready", "ok detail reads Ready")
end
do
local manifests = {
mf({ id = "one", name = "One", version = "1.0.0", entry = "m.lua" }),
}
local row = byId(LauncherMods.deriveList(manifests, {
mods = { one = true }, modsByVersion = { gold = { one = false } },
}, "gold")).one
check(row.enabledByVersion.red, "the Red checkbox keeps the shared answer")
check(not row.enabledByVersion.gold, "the Gold checkbox reads Gold's answer")
check(not row.enabled, "the selected game's row state matches its checkbox")
end
-- ------- experimental defaults to disabled; github surfaces on the row
do
@@ -291,10 +305,9 @@ end
-- ------- enable flags: the panel reads exactly what the switch writes
--
-- One scope for both halves (SaveData.modScope). While per-game flags are a
-- preview the shared flag is the whole answer, so a modsByVersion overlay --
-- which an imported .g1rmodlist can plant, ModProfile.restoreVersions -- can
-- never leave the switch showing an answer no writer can reach.
-- One scope for both halves (SaveData.modScope). Per-game flags are live, so
-- a modsByVersion answer -- including one restored from a .g1rmodlist -- is
-- both what the launcher shows and what the next boot reads.
local SaveData = require("src.core.SaveData")
@@ -309,9 +322,8 @@ do
}
local planted = { mods = { one = true },
modsByVersion = { gold = { one = false } } }
local expected = SaveData.PER_VERSION_MODS and false or true
eq(byId(LauncherMods.deriveList(manifests, planted, "gold")).one.enabled,
expected, "the overlay is read exactly when a write can reach it")
false, "the overlay is read exactly when a write can reach it")
-- the round trip, the thing the dead switch failed: flip it, re-derive
local options = { mods = {} }
+26
View File
@@ -162,6 +162,32 @@ do
"modScope follows the PER_VERSION_MODS switch")
end
do
-- First launch after per-game controls shipped: preserve every old answer
-- and make the old implicit defaults explicit for the installed set.
local opts = {
mods = { old_on = true, old_off = false },
modsByVersion = { gold = { old_on = false } },
}
check(SaveData.migrateModEnablement(opts, {
{ id = "old_on" }, { id = "old_off" }, { id = "implicit" },
{ id = "lab", experimental = true },
}), "legacy mod state is migrated once")
check(opts.modsByVersionMigrated, "the migration is marked complete")
eq(SaveData.modEnabled(opts, "old_on", "red"), true,
"an old enabled mod is enabled for Red")
eq(SaveData.modEnabled(opts, "old_on", "gold"), false,
"an already-stored preview answer is preserved")
eq(SaveData.modEnabled(opts, "old_off", "blue"), false,
"an old disabled mod stays disabled for every game")
eq(SaveData.modEnabled(opts, "implicit", "yellow"), true,
"an old implicit default is enabled for every game")
eq(SaveData.modEnabled(opts, "lab", "red"), false,
"an experimental mod keeps its existing opt-in default")
check(not SaveData.migrateModEnablement(opts, { { id = "newer" } }),
"a later mod install does not rerun the legacy migration")
end
-- ------- a profile carries the per-game half of a setup
do