import { expect } from "@playwright/test";
import { apiRequest } from "./api.js";
import { expectId, readJsonSafe } from "./generalFixtures.js";
async function createRuleSetFixture(request, token, data) {
  const response = await apiRequest(request, "POST", "/api/business_rules/sets", { token, data });
  const body = await readJsonSafe(response);
  expect(response.status(), "POST /api/business_rules/sets should return 201").toBe(201);
  return expectId(body?.id, "Rule set creation response should include id");
}
async function deleteRuleSetIfExists(request, token, ruleSetId) {
  if (!token || !ruleSetId) return;
  await apiRequest(
    request,
    "DELETE",
    `/api/business_rules/sets?id=${encodeURIComponent(ruleSetId)}`,
    { token }
  ).catch(() => void 0);
}
async function createBusinessRuleFixture(request, token, data) {
  const response = await apiRequest(request, "POST", "/api/business_rules/rules", { token, data });
  const body = await readJsonSafe(response);
  expect(response.status(), "POST /api/business_rules/rules should return 201").toBe(201);
  return expectId(body?.id, "Business rule creation response should include id");
}
async function deleteBusinessRuleIfExists(request, token, ruleId) {
  if (!token || !ruleId) return;
  await apiRequest(
    request,
    "DELETE",
    `/api/business_rules/rules?id=${encodeURIComponent(ruleId)}`,
    { token }
  ).catch(() => void 0);
}
export {
  createBusinessRuleFixture,
  createRuleSetFixture,
  deleteBusinessRuleIfExists,
  deleteRuleSetIfExists
};
//# sourceMappingURL=businessRulesFixtures.js.map
