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

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

interface TestFixtures {
  UserPermissionRole: RoleFixture;
  RolePermissionRole: RoleFixture;
  RoleAssignmentPermissionRole: RoleFixture;
}

export const test = base.extend<TestFixtures>({
  // oxlint-disable-next-line no-empty-pattern
  UserPermissionRole: async ({}, use) => {
    const role = await createRole({
      name: `UserPermRole ${Date.now()}`,
      permissions: ["user-management:user"],
    });
    await use(role);
  },
  // oxlint-disable-next-line no-empty-pattern
  RolePermissionRole: async ({}, use) => {
    const role = await createRole({
      name: `RolePermRole ${Date.now()}`,
      permissions: ["user-management:role"],
    });
    await use(role);
  },
  // oxlint-disable-next-line no-empty-pattern
  RoleAssignmentPermissionRole: async ({}, use) => {
    const role = await createRole({
      name: `RoleAssignPermRole ${Date.now()}`,
      permissions: ["user-management:roleAssignment"],
    });
    await use(role);
  },
});

export const expect = test.expect;
