diff --git a/playwright-tests/pages/TpaConfirmationPage.ts b/playwright-tests/pages/TpaConfirmationPage.ts index fb0460e2..eda89d42 100644 --- a/playwright-tests/pages/TpaConfirmationPage.ts +++ b/playwright-tests/pages/TpaConfirmationPage.ts @@ -4,16 +4,30 @@ import { BasePage } from './BasePage'; export class TpaConfirmationPage extends BasePage { readonly page: Page; readonly successMessage: Locator; + readonly shopConfirmationMessage: Locator; readonly issPageValue = 'tpa-confirmation'; constructor(page: Page) { super(page); this.page = page; - this.successMessage = page.getByText('Success'); + this.successMessage = page.getByText('Thank you for submitting your claim; there is one final step.'); + this.shopConfirmationMessage = page.locator('div.subheader').first() + } + + async getTpaShopSelectedName() { + const sessionStorage = JSON.parse(await this.page.evaluate('sessionStorage.getItem(\'submittedOrder\')')); + const tpaShopSelectedName = sessionStorage.serviceLocation.provider.companyName; + return tpaShopSelectedName; } async validateSuccessMessage() { - await expect(this.successMessage).toBeVisible(); - } + const shopConfirmationMessageText = await this.shopConfirmationMessage.textContent(); + const tpaShopSelectedNameText = await this.getTpaShopSelectedName(); + await this.successMessage.waitFor({ state: 'visible' }); + await expect(this.successMessage).toBeVisible(); + expect.soft(shopConfirmationMessageText?.toLowerCase()).toContain( + ('Your information has been sent to' + ' ' + tpaShopSelectedNameText).toLowerCase() + ); + } } \ No newline at end of file diff --git a/playwright-tests/pages/TpaSearchPage.ts b/playwright-tests/pages/TpaSearchPage.ts index 8f4b8639..15d5e851 100644 --- a/playwright-tests/pages/TpaSearchPage.ts +++ b/playwright-tests/pages/TpaSearchPage.ts @@ -4,22 +4,15 @@ import { BasePage } from './BasePage'; export class TpaSearchPage extends BasePage { readonly page: Page; readonly firstLocationButton: Locator; - readonly doNotSeeMyShopButton: Locator; + //readonly doNotSeeMyShopButton: Locator; issPageValue = 'tpa-search'; constructor(page: Page) { super(page); this.page = page; - // this.firstLocationButton = page.locator("fieldset[aria-labelledby='chooseShop']/span").first(); - this.firstLocationButton = page.locator("#buttonLabelSpan").first(); - - this.doNotSeeMyShopButton = page.getByRole('link', { name: 'I don\'t see my shop' }); + this.firstLocationButton = page.locator('div.button-content').first(); } - - async selectDoNotSeeMyShop() { - await this.doNotSeeMyShopButton.click() - } - + async selectFirstLocation() { await this.firstLocationButton.click(); } diff --git a/playwright-tests/pages/TpaSubmitPage.ts b/playwright-tests/pages/TpaSubmitPage.ts index e563af7a..1726a75e 100644 --- a/playwright-tests/pages/TpaSubmitPage.ts +++ b/playwright-tests/pages/TpaSubmitPage.ts @@ -1,18 +1,38 @@ 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.deductible = page.getByText('Deductible $'); + 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(expDeductible) { - await expect(this.deductible).toContainText(expDeductible); + /* TODO: Fix flakiness of recal alert + /*async validateRecalAlert() { + await this.recalAlert.waitFor({ state: 'visible', timeout: 5000 }); + await this.learnMoreLink.click(); + await this.recalModal.waitFor({ state: 'visible', timeout: 5000 }); + await this.recalModal.getByRole('button', { name: 'Close' }).click(); + + }*/ + + async validateDeductible(claimDetails: IClaimDetails) { + await expect(this.deductible).toContainText(claimDetails.policyDeductible.toLocaleString()); } + + // TODO: Validate change preferred shop and contact details flows } \ No newline at end of file