Skip to content

Commit a88cf0b

Browse files
Add E2E tests shopper checkout (#2513)
* Add helper to manage checkout actions and fields * Add checkout setup for CC tests * Add Github report for the future CI * Add first CC test * Standardize test-data with api field names * Add @woocommerce/woocommerce-rest-api * Add WC API helper * Change address field names to match WC names * Add normal card test case * Add index to utils export * Delete unused files * Add placeholder file for CC failure test * Add initial code for failure cards * Add card failure tests * Add npm script to run smoke tests * Add card failures test case * Refactor normal credit card test * Add SCA card test for regular checkout * Remove unused methods on api helper * Remove unused page object * Update error message on test data * Add Stripe plugin on Woo setup * Replace require for import on test specs * Replace require for import on non-spec files * Rename test function for cards * Fix import * Fix import of env variables
1 parent 7f91db3 commit a88cf0b

18 files changed

+568
-115
lines changed

package-lock.json

Lines changed: 112 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@woocommerce/dependency-extraction-webpack-plugin": "^1.4.0",
2626
"@woocommerce/eslint-plugin": "^1.3.0",
2727
"@woocommerce/navigation": "^6.1.0",
28+
"@woocommerce/woocommerce-rest-api": "^1.0.1",
2829
"@wordpress/api-fetch": "^5.2.1",
2930
"@wordpress/babel-plugin-makepot": "^4.2.0",
3031
"@wordpress/babel-preset-default": "^6.3.1",
@@ -144,6 +145,7 @@
144145
"jt:start": "./docker/bin/jt/tunnel.sh",
145146
"jt:stop": "./docker/bin/jt/tunnel.sh break",
146147
"test:e2e": "./tests/e2e/env/e2e.sh",
148+
"test:e2e-smoke": "./tests/e2e/env/e2e.sh --grep @smoke",
147149
"test:e2e-setup": "./tests/e2e/env/e2e.sh --with_woo_setup --with_stripe_setup",
148150
"test:e2e-debug": "./tests/e2e/env/e2e.sh --debug"
149151
},

tests/e2e/config/global-setup.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ require( 'dotenv' ).config( {
22
path: `${ process.env.E2E_ROOT }/config/local.env`,
33
} );
44

5-
const { chromium } = require( '@playwright/test' );
6-
const fs = require( 'fs' );
5+
import { chromium } from '@playwright/test';
6+
import fs from 'fs';
77

8-
const {
8+
import {
99
loginAdminAndSaveState,
1010
createApiTokens,
1111
installPluginFromRepository,
1212
setupWoo,
1313
setupStripe,
14-
} = require( '../utils/pw-setup' );
14+
} from '../utils/pw-setup';
1515

1616
const {
1717
BASE_URL,

tests/e2e/config/global-teardown.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
const path = require( 'path' );
1+
import path from 'path';
2+
3+
import { chromium } from '@playwright/test';
4+
import { getReleaseZipUrl, deleteZip } from '../utils/plugin-utils';
25

3-
const { chromium } = require( '@playwright/test' );
46
const { ADMIN_USER, ADMIN_PASSWORD, PLUGIN_VERSION } = process.env;
57
const adminUsername = ADMIN_USER ?? 'admin';
68
const adminPassword = ADMIN_PASSWORD ?? 'password';
79

8-
const { getReleaseZipUrl, deleteZip } = require( '../utils/plugin-utils' );
9-
1010
module.exports = async ( config ) => {
1111
const { baseURL, userAgent } = config.projects[ 0 ].use;
1212

tests/e2e/config/playwright.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { devices } = require( '@playwright/test' );
1+
import { devices } from '@playwright/test';
22
const {
33
ALLURE_RESULTS_DIR,
44
BASE_URL,
@@ -19,7 +19,7 @@ const config = {
1919
retries: CI ? 4 : 2,
2020
workers: 4,
2121
reporter: [
22-
[ 'line' ],
22+
[ CI ? 'github' : 'list' ],
2323
[
2424
'html',
2525
{

tests/e2e/test-data/default.json

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@
2828
"addresses": {
2929
"admin": {
3030
"store": {
31-
"firstname": "Admin",
32-
"lastname": "Adminson",
31+
"first_name": "Admin",
32+
"last_name": "Adminson",
3333
"company": "Automattic",
34-
"country": "United States (US)",
35-
"addressfirstline": "60 29th Street #343",
36-
"addresssecondline": "store",
37-
"countryandstate": "United States (US) — California",
34+
"country": "US",
35+
"address_1": "60 29th Street #343",
36+
"address_2": "store",
3837
"city": "San Francisco",
3938
"state": "CA",
4039
"postcode": "94110",
@@ -43,30 +42,28 @@
4342
},
4443
"customer": {
4544
"billing": {
46-
"firstname": "Customer",
47-
"lastname": "Customerson",
45+
"first_name": "Customer",
46+
"last_name": "Customerson",
4847
"company": "",
49-
"country": "United States (US)",
50-
"addressfirstline": "60 29th Street #343",
51-
"addresssecondline": "billing",
48+
"country": "US",
49+
"address_1": "60 29th Street #343",
50+
"address_2": "billing",
5251
"city": "San Francisco",
5352
"state": "CA",
5453
"postcode": "94110",
5554
"phone": "2025550104",
5655
"email": "[email protected]"
5756
},
5857
"shipping": {
59-
"firstname": "Recipient",
60-
"lastname": "Recipientson",
58+
"first_name": "Recipient",
59+
"last_name": "Recipientson",
6160
"company": "",
62-
"country": "United States (US)",
63-
"addressfirstline": "166 Crosby Street",
64-
"addresssecondline": "shipping",
61+
"country": "US",
62+
"address_1": "166 Crosby Street",
63+
"address_2": "shipping",
6564
"city": "New York",
6665
"state": "New York",
67-
"postcode": "10012",
68-
"phone": "8772733049",
69-
"email": "[email protected]"
66+
"postcode": "10012"
7067
}
7168
}
7269
},
@@ -150,7 +147,8 @@
150147
"year": "25"
151148
},
152149
"cvc": "626",
153-
"label": "Visa ending in 0002"
150+
"label": "Visa ending in 0002",
151+
"error" : "The card was declined."
154152
},
155153
"declined-funds": {
156154
"number": "4000000000009995",
@@ -159,7 +157,8 @@
159157
"year": "25"
160158
},
161159
"cvc": "626",
162-
"label": "Visa ending in 9995"
160+
"label": "Visa ending in 9995",
161+
"error" : "The card was declined."
163162
},
164163
"declined-incorrect": {
165164
"number": "4242424242424241",
@@ -168,7 +167,8 @@
168167
"year": "25"
169168
},
170169
"cvc": "626",
171-
"label": "Visa ending in 4241"
170+
"label": "Visa ending in 4241",
171+
"error" : "The card number is not a valid credit card number."
172172
},
173173
"declined-expired": {
174174
"number": "4000000000000069",
@@ -177,7 +177,8 @@
177177
"year": "25"
178178
},
179179
"cvc": "626",
180-
"label": "Visa ending in 0069"
180+
"label": "Visa ending in 0069",
181+
"error" : "The card has expired."
181182
},
182183
"declined-cvc": {
183184
"number": "4000000000000127",
@@ -186,7 +187,8 @@
186187
"year": "25"
187188
},
188189
"cvc": "626",
189-
"label": "Visa ending in 0127"
190+
"label": "Visa ending in 0127",
191+
"error" : "The card's security code is incorrect."
190192
},
191193
"declined-processing": {
192194
"number": "4000000000000119",
@@ -195,7 +197,8 @@
195197
"year": "25"
196198
},
197199
"cvc": "626",
198-
"label": "Visa ending in 0119"
200+
"label": "Visa ending in 0119",
201+
"error" : "An error occurred while processing the card."
199202
},
200203
"declined-3ds": {
201204
"number": "4000008400001629",

0 commit comments

Comments
 (0)