Move method to base page for reusability

This commit is contained in:
JennyNou 2025-11-18 13:49:45 -05:00
parent d9ef3f65b5
commit 9812c874df
3 changed files with 17 additions and 19 deletions

View file

@ -169,4 +169,20 @@ export class BasePage {
Soft.expect(actualProgressPercentage).toBe(progressPercentage);
console.log(`Progress Bar Percentage: Actual - ${actualProgressPercentage} vs Expected - ${progressPercentage}`);
}
async validateOEMPart( isOEM: boolean): Promise<void> {
if (isOEM!) {
// Get Vuex state from localStorage
const vuexState = JSON.parse(await this.page.evaluate('localStorage.getItem(\'vuex\')'));
// Validate the presence of an OEM part
if (vuexState.order?.lineItems?.glassParts?.length > 0) {
const firstGlassPartNumber = vuexState.order.lineItems.glassParts[0].partNumber;
await expect(firstGlassPartNumber.includes("OEM")).toBe(true);
} else {
throw new Error("No glass parts found in the order");
}
}
}
}

View file

@ -497,22 +497,6 @@ export class PaymentMethodPage extends BasePage {
return updatedAppointmentDate;
}
async validateOEMPart( isOEM: boolean): Promise<void> {
if (isOEM == true) {
// Get Vuex state from localStorage
const vuexState = JSON.parse(await this.page.evaluate('localStorage.getItem(\'vuex\')'));
// Validate the presence of an OEM part
if (vuexState.order?.lineItems?.glassParts?.length > 0) {
const firstGlassPartNumber = vuexState.order.lineItems.glassParts[0].partNumber;
await expect(firstGlassPartNumber.includes("OEM")).toBe(true);
} else {
throw new Error("No glass parts found in the order");
}
}
}
@step("PaymentMethodPage >> Select Payment Method: ")
async handlePaymentMethodPage(testData: Partial<ITestData>) {
const { servicePackage, isRecalVehicle, paymentDetails } = testData;

View file

@ -335,12 +335,10 @@ export async function handleInsuranceFlow(testCase: TestCase) {
await insuranceCompanyPage.handleInsuranceCompanyPage(testCase.testData);
// Handle OEM scenario
if (isOEM) {
if (isOEM === true) {
// User should be on heritage problem glass questions page after selecting Allstate on insurance company page
if (testCase.testData.isOEM === true) {
let HeritageProblemGlassQuestionsPage = testCase.pages.heritageProblemGlassQuestionsPage;
await HeritageProblemGlassQuestionsPage.handleHeritageProblemGlassQuestionsPage(testCase.testData);
}
}
// Handle ccPolicyInfoPage