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

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

    constructor(page: Page) {
        this.page = page;
        this.locators = new WebAllLocators(page);
    }
    
    async sellerProductReviewByCustomer(review_star: number, title: string, comments: string) {
        await this.locators.reviewTabButton.click(); 
        await this.page.waitForTimeout(2000);
        
        await this.locators.writeAReviewButton.click();

        await this.page.waitForTimeout(2000);
        await this.locators.reviewRating.nth(review_star).click();
        await this.page.waitForTimeout(2000);

        await this.locators.writeAReviewTitle.fill(title);

        await this.locators.writeAReviewComments.fill(comments);

        await this.locators.submitReviewButton.click();

        await this.page.waitForTimeout(2000);
        await expect(this.locators.productReviewSuccessToast).toBeVisible();
    }
}
