import { Locator, Page, expect } from "@playwright/test";
import { WebAllLocators } from "../locator";
import { sellerProductSearchonFront } from "../../pageObjects/seller/seller-product-search";

export class ToCheckSellerProductFlagAfterReport {
    readonly page: Page;
    readonly locators: WebAllLocators;
    readonly sellerProductSearch: sellerProductSearchonFront;

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

    async AdminProductSectionGoto() {
        await this.page.goto("admin/marketplace/products");
    }

    async CheckSellerProductFlagAfterReport(
        product_name: string,
        customer_email: string
    ) {
        await this.AdminProductSectionGoto();
        await this.page.waitForTimeout(2000);

        await this.locators.searchInput.fill(product_name);
        await this.locators.searchInput.press("Enter");

        await this.locators.clickTotalFlagsButton.click(); //[a.text-sm.text-blue-600.underline]
        await this.page.waitForTimeout(2000);

        const customer_email_visible = await this.page
            .getByText(customer_email)
            .isVisible();

        if (customer_email_visible) {
            await expect(this.page.getByText(customer_email)).toBeVisible();
        } else {
            await expect(this.page.getByText(customer_email)).not.toBeVisible();
        }
    }
}
