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

export class ToCheckSellerFlagAfterReport {
    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 AdminSellerSectionGoto() {
        await this.page.goto("admin/marketplace/sellers");
    }

    async CheckSellerFlagAfterReport(email: string, customer_email: string) {
        await this.AdminSellerSectionGoto();
        await this.page.waitForTimeout(2000);

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

        await this.locators.clickTotalSellerFlagsButton.click();
        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();
        }
    }
}
