import test, { Locator, Page } from '@playwright/test';

import { BasePage } from './BasePage';

// This file is an example of a Page Object Model

export class LeadgenHomePage extends BasePage {
    
    readonly page: Page;
    readonly letsGetStartedButton: Locator;
    readonly zipTextbox: Locator;
    url = process.env['BASE_URL']!;

    constructor(page: Page) {
        super(page);

        this.page = page;
        this.letsGetStartedButton = this.page.locator('#zipCodeTextboxButton');
        this.zipTextbox = this.page.getByPlaceholder('Enter service ZIP code');
    }

    async goto() {
        await this.page.goto(process.env['BASE_URL']!);
        // await this.validateURL(this.url);
    }

    async letsGetStarted(zip: string) {
        await this.zipTextbox.fill(zip);
        await this.letsGetStartedButton.click();
    }

    async isCurrentVariant(): Promise<boolean> {
        return await this.zipTextbox.isVisible();
    }

}