// The following code is generated by playwright codegen.
// This is meant to be a reference.
import { test, expect } from "@playwright/test";

test("test", async ({ page }) => {
  await page.goto("http://localhost:8086/");
  await page.goto(
    "http://localhost:8086/wp-login.php?redirect_to=http%3A%2F%2Flocalhost%3A8086%2Fwp-admin%2F&reauth=1"
  );
  await page.getByLabel("Username or Email Address").fill("admin");
  await page.getByLabel("Username or Email Address").press("Tab");
  await page.getByLabel("Password", { exact: true }).fill("password");
  await page.getByLabel("Password", { exact: true }).press("Enter");
  await page.getByRole("link", { name: "Brands" }).click();
  await page.getByRole("textbox", { name: "Name" }).click();
  await page.getByRole("textbox", { name: "Name" }).fill("WooCommerce");
  await page.getByRole("textbox", { name: "Slug" }).click();
  await page.getByRole("textbox", { name: "Slug" }).fill("woocommerce");
  await page.getByRole("textbox", { name: "Description" }).click();
  await page
    .getByRole("textbox", { name: "Description" })
    .fill("All things WooCommerce!");
  await page.getByRole("button", { name: "Upload/Add image" }).click();
  await page.getByRole("tab", { name: "Media Library" }).click();
  await page.getByRole("checkbox", { name: "single-1.jpg" }).click();
  await page.getByRole("button", { name: "Use image" }).click();
  await page.getByRole("button", { name: "Add New Brand" }).click();
  await page.getByRole("textbox", { name: "Name" }).click();
  await page.getByRole("textbox", { name: "Name" }).fill("WooCommerce Music");
  await page.getByRole("textbox", { name: "Slug" }).click();
  await page.getByRole("textbox", { name: "Slug" }).fill("woocommerce-music");
  await page.getByRole("combobox", { name: "Parent Brand" }).selectOption("22");
  await page.getByRole("textbox", { name: "Description" }).click();
  await page
    .getByRole("textbox", { name: "Description" })
    .fill("WooCommerce Music!");
  await page.locator("#col-container").click();
  await page.getByRole("button", { name: "Upload/Add image" }).click();
  await page.getByRole("checkbox", { name: "album-1.jpg" }).click();
  await page.getByRole("checkbox", { name: "single-1.jpg" }).click();
  await page.getByRole("checkbox", { name: "album-1.jpg" }).click();
  await page.getByRole("button", { name: "Use image" }).click();
  await page.getByRole("button", { name: "Add New Brand" }).click();
  await page.getByRole("link", { name: "Edit “WooCommerce Music”" }).click();
  await page.getByLabel("Description").click();
  await page.getByLabel("Description").press("Meta+ArrowLeft");
  await page.getByLabel("Description").fill("Cool WooCommerce Music!");
  await page.getByRole("button", { name: "Update" }).click();
  await page.getByRole("link", { name: "Brands" }).click();
  await page.getByText("Cool WooCommerce Music!").click();
  await page
    .getByRole("link", { name: "View “WooCommerce Music” archive" })
    .click();
  await page.goto(
    "http://localhost:8086/wp-admin/edit-tags.php?taxonomy=product_brand&post_type=product"
  );
  await page.getByRole("textbox", { name: "Name" }).click();
  await page.getByRole("textbox", { name: "Name" }).fill("DeleteDummy");
  await page.getByRole("textbox", { name: "Slug" }).click();
  await page.getByRole("textbox", { name: "Slug" }).fill("delete-dummy");
  await page.getByRole("textbox", { name: "Description" }).click();
  await page
    .getByRole("textbox", { name: "Description" })
    .fill("A dummy brand to be deleted.");
  await page.getByRole("button", { name: "Upload/Add image" }).click();
  await page.getByRole("checkbox", { name: "beanie-with-logo-1.jpg" }).click();
  await page.getByRole("button", { name: "Use image" }).click();
  await page.getByRole("button", { name: "Add New Brand" }).click();
  await page.getByRole("link", { name: "“DeleteDummy” (Edit)" }).click();
  page.once("dialog", (dialog) => {
    console.log(`Dialog message: ${dialog.message()}`);
    dialog.dismiss().catch(() => {});
  });
  await page.getByRole("link", { name: "Delete" }).click();
  await page.getByRole("link", { name: "All Products" }).click();
  await page.getByRole("link", { name: "Single", exact: true }).click();
  await page
    .locator("#product_brand-23")
    .getByText("WooCommerce Music")
    .click();
  await page
    .locator("#product_brand-22")
    .getByText("WooCommerce", { exact: true })
    .click();
  await page.getByRole("button", { name: "Update" }).click();
  await page.getByRole("link", { name: "Brands", exact: true }).click();
  await page.getByRole("link", { name: "“WooCommerce Music” (Edit)" }).click();
  await page.getByRole("link", { name: "Brands" }).click();
  await page
    .getByRole("link", { name: "View “WooCommerce Music” archive" })
    .click();
  await page.getByRole("link", { name: "Single Sale! $2.00" }).click();
  await page.getByText("Brand: WooCommerce, WooCommerce Music").click();
  await page.getByRole("link", { name: "Single Sale! $2.00" }).click();
  await page.getByText("Brand: WooCommerce, WooCommerce Music").click();
  await page.getByRole("link", { name: "Dashboard" }).click();
  await page
    .locator("#toplevel_page_woocommerce-marketing")
    .getByRole("link", { name: "Coupons" })
    .click();
  await page.getByRole("link", { name: "Create your first coupon" }).click();
  await page.getByPlaceholder("0").click();
  await page.getByLabel("Coupon code").click();
  await page.getByLabel("Coupon code").fill("DISCOUNT5");
  await page.getByPlaceholder("Description (optional)").click();
  await page.getByPlaceholder("0").click();
  await page.getByPlaceholder("0").fill("5");
  await page.getByRole("link", { name: " Usage restriction" }).click();
  await page.getByPlaceholder("Any brand").click();
  await page.getByRole("option", { name: "WooCommerce", exact: true }).click();
  await page
    .getByRole("list")
    .filter({ hasText: "×WooCommerce" })
    .getByRole("textbox")
    .click();
  await page.getByRole("option", { name: "WooCommerce Music" }).click();
  await page.getByRole("button", { name: "Publish", exact: true }).click();
  await page
    .locator("#menu-posts-product")
    .getByRole("link", { name: "Products", exact: true })
    .click();
  await page.getByRole("link", { name: "View “Single”" }).click();
  await page.getByLabel("Single quantity").click({
    clickCount: 4,
  });
  await page.getByLabel("Single quantity").dblclick();
  await page.getByLabel("Single quantity").click();
  await page.getByLabel("Single quantity").fill("10");
  await page.getByRole("button", { name: "Add to cart" }).click();
  await page
    .locator("#content")
    .getByRole("link", { name: "View cart " })
    .click();
  await page.getByPlaceholder("Coupon code").click();
  await page.getByPlaceholder("Coupon code").fill("DISCOUNT5");
  await page.getByRole("button", { name: "Apply coupon" }).click();
  await page
    .getByRole("cell", { name: "Coupon: discount5", exact: true })
    .click();
  await page
    .getByRole("link", { name: " WooCommerce Core E2E Test Suite" })
    .click();
  await page
    .locator("#menu-posts-product")
    .getByRole("link", { name: "Products", exact: true })
    .click();
  await page
    .locator("#product_brand-22")
    .getByText("WooCommerce", { exact: true })
    .click();
  await page.getByRole("button", { name: "Update" }).click();
  await page.getByRole("link", { name: "View Product", exact: true }).click();
  page.once("dialog", (dialog) => {
    console.log(`Dialog message: ${dialog.message()}`);
    dialog.dismiss().catch(() => {});
  });
  await page.getByRole("button", { name: "Add to cart" }).click();
  page.once("dialog", (dialog) => {
    console.log(`Dialog message: ${dialog.message()}`);
    dialog.dismiss().catch(() => {});
  });
  await page.getByRole("button", { name: "Add to cart" }).click();
  await page.goto(
    "http://localhost:8086/wp-admin/post.php?post=10&action=edit"
  );
  await page.getByRole("link", { name: "Attributes" }).click();
  await page.getByRole("link", { name: "Variations" }).click();
  await page.getByRole("link", { name: "All Products" }).click();
  await page.getByRole("link", { name: "Hoodie", exact: true }).click();
  await page.getByRole("link", { name: "Variations" }).click();
  await page
    .locator("#product_brand-22")
    .getByText("WooCommerce", { exact: true })
    .click();
  await page.getByRole("button", { name: "Update" }).click();
  await page
    .getByText(
      "Thumbnail regeneration is running in the background. Depending on the amount of "
    )
    .click();
  await page.getByRole("link", { name: "View Product", exact: true }).click();
  await page.getByRole("combobox", { name: "Logo" }).selectOption("Yes");
  await page.getByRole("button", { name: "Add to cart" }).click();
  await page
    .locator("#content")
    .getByRole("link", { name: "View cart " })
    .click();
  await page
    .getByRole("row", {
      name: "Remove this item Product: Single Price: $2.00 Quantity: Single quantity Subtotal: $20.00",
    })
    .getByRole("link", { name: "Remove this item" })
    .click();
  await page
    .getByRole("cell", { name: "Coupon: discount5: -$5.00 [Remove]" })
    .click();
  await page.getByPlaceholder("Coupon code").click();
  await page.getByPlaceholder("Coupon code").fill("DISCOUNT5");
  await page.getByRole("button", { name: "Apply coupon" }).click();
});
