You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
2.2 KiB
TypeScript

import { expect, Page } from '@playwright/test';
import { ReviewAndCheckoutPage } from "../pages/reviewAndCheckoutPage";
import {DateOperations} from "../../utils/dateOperations";
import {PageBase} from "../../utils/page-base";
export class ReviewAndCheckoutPageStepDefs extends PageBase {
constructor(page: Page) {
super(page);
}
async assertLicenseName(productLicenseName: string): Promise<void> {
await this.page.waitForLoadState()
await this.waitForElement(ReviewAndCheckoutPage.productName)
await expect(this.page.locator(ReviewAndCheckoutPage.productName)).toHaveText(productLicenseName);
}
async assertIpAddress(ipAddress: string): Promise<void> {
await this.waitForElement(ReviewAndCheckoutPage.productName)
await expect(this.page.locator(ReviewAndCheckoutPage.ipAddress)).toHaveText("» IP Address: " + ipAddress);
}
async assertProductMonthlyPrice(productMonthlyPrice: string): Promise<void> {
await expect(this.page.locator(ReviewAndCheckoutPage.productMonthlyPrice)).toHaveText(productMonthlyPrice+ " Monthly");
}
async assertAddonMonthlyPrice(addonMonthlyPrice: string): Promise<void> {
await expect(this.page.locator(ReviewAndCheckoutPage.addonMonthlyPrice)).toHaveText(addonMonthlyPrice + " Monthly");
}
async assertTotalDue(): Promise<void> {
const productTotalDue = await DateOperations.extractPrice(this.page, ReviewAndCheckoutPage.productMonthlyPrice).then(DateOperations.calculateTotalDue);
const addonTotalDue = await DateOperations.extractPrice(this.page, ReviewAndCheckoutPage.addonMonthlyPrice).then(DateOperations.calculateTotalDue);
console.log(`Product Monthly Price: ${productTotalDue}`);
console.log(`Addon Monthly Price: ${addonTotalDue}`);
const expectedTotalDueToday = productTotalDue + addonTotalDue;
const actualTotalDue = await DateOperations.extractPrice(this.page, ReviewAndCheckoutPage.totalDueToday)
expect(expectedTotalDueToday).toBeCloseTo(actualTotalDue, 2);
}
async clickOnCheckout(): Promise<void> {
await this.page.click(ReviewAndCheckoutPage.checkoutButton)
}
}