* Enhance E2E Tests and Configuration - Updated `.gitignore` to exclude `.auth/` directory for cleaner test environment. - Added `test:fast` script in `package.json` for faster Playwright test execution. - Configured Playwright to include a setup project for initializing tests. - Introduced `AUTH_STATES` utility for managing authentication states in tests. - Created `auth.setup.ts` for user authentication tests, ensuring proper login flows. - Refactored various test files to utilize the new authentication state management, improving test reliability and maintainability. - Adjusted team and user billing tests to streamline setup and enhance clarity. - Refactored some dialogs
68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import { Page, expect } from '@playwright/test';
|
|
|
|
export class StripePageObject {
|
|
private readonly page: Page;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
}
|
|
|
|
getStripeCheckoutIframe() {
|
|
return this.page.frameLocator('[name="embedded-checkout"]');
|
|
}
|
|
|
|
async waitForForm() {
|
|
return expect(async () => {
|
|
await expect(this.billingCountry()).toBeVisible();
|
|
}).toPass();
|
|
}
|
|
|
|
async fillForm(
|
|
params: {
|
|
billingName?: string;
|
|
cardNumber?: string;
|
|
expiry?: string;
|
|
cvc?: string;
|
|
billingCountry?: string;
|
|
} = {},
|
|
) {
|
|
const billingName = this.billingName();
|
|
const cardNumber = this.cardNumber();
|
|
const expiry = this.expiry();
|
|
const cvc = this.cvc();
|
|
const billingCountry = this.billingCountry();
|
|
|
|
await billingName.fill(params.billingName ?? 'Mr Makerkit');
|
|
await cardNumber.fill(params.cardNumber ?? '4242424242424242');
|
|
await expiry.fill(params.expiry ?? '1228');
|
|
await cvc.fill(params.cvc ?? '123');
|
|
await billingCountry.selectOption(params.billingCountry ?? 'IT');
|
|
}
|
|
|
|
submitForm() {
|
|
return this.getStripeCheckoutIframe()
|
|
.locator('[data-testid="hosted-payment-submit-button"]')
|
|
.click();
|
|
}
|
|
|
|
cardNumber() {
|
|
return this.getStripeCheckoutIframe().locator('#cardNumber');
|
|
}
|
|
|
|
cvc() {
|
|
return this.getStripeCheckoutIframe().locator('#cardCvc');
|
|
}
|
|
|
|
expiry() {
|
|
return this.getStripeCheckoutIframe().locator('#cardExpiry');
|
|
}
|
|
|
|
billingName() {
|
|
return this.getStripeCheckoutIframe().locator('#billingName');
|
|
}
|
|
|
|
billingCountry() {
|
|
return this.getStripeCheckoutIframe().locator('#billingCountry');
|
|
}
|
|
}
|