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

export class CreateFlag {

    readonly page: Page;
    readonly locators: WebAllLocators;

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

    async goto() {
        await this.page.goto("admin/marketplace/flag-reasons");
    }

    async createProductFlagReason() {
        await this.locators.createFlagButton.click();
        await this.page.waitForTimeout(2000);
        await this.locators.adminLabel.fill("xyz");
        await this.locators.engLabel.fill("xyz");
        await this.locators.reasonTypeDropdown.selectOption("product");
        await this.locators.flagStatusToggle.click();
        await this.locators.saveButton.click();
        await this.page.waitForTimeout(2000);
        await expect(this.locators.flagSuccessToast).toBeVisible();
    }

    async createSellerFlagReason() {
        await this.locators.createFlagButton.click();
        await this.locators.page.waitForTimeout(2000);
        await this.locators.adminLabel.fill("xyz");
        await this.locators.engLabel.fill("xyz");
        await this.locators.reasonTypeDropdown.selectOption("seller");
        await this.locators.flagStatusToggle.click();
        await this.locators.saveButton.click();
        await this.page.waitForTimeout(2000);
        await expect(this.locators.flagSuccessToast).toBeVisible();
    }
}
