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

export class CreateAttribute {
    // Locators

    readonly page: Page;
    readonly locators: WebAllLocators;

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

    // Create methods
    async goto() {
        await this.page.goto("admin/marketplace/seller-attributes");
    }

    async createAttribute(attribute_code: string) {
        await this.locators.createSellerAttributeButton.click();
        await this.page.waitForTimeout(2000);
        await this.locators.adminLabel.fill(attribute_code);
        await this.locators.engLabel.fill(attribute_code);
        await this.locators.attributeCode.fill(attribute_code);
        await this.locators.attributeType.selectOption("textarea");
        await this.locators.saveAttributeButton.click();
        await expect(this.locators.attributeSuccessToast).toBeVisible();
    }
}
