meta {
  name: POST interact gather then GET inventory
  type: http
  seq: 12
}

docs {
  NEO-63 happy path: move near prototype_resource_node_alpha, interact once, then GET inventory and assert scrap_metal_bulk quantity >= 1.
}

script:pre-request {
  const axios = require("axios");
  const baseUrl = bru.getEnvVar("baseUrl") || bru.getVar("baseUrl");
  const playerId = bru.getEnvVar("playerId") || bru.getVar("playerId");
  await axios.post(
    `${baseUrl}/game/players/${playerId}/move`,
    {
      schemaVersion: 1,
      target: { x: 10, y: 0.9, z: -6 },
    },
    { headers: { "Content-Type": "application/json" } },
  );
  await axios.post(
    `${baseUrl}/game/players/${playerId}/interact`,
    {
      schemaVersion: 1,
      interactableId: "prototype_resource_node_alpha",
    },
    { headers: { "Content-Type": "application/json" } },
  );
}

get {
  url: {{baseUrl}}/game/players/{{playerId}}/inventory
  body: none
  auth: none
}

tests {
  test("inventory includes scrap_metal_bulk after gather interact", function () {
    expect(res.getStatus()).to.equal(200);
    const body = res.getBody();
    const total = body.bagSlots
      .filter((s) => s.itemId === "scrap_metal_bulk")
      .reduce((sum, s) => sum + s.quantity, 0);
    expect(total).to.be.at.least(1);
  });
}
