fix: classify SCUM gift items

This commit is contained in:
npc0-hue
2026-09-20 16:16:02 +08:00
parent a10878deee
commit 4abdf75c77
2 changed files with 66 additions and 7 deletions
+25 -1
View File
@@ -5,7 +5,8 @@ import { fileURLToPath } from "node:url";
import { migrateConfigurationRecord, migrateGiftGrantRecord, migratePlayerProfileRecord, migratePlayerRecord, migrateStatePatchRecord, migrateTrajectoryHistoryRecord, migrateTrajectoryRecord, migrationStatus } from "../examples/scum-server-plugin/features/migration.js";
import { createGiftDelivery, deleteGiftDefinition, loadSCUMSurface, parseGiftCommands, parseGiftItems, queueGiftDelivery, resetGiftClaim, resetPendingGift, resolveMapBounds, saveEventProduce, saveGiftDefinition, saveMapSettings, scumCollections, startEvent, type RecordMap, type SCUMSurfaceData, type SCUMWorkspaceActions } from "../examples/scum-server-plugin/features/page-data.js";
import { advanceMapPlayback, bundledVehicleImageUrl, collectMapPoints, mapPointStyle, mapVehicleCategory, playbackStartView, playbackFollowView } from "../examples/scum-server-plugin/features/page.js";
import { advanceMapPlayback, bundledVehicleImageUrl, collectMapPoints, mapPointStyle, mapVehicleCategory, playbackStartView, playbackFollowView, scumCatalogCategoryLabel, scumGiftCatalogCategory, tradeGoodsTypeLabel } from "../examples/scum-server-plugin/features/page.js";
import { scumCatalogEntries } from "../examples/scum-server-plugin/features/scum-catalog.js";
import type { MapTrack, MapTrackPoint } from "../examples/scum-server-plugin/features/contracts.js";
import { renderPluginPage } from "../examples/scum-server-plugin/page-bundle/index.js";
import { configurationCatalog, validateConfigPatch, validateStatePatch, validateVehicleSpawn, vehicleSpawnCatalog } from "../examples/scum-server-plugin/features/schemas.js";
@@ -293,6 +294,29 @@ describe("SCUM plugin feature module", () => {
expect(details.buttons.map((button) => button.label)).toEqual(expect.arrayContaining(["关闭", "编辑礼包"]));
});
it("uses SCUM item categories for gift catalog selection", () => {
const entry = (code: string) => scumCatalogEntries.find((item) => item.code === code)!;
expect(scumGiftCatalogCategory(entry("1H_Cleaver"))).toBe("weapons");
expect(scumGiftCatalogCategory(entry("Aloe_Vera"))).toBe("food");
expect(scumGiftCatalogCategory(entry("Aspirin"))).toBe("medical");
expect(scumGiftCatalogCategory(entry("Animal_Skin"))).toBe("components");
expect(scumGiftCatalogCategory(entry("Air_Pump"))).toBe("tools");
expect(scumGiftCatalogCategory(entry("Backpack_02_01"))).toBe("gear");
expect(pageSource).toContain("礼包物品分类");
expect(pageSource).toContain("entry.kind !== \"item\"");
});
it("labels catalog-backed item lists with SCUM categories", () => {
const entry = (code: string) => scumCatalogEntries.find((item) => item.code === code)!;
expect(scumCatalogCategoryLabel(entry("Aloe_Vera"))).toBe("食物");
expect(scumCatalogCategoryLabel(entry("Aspirin"))).toBe("医疗");
expect(scumCatalogCategoryLabel(entry("1H_Cleaver"))).toBe("武器");
expect(tradeGoodsTypeLabel({ code: "Aloe_Vera", catalogType: "item" })).toBe("食物");
expect(tradeGoodsTypeLabel({ code: "Aspirin", catalogType: "item" })).toBe("医疗");
expect(tradeGoodsTypeLabel({ code: "#spawnvehicle BPC_Laika_C", type: "21" })).toBe("载具");
expect(tradeGoodsTypeLabel({ code: "unknown-item", typeName: "item" })).toBe("未知类型");
});
it("renders map layers, filter controls, points, and selected-point details", () => {
const view = renderAndCollect({ pageKey: "live-map", pageTitle: "实时地图" });
expect(view.nodes).toContain("div:SCUM 地图图层");