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

export class SellerAssignAdminProduct {
    readonly page: Page;
    readonly locators: WebAllLocators;

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

    async sellerProductPageGoto() {
        await this.page.goto("seller/products");
    }

    async sellerAssignAdminProduct(
        productname: string,
        conditionType: string,
        shortDescription: string,
        price: Number,
        inventory: Number
    ) {
        await this.locators.createProductButton.click();
        await this.page.waitForTimeout(2000);

        await this.locators.searchAdminProduct.fill(productname);

        await this.locators.clickSuggestProduct.click();
        await this.page.waitForTimeout(2000);
        await this.locators.productCondition.selectOption(conditionType);
        await this.locators.descriptiontextarea.fill(shortDescription);
        await this.locators.assignQuantity.fill(inventory.toString());

        await this.locators.productPrice.fill(price.toString());
        await this.locators.clickAssignSaveButton.click();
        await this.page.waitForTimeout(2000);

        await expect(this.locators.assignSuccessToast).toBeVisible();
    }
}
