neon-sprawl/bruno/neon-sprawl-server/craft/Post craft deny insufficien...

52 lines
1.4 KiB
Plaintext

meta {
name: POST craft deny insufficient materials
type: http
seq: 1
}
docs {
NEO-70: craft without seeded materials denies with insufficient_materials. Requires empty bag (run before spine or on fresh server).
}
script:pre-request {
const { getInventory, sumItemQuantity } = require("./scripts/inventory-api-helper.js");
const inventory = await getInventory(bru);
const scrap = sumItemQuantity(inventory, "scrap_metal_bulk");
const refined = sumItemQuantity(inventory, "refined_plate_stock");
if (scrap >= 5 || refined > 0) {
throw new Error(
`expected empty craft inputs before insufficient_materials test; scrap=${scrap} refined=${refined} — restart server or run this request before spine`,
);
}
bru.setVar("scrapBeforeInsufficientDeny", scrap);
}
post {
url: {{baseUrl}}/game/players/{{playerId}}/craft
body: json
auth: none
}
headers {
content-type: application/json
}
body:json {
{
"schemaVersion": 1,
"recipeId": "refine_scrap_standard"
}
}
tests {
test("denies with insufficient_materials", function () {
expect(res.getStatus()).to.equal(200);
const body = res.getBody();
expect(body.schemaVersion).to.equal(1);
expect(body.success).to.equal(false);
expect(body.reasonCode).to.equal("insufficient_materials");
expect(body.inputsConsumed).to.be.an("array").that.is.empty;
expect(body.outputsGranted).to.be.an("array").that.is.empty;
});
}