neon-sprawl/bruno/neon-sprawl-server/quest-progress/Accept duplicate.bru

57 lines
1.7 KiB
Plaintext

meta {
name: Accept duplicate
type: http
seq: 5
}
docs {
NEO-120: second accept on an active quest returns already_active with quest snapshot (no mutation).
Pre-request ensures gather intro is active (idempotent when seq 3 already ran).
}
script:pre-request {
const axios = require("axios");
const { resetGatherIntroQuestProgress } = require("./scripts/bruno-dev-fixture-helper");
const baseUrl = bru.getEnvVar("baseUrl") || bru.getVar("baseUrl");
const playerId = bru.getEnvVar("playerId") || bru.getVar("playerId");
const jsonHeaders = { headers: { "Content-Type": "application/json" } };
await resetGatherIntroQuestProgress(bru);
const setup = await axios.post(
`${baseUrl}/game/players/${playerId}/quests/prototype_quest_gather_intro/accept`,
{ schemaVersion: 1 },
{ ...jsonHeaders, validateStatus: () => true },
);
if (setup.status !== 200 || setup.data?.accepted !== true) {
throw new Error(
`duplicate setup accept failed: ${setup.status} ${JSON.stringify(setup.data)}`,
);
}
}
post {
url: {{baseUrl}}/game/players/{{playerId}}/quests/prototype_quest_gather_intro/accept
body: json
auth: none
}
body:json {
{
"schemaVersion": 1
}
}
tests {
test("duplicate accept returns already_active with active quest row", function () {
expect(res.getStatus()).to.equal(200);
const body = res.getBody();
expect(body.schemaVersion).to.equal(1);
expect(body.accepted).to.equal(false);
expect(body.reasonCode).to.equal("already_active");
expect(body.quest).to.be.an("object");
expect(body.quest.questId).to.equal("prototype_quest_gather_intro");
expect(body.quest.status).to.equal("active");
});
}