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

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

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

    async registerGoto() {
        await this.page.goto("seller/register");
    }

    async loginGoto() {
        await this.page.goto("seller/login");
    }

    async registerSeller(
        sellerName: string,
        email: string,
        password: string,
        businessName: string,
        shopSlug: string
    ) {
        await this.locators.sellerNameInput.fill(sellerName);
        await this.locators.emailInput.fill(email);
        await this.locators.passwordInput.fill(password);
        await this.locators.confirmPasswordInput.fill(password);
        await this.locators.businessName.fill(businessName);
        await this.locators.slugInput.fill(shopSlug);
        await this.locators.registerButton.click();
        await expect(this.locators.sellerCreateSuccessToast).toBeVisible();
    }

    async loginSeller(email: string, password: string) {
        await this.locators.emailInput.fill(email);
        await this.locators.passwordInput.fill(password);

        await this.locators.sellerLoginButton.click();
    }
}
