Skip to content

Commit 116fbfb

Browse files
committed
Update tests
1 parent ceab68d commit 116fbfb

12 files changed

+111
-185
lines changed

playwright.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ dotenv.config({ path: path.resolve(__dirname, '.env') });
1414
export default defineConfig({
1515
globalSetup: require.resolve('./tests/setup/global-setup'),
1616
testDir: './tests',
17-
fullyParallel: true,
17+
fullyParallel: false,
1818
forbidOnly: !!process.env.CI,
1919
retries: process.env.CI ? 2 : 0,
20-
workers: process.env.CI ? 1 : undefined,
20+
workers: 1,
2121
reporter: 'html',
2222
use: {
2323
baseURL: process.env.TESTSITE_URL,

tests/fixtures/checkout-types.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,4 @@ export const CHECKOUT_TYPES: Record<string, CheckoutType> = {
2727
url: '/checkout/',
2828
isBlockCheckout: true
2929
},
30-
31-
// Pay for Order page (for failed payment recovery)
32-
PAY_FOR_ORDER: {
33-
id: 'pay_for_order',
34-
name: 'Pay for Order',
35-
url: '/checkout/order-pay/',
36-
isBlockCheckout: false
37-
}
3830
};

tests/fixtures/payment-methods.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const PAYMENT_METHODS: Record<string, PaymentMethod> = {
2323
// Credit Card (with Component)
2424
CREDIT_CARD_SUCCESS: {
2525
id: 'monei',
26-
name: 'Credit Card',
26+
name: 'Credit Card Success',
2727
className: 'wc-monei-credit-card-payment-method',
2828
isApplicableToSubscription: true,
2929
paymentProcessFunction: 'processCreditCardPayment',
@@ -37,14 +37,14 @@ export const PAYMENT_METHODS: Record<string, PaymentMethod> = {
3737
},
3838

3939
// Credit Card (with Redirect/Hosted)
40-
CREDIT_CARD_HOSTED: {
40+
CREDIT_CARD_3DSECURE: {
4141
id: 'monei',
42-
name: 'Credit Card (Hosted)',
42+
name: 'Credit Card (3DSecure)',
4343
className: 'wc-monei-credit-card-hosted-payment-method',
4444
isApplicableToSubscription: true,
4545
paymentProcessFunction: 'processCreditCardHostedPayment',
4646
isHostedPayment: true,
47-
countriesSupported: ['ES', 'PT', 'FR', 'DE', 'IT', 'UK'], // Example countries
47+
countriesSupported: ['ES', 'PT', 'FR', 'DE', 'IT', 'GB'], // Example countries
4848
selector: {
4949
classic: 'input[name="payment_method"][value="monei"]',
5050
block: '.wc-block-components-radio-control__input[value="monei"]'
@@ -53,12 +53,12 @@ export const PAYMENT_METHODS: Record<string, PaymentMethod> = {
5353
},
5454
CREDIT_CARD_FAIL: {
5555
id: 'monei',
56-
name: 'Credit Card (Hosted)',
56+
name: 'Credit Card (Hosted) fail',
5757
className: 'wc-monei-credit-card-hosted-payment-method',
5858
isApplicableToSubscription: true,
5959
paymentProcessFunction: 'processCreditCardHostedPayment',
6060
isHostedPayment: true,
61-
countriesSupported: ['ES', 'PT', 'FR', 'DE', 'IT', 'UK'], // Example countries
61+
countriesSupported: ['ES', 'PT', 'FR', 'DE', 'IT', 'GB'], // Example countries
6262
selector: {
6363
classic: 'input[name="payment_method"][value="monei"]',
6464
block: '.wc-block-components-radio-control__input[value="monei"]'
@@ -90,14 +90,13 @@ export const PAYMENT_METHODS: Record<string, PaymentMethod> = {
9090
isApplicableToSubscription: true,
9191
paymentProcessFunction: 'processPayPalPayment',
9292
isHostedPayment: true,
93-
countriesSupported: ['ES', 'PT', 'FR', 'DE', 'IT', 'UK', 'US'], // Example countries
93+
countriesSupported: ['ES', 'PT', 'FR', 'DE', 'IT', 'GB', 'US'], // Example countries
9494
selector: {
9595
classic: 'input[name="payment_method"][value="monei_paypal"]',
9696
block: '.wc-block-components-radio-control__input[value="monei_paypal"]'
9797
},
9898
presetCredentials: 'success'
9999
},
100-
101100
// Apple Pay
102101
APPLE_PAY: {
103102
id: 'monei_apple_pay',
@@ -106,14 +105,13 @@ export const PAYMENT_METHODS: Record<string, PaymentMethod> = {
106105
isApplicableToSubscription: true,
107106
paymentProcessFunction: 'processApplePayPayment',
108107
isHostedPayment: false,
109-
countriesSupported: ['ES', 'PT', 'FR', 'DE', 'IT', 'UK', 'US'], // Example countries
108+
countriesSupported: ['ES', 'PT', 'FR', 'DE', 'IT', 'GB', 'US'], // Example countries
110109
selector: {
111110
classic: 'input[name="payment_method"][value="monei_apple_pay"]',
112111
block: '.wc-block-components-radio-control__input[value="monei_apple_pay"]'
113112
},
114113
presetCredentials: 'success'
115114
},
116-
117115
// Google Pay
118116
GOOGLE_PAY: {
119117
id: 'monei_google_pay',
@@ -122,14 +120,13 @@ export const PAYMENT_METHODS: Record<string, PaymentMethod> = {
122120
isApplicableToSubscription: true,
123121
paymentProcessFunction: 'processGooglePayPayment',
124122
isHostedPayment: false,
125-
countriesSupported: ['ES', 'PT', 'FR', 'DE', 'IT', 'UK', 'US'], // Example countries
123+
countriesSupported: ['ES', 'PT', 'FR', 'DE', 'IT', 'GB', 'US'], // Example countries
126124
selector: {
127-
classic: 'input[name="payment_method"][value="monei_google_pay"]',
128-
block: '.wc-block-components-radio-control__input[value="monei_google_pay"]'
125+
classic: 'input[name="payment_method"][value="monei_apple_google"]',
126+
block: '.wc-block-components-radio-control__input[value="monei_apple_google"]'
129127
},
130128
presetCredentials: 'success'
131129
},
132-
133130
// Multibanco
134131
MULTIBANCO: {
135132
id: 'monei_multibanco',
@@ -145,7 +142,6 @@ export const PAYMENT_METHODS: Record<string, PaymentMethod> = {
145142
},
146143
presetCredentials: 'success'
147144
},
148-
149145
// MBWay
150146
MBWAY: {
151147
id: 'monei_mbway',

tests/fixtures/product-types.ts

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export interface ProductType {
1212
woocommerce?: {
1313
type: 'simple' | 'variable' | 'subscription' | 'grouped' | 'external';
1414
status?: 'draft' | 'pending' | 'private' | 'publish';
15+
virtual?: boolean;
16+
downloadable?: boolean;
1517
catalog_visibility?: 'visible' | 'catalog' | 'search' | 'hidden';
1618
description?: string;
1719
short_description?: string;
@@ -46,7 +48,7 @@ export const PRODUCT_TYPES: Record<string, ProductType> = {
4648
},
4749
BIZUM_SUCCESS: {
4850
id: 'bizum-success-simple-product',
49-
sku: 'TEST-BIZUM-01',
51+
sku: 'TEST-BIZUM-S',
5052
name: 'Bizum Success Simple Product',
5153
isSubscription: false,
5254
sampleProductId: 64,
@@ -55,6 +57,8 @@ export const PRODUCT_TYPES: Record<string, ProductType> = {
5557
woocommerce: {
5658
type: 'simple',
5759
status: 'publish',
60+
virtual: true,
61+
downloadable: true,
5862
catalog_visibility: 'visible',
5963
description: 'A simple test product for automated testing',
6064
short_description: 'Simple test product'
@@ -102,55 +106,7 @@ export const PRODUCT_TYPES: Record<string, ProductType> = {
102106
}
103107
]
104108
}
105-
},
106-
107-
// WooCommerce Subscription
108-
/*WOO_SUBSCRIPTION: {
109-
id: 'woo-subscription',
110-
sku: 'TEST-SUBSCRIPTION-WOO-01',
111-
name: 'WooCommerce Subscription Product',
112-
isSubscription: true,
113-
subscriptionPlugin: 'woocommerce',
114-
sampleProductId: 65,
115-
sampleProductSlug: 'woo-subscription',
116-
price: 9.99,
117-
woocommerce: {
118-
type: 'subscription',//check this cause it fails
119-
status: 'publish',
120-
catalog_visibility: 'visible',
121-
description: 'A WooCommerce subscription test product',
122-
short_description: 'WooCommerce subscription test product',
123-
meta_data: [
124-
{ key: '_subscription_price', value: '9.99' },
125-
{ key: '_subscription_period', value: 'month' },
126-
{ key: '_subscription_period_interval', value: '1' }
127-
]
128-
}
129-
},
130-
131-
// YITH Subscription
132-
YITH_SUBSCRIPTION: {
133-
id: 'yith-subscription',
134-
sku: 'TEST-SUBSCRIPTION-YITH-01',
135-
name: 'YITH Subscription Product',
136-
isSubscription: true,
137-
subscriptionPlugin: 'yith',
138-
sampleProductId: 66,
139-
sampleProductSlug: 'yith-subscription',
140-
price: 14.99,
141-
woocommerce: {
142-
type: 'simple',
143-
status: 'publish',
144-
catalog_visibility: 'visible',
145-
description: 'A YITH subscription test product',
146-
short_description: 'YITH subscription test product',
147-
meta_data: [
148-
{ key: '_ywsbs_subscription', value: 'yes' },
149-
{ key: '_ywsbs_price_is_per', value: 'month' },
150-
{ key: '_ywsbs_price_time', value: '1' }
151-
]
152-
}
153-
}*/
109+
}
154110
};
155111

156112
// Helper to get specific product types

tests/fixtures/test-configurations.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,23 @@ export const TEST_CONFIGURATIONS = {
140140

141141
// Credit card comprehensive tests
142142
CREDIT_CARD_TESTS: generateTestConfigurations({
143-
paymentMethods: [PAYMENT_METHODS.CREDIT_CARD_HOSTED],
143+
paymentMethods: [PAYMENT_METHODS.CREDIT_CARD_3DSECURE],
144144
checkoutTypes: Object.values(CHECKOUT_TYPES),
145145
productTypes: [PRODUCT_TYPES.SIMPLE],
146146
userStates: Object.values(USER_STATES),
147147
userTypes: Object.values(USER_TYPES)
148148
}),
149-
150-
// Subscription tests
151-
SUBSCRIPTION_TESTS: generateTestConfigurations({
152-
productTypes: [PRODUCT_TYPES.WOO_SUBSCRIPTION, PRODUCT_TYPES.YITH_SUBSCRIPTION],
153-
paymentMethods: Object.values(PAYMENT_METHODS).filter(pm => pm.isApplicableToSubscription),
154-
checkoutTypes: [CHECKOUT_TYPES.CLASSIC, CHECKOUT_TYPES.BLOCK],
155-
userStates: [USER_STATES.LOGGED_IN], // Subscriptions usually require login
156-
userTypes: [USER_TYPES.ES_USER, USER_TYPES.US_USER]
157-
})
149+
ALL_METHODS_TESTS_SIMPLE: generateTestConfigurations({
150+
paymentMethods: [
151+
PAYMENT_METHODS.CREDIT_CARD_SUCCESS,
152+
PAYMENT_METHODS.CREDIT_CARD_HOSTED,
153+
PAYMENT_METHODS.CREDIT_CARD_FAIL,
154+
PAYMENT_METHODS.BIZUM,
155+
PAYMENT_METHODS.PAYPAL,
156+
],
157+
checkoutTypes: Object.values(CHECKOUT_TYPES),
158+
productTypes: [PRODUCT_TYPES.SIMPLE],
159+
userStates: [USER_STATES.GUEST],
160+
userTypes: [USER_TYPES.ES_USER]
161+
}),
158162
};

tests/helpers/order-creation-helper.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class OrderCreationHelper {
3737
paymentMethod = 'monei',
3838
status = 'pending',
3939
lineItems,
40-
shippingMethod = 'flat_rate',
40+
shippingMethod = '',
4141
couponCodes = []
4242
} = options;
4343

@@ -76,13 +76,13 @@ export class OrderCreationHelper {
7676
country: userType.country
7777
} : undefined,
7878
line_items: items,
79-
shipping_lines: [
79+
/*shipping_lines: [
8080
{
8181
method_id: shippingMethod,
8282
method_title: this.getShippingMethodTitle(shippingMethod),
83-
total: '10.00'
83+
total: '0'
8484
}
85-
],
85+
],*/
8686
coupon_lines: couponCodes.map(code => ({ code }))
8787
};
8888

tests/setup/wordpress-api-client.ts

Lines changed: 16 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,24 @@ interface WordPressError {
1515
data?: any;
1616
}
1717

18+
interface WooCommerceRestApiResponse<T> {
19+
data: T;
20+
status: number;
21+
headers: Record<string, string>;
22+
}
23+
24+
interface WooCommerceRestApi {
25+
get(endpoint: string, params?: Record<string, any>): Promise<WooCommerceRestApiResponse<any>>;
26+
post(endpoint: string, data: Record<string, any>): Promise<WooCommerceRestApiResponse<any>>;
27+
put(endpoint: string, data: Record<string, any>): Promise<WooCommerceRestApiResponse<any>>;
28+
delete(endpoint: string, params?: Record<string, any>): Promise<WooCommerceRestApiResponse<any>>;
29+
options(endpoint: string): Promise<WooCommerceRestApiResponse<any>>;
30+
}
31+
1832
export class WordPressApiClient {
1933
private baseUrl: string;
2034
private wpAuth: string;
21-
wooCommerce: any;
35+
wooCommerce: WooCommerceRestApi;
2236

2337
constructor() {
2438
this.baseUrl = process.env.TESTSITE_URL || 'http://localhost:8080';
@@ -183,21 +197,6 @@ export class WordPressApiClient {
183197
}
184198
}
185199

186-
async updateProduct(productId: number, productData: any): Promise<any> {
187-
this.logApiCall('PUT', `/wp-json/wc/v3/products/${productId}`, `Updating: ${productData.name || productId}`);
188-
189-
try {
190-
const response = await this.wooCommerce.put(`products/${productId}`, productData);
191-
const product = response.data;
192-
193-
console.log(` ✅ Product updated: ${product.name} (ID: ${product.id})`);
194-
return product;
195-
196-
} catch (error) {
197-
this.handleWooCommerceError(error, `updating product ID: ${productId}`);
198-
}
199-
}
200-
201200
async getPageBySlug(slug: string): Promise<any | null> {
202201
this.logApiCall('GET', '/wp-json/wp/v2/pages', `Slug: ${slug}`);
203202

@@ -293,69 +292,12 @@ export class WordPressApiClient {
293292
}
294293
}
295294

296-
async updateGatewaySettings(gatewayId, settings) {
295+
async updateGatewaySettings(gatewayId: string, settings: Record<string, any>): Promise<any> {
297296
try {
298297
const response = await this.wooCommerce.put(`payment_gateways/${gatewayId}`, settings);
299298
return response.data;
300299
} catch (error) {
301300
this.handleWooCommerceError(error, 'Error updating gateway');
302301
}
303302
}
304-
305-
// Additional WooCommerce helper methods
306-
async getTaxRates(): Promise<any[]> {
307-
this.logApiCall('GET', '/wp-json/wc/v3/taxes', 'All tax rates');
308-
309-
try {
310-
const response = await this.wooCommerce.get('taxes');
311-
const taxes = response.data;
312-
console.log(` 💰 Tax rates found: ${taxes.length}`);
313-
return taxes;
314-
315-
} catch (error) {
316-
this.handleWooCommerceError(error, 'fetching tax rates');
317-
}
318-
}
319-
320-
async createTaxRate(taxData: any): Promise<any> {
321-
this.logApiCall('POST', '/wp-json/wc/v3/taxes', `Creating tax: ${taxData.name}`);
322-
323-
try {
324-
const response = await this.wooCommerce.post('taxes', taxData);
325-
const tax = response.data;
326-
console.log(` ✅ Tax rate created: ${tax.name} (${tax.rate}%)`);
327-
return tax;
328-
329-
} catch (error) {
330-
this.handleWooCommerceError(error, `creating tax rate: ${taxData.name}`);
331-
}
332-
}
333-
334-
async getShippingZones(): Promise<any[]> {
335-
this.logApiCall('GET', '/wp-json/wc/v3/shipping/zones', 'All shipping zones');
336-
337-
try {
338-
const response = await this.wooCommerce.get('shipping/zones');
339-
const zones = response.data;
340-
console.log(` 🚚 Shipping zones found: ${zones.length}`);
341-
return zones;
342-
343-
} catch (error) {
344-
this.handleWooCommerceError(error, 'fetching shipping zones');
345-
}
346-
}
347-
348-
async createShippingMethod(zoneId: number, methodData: any): Promise<any> {
349-
this.logApiCall('POST', `/wp-json/wc/v3/shipping/zones/${zoneId}/methods`, `Creating shipping method`);
350-
351-
try {
352-
const response = await this.wooCommerce.post(`shipping/zones/${zoneId}/methods`, methodData);
353-
const method = response.data;
354-
console.log(` ✅ Shipping method created: ${method.method_title} (ID: ${method.id})`);
355-
return method;
356-
357-
} catch (error) {
358-
this.handleWooCommerceError(error, `creating shipping method for zone ${zoneId}`);
359-
}
360-
}
361303
}

0 commit comments

Comments
 (0)