import { createRole, updateRole } from "../utils/role-factory";
import { test as base } from "./user";

type RoleFixture = Awaited<ReturnType<typeof createRole>>;

interface TestFixtures {
  AuditRole: RoleFixture;
  UpdatedAuditRole: RoleFixture;
}

export const test = base.extend<TestFixtures>({
  // oxlint-disable-next-line no-empty-pattern
  AuditRole: async ({}, use) => {
    const role = await createRole({
      name: `AuditRole ${Date.now()}`,
      permissions: ["user-management:role"],
    });
    await use(role);
  },
  // oxlint-disable-next-line no-empty-pattern
  UpdatedAuditRole: async ({}, use) => {
    const role = await createRole({
      name: `UpdatedAuditRole ${Date.now()}`,
      permissions: ["user-management:role"],
    });
    await updateRole({
      roleId: role.roleId,
      permissions: ["user-management:role", "user-management:user"],
    });
    await use(role);
  },
});

export const expect = test.expect;
