Files
myeasycms-v2/apps/e2e/tests/utils/stripe.po.ts
Giancarlo Buomprisco 40afecde93 28 05 2025 deps update (#262)
* Update dependencies across all packages

Updated multiple dependencies to their latest versions to ensure compatibility, security, and performance improvements. This includes packages like @supabase/supabase-js, @tanstack/react-query, @types/react, and zod across various projects.

* Update selector for Stripe form submission button

Replaced the form button selector with a `data-testid` attribute selector for improved reliability and maintainability. This ensures the test is less prone to breaks from UI changes.
2025-05-28 09:26:28 +08:00

63 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().getByTestId('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');
}
}