diff --git a/package-lock.json b/package-lock.json index f0dffc999be..65f139d0465 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5638,10 +5638,7 @@ "@types/moxios": { "version": "0.4.9", "resolved": "https://registry.npmjs.org/@types/moxios/-/moxios-0.4.9.tgz", - "integrity": "sha512-Sd1b24QRW2N194j2LEDPQAZK1h0TBtpN+2EIH+rERCgm38qm14JZwC7NlpE7n3jULhlCIPZBG8uNcbjF8KcCaQ==", - "requires": { - "axios": "^0.19.0" - } + "integrity": "sha512-Sd1b24QRW2N194j2LEDPQAZK1h0TBtpN+2EIH+rERCgm38qm14JZwC7NlpE7n3jULhlCIPZBG8uNcbjF8KcCaQ==" }, "@types/node": { "version": "13.13.5", @@ -5833,11 +5830,12 @@ "integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==" }, "axios": { - "version": "0.19.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", - "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", + "version": "0.21.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.2.tgz", + "integrity": "sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg==", + "dev": true, "requires": { - "follow-redirects": "1.5.10" + "follow-redirects": "^1.14.0" } }, "babel-jest": { @@ -6289,10 +6287,7 @@ "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "requires": { - "ms": "2.0.0" - } + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==" }, "decamelize": { "version": "1.2.0", @@ -6477,10 +6472,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { - "ms": "2.0.0" - } + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==" }, "define-property": { "version": "0.2.5", @@ -6642,12 +6634,10 @@ } }, "follow-redirects": { - "version": "1.5.10", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", - "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", - "requires": { - "debug": "=3.1.0" - } + "version": "1.14.4", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz", + "integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==", + "dev": true }, "for-in": { "version": "1.0.2", @@ -8659,10 +8649,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { - "ms": "2.0.0" - } + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==" }, "define-property": { "version": "0.2.5", @@ -9778,7 +9765,7 @@ } }, "prettier": { - "version": "npm:prettier@1.19.1", + "version": "npm:wp-prettier@1.19.1", "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-1.19.1.tgz", "integrity": "sha512-mqAC2r1NDmRjG+z3KCJ/i61tycKlmADIjxnDhQab+KBxSAGbF/W7/zwB2guy/ypIeKrrftNsIYkNZZQKf3vJcg==", "dev": true diff --git a/tests/e2e/api-core-tests/tests/orders/orders.test.js b/tests/e2e/api-core-tests/tests/orders/orders.test.js index 82c521acda7..4ece1381286 100644 --- a/tests/e2e/api-core-tests/tests/orders/orders.test.js +++ b/tests/e2e/api-core-tests/tests/orders/orders.test.js @@ -46,7 +46,7 @@ describe('Orders API tests', () => { it('can create an order', async () => { const response = await ordersApi.create.order( order ); - expect( response.statusCode ).toEqual( ordersApi.create.responseCode ); + expect( response.status ).toEqual( ordersApi.create.responseCode ); expect( response.body.id ).toBeDefined(); orderId = response.body.id; @@ -57,7 +57,7 @@ describe('Orders API tests', () => { it('can retrieve an order', async () => { const response = await ordersApi.retrieve.order( orderId ); - expect( response.statusCode ).toEqual( ordersApi.retrieve.responseCode ); + expect( response.status ).toEqual( ordersApi.retrieve.responseCode ); expect( response.body.id ).toEqual( orderId ); }); @@ -67,7 +67,7 @@ describe('Orders API tests', () => { order.shipping = updatedCustomerShipping; const response = await ordersApi.update.order( orderId, order ); - expect( response.statusCode).toEqual( ordersApi.update.responseCode ); + expect( response.status).toEqual( ordersApi.update.responseCode ); expect( response.body.billing ).toEqual( updatedCustomerBilling ); expect( response.body.shipping ).toEqual( updatedCustomerShipping ); @@ -75,9 +75,9 @@ describe('Orders API tests', () => { it('can permanently delete an order', async () => { const response = await ordersApi.delete.order( orderId, true ); - expect( response.statusCode ).toEqual( ordersApi.delete.responseCode ); + expect( response.status ).toEqual( ordersApi.delete.responseCode ); const getOrderResponse = await ordersApi.retrieve.order( orderId ); - expect( getOrderResponse.statusCode ).toEqual( 404 ); + expect( getOrderResponse.status ).toEqual( 404 ); }); }); diff --git a/tests/e2e/api/README.md b/tests/e2e/api/README.md index c21bc9ca82a..b27722004cc 100644 --- a/tests/e2e/api/README.md +++ b/tests/e2e/api/README.md @@ -36,7 +36,7 @@ client = HTTPClientFactory.build( 'https://example.com' ) // You can then use the client to make API requests. client.get( '/wc/v3/products' ).then( ( response ) => { // Access the status code from the response. - response.statusCode; + response.status; // Access the headers from the response. response.headers; // Access the data from the response, in this case, the products. diff --git a/tests/e2e/core-tests/specs/activate-and-setup/setup.test.js b/tests/e2e/core-tests/specs/activate-and-setup/setup.test.js index 1183c8c1077..9fcdeb74f5a 100644 --- a/tests/e2e/core-tests/specs/activate-and-setup/setup.test.js +++ b/tests/e2e/core-tests/specs/activate-and-setup/setup.test.js @@ -1,4 +1,3 @@ -/* eslint-disable jest/no-export, jest/no-disabled-tests */ /** * External dependencies */ @@ -82,7 +81,7 @@ const runInitialStoreSettingsTest = () => { .create(); const response = await client.get( '/wc/v3/products' ); - expect( response.statusCode ).toBe( 200 ); + expect( response.status ).toBe( 200 ); }); }); }; diff --git a/tests/e2e/core-tests/specs/api/coupon.test.js b/tests/e2e/core-tests/specs/api/coupon.test.js index 6ba22bb4d3e..0d29996ea8b 100644 --- a/tests/e2e/core-tests/specs/api/coupon.test.js +++ b/tests/e2e/core-tests/specs/api/coupon.test.js @@ -1,4 +1,3 @@ -/* eslint-disable jest/no-export, jest/no-disabled-tests */ /** * Internal dependencies */ @@ -53,7 +52,7 @@ const runCouponApiTest = () => { // Read coupon directly from API to compare. const response = await client.get( `/wc/v3/coupons/${coupon.id}` ); - expect( response.statusCode ).toBe( 200 ); + expect( response.status ).toBe( 200 ); expect( response.data ).toEqual( expect.objectContaining( couponProperties ) ); }); @@ -68,7 +67,7 @@ const runCouponApiTest = () => { // Check the coupon response for the updated values. const response = await client.get( `/wc/v3/coupons/${coupon.id}` ); - expect( response.statusCode ).toBe( 200 ); + expect( response.status ).toBe( 200 ); expect( response.data ).toEqual( expect.objectContaining( updatedCouponProperties ) ); }); diff --git a/tests/e2e/core-tests/specs/api/external-product.test.js b/tests/e2e/core-tests/specs/api/external-product.test.js index 463f248b726..9cd552a3250 100644 --- a/tests/e2e/core-tests/specs/api/external-product.test.js +++ b/tests/e2e/core-tests/specs/api/external-product.test.js @@ -1,4 +1,3 @@ -/* eslint-disable jest/no-export, jest/no-disabled-tests */ /** * Internal dependencies */ @@ -54,7 +53,7 @@ const runExternalProductAPITest = () => { // Read product directly from api. const response = await client.get( `/wc/v3/products/${product.id}` ); - expect( response.statusCode ).toBe( 200 ); + expect( response.status ).toBe( 200 ); expect( response.data ).toEqual( expect.objectContaining( rawProperties ) ); }); diff --git a/tests/e2e/core-tests/specs/api/grouped-product.test.js b/tests/e2e/core-tests/specs/api/grouped-product.test.js index 7ad4f2f2bd7..fef241654f9 100644 --- a/tests/e2e/core-tests/specs/api/grouped-product.test.js +++ b/tests/e2e/core-tests/specs/api/grouped-product.test.js @@ -1,4 +1,3 @@ -/* eslint-disable jest/no-export, jest/no-disabled-tests */ /** * Internal dependencies */ @@ -67,7 +66,7 @@ const runGroupedProductAPITest = () => { // Read product directly from api. const response = await client.get( `/wc/v3/products/${product.id}` ); - expect( response.statusCode ).toBe( 200 ); + expect( response.status ).toBe( 200 ); expect( response.data ).toEqual( expect.objectContaining( rawProperties ) ); }); diff --git a/tests/e2e/core-tests/specs/api/order.test.js b/tests/e2e/core-tests/specs/api/order.test.js index cdfc0b7a5c1..220326e45ba 100644 --- a/tests/e2e/core-tests/specs/api/order.test.js +++ b/tests/e2e/core-tests/specs/api/order.test.js @@ -1,4 +1,3 @@ -/* eslint-disable jest/no-export, jest/no-disabled-tests */ /** * Internal dependencies */ @@ -51,7 +50,7 @@ const runOrderApiTest = () => { // Read order directly from API to compare. const response = await client.get( `/wc/v3/orders/${order.id}` ); - expect( response.statusCode ).toBe( 200 ); + expect( response.status ).toBe( 200 ); expect( response.data ).toEqual( expect.objectContaining( orderProperties ) ); }); @@ -65,7 +64,7 @@ const runOrderApiTest = () => { // Check the order response for the updated values. const response = await client.get( `/wc/v3/orders/${order.id}` ); - expect( response.statusCode ).toBe( 200 ); + expect( response.status ).toBe( 200 ); expect( response.data ).toEqual( expect.objectContaining( updatedOrderProperties ) ); }); diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filters.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filters.test.js index a007fa0c66e..e3e36389a52 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filters.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filters.test.js @@ -22,7 +22,14 @@ const orderStatus = [ ['Refunded', 'wc-refunded'], ['Failed', 'wc-failed'], ]; -const defaultOrder = config.get('orders.basicPaidOrder'); +const defaultOrder = { + payment_method: 'cod', + billing: { + first_name: 'John', + last_name: 'Doe', + email: 'john.doe@example.com', + } +}; const runOrderStatusFiltersTest = () => { describe('WooCommerce Orders > Filter Orders by Status', () => { diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index ce53b6cc001..86ddb9d2ad9 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -398,8 +398,8 @@ const batchCreateOrders = async (statuses) => { // Set the request payload from the created orders. // Then send the API request. const payload = { create: orders }; - const { statusCode } = await client.post(path, payload); - expect(statusCode).toEqual(200); + const response = await client.post(path, payload); + expect( response.status ).toEqual(200); }; /** diff --git a/tests/e2e/utils/src/flows/with-rest-api.js b/tests/e2e/utils/src/flows/with-rest-api.js index 20be6e4fb87..e4e4a72817d 100644 --- a/tests/e2e/utils/src/flows/with-rest-api.js +++ b/tests/e2e/utils/src/flows/with-rest-api.js @@ -63,7 +63,7 @@ export const withRestApi = { }; const response = await client.put( onboardingProfileEndpoint, onboardingReset ); - expect( response.statusCode ).toEqual( 200 ); + expect( response.status ).toEqual( 200 ); }, /** * Use api package to delete coupons. @@ -115,7 +115,7 @@ export const withRestApi = { const path = 'wc/v3/shipping/zones'; const response = await client.post( path, { name: zoneName } ); - expect(response.statusCode).toEqual(201); + expect(response.status).toEqual(201); let zoneId = response.data.id; // Select shipping zone location @@ -136,7 +136,7 @@ export const withRestApi = { } const locationResponse = await client.put( path + `/${zoneId}/locations`, zoneLocationPayload ); - expect(locationResponse.statusCode).toEqual(200); + expect(locationResponse.status).toEqual(200); // Add shipping zone method let methodPayload = { @@ -144,7 +144,7 @@ export const withRestApi = { } const methodsResponse = await client.post( path + `/${zoneId}/methods`, methodPayload ); - expect(methodsResponse.statusCode).toEqual(200); + expect(methodsResponse.status).toEqual(200); let methodId = methodsResponse.data.id; // Add in cost, if provided @@ -156,14 +156,14 @@ export const withRestApi = { } const costResponse = await client.put( path + `/${zoneId}/methods/${methodId}`, costPayload ); - expect(costResponse.statusCode).toEqual(200); + expect(costResponse.status).toEqual(200); } // Add any additional zones, if provided if (additionalZoneMethods.length > 0) { for ( let z = 0; z < additionalZoneMethods.length; z++ ) { let response = await client.post( path + `/${zoneId}/methods`, { method_id: additionalZoneMethods[z] } ); - expect(response.statusCode).toEqual(200); + expect(response.status).toEqual(200); } } }, @@ -181,7 +181,7 @@ export const withRestApi = { continue; } const response = await client.delete( shippingZoneEndpoint + `/${shippingZones.data[z].id}?force=true` ); - expect( response.statusCode ).toBe( 200 ); + expect( response.status ).toBe( 200 ); } } }, @@ -195,7 +195,7 @@ export const withRestApi = { if ( shippingClasses.data && shippingClasses.data.length ) { for ( let c = 0; c < shippingClasses.data.length; c++ ) { const response = await client.delete( shippingClassesEndpoint + `/${shippingClasses.data[c].id}?force=true` ); - expect( response.statusCode ).toBe( 200 ); + expect( response.status ).toBe( 200 ); } } }, @@ -272,7 +272,7 @@ export const withRestApi = { */ updatePaymentGateway: async ( paymentGatewayId, payload = {} ) => { const response = await client.put( `/wc/v3/payment_gateways/${paymentGatewayId}`, payload ); - expect( response.statusCode ).toBe( 200 ); + expect( response.status ).toBe( 200 ); }, /** * Create a batch of orders using the "Batch Create Order" API endpoint. @@ -283,9 +283,8 @@ export const withRestApi = { const path = '/wc/v3/orders/batch'; const payload = { create: orders }; - const { statusCode } = await client.post(path, payload); - - expect(statusCode).toEqual(200); + const response = await client.post(path, payload); + expect( response.status ).toEqual(200); }, /** * Get the current environment from the WooCommerce system status API.