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

export default async function openIngredientBottomSheet(
  page: Page,
  ingredientTitle: string,
) {
  const ingredientItem = page.getByRole("button", {
    name: ingredientTitle,
  });

  await ingredientItem.dispatchEvent("touchstart");

  const bottomSheet = page.getByRole("dialog", {
    name: new RegExp(ingredientTitle),
  });

  await bottomSheet.waitFor({ state: "visible" });
  await bottomSheet.dispatchEvent("touchend");
}
