Updates on report, order confirmation

This commit is contained in:
Siraj Shaik 2025-02-18 16:10:11 -05:00
parent 6d5a0524e3
commit 5f22af740b
4 changed files with 32 additions and 29 deletions

View file

@ -61,6 +61,21 @@ export function consolidateJsonReport() {
}
function generateSummaryTable(existingIssues: { [key: string]: any[] }): string {
let totalCritical = 0;
let totalSerious = 0;
let totalModerate = 0;
let totalMinor = 0;
let totalTotal = 0;
Object.keys(existingIssues).forEach(pageName => {
const issues = existingIssues[pageName];
totalCritical += issues.filter(issue => issue.impact === 'critical').length;
totalSerious += issues.filter(issue => issue.impact === 'serious').length;
totalModerate += issues.filter(issue => issue.impact === 'moderate').length;
totalMinor += issues.filter(issue => issue.impact === 'minor').length;
totalTotal += issues.length;
});
return `
<table class="summary-table" role="table">
<thead>
@ -94,6 +109,16 @@ function generateSummaryTable(existingIssues: { [key: string]: any[] }): string
`;
}).join('')}
</tbody>
<tfoot>
<tr>
<td><b>Total</b></td>
<td><b>${totalCritical}</b></td>
<td><b>${totalSerious}</b></td>
<td><b>${totalModerate}</b></td>
<td><b>${totalMinor}</b></td>
<td><b>${totalTotal}</b></td>
</tr>
</tfoot>
</table>
`;
}
@ -334,4 +359,4 @@ function isDuplicateIssue(existingIssues: any[], newIssue: any): boolean {
return existingIssues.some(issue => {
return issue.id === newIssue.id && issue.pageName === newIssue.pageName;
});
}
}

View file

@ -35,7 +35,7 @@ export class OrderConfirmationPage extends BasePage {
async validateOrderConfirmationPage(testData: Partial<ITestData>) {
// Destructure data we use
const { vehicleDetails, customerDetails, servicePackage, isItac,
isNoComp, isPolicyFound, claimDetails, paymentDetails, isUseVehicleOnPolicy } = testData;
isNoComp, isPolicyFound, claimDetails, paymentDetails, isUseVehicleOnPolicy } = testData;
await this.serviceText.waitFor({ state: "visible" });
await this.logOrderNumber();
@ -45,7 +45,7 @@ export class OrderConfirmationPage extends BasePage {
const emailTextValue = await this.emailText.textContent();
const servicePackageValue = await this.cartServicePackageText.textContent();
const amountDueValue = await this.amountDueText.textContent();
const deductibleTextValue = (isItac || isNoComp)? null: await this.deductibleText.textContent();
const deductibleTextValue = (isItac || isNoComp) ? null : await this.deductibleText.textContent();
const subtotalTextValue = await this.subtotalText.textContent();
const finalAmountDueValue = await this.finalAmountDue.textContent();
@ -59,7 +59,7 @@ export class OrderConfirmationPage extends BasePage {
// Service package validations
await expect.soft(this.cartServicePackageText).toContainText(`${servicePackage}`)
if (servicePackage === ServicePackage.Premium || servicePackage === ServicePackage.Standard) {
if ((servicePackage === ServicePackage.Premium && testData.isReplace === true) || servicePackage === ServicePackage.Standard) {
expect.soft(servicePackageValue).toContain('New wiper blades');
}
if (servicePackage === ServicePackage.Premium) {
@ -76,7 +76,7 @@ export class OrderConfirmationPage extends BasePage {
if (isPolicyFound && (isUseVehicleOnPolicy ?? true)) {
// Extract numbers
const amountDueAmt = Number.parseFloat(amountDueValue!.split('$')[1].replaceAll(',', ''));
const deductibleAmt = deductibleTextValue? Number.parseFloat(deductibleTextValue.split('$')[1].replaceAll(',', '')): 0;
const deductibleAmt = deductibleTextValue ? Number.parseFloat(deductibleTextValue.split('$')[1].replaceAll(',', '')) : 0;
const subtotalAmt = Number.parseFloat(subtotalTextValue!.split('$')[1].replaceAll(',', ''));
subtotalTextValue?.replaceAll(',', '')
const finalAmountDueAmt = Number.parseFloat(finalAmountDueValue!.split('$')[1].replaceAll(',', ''));

View file

@ -79,27 +79,5 @@ export class WelcomePage extends BasePage {
await this.city.fill(customerDetails.address.city);
await this.state.selectOption(customerDetails.address.state);
}
await this.logReferralNumber();
}
async logReferralNumber() {
let mainLocalStorage = JSON.parse(await this.page.evaluate('localStorage.getItem(\'main\')'));
let referralNumber = mainLocalStorage.order.referralNumber as number;
let referralSequenceNumber = mainLocalStorage.order.referralSequenceNumber as number;
if (referralNumber == null) {
for (let i = 1; i <= 20; i++) {
if (!referralNumber == null) break;
await this.page.waitForTimeout(500);
mainLocalStorage = JSON.parse(await this.page.evaluate('localStorage.getItem(\'main\')'));
referralNumber = mainLocalStorage.order.referralNumber as number;
referralSequenceNumber = mainLocalStorage.order.referralSequenceNumber as number;
}
}
await test.step(`Referral Number:${referralNumber} Referral Sequence Number:${referralSequenceNumber}`, async () => {
console.log(`Referral Number:${referralNumber}`);
console.log(`Referral Sequence Number:${referralSequenceNumber}`);
});
}
}

View file

@ -39,8 +39,8 @@ const reportConfig: OrtoniReportConfig = {
base64Image: true,
};
export const reportFilePath = path.resolve(__dirname, './test-results/accessibility-report.html');
export const jsonReportFilePath = path.resolve(__dirname, './test-results/accessibility-report.json');
export const reportFilePath = path.resolve(__dirname, './../test-results/accessibility-report.html');
export const jsonReportFilePath = path.resolve(__dirname, './../test-results/accessibility-report.json');
export default defineConfig({
testDir: './tests',