import { Locator, Page, expect } from "@playwright/test";
import { WebAllLocators } from "../locator";

export class SellerAllowProducts {

  readonly page: Page;
  readonly locators: WebAllLocators;


  constructor(page: Page) {
    this.page = page;
    this.locators = new WebAllLocators(page);
  }

  async gotoAllowProducts() {
    await this.page.goto('admin/marketplace/sellers');
  }

  async allowProducts(productTypes: string[], sellerEmail: string) {
    await this.page.waitForTimeout(2000);
    await this.locators.searchSellerInput.fill(sellerEmail);
    await this.locators.searchSellerInput.press('Enter');
    await this.locators.editButton.click();
    await this.locators.productType.selectOption(productTypes);
    await this.locators.allowSellerSaveButton.click();

    await this.page.waitForTimeout(2000); 
    await this.locators.updateSuccessToast.waitFor({ state: 'attached', timeout: 30000 });
    await expect(this.locators.updateSuccessToast).toBeVisible();
  }
}