external-services-automation
Version:
External services automation library for Playwright and Cucumber
42 lines (41 loc) • 2.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StripeService = void 0;
const test_1 = require("playwright/test");
const ConfirmUpdatePage_1 = require("../pages/stripe/ConfirmUpdatePage");
const CurrentSubscriptionPage_1 = require("../pages/stripe/CurrentSubscriptionPage");
const LeftPanelPage_1 = require("../pages/stripe/LeftPanelPage");
const UpdatePaymentMethodPage_1 = require("../pages/stripe/UpdatePaymentMethodPage");
const UpdateSubscriptionPage_1 = require("../pages/stripe/UpdateSubscriptionPage");
class StripeService {
constructor(page) {
this.page = page;
this.stripeCurrentSubscriptionPage = new CurrentSubscriptionPage_1.CurrentSubscriptionPage(page);
this.stripeUpdateSubscriptionPage = new UpdateSubscriptionPage_1.UpdateSubscriptionPage(page);
this.stripeConfirmUpdatePage = new ConfirmUpdatePage_1.ConfirmUpdatePage(page);
this.stripeUpdatePaymentMethodPage = new UpdatePaymentMethodPage_1.UpdatePaymentMethodPage(page);
this.stripeLeftPanelPage = new LeftPanelPage_1.LeftPanelPage(page);
}
async upgradePlan(planType) {
await (0, test_1.expect)(this.page).toHaveURL(/billing\.stripe\.com/, { timeout: 20000 });
await this.page.waitForLoadState('domcontentloaded');
await this.stripeCurrentSubscriptionPage.navigateToUpdateSubscription();
await this.stripeUpdateSubscriptionPage.isOnUpdateSubscriptionPage();
const planTypeFormatted = planType.toLowerCase();
await this.stripeUpdateSubscriptionPage.selectPlan(planTypeFormatted);
await this.stripeUpdateSubscriptionPage.clickContinue();
await this.stripeConfirmUpdatePage.isOnConfirmUpdatePage();
await this.stripeConfirmUpdatePage.clickConfirm();
}
async completePayment() {
await (0, test_1.expect)(this.page).toHaveURL(/update-payment-method/, { timeout: 10000 });
await this.stripeUpdatePaymentMethodPage.isOnUpdatePaymentMethodPage();
await this.stripeUpdatePaymentMethodPage.fillCardInformation();
await this.stripeUpdatePaymentMethodPage.clickContinue();
await this.stripeCurrentSubscriptionPage.isOnCurrentSubscriptionPage();
await this.stripeLeftPanelPage.navigateBackToEmailAwesome();
await (0, test_1.expect)(this.page).toHaveURL(/emailawesome\.com/, { timeout: 10000 });
await (0, test_1.expect)(this.page).not.toHaveURL(/stripe\.com/);
}
}
exports.StripeService = StripeService;