fix: support mixed SCUM gift catalog entries
This commit is contained in:
@@ -5,7 +5,7 @@ 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, scumCatalogCategoryLabel, scumGiftCatalogCategory, tradeGoodsTypeLabel } from "../examples/scum-server-plugin/features/page.js";
|
||||
import { advanceMapPlayback, bundledVehicleImageUrl, collectMapPoints, mapPointStyle, mapVehicleCategory, playbackStartView, playbackFollowView, scumCatalogCategoryLabel, scumGiftCatalogCategory, scumGiftCatalogFilterKey, 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";
|
||||
@@ -302,8 +302,12 @@ describe("SCUM plugin feature module", () => {
|
||||
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\"");
|
||||
expect(pageSource).toContain("礼包目录分类");
|
||||
expect(scumGiftCatalogFilterKey(entry("BPC_Laika"))).toBe("vehicle");
|
||||
expect(scumGiftCatalogFilterKey(entry("BP_Bear2"))).toBe("animal");
|
||||
expect(scumGiftCatalogFilterKey(entry("BP_Zombie_Hospital_Normal"))).toBe("zombie");
|
||||
expect(scumGiftCatalogFilterKey(entry("BP_Drifter_Lvl_1"))).toBe("armed-npc");
|
||||
expect(pageSource).not.toContain("entry.kind !== \"item\"");
|
||||
});
|
||||
|
||||
it("labels catalog-backed item lists with SCUM categories", () => {
|
||||
@@ -317,6 +321,24 @@ describe("SCUM plugin feature module", () => {
|
||||
expect(tradeGoodsTypeLabel({ code: "unknown-item", typeName: "item" })).toBe("未知类型");
|
||||
});
|
||||
|
||||
it("uses catalog spawn commands for mixed gift contents", async () => {
|
||||
const pluginData = pluginDataActions();
|
||||
const dispatch = vi.fn<NonNullable<SCUMWorkspaceActions["dispatch"]>>(async (envelope) => ({ status: "queued", result: { jobId: envelope.requestId } }));
|
||||
await queueGiftDelivery({ pluginData, dispatch }, { code: "mixed-gift", name: "Mixed Gift", items: [
|
||||
{ catalogCode: "BPC_Laika", quantity: 1 },
|
||||
{ catalogCode: "BP_Bear2", quantity: 2 },
|
||||
{ catalogCode: "BP_Zombie_Hospital_Normal", quantity: 1 },
|
||||
{ catalogCode: "BP_Drifter_Lvl_1", quantity: 1 }
|
||||
] }, surfaceData.players[0]);
|
||||
expect(dispatch.mock.calls.map(([request]) => request.payload?.["input.command"])).toEqual([
|
||||
"#spawnvehicle BPC_Laika",
|
||||
"#spawnanimal BP_Bear2",
|
||||
"#spawnanimal BP_Bear2",
|
||||
"#spawnzombie BP_Zombie_Hospital_Normal",
|
||||
"#SpawnArmedNPC BP_Drifter_Lvl_1"
|
||||
]);
|
||||
});
|
||||
|
||||
it("renders map layers, filter controls, points, and selected-point details", () => {
|
||||
const view = renderAndCollect({ pageKey: "live-map", pageTitle: "实时地图" });
|
||||
expect(view.nodes).toContain("div:SCUM 地图图层");
|
||||
|
||||
Reference in New Issue
Block a user