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

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

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

    async reportSellerProduct(option: string) {
        await this.locators.sellerReportIssueIcon.click();

        await this.page.waitForTimeout(3000);

        await this.locators.fillsellerProductReason.selectOption({
            value: option,
        }); //[select[name="reason"]]
        await this.page.waitForTimeout(2000);

        await this.page.waitForTimeout(2000);

        await this.locators.reportIssueSubmitButton.click();
        await this.page.waitForTimeout(2000);

        const product_report_condition = await this.page
            .getByText("You have already reported this product")
            .nth(0)
            .isVisible();

        if (product_report_condition) {
            console.log("You have already reported this product");
        } else {
            console.log("Product Reported successfully");
            await expect(this.locators.reportProductSuccessToast).toBeVisible();
        }
    }
}
