neon-sprawl/bruno/neon-sprawl-server/quest-progress/Get quest progress after ga...

103 lines
3.3 KiB
Plaintext

meta {
name: GET quest progress after gather intro complete
type: http
seq: 8
}
docs {
NEO-129: accept gather intro, complete via three alpha gathers, GET quest-progress asserts completionRewardSummary; second GET unchanged.
}
script:pre-request {
const axios = require("axios");
const baseUrl = bru.getEnvVar("baseUrl") || bru.getVar("baseUrl");
const playerId = bru.getEnvVar("playerId") || bru.getVar("playerId");
const headers = { "Content-Type": "application/json" };
await axios.post(
`${baseUrl}/game/players/${playerId}/quests/prototype_quest_gather_intro/accept`,
{ schemaVersion: 1 },
{ headers, validateStatus: () => true },
);
await axios.post(
`${baseUrl}/game/players/${playerId}/move`,
{
schemaVersion: 1,
target: { x: 10, y: 0.9, z: -6 },
},
{ headers },
);
for (let i = 0; i < 3; i += 1) {
const interact = await axios.post(
`${baseUrl}/game/players/${playerId}/interact`,
{
schemaVersion: 1,
interactableId: "prototype_resource_node_alpha",
},
{ headers, validateStatus: () => true },
);
if (interact.status !== 200 || !interact.data?.success) {
throw new Error(`expected gather interact to succeed, got ${JSON.stringify(interact.data)}`);
}
}
const firstGet = await axios.get(
`${baseUrl}/game/players/${playerId}/quest-progress`,
{ validateStatus: () => true },
);
if (firstGet.status !== 200) {
throw new Error(`expected first GET quest-progress to return 200, got ${firstGet.status}`);
}
const firstRow = firstGet.data.quests.find(
(x) => x.questId === "prototype_quest_gather_intro",
);
if (!firstRow || firstRow.status !== "completed" || !firstRow.completionRewardSummary) {
throw new Error(
`expected first GET gather intro completed with summary, got ${JSON.stringify(firstRow)}`,
);
}
bru.setVar(
"firstGatherCompletionRewardSummary",
JSON.stringify(firstRow.completionRewardSummary),
);
}
get {
url: {{baseUrl}}/game/players/{{playerId}}/quest-progress
body: none
auth: none
}
tests {
test("gather intro row is completed with completionRewardSummary", function () {
expect(res.getStatus()).to.equal(200);
const body = res.getBody();
const row = body.quests.find((x) => x.questId === "prototype_quest_gather_intro");
expect(row).to.be.an("object");
expect(row.status).to.equal("completed");
expect(row.completionRewardSummary).to.be.an("object");
expect(row.completionRewardSummary.itemGrants).to.eql([]);
expect(row.completionRewardSummary.skillXpGrants).to.eql([
{ skillId: "salvage", amount: 25 },
]);
});
test("second GET completionRewardSummary matches first GET", function () {
const body = res.getBody();
const row = body.quests.find((x) => x.questId === "prototype_quest_gather_intro");
const firstSummary = JSON.parse(bru.getVar("firstGatherCompletionRewardSummary"));
expect(row.completionRewardSummary).to.eql(firstSummary);
});
test("active and not_started rows omit completionRewardSummary", function () {
const body = res.getBody();
for (const row of body.quests) {
if (row.status === "not_started" || row.status === "active") {
expect(row.completionRewardSummary).to.equal(undefined);
}
}
});
}