meta {
  name: GET ability definitions
  type: http
  seq: 1
}

get {
  url: {{baseUrl}}/game/world/ability-definitions
  body: none
  auth: none
}

tests {
  test("returns 200 JSON with schema v1 and abilities 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.abilities).to.be.an("array");
    expect(body.abilities.length).to.equal(4);
  });

  test("abilities are ascending by id (ordinal)", function () {
    const body = res.getBody();
    const ids = body.abilities.map((x) => x.id);
    const sorted = [...ids].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
    expect(ids).to.eql(sorted);
  });

  test("frozen prototype four matches registry id order", function () {
    const body = res.getBody();
    const ids = body.abilities.map((x) => x.id);
    expect(ids).to.eql([
      "prototype_burst",
      "prototype_dash",
      "prototype_guard",
      "prototype_pulse",
    ]);
  });

  test("prototype_pulse row matches catalog", function () {
    const body = res.getBody();
    const row = body.abilities.find((x) => x.id === "prototype_pulse");
    expect(row).to.be.an("object");
    expect(row.displayName).to.equal("Prototype Pulse");
    expect(row.baseDamage).to.equal(25);
    expect(row.cooldownSeconds).to.equal(3);
    expect(row.abilityKind).to.equal("attack");
  });

  test("prototype_burst row matches catalog", function () {
    const body = res.getBody();
    const row = body.abilities.find((x) => x.id === "prototype_burst");
    expect(row).to.be.an("object");
    expect(row.displayName).to.equal("Prototype Burst");
    expect(row.baseDamage).to.equal(40);
    expect(row.cooldownSeconds).to.equal(5);
    expect(row.abilityKind).to.equal("attack");
  });

  test("prototype_guard row matches catalog", function () {
    const body = res.getBody();
    const row = body.abilities.find((x) => x.id === "prototype_guard");
    expect(row).to.be.an("object");
    expect(row.abilityKind).to.equal("utility");
    expect(row.baseDamage).to.equal(0);
    expect(row.cooldownSeconds).to.equal(6);
  });

  test("prototype_dash row matches catalog", function () {
    const body = res.getBody();
    const row = body.abilities.find((x) => x.id === "prototype_dash");
    expect(row).to.be.an("object");
    expect(row.abilityKind).to.equal("movement");
    expect(row.baseDamage).to.equal(0);
    expect(row.cooldownSeconds).to.equal(4);
  });
}
