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

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

  async goto() {
    await this.page.goto("/product/category");
  }

  get heading() {
    return this.page.getByRole("heading", { name: /^categories$/i });
  }

  get createButton() {
    return this.page.getByRole("link", { name: /create/i });
  }

  get table() {
    return this.page.getByRole("table");
  }

  getRow(name: string) {
    return this.page.getByRole("row").filter({ hasText: name });
  }

  getViewLink(name: string) {
    return this.getRow(name).getByRole("link", { name: /view/i });
  }
}
