Skip to content

Commit 983da3d

Browse files
refactor: move E2E shard preconditions into setup projects
1 parent 4262902 commit 983da3d

14 files changed

Lines changed: 186 additions & 229 deletions

tests/qa/playwright.config.ts

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import path from 'path';
1111
import { BaseExtend } from './utils';
1212

1313
const dotenvPath = process.env.CI
14-
? path.resolve( __dirname, '.env.ci' )
15-
: undefined;
14+
? path.resolve( __dirname, '.env.ci' )
15+
: undefined;
1616
dotenv.config( { path: dotenvPath } );
1717

1818
const viewportSize: ViewportSize = { width: 1280, height: 850 };
@@ -63,12 +63,12 @@ export default defineConfig< BaseExtend >( {
6363
* For envs with Basic Auth. Omit when both are empty (e.g. wp-env).
6464
*/
6565
...( process.env.WP_BASIC_AUTH_USER &&
66-
process.env.WP_BASIC_AUTH_PASS && {
67-
httpCredentials: {
68-
username: process.env.WP_BASIC_AUTH_USER,
69-
password: process.env.WP_BASIC_AUTH_PASS,
70-
},
71-
} ),
66+
process.env.WP_BASIC_AUTH_PASS && {
67+
httpCredentials: {
68+
username: process.env.WP_BASIC_AUTH_USER,
69+
password: process.env.WP_BASIC_AUTH_PASS,
70+
},
71+
} ),
7272

7373
...devices[ 'Desktop Chrome' ],
7474

@@ -106,7 +106,7 @@ export default defineConfig< BaseExtend >( {
106106
host: process.env.SSH_HOST,
107107
port: process.env.SSH_PORT,
108108
path: process.env.SSH_PATH,
109-
}
109+
},
110110
},
111111
},
112112

@@ -121,6 +121,34 @@ export default defineConfig< BaseExtend >( {
121121
testMatch: /pcp\.setup\.ts/,
122122
fullyParallel: false,
123123
},
124+
{
125+
name: 'setup-pcp-usa-for-transactions',
126+
dependencies: [ 'setup-woocommerce' ],
127+
testMatch: /pcp\.setup\.ts/,
128+
grep: /setup:pcp:usa:transactions;/,
129+
fullyParallel: false,
130+
},
131+
{
132+
name: 'setup-pcp-usa-for-refund',
133+
dependencies: [ 'setup-woocommerce' ],
134+
testMatch: /pcp\.setup\.ts/,
135+
grep: /setup:pcp:usa:refund;/,
136+
fullyParallel: false,
137+
},
138+
{
139+
name: 'setup-pcp-vaulting',
140+
dependencies: [ 'setup-woocommerce' ],
141+
testMatch: /pcp\.setup\.ts/,
142+
grep: /setup:pcp:usa:vaulting;/,
143+
fullyParallel: false,
144+
},
145+
{
146+
name: 'setup-pcp-subscription',
147+
dependencies: [ 'setup-woocommerce' ],
148+
testMatch: /pcp\.setup\.ts/,
149+
grep: /setup:pcp:usa:subscription;/,
150+
fullyParallel: false,
151+
},
124152
{
125153
name: 'plugin-foundation',
126154
dependencies: [ 'setup-woocommerce' ],
@@ -129,10 +157,7 @@ export default defineConfig< BaseExtend >( {
129157
{
130158
name: 'all',
131159
dependencies: [ 'setup-woocommerce' ],
132-
testIgnore: [
133-
/stress\.spec\.ts/,
134-
/plugin-foundation\.spec\.ts/,
135-
],
160+
testIgnore: [ /stress\.spec\.ts/, /plugin-foundation\.spec\.ts/ ],
136161
},
137162
{
138163
name: 'stress',
@@ -153,22 +178,22 @@ export default defineConfig< BaseExtend >( {
153178
},
154179
{
155180
name: 'shard:transactions',
156-
dependencies: [ 'setup-woocommerce' ],
181+
dependencies: [ 'setup-pcp-usa-for-transactions' ],
157182
testMatch: /05-transactions\/.*\.spec\.ts/,
158183
},
159184
{
160185
name: 'shard:refund',
161-
dependencies: [ 'setup-woocommerce' ],
186+
dependencies: [ 'setup-pcp-usa-for-refund' ],
162187
testMatch: /06-refund\/.*\.spec\.ts/,
163188
},
164189
{
165190
name: 'shard:vaulting',
166-
dependencies: [ 'setup-woocommerce' ],
191+
dependencies: [ 'setup-pcp-vaulting' ],
167192
testMatch: /07-vaulting\/.*\.spec\.ts/,
168193
},
169194
{
170195
name: 'shard:subscription',
171-
dependencies: [ 'setup-woocommerce' ],
196+
dependencies: [ 'setup-pcp-subscription' ],
172197
testMatch: /08-subscription\/.*\.spec\.ts/,
173198
},
174199
],

tests/qa/tests/05-transactions/transaction-googlepay.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Internal dependencies
33
*/
44
import { test } from '../../utils';
5-
import { merchants, storeConfigUsa, gateways, customers } from '../../resources';
5+
import { customers, gateways, storeConfigUsa } from '../../resources';
66
import { transactionsOnCheckout } from './_test-scenarios';
77
import { googlePayCheckout } from './_test-data/googlepay';
88
import { GooglePayPopup } from '../../utils/frontend/google-pay-popup';
@@ -30,10 +30,11 @@ test.beforeEach( async ( { visitorPage } ) => {
3030
} );
3131

3232
test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
33-
await utils.configureStore( { ...storeConfigUsa, customer: customers.usa } );
34-
await utils.installAndActivatePcp();
35-
await pcpApi.resetDb();
36-
await pcpApi.connectMerchant( merchants.usa.client_id, merchants.usa.client_secret );
33+
await utils.configureStore( {
34+
...storeConfigUsa,
35+
enableClassicPages: false,
36+
customer: customers.usa,
37+
} );
3738
// Google Pay requires ACDC to be enabled alongside it.
3839
await pcpApi.updatePcpPaymentMethods( {
3940
[ acdc.id ]: { id: acdc.id, enabled: true },

tests/qa/tests/05-transactions/transaction-usa-classic.spec.ts

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,12 @@
33
*/
44
import { test } from '../../utils';
55
import {
6-
merchants,
7-
storeConfigUsa,
6+
customers,
87
gateways,
8+
storeConfigUsa,
99
taxSettings,
10-
customers,
1110
} from '../../resources';
12-
import {
13-
transactionsOnClassicCart,
14-
transactionsOnClassicCheckout,
15-
transactionsOnClassicProduct,
16-
} from './_test-scenarios';
17-
import {
18-
venmoClassicCartUsa,
19-
venmoClassicCheckoutUsa,
20-
venmoClassicProductUsa,
21-
} from './_test-data/venmo';
11+
import { transactionsOnClassicCheckout } from './_test-scenarios';
2212
import {
2313
payPalClassicCheckout,
2414
payPalClassicCheckoutExcludingTax,
@@ -37,27 +27,14 @@ import {
3727
} from './_test-data/acdc';
3828
import { fastlaneClassicCheckout } from './_test-data/fastlane';
3929

40-
const { payPal, payLater, venmo, acdc, fastlane } = gateways;
30+
const { fastlane } = gateways;
4131

42-
test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
32+
test.beforeAll( async ( { utils, wooCommerceApi } ) => {
4333
await utils.configureStore( {
4434
...storeConfigUsa,
4535
enableClassicPages: true,
4636
customer: customers.usa,
4737
} );
48-
await utils.installAndActivatePcp();
49-
await pcpApi.resetDb();
50-
await pcpApi.connectMerchant(
51-
merchants.usa.client_id,
52-
merchants.usa.client_secret
53-
);
54-
await pcpApi.updatePcpPaymentMethods( {
55-
[ payPal.id ]: { id: payPal.id, enabled: true },
56-
[ payLater.id ]: { id: payLater.id, enabled: true },
57-
[ venmo.id ]: { id: venmo.id, enabled: true },
58-
[ acdc.id ]: { id: acdc.id, enabled: true },
59-
[ fastlane.id ]: { id: fastlane.id, enabled: false },
60-
} );
6138
await wooCommerceApi.deleteAllOrders();
6239
} );
6340

tests/qa/tests/05-transactions/transaction-usa.spec.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
*/
44
import { test } from '../../utils';
55
import {
6-
merchants,
7-
storeConfigUsa,
6+
customers,
87
gateways,
8+
storeConfigUsa,
99
taxSettings,
10-
customers,
1110
} from '../../resources';
1211
import {
1312
transactionsOnCheckout,
@@ -38,26 +37,14 @@ import {
3837
} from './_test-data/acdc';
3938
import { fastlaneCheckout } from './_test-data/fastlane';
4039

41-
const { payPal, payLater, venmo, acdc, fastlane } = gateways;
40+
const { fastlane } = gateways;
4241

43-
test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
42+
test.beforeAll( async ( { utils, wooCommerceApi } ) => {
4443
await utils.configureStore( {
4544
...storeConfigUsa,
45+
enableClassicPages: false,
4646
customer: customers.usa,
4747
} );
48-
await utils.installAndActivatePcp();
49-
await pcpApi.resetDb();
50-
await pcpApi.connectMerchant(
51-
merchants.usa.client_id,
52-
merchants.usa.client_secret
53-
);
54-
await pcpApi.updatePcpPaymentMethods( {
55-
[ payPal.id ]: { id: payPal.id, enabled: true },
56-
[ payLater.id ]: { id: payLater.id, enabled: true },
57-
[ venmo.id ]: { id: venmo.id, enabled: true },
58-
[ acdc.id ]: { id: acdc.id, enabled: true },
59-
[ fastlane.id ]: { id: fastlane.id, enabled: false },
60-
} );
6148
await wooCommerceApi.deleteAllOrders();
6249
} );
6350

tests/qa/tests/06-refund/refund-usa.spec.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
/**
22
* Internal dependencies
33
*/
4-
import { test } from '../../utils';
5-
import {
6-
merchants,
7-
storeConfigUsa,
8-
gateways,
9-
customers,
10-
} from '../../resources';
114
import { testRefund } from './_test-scenarios';
125
import {
136
refundPayPalFromCheckout,
@@ -16,26 +9,6 @@ import {
169
refundAcdcFromPayByLink,
1710
} from './_test-data';
1811

19-
const { payPal, acdc } = gateways;
20-
21-
test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
22-
await utils.configureStore( {
23-
...storeConfigUsa,
24-
customer: customers.usa,
25-
} );
26-
await utils.installAndActivatePcp();
27-
await pcpApi.resetDb();
28-
await pcpApi.connectMerchant(
29-
merchants.usa.client_id,
30-
merchants.usa.client_secret
31-
);
32-
await pcpApi.updatePcpPaymentMethods( {
33-
[ payPal.id ]: { id: payPal.id, enabled: true },
34-
[ acdc.id ]: { id: acdc.id, enabled: true },
35-
} );
36-
await wooCommerceApi.deleteAllOrders();
37-
} );
38-
3912
for ( const testOrder of refundPayPalFromCheckout ) {
4013
testRefund( testOrder );
4114
}

tests/qa/tests/07-vaulting/vaulting-checkout.spec.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Internal dependencies
33
*/
44
import { test } from '../../utils';
5-
import { merchants, storeConfigUsa } from '../../resources';
5+
import { storeConfigUsa } from '../../resources';
66
import { vaultingCheckout } from './_test-data';
77
import { testVaultingCheckout } from './_test-scenarios';
88

@@ -18,25 +18,11 @@ const {
1818
testVaultedPaymentMethod,
1919
} = testVaultingCheckout;
2020

21-
test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
21+
test.beforeAll( async ( { utils, wooCommerceApi } ) => {
2222
await utils.configureStore( {
2323
...storeConfigUsa,
2424
enableClassicPages: false,
2525
} );
26-
await utils.installAndActivatePcp();
27-
await pcpApi.resetDb();
28-
await pcpApi.connectMerchant(
29-
merchants.usa.client_id,
30-
merchants.usa.client_secret,
31-
{
32-
isCasualSeller: false,
33-
areOptionalPaymentMethodsEnabled: true,
34-
}
35-
);
36-
await pcpApi.updatePcpSettings( {
37-
savePaypalAndVenmo: true,
38-
saveCardDetails: true,
39-
} );
4026
await wooCommerceApi.deleteAllOrders();
4127
} );
4228

tests/qa/tests/07-vaulting/vaulting-classic-cart.spec.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Internal dependencies
33
*/
44
import { test } from '../../utils';
5-
import { merchants, storeConfigUsa } from '../../resources';
5+
import { storeConfigUsa } from '../../resources';
66
import { vaultingClassicCart } from './_test-data';
77
import { testVaultingClassicCart } from './_test-scenarios';
88

@@ -11,25 +11,11 @@ const { savePaymentMethodData, vaultedPaymentMethodData } = vaultingClassicCart;
1111
const { testSavePaymentMethod, testVaultedPaymentMethod } =
1212
testVaultingClassicCart;
1313

14-
test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
14+
test.beforeAll( async ( { utils, wooCommerceApi } ) => {
1515
await utils.configureStore( {
1616
...storeConfigUsa,
1717
enableClassicPages: true,
1818
} );
19-
await utils.installAndActivatePcp();
20-
await pcpApi.resetDb();
21-
await pcpApi.connectMerchant(
22-
merchants.usa.client_id,
23-
merchants.usa.client_secret,
24-
{
25-
isCasualSeller: false,
26-
areOptionalPaymentMethodsEnabled: true,
27-
}
28-
);
29-
await pcpApi.updatePcpSettings( {
30-
savePaypalAndVenmo: true,
31-
saveCardDetails: true,
32-
} );
3319
await wooCommerceApi.deleteAllOrders();
3420
} );
3521

tests/qa/tests/07-vaulting/vaulting-classic-checkout.spec.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Internal dependencies
33
*/
44
import { test } from '../../utils';
5-
import { merchants, storeConfigUsa } from '../../resources';
5+
import { storeConfigUsa } from '../../resources';
66
import { vaultingClassicCheckout } from './_test-data';
77
import { testVaultingClassicCheckout } from './_test-scenarios';
88

@@ -18,25 +18,11 @@ const {
1818
testVaultedPaymentMethod,
1919
} = testVaultingClassicCheckout;
2020

21-
test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
21+
test.beforeAll( async ( { utils, wooCommerceApi } ) => {
2222
await utils.configureStore( {
2323
...storeConfigUsa,
2424
enableClassicPages: true,
2525
} );
26-
await utils.installAndActivatePcp();
27-
await pcpApi.resetDb();
28-
await pcpApi.connectMerchant(
29-
merchants.usa.client_id,
30-
merchants.usa.client_secret,
31-
{
32-
isCasualSeller: false,
33-
areOptionalPaymentMethodsEnabled: true,
34-
}
35-
);
36-
await pcpApi.updatePcpSettings( {
37-
savePaypalAndVenmo: true,
38-
saveCardDetails: true,
39-
} );
4026
await wooCommerceApi.deleteAllOrders();
4127
} );
4228

0 commit comments

Comments
 (0)