import { expect, type Locator, type Page } from '@playwright/test';
import { BasePage } from './BasePage';
import { IClaimDetails } from '@business-logic/types/CustomerDetails';

export class TpaSubmitPage extends BasePage {
    readonly page: Page;
    readonly deductible: Locator;
    readonly recalAlert: Locator;
    readonly learnMoreLink: Locator;
    readonly recalModal: Locator;
    readonly closeRecalModalButton: Locator;
    issPageValue = 'tpa-submit';

    constructor(page: Page) {
        super(page);
        this.page = page;
        this.recalAlert = page.getByRole('alert').filter({ hasText: 'Some vehicle safety features may not work properly.'});
        this.learnMoreLink = page.getByRole('link', { name: 'Learn more' });
        this.recalModal = page.getByRole('dialog').filter({ hasText: 'IMPORTANT SERVICE REQUIRED' }).first();
        this.closeRecalModalButton = page.locator('.modalbtn', { hasText: 'Close' });
        this.deductible = page.locator('span#deductible-value, span.deductible-value');
    }

    async validateDeductible(claimDetails: IClaimDetails) {
        await expect(this.deductible).toContainText(claimDetails.policyDeductible.toLocaleString());
    }

    // TODO: Validate change preferred shop and contact details flows
}