Skip to content

Commit 80909a4

Browse files
committed
Add bizum success and fail
1 parent 54fe52e commit 80909a4

File tree

8 files changed

+89
-61
lines changed

8 files changed

+89
-61
lines changed

playwright.config.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,36 +35,6 @@ export default defineConfig({
3535
use: { ...devices['Desktop Chrome'] },
3636
testMatch: '**/payment-gateway-matrix.spec.ts',
3737
},
38-
39-
/*{
40-
name: 'firefox',
41-
use: { ...devices['Desktop Firefox'] },
42-
},
43-
44-
{
45-
name: 'webkit',
46-
use: { ...devices['Desktop Safari'] },
47-
},*/
48-
49-
/* Test against mobile viewports. */
50-
// {
51-
// name: 'Mobile Chrome',
52-
// use: { ...devices['Pixel 5'] },
53-
// },
54-
// {
55-
// name: 'Mobile Safari',
56-
// use: { ...devices['iPhone 12'] },
57-
// },
58-
59-
/* Test against branded browsers. */
60-
// {
61-
// name: 'Microsoft Edge',
62-
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
63-
// },
64-
// {
65-
// name: 'Google Chrome',
66-
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
67-
// },
6838
],
6939

7040
/* Run your local dev server before starting the tests */

tests/fixtures/product-types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ export const PRODUCT_TYPES: Record<string, ProductType> = {
4545
}
4646
},
4747
BIZUM_SUCCESS: {
48-
id: 'bizum_success',
48+
id: 'bizum-success-simple-product',
4949
sku: 'TEST-BIZUM-01',
5050
name: 'Bizum Success Simple Product',
5151
isSubscription: false,
5252
sampleProductId: 64,
53-
sampleProductSlug: 'bizum_success',
53+
sampleProductSlug: 'bizum-success-simple-product',
5454
price: 1.00,
5555
woocommerce: {
5656
type: 'simple',
@@ -61,12 +61,12 @@ export const PRODUCT_TYPES: Record<string, ProductType> = {
6161
}
6262
},
6363
BIZUM_FAILS: {
64-
id: 'bizum_fails',
64+
id: 'bizum-fails-simple-product',
6565
sku: 'TEST-BIZUM-02',
6666
name: 'Bizum Fails Simple Product',
6767
isSubscription: false,
6868
sampleProductId: 65,
69-
sampleProductSlug: 'bizum_fails',
69+
sampleProductSlug: 'bizum-fails-simple-product',
7070
price: 10.00,
7171
woocommerce: {
7272
type: 'simple',

tests/fixtures/test-configurations.ts

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,82 @@ export function generateTestConfigurations(options: {
6565
/**
6666
* Predefined common test configurations
6767
*/
68+
// tests/fixtures/test-configurations.ts
69+
6870
export const TEST_CONFIGURATIONS = {
71+
// Quick smoke test
6972
QUICK: generateTestConfigurations({
70-
paymentMethods: [PAYMENT_METHODS.BIZUM],
73+
paymentMethods: [PAYMENT_METHODS.CREDIT_CARD_SUCCESS],
7174
checkoutTypes: [CHECKOUT_TYPES.CLASSIC],
7275
productTypes: [PRODUCT_TYPES.SIMPLE],
7376
userStates: [USER_STATES.GUEST],
74-
expectSuccess: true,
7577
userTypes: [USER_TYPES.ES_USER]
7678
}),
79+
// Bizum-specific tests
80+
BIZUM_TESTS: [
81+
// Bizum success scenario
82+
{
83+
paymentMethod: PAYMENT_METHODS.BIZUM,
84+
checkoutType: CHECKOUT_TYPES.CLASSIC,
85+
productType: PRODUCT_TYPES.BIZUM_SUCCESS,
86+
userState: USER_STATES.GUEST,
87+
userType: USER_TYPES.ES_USER,
88+
expectSuccess: true
89+
},
90+
{
91+
paymentMethod: PAYMENT_METHODS.BIZUM,
92+
checkoutType: CHECKOUT_TYPES.BLOCK,
93+
productType: PRODUCT_TYPES.BIZUM_SUCCESS,
94+
userState: USER_STATES.GUEST,
95+
userType: USER_TYPES.ES_USER,
96+
expectSuccess: true
97+
},
98+
// Bizum failure scenario
99+
{
100+
paymentMethod: PAYMENT_METHODS.BIZUM,
101+
checkoutType: CHECKOUT_TYPES.CLASSIC,
102+
productType: PRODUCT_TYPES.BIZUM_FAILS,
103+
userState: USER_STATES.GUEST,
104+
userType: USER_TYPES.ES_USER,
105+
expectSuccess: false
106+
}
107+
],
77108

78-
FULL_MATRIX: generateTestConfigurations({}),
109+
// Portugal-specific payment methods
110+
PORTUGAL_TESTS: [
111+
{
112+
paymentMethod: PAYMENT_METHODS.MULTIBANCO,
113+
checkoutType: CHECKOUT_TYPES.CLASSIC,
114+
productType: PRODUCT_TYPES.SIMPLE,
115+
userState: USER_STATES.GUEST,
116+
userType: USER_TYPES.PT_USER,
117+
expectSuccess: true
118+
},
119+
{
120+
paymentMethod: PAYMENT_METHODS.MBWAY,
121+
checkoutType: CHECKOUT_TYPES.BLOCK,
122+
productType: PRODUCT_TYPES.SIMPLE,
123+
userState: USER_STATES.LOGGED_IN,
124+
userType: USER_TYPES.PT_USER,
125+
expectSuccess: true
126+
}
127+
],
79128

129+
// Credit card comprehensive tests
130+
CREDIT_CARD_TESTS: generateTestConfigurations({
131+
paymentMethods: [PAYMENT_METHODS.CREDIT_CARD_SUCCESS, PAYMENT_METHODS.CREDIT_CARD_HOSTED],
132+
checkoutTypes: Object.values(CHECKOUT_TYPES),
133+
productTypes: [PRODUCT_TYPES.SIMPLE, PRODUCT_TYPES.VARIABLE],
134+
userStates: Object.values(USER_STATES),
135+
userTypes: Object.values(USER_TYPES)
136+
}),
137+
138+
// Subscription tests
80139
SUBSCRIPTION_TESTS: generateTestConfigurations({
81-
productTypes: [PRODUCT_TYPES.WC_SUBSCRIPTION, PRODUCT_TYPES.YITH_SUBSCRIPTION],
140+
productTypes: [PRODUCT_TYPES.WOO_SUBSCRIPTION, PRODUCT_TYPES.YITH_SUBSCRIPTION],
82141
paymentMethods: Object.values(PAYMENT_METHODS).filter(pm => pm.isApplicableToSubscription),
83-
checkoutTypes: [CHECKOUT_TYPES.CLASSIC],
84-
userStates: [USER_STATES.LOGGED_IN],
85-
expectSuccess: true,
86-
userTypes: [USER_TYPES.ES_USER]
142+
checkoutTypes: [CHECKOUT_TYPES.CLASSIC, CHECKOUT_TYPES.BLOCK],
143+
userStates: [USER_STATES.LOGGED_IN], // Subscriptions usually require login
144+
userTypes: [USER_TYPES.ES_USER, USER_TYPES.US_USER]
87145
})
88146
};

tests/fixtures/user-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const USER_TYPES: Record<string, UserType> = {
1818
city: 'Madrid',
1919
postcode: '28001',
2020
country: 'ES',
21+
state: 'Madrid',
2122
phone: '+34612345678',
2223
email: 'juan.perez@example.com'
2324
},
@@ -28,6 +29,7 @@ export const USER_TYPES: Record<string, UserType> = {
2829
city: 'Lisbon',
2930
postcode: '1100-053',
3031
country: 'PT',
32+
state: 'Lisboa',
3133
phone: '+351912345678',
3234
email: 'joao.silva@example.com'
3335
},

tests/helpers/payment-processors/bizum-processor.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {PAYMENT_TEST_DATA} from "../../fixtures/payment-test-data";
55
export class BizumProcessor extends BasePaymentProcessor {
66

77
// Locators
8+
readonly bizumContainerSelector = '#bizum-container';
89
readonly phoneInput = 'bizum-phone-input';
910
readonly bizumButton = 'bizum-button';
1011
readonly submitButton = 'bizum-pay-button';
@@ -27,13 +28,13 @@ export class BizumProcessor extends BasePaymentProcessor {
2728
async processPayment(expectSuccess, preset: string = 'success') {
2829
const bizumDetails = PAYMENT_TEST_DATA.bizum[preset];
2930

30-
const buttonLocator = this.page.frameLocator('iframe[name^="__zoid__monei_bizum_button"]');
31-
await buttonLocator.getByTestId(this.phoneInput).click();
31+
await this.page.waitForTimeout(1000);
32+
await this.page.click(this.bizumContainerSelector);
3233
const frameLocator = this.page.frameLocator('iframe[name^="__zoid__monei_bizum__"]');
3334
await frameLocator.getByTestId(this.phoneInput).fill(bizumDetails.phoneNumber);
3435
await frameLocator.getByTestId(this.submitButton).click();
3536

36-
await this.page.waitForTimeout(15000);
37+
await this.page.waitForTimeout(10000);
3738
}
3839

3940
/**

tests/pages/checkout-page.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ export class CheckoutPage {
3232
}
3333

3434
private initializeLocators() {
35-
if (this.checkoutType.isBlockCheckout) {
35+
if (this.checkoutType.isBlockCheckout == true) {
3636
this.billingFirstNameInput = '#billing-first_name';
3737
this.billingLastNameInput = '#billing-last_name';
3838
this.billingAddressInput = '#billing-address_1';
3939
this.billingCityInput = '#billing-city';
4040
this.billingPostcodeInput = '#billing-postcode';
4141
this.billingPhoneInput = '#billing-phone';
42-
this.billingEmailInput = '#billing-email';
42+
this.billingEmailInput = '#email';
4343
this.paymentMethodOptions = '.wc-block-components-radio-control__input';
4444
this.placeOrderButton = '.wc-block-components-checkout-place-order-button';
4545
this.savedPaymentMethodsSection = '.wc-block-components-payment-methods__saved-payment-methods';
@@ -74,26 +74,25 @@ export class CheckoutPage {
7474
country?: string;
7575
state?: string;
7676
}) {
77-
await this.page.fill(this.billingFirstNameInput, details.firstName);
78-
await this.page.fill(this.billingLastNameInput, details.lastName);
79-
await this.page.fill(this.billingAddressInput, details.address);
80-
await this.page.fill(this.billingCityInput, details.city);
81-
await this.page.fill(this.billingPostcodeInput, details.postcode);
82-
await this.page.fill(this.billingPhoneInput, details.phone);
8377
await this.page.fill(this.billingEmailInput, details.email);
84-
8578
if (details.country) {
8679
await this.page.selectOption(this.checkoutType.isBlockCheckout ? '#billing-country' : '#billing_country', details.country);
8780
}
8881
if (details.state) {
8982
await this.page.selectOption(this.checkoutType.isBlockCheckout ? '#billing-state' : '#billing_state', details.state);
9083
}
84+
await this.page.fill(this.billingFirstNameInput, details.firstName);
85+
await this.page.fill(this.billingLastNameInput, details.lastName);
86+
await this.page.fill(this.billingAddressInput, details.address);
87+
await this.page.fill(this.billingCityInput, details.city);
88+
await this.page.fill(this.billingPostcodeInput, details.postcode);
89+
await this.page.fill(this.billingPhoneInput, details.phone);
9190
}
9291

9392
async goToCheckout(checkoutType: CheckoutType) {
9493
const { page } = this;
9594
// Navigate to the cart page
96-
if (checkoutType.isBlockCheckout) {
95+
if (this.checkoutType.isBlockCheckout == true) {
9796
await page.goto('/checkout/');
9897
}else {
9998
await page.goto('/checkout-short-code/');

tests/specs/payment-gateway-matrix.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getPaymentProcessor } from '../helpers/payment-processors';
66
import { OrderVerification } from '../verification/order-verification';
77
import {CartPage} from "../pages/cart-page";
88

9-
const configName = process.env.TEST_CONFIG || 'QUICK';
9+
const configName = process.env.TEST_CONFIG || 'BIZUM_TESTS';
1010
const configurations = TEST_CONFIGURATIONS[configName];
1111

1212
// Each configuration is a complete test case with all the properties needed for the test
@@ -29,7 +29,8 @@ test.describe('Payment Gateway Matrix Tests', () => {
2929
await cartHelper.addProductToCart(productType);
3030
await checkoutPage.goToCheckout(checkoutType.isBlockCheckout);
3131
await checkoutPage.fillBillingDetails(userType);
32-
const selector = paymentMethod.selector[checkoutType === 'block'? 'block' : 'classic'];
32+
const selector = paymentMethod.selector[checkoutType.isBlockCheckout? 'block' : 'classic'];
33+
console.log(selector);
3334
await page.click(selector);
3435

3536
await paymentProcessor.processPayment(paymentMethod.isHostedPayment, paymentMethod.presetCredentials);

tests/verification/order-verification.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Page, expect } from '@playwright/test';
22

33
export class OrderVerification {
44
private readonly successSelector = '.wc-block-order-confirmation-status';
5-
private readonly failureSelector = '.woocommerce-error';
5+
private readonly failureSelector = '.is-error';
66
private readonly orderNumberSelector = '.woocommerce-order-overview__order strong';
77
private readonly orderItemsSelector = '.woocommerce-table--order-details tbody tr';
88

@@ -21,9 +21,6 @@ export class OrderVerification {
2121
async verifyFailedPayment() {
2222
await this.page.waitForSelector(this.failureSelector, { timeout: 30000 });
2323

24-
const isErrorVisible = await this.page.isVisible(this.failureSelector);
25-
expect(isErrorVisible).toBeTruthy();
26-
2724
const errorMessage = await this.page.textContent(this.failureSelector);
2825
expect(errorMessage).toBeTruthy();
2926
}

0 commit comments

Comments
 (0)