neon-sprawl/bruno/neon-sprawl-server/inventory/Get inventory.bru

51 lines
1.6 KiB
Plaintext

meta {
name: GET inventory
type: http
seq: 1
}
docs {
NEO-55: per-player inventory read model; join with GET /game/world/item-definitions for stackMax and slot kinds.
Does not assume a fresh server — dev-local-1 inventory persists across Bruno runs (in-memory/Postgres).
Restart server (or truncate DB in Postgres mode) to see an all-empty grid again.
}
get {
url: {{baseUrl}}/game/players/dev-local-1/inventory
body: none
auth: none
}
tests {
test("returns 200 JSON with schema v1 and fixed slot arrays", function () {
expect(res.getStatus()).to.equal(200);
expect(res.getHeader("content-type")).to.contain("application/json");
const body = res.getBody();
expect(body.schemaVersion).to.equal(1);
expect(body.playerId).to.equal("dev-local-1");
expect(body.bagSlots).to.be.an("array");
expect(body.bagSlots.length).to.equal(24);
expect(body.equipmentSlots).to.be.an("array");
expect(body.equipmentSlots.length).to.equal(1);
});
test("empty slots omit itemId; occupied slots include itemId and positive quantity", function () {
const body = res.getBody();
const assertSlotShape = (slot) => {
expect(slot.slotIndex).to.be.a("number");
expect(slot.quantity).to.be.a("number");
expect(slot.quantity).to.be.at.least(0);
if (slot.quantity === 0) {
expect(slot.itemId).to.equal(undefined);
} else {
expect(slot.itemId).to.be.a("string");
expect(slot.itemId.length).to.be.at.least(1);
}
};
for (const slot of body.bagSlots) {
assertSlotShape(slot);
}
assertSlotShape(body.equipmentSlots[0]);
});
}