59 lines
1.9 KiB
Plaintext
59 lines
1.9 KiB
Plaintext
meta {
|
|
name: GET combat targets
|
|
type: http
|
|
seq: 1
|
|
}
|
|
|
|
script:pre-request {
|
|
const { resetPrototypeCombatTargets } = require("./scripts/combat-targets-reset-helper.js");
|
|
await resetPrototypeCombatTargets(bru);
|
|
}
|
|
|
|
get {
|
|
url: {{baseUrl}}/game/world/combat-targets
|
|
body: none
|
|
auth: none
|
|
}
|
|
|
|
tests {
|
|
test("returns 200 JSON with schema v1 and targets array", function () {
|
|
expect(res.getStatus()).to.equal(200);
|
|
expect(res.getHeader("content-type")).to.contain("application/json");
|
|
const body = res.getBody();
|
|
expect(body.schemaVersion).to.equal(1);
|
|
expect(body.targets).to.be.an("array");
|
|
expect(body.targets.length).to.equal(3);
|
|
});
|
|
|
|
test("targets are ascending by targetId (ordinal)", function () {
|
|
const body = res.getBody();
|
|
const ids = body.targets.map((x) => x.targetId);
|
|
const sorted = [...ids].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
expect(ids).to.eql(sorted);
|
|
});
|
|
|
|
test("prototype NPC registry targets match id order", function () {
|
|
const body = res.getBody();
|
|
const ids = body.targets.map((x) => x.targetId);
|
|
expect(ids).to.eql([
|
|
"prototype_npc_elite",
|
|
"prototype_npc_melee",
|
|
"prototype_npc_ranged",
|
|
]);
|
|
});
|
|
|
|
test("all targets start at catalog max HP on fresh server", function () {
|
|
const body = res.getBody();
|
|
const byId = Object.fromEntries(body.targets.map((x) => [x.targetId, x]));
|
|
expect(byId.prototype_npc_elite.maxHp).to.equal(200);
|
|
expect(byId.prototype_npc_elite.currentHp).to.equal(200);
|
|
expect(byId.prototype_npc_elite.defeated).to.equal(false);
|
|
expect(byId.prototype_npc_melee.maxHp).to.equal(100);
|
|
expect(byId.prototype_npc_melee.currentHp).to.equal(100);
|
|
expect(byId.prototype_npc_melee.defeated).to.equal(false);
|
|
expect(byId.prototype_npc_ranged.maxHp).to.equal(80);
|
|
expect(byId.prototype_npc_ranged.currentHp).to.equal(80);
|
|
expect(byId.prototype_npc_ranged.defeated).to.equal(false);
|
|
});
|
|
}
|