import type { Page } from "@playwright/test";

export class RoleDetailPage {
  private page: Page;
  constructor(page: Page) {
    this.page = page;
  }

  async goto(id: string) {
    await this.page.goto(`/user-management/role/${id}`);
  }

  get heading() {
    return this.page.getByRole("heading", { name: /role detail/i });
  }

  get nameField() {
    return this.page.getByText(/name/i).first();
  }

  get descriptionField() {
    return this.page.getByText(/description/i).first();
  }

  get statusField() {
    return this.page.getByText(/status/i).first();
  }

  get permissionsField() {
    return this.page.getByText(/permissions/i).first();
  }

  get editButton() {
    return this.page.getByRole("button", { name: /edit role/i });
  }

  get deactivateButton() {
    return this.page.getByRole("button", { name: /deactivate/i });
  }

  get reactivateButton() {
    return this.page.getByRole("button", { name: /reactivate/i });
  }

  get backButton() {
    return this.page.getByRole("button", { name: /back/i });
  }
}
