meta {
  name: POST cast unknown ability deny
  type: http
  seq: 9
}

docs {
  NEO-79: unknown ability ids deny with reasonCode unknown_ability (catalog-backed IAbilityDefinitionRegistry).
  Pre-request binds slot 0 so cast validation reaches ability allowlist (not slot_unbound).
}

script:pre-request {
  const axios = require("axios");
  const baseUrl = bru.getEnvVar("baseUrl") || bru.getVar("baseUrl");
  const playerId = bru.getEnvVar("playerId") || bru.getVar("playerId") || "dev-local-1";
  await axios.post(
    `${baseUrl}/game/players/${playerId}/hotbar-loadout`,
    {
      schemaVersion: 1,
      slots: [{ slotIndex: 0, abilityId: "prototype_pulse" }],
    },
    { headers: { "Content-Type": "application/json" } },
  );
}

post {
  url: {{baseUrl}}/game/players/dev-local-1/ability-cast
  body: json
  auth: none
}

body:json {
  {
    "schemaVersion": 1,
    "slotIndex": 0,
    "abilityId": "not_a_real_ability",
    "targetId": null
  }
}

tests {
  test("status 200", function () {
    expect(res.getStatus()).to.equal(200);
  });

  test("accepted false with unknown_ability", function () {
    const body = res.getBody();
    expect(body.accepted).to.equal(false);
    expect(body.reasonCode).to.equal("unknown_ability");
  });
}
