Refactor billing process in e2e tests
Code for billing process was refactored in end-to-end tests for clean code and better structure. In the described tests, related codes and classes have been moved to a new class named BillingPageObject. All corresponding calls were updated accordingly.
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
import { Page } from '@playwright/test';
|
||||
import { StripePageObject } from '../utils/stripe.po';
|
||||
import { TeamAccountsPageObject } from '../team-accounts/team-accounts.po';
|
||||
import { BillingPageObject } from '../utils/billing.po';
|
||||
|
||||
export class TeamBillingPageObject {
|
||||
private readonly teamAccounts: TeamAccountsPageObject;
|
||||
public readonly stripe: StripePageObject;
|
||||
public readonly teamAccounts: TeamAccountsPageObject;
|
||||
public readonly billing: BillingPageObject;
|
||||
|
||||
constructor(page: Page) {
|
||||
this.teamAccounts = new TeamAccountsPageObject(page);
|
||||
this.stripe = new StripePageObject(page);
|
||||
this.billing = new BillingPageObject(page);
|
||||
}
|
||||
|
||||
async setup() {
|
||||
await this.teamAccounts.setup();
|
||||
await this.teamAccounts.goToBilling();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,32 @@
|
||||
import { expect, Page, test } from '@playwright/test';
|
||||
import { TeamBillingPageObject } from './team-billing.po';
|
||||
import exp from 'node:constants';
|
||||
|
||||
test.describe('Team Billing', () => {
|
||||
let page: Page;
|
||||
let billing: TeamBillingPageObject;
|
||||
let po: TeamBillingPageObject;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
billing = new TeamBillingPageObject(page);
|
||||
po = new TeamBillingPageObject(page);
|
||||
|
||||
await billing.setup();
|
||||
await po.setup();
|
||||
await po.teamAccounts.goToBilling();
|
||||
});
|
||||
|
||||
test('a team can subscribe to a plan', async () => {
|
||||
await billing.stripe.selectPlan(0);
|
||||
await billing.stripe.proceedToCheckout();
|
||||
await po.billing.selectPlan(0);
|
||||
await po.billing.proceedToCheckout();
|
||||
|
||||
await billing.stripe.fillForm();
|
||||
await billing.stripe.submitForm();
|
||||
await po.billing.stripe.fillForm();
|
||||
await po.billing.stripe.submitForm();
|
||||
|
||||
await expect(billing.stripe.successStatus()).toBeVisible();
|
||||
await expect(po.billing.successStatus()).toBeVisible();
|
||||
await po.billing.returnToHome();
|
||||
|
||||
await po.teamAccounts.goToBilling();
|
||||
|
||||
await expect(await po.billing.getStatus()).toContainText('active');
|
||||
await expect(po.billing.manageBillingButton()).toBeVisible();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user