neon-sprawl/bruno/neon-sprawl-server/interaction/Post interact depleted node...

68 lines
1.7 KiB
Plaintext

meta {
name: POST interact depleted node deny
type: http
seq: 13
}
docs {
NEO-63: uses prototype_urban_bulk_delta (not alpha) so earlier interaction requests in this collection do not pre-deplete capacity. Pre-request gathers until node_depleted (craft spine may consume one gather first). POST interact should deny with node_depleted.
}
script:pre-request {
const axios = require("axios");
const baseUrl = bru.getEnvVar("baseUrl") || bru.getVar("baseUrl");
const playerId = bru.getEnvVar("playerId") || bru.getVar("playerId");
const nodeId = "prototype_urban_bulk_delta";
await axios.post(
`${baseUrl}/game/players/${playerId}/move`,
{
schemaVersion: 1,
target: { x: 16, y: 0.9, z: 0 },
},
{ headers: { "Content-Type": "application/json" } },
);
while (true) {
const res = await axios.post(
`${baseUrl}/game/players/${playerId}/interact`,
{
schemaVersion: 1,
interactableId: nodeId,
},
{ headers: { "Content-Type": "application/json" } },
);
if (res.data?.allowed === true) {
continue;
}
if (res.data?.reasonCode === "node_depleted") {
break;
}
throw new Error(`expected gather to succeed or end with node_depleted, got ${JSON.stringify(res.data)}`);
}
}
post {
url: {{baseUrl}}/game/players/{{playerId}}/interact
body: json
auth: none
}
headers {
content-type: application/json
}
body:json {
{
"schemaVersion": 1,
"interactableId": "prototype_urban_bulk_delta"
}
}
tests {
test("depleted node interact denied with node_depleted", function () {
expect(res.getStatus()).to.equal(200);
const body = res.getBody();
expect(body.allowed).to.equal(false);
expect(body.reasonCode).to.equal("node_depleted");
});
}