neon-sprawl/bruno/neon-sprawl-server/perk-state/Post branch select deny bra...

73 lines
2.0 KiB
Plaintext

meta {
name: POST branch select deny branch already chosen
type: http
seq: 4
}
docs {
NEO-48: self-contained deny — pre-request grants salvage to level 2 and picks scrap_efficiency;
main request conflicts with bulk_haul on the same tier. Expects selected false + branch_already_chosen.
}
script:pre-request {
const baseUrl = bru.getVar("baseUrl");
const grant = await bru.sendRequest({
method: "POST",
url: `${baseUrl}/game/players/dev-local-1/skill-progression`,
headers: { "Content-Type": "application/json" },
data: {
schemaVersion: 1,
skillId: "salvage",
amount: 100,
sourceKind: "activity",
},
});
if (grant.status !== 200) {
throw new Error(`salvage grant failed: ${grant.status}`);
}
const firstPick = await bru.sendRequest({
method: "POST",
url: `${baseUrl}/game/players/dev-local-1/perk-state`,
headers: { "Content-Type": "application/json" },
data: {
schemaVersion: 1,
skillId: "salvage",
tierIndex: 1,
branchId: "scrap_efficiency",
},
});
if (firstPick.status !== 200 || firstPick.data?.selected !== true) {
throw new Error(`tier-1 pick failed: ${firstPick.status} ${JSON.stringify(firstPick.data)}`);
}
}
post {
url: {{baseUrl}}/game/players/dev-local-1/perk-state
body: json
auth: none
}
body:json {
{
"schemaVersion": 1,
"skillId": "salvage",
"tierIndex": 1,
"branchId": "bulk_haul"
}
}
tests {
test("denies second pick with branch_already_chosen", function () {
expect(res.getStatus()).to.equal(200);
const body = res.getBody();
expect(body.schemaVersion).to.equal(1);
expect(body.selected).to.equal(false);
expect(body.reasonCode).to.equal("branch_already_chosen");
expect(body.unlockedEvents).to.be.an("array").that.is.empty;
const salvage = body.perkState.branchPicks.find((t) => t.skillId === "salvage");
expect(salvage).to.be.an("object");
const pick = salvage.picks.find((p) => p.tierIndex === 1);
expect(pick.branchId).to.equal("scrap_efficiency");
});
}